2 * NFS internal definitions
5 #include <linux/mount.h>
7 struct nfs_clone_mount {
8 const struct super_block *sb;
9 const struct dentry *dentry;
11 struct nfs_fattr *fattr;
14 struct sockaddr_in *addr;
15 rpc_authflavor_t authflavor;
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);
26 extern struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry);
29 struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry)
31 return ERR_PTR(-ENOENT);
36 extern struct svc_version nfs4_callback_version1;
39 extern int __init nfs_init_nfspagecache(void);
40 extern void nfs_destroy_nfspagecache(void);
41 extern int __init nfs_init_readpagecache(void);
42 extern void nfs_destroy_readpagecache(void);
43 extern int __init nfs_init_writepagecache(void);
44 extern void nfs_destroy_writepagecache(void);
46 #ifdef CONFIG_NFS_DIRECTIO
47 extern int __init nfs_init_directcache(void);
48 extern void nfs_destroy_directcache(void);
50 #define nfs_init_directcache() (0)
51 #define nfs_destroy_directcache() do {} while(0)
55 extern int nfs_stat_to_errno(int);
56 extern struct rpc_procinfo nfs_procedures[];
57 extern u32 * nfs_decode_dirent(u32 *, struct nfs_entry *, int);
60 extern struct rpc_procinfo nfs3_procedures[];
61 extern u32 *nfs3_decode_dirent(u32 *, struct nfs_entry *, int);
65 extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus);
70 extern struct rpc_procinfo nfs4_procedures[];
72 extern int nfs4_proc_fs_locations(struct inode *dir, struct dentry *dentry,
73 struct nfs4_fs_locations *fs_locations,
78 extern int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask);
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 *);
86 extern void nfs4_clear_inode(struct inode *);
90 extern struct file_system_type nfs_referral_nfs4_fs_type;
91 extern struct file_system_type clone_nfs_fs_type;
93 extern struct file_system_type clone_nfs4_fs_type;
96 extern struct rpc_stat nfs_rpcstat;
98 extern int __init register_nfs_fs(void);
99 extern void __exit unregister_nfs_fs(void);
102 extern char *nfs_path(const char *base, const struct dentry *dentry,
103 char *buffer, ssize_t buflen);
106 * Determine the mount path as a string
110 nfs4_path(const struct dentry *dentry, char *buffer, ssize_t buflen)
112 return nfs_path(NFS_SB(dentry->d_sb)->mnt_path, dentry, buffer, buflen);
117 * Determine the device name as a string
119 static inline char *nfs_devname(const struct vfsmount *mnt_parent,
120 const struct dentry *dentry,
121 char *buffer, ssize_t buflen)
123 return nfs_path(mnt_parent->mnt_devname, dentry, buffer, buflen);
127 * Determine the actual block size (and log2 thereof)
130 unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp)
132 /* make sure blocksize is a power of two */
133 if ((bsize & (bsize - 1)) || nrbitsp) {
134 unsigned char nrbits;
136 for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--)
147 * Calculate the number of 512byte blocks used.
149 static inline unsigned long nfs_calc_block_size(u64 tsize)
151 loff_t used = (tsize + 511) >> 9;
152 return (used > ULONG_MAX) ? ULONG_MAX : used;
156 * Compute and set NFS server blocksize
159 unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp)
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;
166 return nfs_block_bits(bsize, nrbitsp);
170 * Determine the maximum file size for a superblock
173 void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize)
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;
181 * Check if the string represents a "valid" IPv4 address
183 static inline int valid_ipaddr4(const char *buf)
185 int rc, count, in[4];
187 rc = sscanf(buf, "%d.%d.%d.%d", &in[0], &in[1], &in[2], &in[3]);
190 for (count = 0; count < 4; count++) {