Commit | Line | Data |
---|---|---|
f7b422b1 DH |
1 | /* |
2 | * NFS internal definitions | |
3 | */ | |
4 | ||
5 | #include <linux/mount.h> | |
6 | ||
7 | struct nfs_clone_mount { | |
8 | const struct super_block *sb; | |
9 | const struct dentry *dentry; | |
10 | struct nfs_fh *fh; | |
11 | struct nfs_fattr *fattr; | |
12 | char *hostname; | |
13 | char *mnt_path; | |
14 | struct sockaddr_in *addr; | |
15 | rpc_authflavor_t authflavor; | |
16 | }; | |
17 | ||
24c8dbbb DH |
18 | /* client.c */ |
19 | extern void nfs_put_client(struct nfs_client *); | |
20 | extern struct nfs_client *nfs_find_client(const struct sockaddr_in *, int); | |
21 | extern struct nfs_client *nfs_get_client(const char *, const struct sockaddr_in *, int); | |
22 | extern void nfs_mark_client_ready(struct nfs_client *, int); | |
23 | ||
7d4e2747 | 24 | /* nfs4namespace.c */ |
f7b422b1 DH |
25 | #ifdef CONFIG_NFS_V4 |
26 | extern struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry); | |
27 | #else | |
28 | static inline | |
29 | struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry) | |
30 | { | |
31 | return ERR_PTR(-ENOENT); | |
32 | } | |
33 | #endif | |
34 | ||
35 | /* callback_xdr.c */ | |
36 | extern struct svc_version nfs4_callback_version1; | |
37 | ||
38 | /* pagelist.c */ | |
39 | extern int __init nfs_init_nfspagecache(void); | |
266bee88 | 40 | extern void nfs_destroy_nfspagecache(void); |
f7b422b1 | 41 | extern int __init nfs_init_readpagecache(void); |
266bee88 | 42 | extern void nfs_destroy_readpagecache(void); |
f7b422b1 | 43 | extern int __init nfs_init_writepagecache(void); |
266bee88 | 44 | extern void nfs_destroy_writepagecache(void); |
f7b422b1 DH |
45 | |
46 | #ifdef CONFIG_NFS_DIRECTIO | |
47 | extern int __init nfs_init_directcache(void); | |
266bee88 | 48 | extern void nfs_destroy_directcache(void); |
f7b422b1 DH |
49 | #else |
50 | #define nfs_init_directcache() (0) | |
51 | #define nfs_destroy_directcache() do {} while(0) | |
52 | #endif | |
53 | ||
54 | /* nfs2xdr.c */ | |
7d4e2747 | 55 | extern int nfs_stat_to_errno(int); |
f7b422b1 DH |
56 | extern struct rpc_procinfo nfs_procedures[]; |
57 | extern u32 * nfs_decode_dirent(u32 *, struct nfs_entry *, int); | |
58 | ||
59 | /* nfs3xdr.c */ | |
60 | extern struct rpc_procinfo nfs3_procedures[]; | |
61 | extern u32 *nfs3_decode_dirent(u32 *, struct nfs_entry *, int); | |
62 | ||
63 | /* nfs4xdr.c */ | |
7d4e2747 | 64 | #ifdef CONFIG_NFS_V4 |
f7b422b1 | 65 | extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus); |
7d4e2747 | 66 | #endif |
f7b422b1 DH |
67 | |
68 | /* nfs4proc.c */ | |
d75d5414 | 69 | #ifdef CONFIG_NFS_V4 |
f7b422b1 DH |
70 | extern struct rpc_procinfo nfs4_procedures[]; |
71 | ||
72 | extern int nfs4_proc_fs_locations(struct inode *dir, struct dentry *dentry, | |
73 | struct nfs4_fs_locations *fs_locations, | |
74 | struct page *page); | |
d75d5414 | 75 | #endif |
f7b422b1 | 76 | |
979df72e TM |
77 | /* dir.c */ |
78 | extern int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask); | |
79 | ||
f7b422b1 DH |
80 | /* inode.c */ |
81 | extern struct inode *nfs_alloc_inode(struct super_block *sb); | |
82 | extern void nfs_destroy_inode(struct inode *); | |
83 | extern int nfs_write_inode(struct inode *,int); | |
84 | extern void nfs_clear_inode(struct inode *); | |
85 | #ifdef CONFIG_NFS_V4 | |
86 | extern void nfs4_clear_inode(struct inode *); | |
87 | #endif | |
88 | ||
89 | /* super.c */ | |
90 | extern struct file_system_type nfs_referral_nfs4_fs_type; | |
91 | extern struct file_system_type clone_nfs_fs_type; | |
92 | #ifdef CONFIG_NFS_V4 | |
93 | extern struct file_system_type clone_nfs4_fs_type; | |
94 | #endif | |
4ebd9ab3 | 95 | |
f7b422b1 | 96 | extern struct rpc_stat nfs_rpcstat; |
4ebd9ab3 | 97 | |
f7b422b1 DH |
98 | extern int __init register_nfs_fs(void); |
99 | extern void __exit unregister_nfs_fs(void); | |
100 | ||
101 | /* namespace.c */ | |
102 | extern char *nfs_path(const char *base, const struct dentry *dentry, | |
103 | char *buffer, ssize_t buflen); | |
104 | ||
105 | /* | |
106 | * Determine the mount path as a string | |
107 | */ | |
7d4e2747 | 108 | #ifdef CONFIG_NFS_V4 |
d75d5414 AM |
109 | static inline char * |
110 | nfs4_path(const struct dentry *dentry, char *buffer, ssize_t buflen) | |
f7b422b1 DH |
111 | { |
112 | return nfs_path(NFS_SB(dentry->d_sb)->mnt_path, dentry, buffer, buflen); | |
113 | } | |
7d4e2747 | 114 | #endif |
f7b422b1 DH |
115 | |
116 | /* | |
117 | * Determine the device name as a string | |
118 | */ | |
119 | static inline char *nfs_devname(const struct vfsmount *mnt_parent, | |
120 | const struct dentry *dentry, | |
121 | char *buffer, ssize_t buflen) | |
122 | { | |
123 | return nfs_path(mnt_parent->mnt_devname, dentry, buffer, buflen); | |
124 | } | |
125 | ||
126 | /* | |
127 | * Determine the actual block size (and log2 thereof) | |
128 | */ | |
129 | static inline | |
130 | unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp) | |
131 | { | |
132 | /* make sure blocksize is a power of two */ | |
133 | if ((bsize & (bsize - 1)) || nrbitsp) { | |
134 | unsigned char nrbits; | |
135 | ||
136 | for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--) | |
137 | ; | |
138 | bsize = 1 << nrbits; | |
139 | if (nrbitsp) | |
140 | *nrbitsp = nrbits; | |
141 | } | |
142 | ||
143 | return bsize; | |
144 | } | |
145 | ||
146 | /* | |
147 | * Calculate the number of 512byte blocks used. | |
148 | */ | |
149 | static inline unsigned long nfs_calc_block_size(u64 tsize) | |
150 | { | |
151 | loff_t used = (tsize + 511) >> 9; | |
152 | return (used > ULONG_MAX) ? ULONG_MAX : used; | |
153 | } | |
154 | ||
155 | /* | |
156 | * Compute and set NFS server blocksize | |
157 | */ | |
158 | static inline | |
159 | unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp) | |
160 | { | |
161 | if (bsize < NFS_MIN_FILE_IO_SIZE) | |
162 | bsize = NFS_DEF_FILE_IO_SIZE; | |
163 | else if (bsize >= NFS_MAX_FILE_IO_SIZE) | |
164 | bsize = NFS_MAX_FILE_IO_SIZE; | |
165 | ||
166 | return nfs_block_bits(bsize, nrbitsp); | |
167 | } | |
168 | ||
169 | /* | |
170 | * Determine the maximum file size for a superblock | |
171 | */ | |
172 | static inline | |
173 | void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize) | |
174 | { | |
175 | sb->s_maxbytes = (loff_t)maxfilesize; | |
176 | if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0) | |
177 | sb->s_maxbytes = MAX_LFS_FILESIZE; | |
178 | } | |
179 | ||
180 | /* | |
181 | * Check if the string represents a "valid" IPv4 address | |
182 | */ | |
183 | static inline int valid_ipaddr4(const char *buf) | |
184 | { | |
185 | int rc, count, in[4]; | |
186 | ||
187 | rc = sscanf(buf, "%d.%d.%d.%d", &in[0], &in[1], &in[2], &in[3]); | |
188 | if (rc != 4) | |
189 | return -EINVAL; | |
190 | for (count = 0; count < 4; count++) { | |
191 | if (in[count] > 255) | |
192 | return -EINVAL; | |
193 | } | |
194 | return 0; | |
195 | } |