xref: /openbmc/linux/fs/nfs/internal.h (revision 764302cc)
1f7b422b1SDavid Howells /*
2f7b422b1SDavid Howells  * NFS internal definitions
3f7b422b1SDavid Howells  */
4f7b422b1SDavid Howells 
5eedc020eSAndy Adamson #include "nfs4_fs.h"
6f7b422b1SDavid Howells #include <linux/mount.h>
7f9c3a380SEric Paris #include <linux/security.h>
8f7b422b1SDavid Howells 
908734048SDavid Howells #define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS)
1008734048SDavid Howells 
1154ceac45SDavid Howells struct nfs_string;
1254ceac45SDavid Howells 
1354ceac45SDavid Howells /* Maximum number of readahead requests
1454ceac45SDavid Howells  * FIXME: this should really be a sysctl so that users may tune it to suit
1554ceac45SDavid Howells  *        their needs. People that do NFS over a slow network, might for
1654ceac45SDavid Howells  *        instance want to reduce it to something closer to 1 for improved
1754ceac45SDavid Howells  *        interactive response.
1854ceac45SDavid Howells  */
1954ceac45SDavid Howells #define NFS_MAX_READAHEAD	(RPC_DEF_SLOT_TABLE - 1)
2054ceac45SDavid Howells 
21eedc020eSAndy Adamson /*
22eedc020eSAndy Adamson  * Determine if sessions are in use.
23eedc020eSAndy Adamson  */
24eedc020eSAndy Adamson static inline int nfs4_has_session(const struct nfs_client *clp)
25eedc020eSAndy Adamson {
26eedc020eSAndy Adamson #ifdef CONFIG_NFS_V4_1
27eedc020eSAndy Adamson 	if (clp->cl_session)
28eedc020eSAndy Adamson 		return 1;
29eedc020eSAndy Adamson #endif /* CONFIG_NFS_V4_1 */
30eedc020eSAndy Adamson 	return 0;
31eedc020eSAndy Adamson }
32eedc020eSAndy Adamson 
33f7b422b1SDavid Howells struct nfs_clone_mount {
34f7b422b1SDavid Howells 	const struct super_block *sb;
35f7b422b1SDavid Howells 	const struct dentry *dentry;
36f7b422b1SDavid Howells 	struct nfs_fh *fh;
37f7b422b1SDavid Howells 	struct nfs_fattr *fattr;
38f7b422b1SDavid Howells 	char *hostname;
39f7b422b1SDavid Howells 	char *mnt_path;
406677d095SChuck Lever 	struct sockaddr *addr;
416677d095SChuck Lever 	size_t addrlen;
42f7b422b1SDavid Howells 	rpc_authflavor_t authflavor;
43f7b422b1SDavid Howells };
44f7b422b1SDavid Howells 
456b18eaa0S\"Talpey, Thomas\ /*
46a14017dbSChuck Lever  * Note: RFC 1813 doesn't limit the number of auth flavors that
47a14017dbSChuck Lever  * a server can return, so make something up.
48a14017dbSChuck Lever  */
49a14017dbSChuck Lever #define NFS_MAX_SECFLAVORS	(12)
50a14017dbSChuck Lever 
51a14017dbSChuck Lever /*
524cfd74fcSChuck Lever  * Value used if the user did not specify a port value.
534cfd74fcSChuck Lever  */
544cfd74fcSChuck Lever #define NFS_UNSPEC_PORT		(-1)
554cfd74fcSChuck Lever 
564cfd74fcSChuck Lever /*
576b18eaa0S\"Talpey, Thomas\  * In-kernel mount arguments
586b18eaa0S\"Talpey, Thomas\  */
596b18eaa0S\"Talpey, Thomas\ struct nfs_parsed_mount_data {
606b18eaa0S\"Talpey, Thomas\ 	int			flags;
616b18eaa0S\"Talpey, Thomas\ 	int			rsize, wsize;
626b18eaa0S\"Talpey, Thomas\ 	int			timeo, retrans;
636b18eaa0S\"Talpey, Thomas\ 	int			acregmin, acregmax,
646b18eaa0S\"Talpey, Thomas\ 				acdirmin, acdirmax;
656b18eaa0S\"Talpey, Thomas\ 	int			namlen;
66b797cac7SDavid Howells 	unsigned int		options;
676b18eaa0S\"Talpey, Thomas\ 	unsigned int		bsize;
686b18eaa0S\"Talpey, Thomas\ 	unsigned int		auth_flavor_len;
696b18eaa0S\"Talpey, Thomas\ 	rpc_authflavor_t	auth_flavors[1];
706b18eaa0S\"Talpey, Thomas\ 	char			*client_address;
71764302ccSChuck Lever 	unsigned int		version;
723fd5be9eSMike Sager 	unsigned int		minorversion;
7308734048SDavid Howells 	char			*fscache_uniq;
746b18eaa0S\"Talpey, Thomas\ 
756b18eaa0S\"Talpey, Thomas\ 	struct {
764c568017SChuck Lever 		struct sockaddr_storage	address;
774c568017SChuck Lever 		size_t			addrlen;
786b18eaa0S\"Talpey, Thomas\ 		char			*hostname;
7978fa701fSChuck Lever 		u32			version;
804cfd74fcSChuck Lever 		int			port;
8178fa701fSChuck Lever 		unsigned short		protocol;
826b18eaa0S\"Talpey, Thomas\ 	} mount_server;
836b18eaa0S\"Talpey, Thomas\ 
846b18eaa0S\"Talpey, Thomas\ 	struct {
854c568017SChuck Lever 		struct sockaddr_storage	address;
864c568017SChuck Lever 		size_t			addrlen;
876b18eaa0S\"Talpey, Thomas\ 		char			*hostname;
886b18eaa0S\"Talpey, Thomas\ 		char			*export_path;
894cfd74fcSChuck Lever 		int			port;
9078fa701fSChuck Lever 		unsigned short		protocol;
916b18eaa0S\"Talpey, Thomas\ 	} nfs_server;
92f9c3a380SEric Paris 
93f9c3a380SEric Paris 	struct security_mnt_opts lsm_opts;
946b18eaa0S\"Talpey, Thomas\ };
956b18eaa0S\"Talpey, Thomas\ 
96146ec944SChuck Lever /* mount_clnt.c */
97c5d120f8SChuck Lever struct nfs_mount_request {
98c5d120f8SChuck Lever 	struct sockaddr		*sap;
99c5d120f8SChuck Lever 	size_t			salen;
100c5d120f8SChuck Lever 	char			*hostname;
101c5d120f8SChuck Lever 	char			*dirpath;
102c5d120f8SChuck Lever 	u32			version;
103c5d120f8SChuck Lever 	unsigned short		protocol;
104c5d120f8SChuck Lever 	struct nfs_fh		*fh;
10550a737f8SChuck Lever 	int			noresvport;
1068e02f6b9SChuck Lever 	unsigned int		*auth_flav_len;
1078e02f6b9SChuck Lever 	rpc_authflavor_t	*auth_flavs;
108c5d120f8SChuck Lever };
109c5d120f8SChuck Lever 
110c5d120f8SChuck Lever extern int nfs_mount(struct nfs_mount_request *info);
1110b524123SChuck Lever extern void nfs_umount(const struct nfs_mount_request *info);
112146ec944SChuck Lever 
11324c8dbbbSDavid Howells /* client.c */
11454ceac45SDavid Howells extern struct rpc_program nfs_program;
11554ceac45SDavid Howells 
11624c8dbbbSDavid Howells extern void nfs_put_client(struct nfs_client *);
117ff052645SChuck Lever extern struct nfs_client *nfs_find_client(const struct sockaddr *, u32);
1183fbd67adSTrond Myklebust extern struct nfs_client *nfs_find_client_next(struct nfs_client *);
1192283f8d6S\"Talpey, Thomas\ extern struct nfs_server *nfs_create_server(
1202283f8d6S\"Talpey, Thomas\ 					const struct nfs_parsed_mount_data *,
12154ceac45SDavid Howells 					struct nfs_fh *);
12291ea40b9S\"Talpey, Thomas\ extern struct nfs_server *nfs4_create_server(
12391ea40b9S\"Talpey, Thomas\ 					const struct nfs_parsed_mount_data *,
12454ceac45SDavid Howells 					struct nfs_fh *);
12554ceac45SDavid Howells extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *,
12654ceac45SDavid Howells 						      struct nfs_fh *);
12754ceac45SDavid Howells extern void nfs_free_server(struct nfs_server *server);
12854ceac45SDavid Howells extern struct nfs_server *nfs_clone_server(struct nfs_server *,
12954ceac45SDavid Howells 					   struct nfs_fh *,
13054ceac45SDavid Howells 					   struct nfs_fattr *);
13176db6d95SAndy Adamson extern void nfs_mark_client_ready(struct nfs_client *clp, int state);
132008f55d0SBenny Halevy extern int nfs4_check_client_ready(struct nfs_client *clp);
1336aaca566SDavid Howells #ifdef CONFIG_PROC_FS
1346aaca566SDavid Howells extern int __init nfs_fs_proc_init(void);
1356aaca566SDavid Howells extern void nfs_fs_proc_exit(void);
1366aaca566SDavid Howells #else
1376aaca566SDavid Howells static inline int nfs_fs_proc_init(void)
1386aaca566SDavid Howells {
1396aaca566SDavid Howells 	return 0;
1406aaca566SDavid Howells }
1416aaca566SDavid Howells static inline void nfs_fs_proc_exit(void)
1426aaca566SDavid Howells {
1436aaca566SDavid Howells }
1446aaca566SDavid Howells #endif
14524c8dbbbSDavid Howells 
1467d4e2747SDavid Howells /* nfs4namespace.c */
147f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4
148f7b422b1SDavid Howells extern struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry);
149f7b422b1SDavid Howells #else
150f7b422b1SDavid Howells static inline
151f7b422b1SDavid Howells struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry)
152f7b422b1SDavid Howells {
153f7b422b1SDavid Howells 	return ERR_PTR(-ENOENT);
154f7b422b1SDavid Howells }
155f7b422b1SDavid Howells #endif
156f7b422b1SDavid Howells 
157f7b422b1SDavid Howells /* callback_xdr.c */
158f7b422b1SDavid Howells extern struct svc_version nfs4_callback_version1;
159f7b422b1SDavid Howells 
160f7b422b1SDavid Howells /* pagelist.c */
161f7b422b1SDavid Howells extern int __init nfs_init_nfspagecache(void);
162266bee88SDavid Brownell extern void nfs_destroy_nfspagecache(void);
163f7b422b1SDavid Howells extern int __init nfs_init_readpagecache(void);
164266bee88SDavid Brownell extern void nfs_destroy_readpagecache(void);
165f7b422b1SDavid Howells extern int __init nfs_init_writepagecache(void);
166266bee88SDavid Brownell extern void nfs_destroy_writepagecache(void);
167f7b422b1SDavid Howells 
168f7b422b1SDavid Howells extern int __init nfs_init_directcache(void);
169266bee88SDavid Brownell extern void nfs_destroy_directcache(void);
170f7b422b1SDavid Howells 
171f7b422b1SDavid Howells /* nfs2xdr.c */
1727d4e2747SDavid Howells extern int nfs_stat_to_errno(int);
173f7b422b1SDavid Howells extern struct rpc_procinfo nfs_procedures[];
1740dbb4c67SAl Viro extern __be32 * nfs_decode_dirent(__be32 *, struct nfs_entry *, int);
175f7b422b1SDavid Howells 
176f7b422b1SDavid Howells /* nfs3xdr.c */
177f7b422b1SDavid Howells extern struct rpc_procinfo nfs3_procedures[];
1780dbb4c67SAl Viro extern __be32 *nfs3_decode_dirent(__be32 *, struct nfs_entry *, int);
179f7b422b1SDavid Howells 
180eedc020eSAndy Adamson /* nfs4proc.c */
181eedc020eSAndy Adamson static inline void nfs4_restart_rpc(struct rpc_task *task,
182eedc020eSAndy Adamson 				    const struct nfs_client *clp)
183eedc020eSAndy Adamson {
184eedc020eSAndy Adamson #ifdef CONFIG_NFS_V4_1
185eedc020eSAndy Adamson 	if (nfs4_has_session(clp) &&
186eedc020eSAndy Adamson 	    test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)) {
187eedc020eSAndy Adamson 		rpc_restart_call_prepare(task);
188eedc020eSAndy Adamson 		return;
189eedc020eSAndy Adamson 	}
190eedc020eSAndy Adamson #endif /* CONFIG_NFS_V4_1 */
191eedc020eSAndy Adamson 	rpc_restart_call(task);
192eedc020eSAndy Adamson }
193eedc020eSAndy Adamson 
194f7b422b1SDavid Howells /* nfs4xdr.c */
1957d4e2747SDavid Howells #ifdef CONFIG_NFS_V4
1960dbb4c67SAl Viro extern __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus);
1977d4e2747SDavid Howells #endif
198f7b422b1SDavid Howells 
199f7b422b1SDavid Howells /* nfs4proc.c */
200d75d5414SAndrew Morton #ifdef CONFIG_NFS_V4
201f7b422b1SDavid Howells extern struct rpc_procinfo nfs4_procedures[];
202d75d5414SAndrew Morton #endif
203f7b422b1SDavid Howells 
2047fe5c398STrond Myklebust /* proc.c */
2057fe5c398STrond Myklebust void nfs_close_context(struct nfs_open_context *ctx, int is_sync);
2067fe5c398STrond Myklebust 
207979df72eSTrond Myklebust /* dir.c */
208979df72eSTrond Myklebust extern int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask);
209979df72eSTrond Myklebust 
210f7b422b1SDavid Howells /* inode.c */
2115746006fSTrond Myklebust extern struct workqueue_struct *nfsiod_workqueue;
212f7b422b1SDavid Howells extern struct inode *nfs_alloc_inode(struct super_block *sb);
213f7b422b1SDavid Howells extern void nfs_destroy_inode(struct inode *);
214f7b422b1SDavid Howells extern int nfs_write_inode(struct inode *,int);
215f7b422b1SDavid Howells extern void nfs_clear_inode(struct inode *);
216f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4
217f7b422b1SDavid Howells extern void nfs4_clear_inode(struct inode *);
218f7b422b1SDavid Howells #endif
219f41f7418STrond Myklebust void nfs_zap_acl_cache(struct inode *inode);
22072cb77f4STrond Myklebust extern int nfs_wait_bit_killable(void *word);
221f7b422b1SDavid Howells 
222f7b422b1SDavid Howells /* super.c */
22354ceac45SDavid Howells extern struct file_system_type nfs_xdev_fs_type;
224f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4
22554ceac45SDavid Howells extern struct file_system_type nfs4_xdev_fs_type;
22654ceac45SDavid Howells extern struct file_system_type nfs4_referral_fs_type;
227f7b422b1SDavid Howells #endif
2284ebd9ab3SDominik Hackl 
229f7b422b1SDavid Howells extern struct rpc_stat nfs_rpcstat;
2304ebd9ab3SDominik Hackl 
231f7b422b1SDavid Howells extern int __init register_nfs_fs(void);
232f7b422b1SDavid Howells extern void __exit unregister_nfs_fs(void);
2331daef0a8STrond Myklebust extern void nfs_sb_active(struct super_block *sb);
2341daef0a8STrond Myklebust extern void nfs_sb_deactive(struct super_block *sb);
235f7b422b1SDavid Howells 
236f7b422b1SDavid Howells /* namespace.c */
23754ceac45SDavid Howells extern char *nfs_path(const char *base,
23854ceac45SDavid Howells 		      const struct dentry *droot,
23954ceac45SDavid Howells 		      const struct dentry *dentry,
240f7b422b1SDavid Howells 		      char *buffer, ssize_t buflen);
241f7b422b1SDavid Howells 
24254ceac45SDavid Howells /* getroot.c */
24354ceac45SDavid Howells extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *);
2447d4e2747SDavid Howells #ifdef CONFIG_NFS_V4
24554ceac45SDavid Howells extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *);
24654ceac45SDavid Howells 
24754ceac45SDavid Howells extern int nfs4_path_walk(struct nfs_server *server,
24854ceac45SDavid Howells 			  struct nfs_fh *mntfh,
24954ceac45SDavid Howells 			  const char *path);
2507d4e2747SDavid Howells #endif
251f7b422b1SDavid Howells 
252f11c88afSAndy Adamson /* read.c */
253f11c88afSAndy Adamson extern void nfs_read_prepare(struct rpc_task *task, void *calldata);
254f11c88afSAndy Adamson 
255def6ed7eSAndy Adamson /* write.c */
256def6ed7eSAndy Adamson extern void nfs_write_prepare(struct rpc_task *task, void *calldata);
257074cc1deSTrond Myklebust #ifdef CONFIG_MIGRATION
258074cc1deSTrond Myklebust extern int nfs_migrate_page(struct address_space *,
259074cc1deSTrond Myklebust 		struct page *, struct page *);
260074cc1deSTrond Myklebust #else
261074cc1deSTrond Myklebust #define nfs_migrate_page NULL
262074cc1deSTrond Myklebust #endif
263def6ed7eSAndy Adamson 
264cccef3b9SAndy Adamson /* nfs4proc.c */
265cccef3b9SAndy Adamson extern int _nfs4_call_sync(struct nfs_server *server,
266cccef3b9SAndy Adamson 			   struct rpc_message *msg,
267cccef3b9SAndy Adamson 			   struct nfs4_sequence_args *args,
268cccef3b9SAndy Adamson 			   struct nfs4_sequence_res *res,
269cccef3b9SAndy Adamson 			   int cache_reply);
270cccef3b9SAndy Adamson extern int _nfs4_call_sync_session(struct nfs_server *server,
271cccef3b9SAndy Adamson 				   struct rpc_message *msg,
272cccef3b9SAndy Adamson 				   struct nfs4_sequence_args *args,
273cccef3b9SAndy Adamson 				   struct nfs4_sequence_res *res,
274cccef3b9SAndy Adamson 				   int cache_reply);
275cccef3b9SAndy Adamson 
27613615871SAndy Adamson #ifdef CONFIG_NFS_V4_1
27713615871SAndy Adamson extern void nfs41_sequence_free_slot(const struct nfs_client *,
27813615871SAndy Adamson 				     struct nfs4_sequence_res *res);
27913615871SAndy Adamson #endif /* CONFIG_NFS_V4_1 */
28013615871SAndy Adamson 
28113615871SAndy Adamson static inline void nfs4_sequence_free_slot(const struct nfs_client *clp,
28213615871SAndy Adamson 					   struct nfs4_sequence_res *res)
28313615871SAndy Adamson {
28413615871SAndy Adamson #ifdef CONFIG_NFS_V4_1
28513615871SAndy Adamson 	if (nfs4_has_session(clp))
28613615871SAndy Adamson 		nfs41_sequence_free_slot(clp, res);
28713615871SAndy Adamson #endif /* CONFIG_NFS_V4_1 */
28813615871SAndy Adamson }
28913615871SAndy Adamson 
290557134a3SAndy Adamson /*
291f7b422b1SDavid Howells  * Determine the device name as a string
292f7b422b1SDavid Howells  */
293f7b422b1SDavid Howells static inline char *nfs_devname(const struct vfsmount *mnt_parent,
294f7b422b1SDavid Howells 				const struct dentry *dentry,
295f7b422b1SDavid Howells 				char *buffer, ssize_t buflen)
296f7b422b1SDavid Howells {
29754ceac45SDavid Howells 	return nfs_path(mnt_parent->mnt_devname, mnt_parent->mnt_root,
29854ceac45SDavid Howells 			dentry, buffer, buflen);
299f7b422b1SDavid Howells }
300f7b422b1SDavid Howells 
301f7b422b1SDavid Howells /*
302f7b422b1SDavid Howells  * Determine the actual block size (and log2 thereof)
303f7b422b1SDavid Howells  */
304f7b422b1SDavid Howells static inline
305f7b422b1SDavid Howells unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp)
306f7b422b1SDavid Howells {
307f7b422b1SDavid Howells 	/* make sure blocksize is a power of two */
308f7b422b1SDavid Howells 	if ((bsize & (bsize - 1)) || nrbitsp) {
309f7b422b1SDavid Howells 		unsigned char	nrbits;
310f7b422b1SDavid Howells 
311f7b422b1SDavid Howells 		for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--)
312f7b422b1SDavid Howells 			;
313f7b422b1SDavid Howells 		bsize = 1 << nrbits;
314f7b422b1SDavid Howells 		if (nrbitsp)
315f7b422b1SDavid Howells 			*nrbitsp = nrbits;
316f7b422b1SDavid Howells 	}
317f7b422b1SDavid Howells 
318f7b422b1SDavid Howells 	return bsize;
319f7b422b1SDavid Howells }
320f7b422b1SDavid Howells 
321f7b422b1SDavid Howells /*
322f7b422b1SDavid Howells  * Calculate the number of 512byte blocks used.
323f7b422b1SDavid Howells  */
3249eaa67c6SChuck Lever static inline blkcnt_t nfs_calc_block_size(u64 tsize)
325f7b422b1SDavid Howells {
3269eaa67c6SChuck Lever 	blkcnt_t used = (tsize + 511) >> 9;
327f7b422b1SDavid Howells 	return (used > ULONG_MAX) ? ULONG_MAX : used;
328f7b422b1SDavid Howells }
329f7b422b1SDavid Howells 
330f7b422b1SDavid Howells /*
331f7b422b1SDavid Howells  * Compute and set NFS server blocksize
332f7b422b1SDavid Howells  */
333f7b422b1SDavid Howells static inline
334f7b422b1SDavid Howells unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp)
335f7b422b1SDavid Howells {
336f7b422b1SDavid Howells 	if (bsize < NFS_MIN_FILE_IO_SIZE)
337f7b422b1SDavid Howells 		bsize = NFS_DEF_FILE_IO_SIZE;
338f7b422b1SDavid Howells 	else if (bsize >= NFS_MAX_FILE_IO_SIZE)
339f7b422b1SDavid Howells 		bsize = NFS_MAX_FILE_IO_SIZE;
340f7b422b1SDavid Howells 
341f7b422b1SDavid Howells 	return nfs_block_bits(bsize, nrbitsp);
342f7b422b1SDavid Howells }
343f7b422b1SDavid Howells 
344f7b422b1SDavid Howells /*
345f7b422b1SDavid Howells  * Determine the maximum file size for a superblock
346f7b422b1SDavid Howells  */
347f7b422b1SDavid Howells static inline
348f7b422b1SDavid Howells void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize)
349f7b422b1SDavid Howells {
350f7b422b1SDavid Howells 	sb->s_maxbytes = (loff_t)maxfilesize;
351f7b422b1SDavid Howells 	if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0)
352f7b422b1SDavid Howells 		sb->s_maxbytes = MAX_LFS_FILESIZE;
353f7b422b1SDavid Howells }
35449a70f27STrond Myklebust 
35549a70f27STrond Myklebust /*
35649a70f27STrond Myklebust  * Determine the number of bytes of data the page contains
35749a70f27STrond Myklebust  */
35849a70f27STrond Myklebust static inline
35949a70f27STrond Myklebust unsigned int nfs_page_length(struct page *page)
36049a70f27STrond Myklebust {
36149a70f27STrond Myklebust 	loff_t i_size = i_size_read(page->mapping->host);
36249a70f27STrond Myklebust 
36349a70f27STrond Myklebust 	if (i_size > 0) {
36449a70f27STrond Myklebust 		pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
36549a70f27STrond Myklebust 		if (page->index < end_index)
36649a70f27STrond Myklebust 			return PAGE_CACHE_SIZE;
36749a70f27STrond Myklebust 		if (page->index == end_index)
36849a70f27STrond Myklebust 			return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1;
36949a70f27STrond Myklebust 	}
37049a70f27STrond Myklebust 	return 0;
37149a70f27STrond Myklebust }
3728d5658c9STrond Myklebust 
3738d5658c9STrond Myklebust /*
3748d5658c9STrond Myklebust  * Determine the number of pages in an array of length 'len' and
3758d5658c9STrond Myklebust  * with a base offset of 'base'
3768d5658c9STrond Myklebust  */
3778d5658c9STrond Myklebust static inline
3788d5658c9STrond Myklebust unsigned int nfs_page_array_len(unsigned int base, size_t len)
3798d5658c9STrond Myklebust {
3808d5658c9STrond Myklebust 	return ((unsigned long)len + (unsigned long)base +
3818d5658c9STrond Myklebust 		PAGE_SIZE - 1) >> PAGE_SHIFT;
3828d5658c9STrond Myklebust }
383