aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/internal.h
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-06-09 09:34:33 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-06-09 09:34:33 -0400
commitf7b422b17ee5ee4920e8ae24a6ad04bf3481ce72 (patch)
tree4ae8372762efc092ceb4f884b57cad1efe6594de /fs/nfs/internal.h
parent4e5ccf60c5aa79d325c123f47d288a068166f389 (diff)
NFS: Split fs/nfs/inode.c
As fs/nfs/inode.c is rather large, heterogenous and unwieldy, the attached patch splits it up into a number of files: (*) fs/nfs/inode.c Strictly inode specific functions. (*) fs/nfs/super.c Superblock management functions for NFS and NFS4, normal access, clones and referrals. The NFS4 superblock functions _could_ move out into a separate conditionally compiled file, but it's probably not worth it as there're so many common bits. (*) fs/nfs/namespace.c Some namespace-specific functions have been moved here. (*) fs/nfs/nfs4namespace.c NFS4-specific namespace functions (this could be merged into the previous file). This file is conditionally compiled. (*) fs/nfs/internal.h Inter-file declarations, plus a few simple utility functions moved from fs/nfs/inode.c. Additionally, all the in-.c-file externs have been moved here, and those files they were moved from now includes this file. For the most part, the functions have not been changed, only some multiplexor functions have changed significantly. I've also: (*) Added some extra banner comments above some functions. (*) Rearranged the function order within the files to be more logical and better grouped (IMO), though someone may prefer a different order. (*) Reduced the number of #ifdefs in .c files. (*) Added missing __init and __exit directives. Signed-Off-By: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/nfs/internal.h')
-rw-r--r--fs/nfs/internal.h179
1 files changed, 179 insertions, 0 deletions
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
new file mode 100644
index 000000000000..5e51c4535b6f
--- /dev/null
+++ b/fs/nfs/internal.h
@@ -0,0 +1,179 @@
1/*
2 * NFS internal definitions
3 */
4
5#include <linux/mount.h>
6
7struct 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
18/* namespace-nfs4.c */
19#ifdef CONFIG_NFS_V4
20extern struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry);
21#else
22static inline
23struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry)
24{
25 return ERR_PTR(-ENOENT);
26}
27#endif
28
29/* callback_xdr.c */
30extern struct svc_version nfs4_callback_version1;
31
32/* pagelist.c */
33extern int __init nfs_init_nfspagecache(void);
34extern void __exit nfs_destroy_nfspagecache(void);
35extern int __init nfs_init_readpagecache(void);
36extern void __exit nfs_destroy_readpagecache(void);
37extern int __init nfs_init_writepagecache(void);
38extern void __exit nfs_destroy_writepagecache(void);
39
40#ifdef CONFIG_NFS_DIRECTIO
41extern int __init nfs_init_directcache(void);
42extern void __exit nfs_destroy_directcache(void);
43#else
44#define nfs_init_directcache() (0)
45#define nfs_destroy_directcache() do {} while(0)
46#endif
47
48/* nfs2xdr.c */
49extern struct rpc_procinfo nfs_procedures[];
50extern u32 * nfs_decode_dirent(u32 *, struct nfs_entry *, int);
51
52/* nfs3xdr.c */
53extern struct rpc_procinfo nfs3_procedures[];
54extern u32 *nfs3_decode_dirent(u32 *, struct nfs_entry *, int);
55
56/* nfs4xdr.c */
57extern int nfs_stat_to_errno(int);
58extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus);
59
60/* nfs4proc.c */
61extern struct rpc_procinfo nfs4_procedures[];
62
63extern int nfs4_proc_fs_locations(struct inode *dir, struct dentry *dentry,
64 struct nfs4_fs_locations *fs_locations,
65 struct page *page);
66
67/* inode.c */
68extern struct inode *nfs_alloc_inode(struct super_block *sb);
69extern void nfs_destroy_inode(struct inode *);
70extern int nfs_write_inode(struct inode *,int);
71extern void nfs_clear_inode(struct inode *);
72#ifdef CONFIG_NFS_V4
73extern void nfs4_clear_inode(struct inode *);
74#endif
75
76/* super.c */
77extern struct file_system_type nfs_referral_nfs4_fs_type;
78extern struct file_system_type clone_nfs_fs_type;
79#ifdef CONFIG_NFS_V4
80extern struct file_system_type clone_nfs4_fs_type;
81#endif
82#ifdef CONFIG_PROC_FS
83extern struct rpc_stat nfs_rpcstat;
84#endif
85extern int __init register_nfs_fs(void);
86extern void __exit unregister_nfs_fs(void);
87
88/* namespace.c */
89extern char *nfs_path(const char *base, const struct dentry *dentry,
90 char *buffer, ssize_t buflen);
91
92/*
93 * Determine the mount path as a string
94 */
95static inline char *nfs4_path(const struct dentry *dentry, char *buffer, ssize_t buflen)
96{
97 return nfs_path(NFS_SB(dentry->d_sb)->mnt_path, dentry, buffer, buflen);
98}
99
100/*
101 * Determine the device name as a string
102 */
103static inline char *nfs_devname(const struct vfsmount *mnt_parent,
104 const struct dentry *dentry,
105 char *buffer, ssize_t buflen)
106{
107 return nfs_path(mnt_parent->mnt_devname, dentry, buffer, buflen);
108}
109
110/*
111 * Determine the actual block size (and log2 thereof)
112 */
113static inline
114unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp)
115{
116 /* make sure blocksize is a power of two */
117 if ((bsize & (bsize - 1)) || nrbitsp) {
118 unsigned char nrbits;
119
120 for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--)
121 ;
122 bsize = 1 << nrbits;
123 if (nrbitsp)
124 *nrbitsp = nrbits;
125 }
126
127 return bsize;
128}
129
130/*
131 * Calculate the number of 512byte blocks used.
132 */
133static inline unsigned long nfs_calc_block_size(u64 tsize)
134{
135 loff_t used = (tsize + 511) >> 9;
136 return (used > ULONG_MAX) ? ULONG_MAX : used;
137}
138
139/*
140 * Compute and set NFS server blocksize
141 */
142static inline
143unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp)
144{
145 if (bsize < NFS_MIN_FILE_IO_SIZE)
146 bsize = NFS_DEF_FILE_IO_SIZE;
147 else if (bsize >= NFS_MAX_FILE_IO_SIZE)
148 bsize = NFS_MAX_FILE_IO_SIZE;
149
150 return nfs_block_bits(bsize, nrbitsp);
151}
152
153/*
154 * Determine the maximum file size for a superblock
155 */
156static inline
157void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize)
158{
159 sb->s_maxbytes = (loff_t)maxfilesize;
160 if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0)
161 sb->s_maxbytes = MAX_LFS_FILESIZE;
162}
163
164/*
165 * Check if the string represents a "valid" IPv4 address
166 */
167static inline int valid_ipaddr4(const char *buf)
168{
169 int rc, count, in[4];
170
171 rc = sscanf(buf, "%d.%d.%d.%d", &in[0], &in[1], &in[2], &in[3]);
172 if (rc != 4)
173 return -EINVAL;
174 for (count = 0; count < 4; count++) {
175 if (in[count] > 255)
176 return -EINVAL;
177 }
178 return 0;
179}