aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/internal.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:54:14 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:54:14 -0400
commit1d77062b1402aef5b26e1d3776991126e8026bde (patch)
tree96e4da18878f5fb2ae50b260e194b78803d4c7a9 /fs/nfs/internal.h
parent25581ad107be24b89d805da51a03d616f8f3d1be (diff)
parent76a9f26c9e40e9c0ed5dc8f0cedd74e733f0088d (diff)
Merge git://git.linux-nfs.org/pub/linux/nfs-2.6
* git://git.linux-nfs.org/pub/linux/nfs-2.6: (51 commits) nfs: remove nfs_put_link() nfs-build-fix-99 git-nfs-build-fixes Merge branch 'odirect' NFS: alloc nfs_read/write_data as direct I/O is scheduled NFS: Eliminate nfs_get_user_pages() NFS: refactor nfs_direct_free_user_pages NFS: remove user_addr, user_count, and pos from nfs_direct_req NFS: "open code" the NFS direct write rescheduler NFS: Separate functions for counting outstanding NFS direct I/Os NLM: Fix reclaim races NLM: sem to mutex conversion locks.c: add the fl_owner to nlm_compare_locks NFS: Display the chosen RPCSEC_GSS security flavour in /proc/mounts NFS: Split fs/nfs/inode.c NFS: Fix typo in nfs_do_clone_mount() NFS: Fix compile errors introduced by referrals patches NFSv4: Ensure that referral mounts bind to a reserved port NFSv4: A root pathname is sent as a zero component4 NFSv4: Follow a referral ...
Diffstat (limited to 'fs/nfs/internal.h')
-rw-r--r--fs/nfs/internal.h186
1 files changed, 186 insertions, 0 deletions
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
new file mode 100644
index 000000000000..bd2815e2dec1
--- /dev/null
+++ b/fs/nfs/internal.h
@@ -0,0 +1,186 @@
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 */
61#ifdef CONFIG_NFS_V4
62extern struct rpc_procinfo nfs4_procedures[];
63
64extern int nfs4_proc_fs_locations(struct inode *dir, struct dentry *dentry,
65 struct nfs4_fs_locations *fs_locations,
66 struct page *page);
67#endif
68
69/* inode.c */
70extern struct inode *nfs_alloc_inode(struct super_block *sb);
71extern void nfs_destroy_inode(struct inode *);
72extern int nfs_write_inode(struct inode *,int);
73extern void nfs_clear_inode(struct inode *);
74#ifdef CONFIG_NFS_V4
75extern void nfs4_clear_inode(struct inode *);
76#endif
77
78/* super.c */
79extern struct file_system_type nfs_referral_nfs4_fs_type;
80extern struct file_system_type clone_nfs_fs_type;
81#ifdef CONFIG_NFS_V4
82extern struct file_system_type clone_nfs4_fs_type;
83#endif
84#ifdef CONFIG_PROC_FS
85extern struct rpc_stat nfs_rpcstat;
86#endif
87extern int __init register_nfs_fs(void);
88extern void __exit unregister_nfs_fs(void);
89
90/* namespace.c */
91extern char *nfs_path(const char *base, const struct dentry *dentry,
92 char *buffer, ssize_t buflen);
93
94/*
95 * Determine the mount path as a string
96 */
97static inline char *
98nfs4_path(const struct dentry *dentry, char *buffer, ssize_t buflen)
99{
100#ifdef CONFIG_NFS_V4
101 return nfs_path(NFS_SB(dentry->d_sb)->mnt_path, dentry, buffer, buflen);
102#else
103 return NULL;
104#endif
105}
106
107/*
108 * Determine the device name as a string
109 */
110static inline char *nfs_devname(const struct vfsmount *mnt_parent,
111 const struct dentry *dentry,
112 char *buffer, ssize_t buflen)
113{
114 return nfs_path(mnt_parent->mnt_devname, dentry, buffer, buflen);
115}
116
117/*
118 * Determine the actual block size (and log2 thereof)
119 */
120static inline
121unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp)
122{
123 /* make sure blocksize is a power of two */
124 if ((bsize & (bsize - 1)) || nrbitsp) {
125 unsigned char nrbits;
126
127 for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--)
128 ;
129 bsize = 1 << nrbits;
130 if (nrbitsp)
131 *nrbitsp = nrbits;
132 }
133
134 return bsize;
135}
136
137/*
138 * Calculate the number of 512byte blocks used.
139 */
140static inline unsigned long nfs_calc_block_size(u64 tsize)
141{
142 loff_t used = (tsize + 511) >> 9;
143 return (used > ULONG_MAX) ? ULONG_MAX : used;
144}
145
146/*
147 * Compute and set NFS server blocksize
148 */
149static inline
150unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp)
151{
152 if (bsize < NFS_MIN_FILE_IO_SIZE)
153 bsize = NFS_DEF_FILE_IO_SIZE;
154 else if (bsize >= NFS_MAX_FILE_IO_SIZE)
155 bsize = NFS_MAX_FILE_IO_SIZE;
156
157 return nfs_block_bits(bsize, nrbitsp);
158}
159
160/*
161 * Determine the maximum file size for a superblock
162 */
163static inline
164void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize)
165{
166 sb->s_maxbytes = (loff_t)maxfilesize;
167 if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0)
168 sb->s_maxbytes = MAX_LFS_FILESIZE;
169}
170
171/*
172 * Check if the string represents a "valid" IPv4 address
173 */
174static inline int valid_ipaddr4(const char *buf)
175{
176 int rc, count, in[4];
177
178 rc = sscanf(buf, "%d.%d.%d.%d", &in[0], &in[1], &in[2], &in[3]);
179 if (rc != 4)
180 return -EINVAL;
181 for (count = 0; count < 4; count++) {
182 if (in[count] > 255)
183 return -EINVAL;
184 }
185 return 0;
186}