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 33d8cb1a7cSAlexandros Batsakis static inline int nfs4_has_persistent_session(const struct nfs_client *clp) 34d8cb1a7cSAlexandros Batsakis { 35d8cb1a7cSAlexandros Batsakis #ifdef CONFIG_NFS_V4_1 36d8cb1a7cSAlexandros Batsakis if (nfs4_has_session(clp)) 37d8cb1a7cSAlexandros Batsakis return (clp->cl_session->flags & SESSION4_PERSIST); 38d8cb1a7cSAlexandros Batsakis #endif /* CONFIG_NFS_V4_1 */ 39d8cb1a7cSAlexandros Batsakis return 0; 40d8cb1a7cSAlexandros Batsakis } 41d8cb1a7cSAlexandros Batsakis 42f7b422b1SDavid Howells struct nfs_clone_mount { 43f7b422b1SDavid Howells const struct super_block *sb; 44f7b422b1SDavid Howells const struct dentry *dentry; 45f7b422b1SDavid Howells struct nfs_fh *fh; 46f7b422b1SDavid Howells struct nfs_fattr *fattr; 47f7b422b1SDavid Howells char *hostname; 48f7b422b1SDavid Howells char *mnt_path; 496677d095SChuck Lever struct sockaddr *addr; 506677d095SChuck Lever size_t addrlen; 51f7b422b1SDavid Howells rpc_authflavor_t authflavor; 52f7b422b1SDavid Howells }; 53f7b422b1SDavid Howells 546b18eaa0S\"Talpey, Thomas\ /* 55a14017dbSChuck Lever * Note: RFC 1813 doesn't limit the number of auth flavors that 56a14017dbSChuck Lever * a server can return, so make something up. 57a14017dbSChuck Lever */ 58a14017dbSChuck Lever #define NFS_MAX_SECFLAVORS (12) 59a14017dbSChuck Lever 60a14017dbSChuck Lever /* 614cfd74fcSChuck Lever * Value used if the user did not specify a port value. 624cfd74fcSChuck Lever */ 634cfd74fcSChuck Lever #define NFS_UNSPEC_PORT (-1) 644cfd74fcSChuck Lever 654cfd74fcSChuck Lever /* 666b18eaa0S\"Talpey, Thomas\ * In-kernel mount arguments 676b18eaa0S\"Talpey, Thomas\ */ 686b18eaa0S\"Talpey, Thomas\ struct nfs_parsed_mount_data { 696b18eaa0S\"Talpey, Thomas\ int flags; 706b18eaa0S\"Talpey, Thomas\ int rsize, wsize; 716b18eaa0S\"Talpey, Thomas\ int timeo, retrans; 726b18eaa0S\"Talpey, Thomas\ int acregmin, acregmax, 736b18eaa0S\"Talpey, Thomas\ acdirmin, acdirmax; 746b18eaa0S\"Talpey, Thomas\ int namlen; 75b797cac7SDavid Howells unsigned int options; 766b18eaa0S\"Talpey, Thomas\ unsigned int bsize; 776b18eaa0S\"Talpey, Thomas\ unsigned int auth_flavor_len; 786b18eaa0S\"Talpey, Thomas\ rpc_authflavor_t auth_flavors[1]; 796b18eaa0S\"Talpey, Thomas\ char *client_address; 80764302ccSChuck Lever unsigned int version; 813fd5be9eSMike Sager unsigned int minorversion; 8208734048SDavid Howells char *fscache_uniq; 836b18eaa0S\"Talpey, Thomas\ 846b18eaa0S\"Talpey, Thomas\ struct { 854c568017SChuck Lever struct sockaddr_storage address; 864c568017SChuck Lever size_t addrlen; 876b18eaa0S\"Talpey, Thomas\ char *hostname; 8878fa701fSChuck Lever u32 version; 894cfd74fcSChuck Lever int port; 9078fa701fSChuck Lever unsigned short protocol; 916b18eaa0S\"Talpey, Thomas\ } mount_server; 926b18eaa0S\"Talpey, Thomas\ 936b18eaa0S\"Talpey, Thomas\ struct { 944c568017SChuck Lever struct sockaddr_storage address; 954c568017SChuck Lever size_t addrlen; 966b18eaa0S\"Talpey, Thomas\ char *hostname; 976b18eaa0S\"Talpey, Thomas\ char *export_path; 984cfd74fcSChuck Lever int port; 9978fa701fSChuck Lever unsigned short protocol; 1006b18eaa0S\"Talpey, Thomas\ } nfs_server; 101f9c3a380SEric Paris 102f9c3a380SEric Paris struct security_mnt_opts lsm_opts; 1036b18eaa0S\"Talpey, Thomas\ }; 1046b18eaa0S\"Talpey, Thomas\ 105146ec944SChuck Lever /* mount_clnt.c */ 106c5d120f8SChuck Lever struct nfs_mount_request { 107c5d120f8SChuck Lever struct sockaddr *sap; 108c5d120f8SChuck Lever size_t salen; 109c5d120f8SChuck Lever char *hostname; 110c5d120f8SChuck Lever char *dirpath; 111c5d120f8SChuck Lever u32 version; 112c5d120f8SChuck Lever unsigned short protocol; 113c5d120f8SChuck Lever struct nfs_fh *fh; 11450a737f8SChuck Lever int noresvport; 1158e02f6b9SChuck Lever unsigned int *auth_flav_len; 1168e02f6b9SChuck Lever rpc_authflavor_t *auth_flavs; 117c5d120f8SChuck Lever }; 118c5d120f8SChuck Lever 119c5d120f8SChuck Lever extern int nfs_mount(struct nfs_mount_request *info); 1200b524123SChuck Lever extern void nfs_umount(const struct nfs_mount_request *info); 121146ec944SChuck Lever 12224c8dbbbSDavid Howells /* client.c */ 12354ceac45SDavid Howells extern struct rpc_program nfs_program; 12454ceac45SDavid Howells 12524c8dbbbSDavid Howells extern void nfs_put_client(struct nfs_client *); 126ff052645SChuck Lever extern struct nfs_client *nfs_find_client(const struct sockaddr *, u32); 1273fbd67adSTrond Myklebust extern struct nfs_client *nfs_find_client_next(struct nfs_client *); 1282283f8d6S\"Talpey, Thomas\ extern struct nfs_server *nfs_create_server( 1292283f8d6S\"Talpey, Thomas\ const struct nfs_parsed_mount_data *, 13054ceac45SDavid Howells struct nfs_fh *); 13191ea40b9S\"Talpey, Thomas\ extern struct nfs_server *nfs4_create_server( 13291ea40b9S\"Talpey, Thomas\ const struct nfs_parsed_mount_data *, 13354ceac45SDavid Howells struct nfs_fh *); 13454ceac45SDavid Howells extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *, 13554ceac45SDavid Howells struct nfs_fh *); 13654ceac45SDavid Howells extern void nfs_free_server(struct nfs_server *server); 13754ceac45SDavid Howells extern struct nfs_server *nfs_clone_server(struct nfs_server *, 13854ceac45SDavid Howells struct nfs_fh *, 13954ceac45SDavid Howells struct nfs_fattr *); 14076db6d95SAndy Adamson extern void nfs_mark_client_ready(struct nfs_client *clp, int state); 141008f55d0SBenny Halevy extern int nfs4_check_client_ready(struct nfs_client *clp); 1426aaca566SDavid Howells #ifdef CONFIG_PROC_FS 1436aaca566SDavid Howells extern int __init nfs_fs_proc_init(void); 1446aaca566SDavid Howells extern void nfs_fs_proc_exit(void); 1456aaca566SDavid Howells #else 1466aaca566SDavid Howells static inline int nfs_fs_proc_init(void) 1476aaca566SDavid Howells { 1486aaca566SDavid Howells return 0; 1496aaca566SDavid Howells } 1506aaca566SDavid Howells static inline void nfs_fs_proc_exit(void) 1516aaca566SDavid Howells { 1526aaca566SDavid Howells } 1536aaca566SDavid Howells #endif 15424c8dbbbSDavid Howells 1557d4e2747SDavid Howells /* nfs4namespace.c */ 156f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4 157f7b422b1SDavid Howells extern struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry); 158f7b422b1SDavid Howells #else 159f7b422b1SDavid Howells static inline 160f7b422b1SDavid Howells struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry) 161f7b422b1SDavid Howells { 162f7b422b1SDavid Howells return ERR_PTR(-ENOENT); 163f7b422b1SDavid Howells } 164f7b422b1SDavid Howells #endif 165f7b422b1SDavid Howells 166f7b422b1SDavid Howells /* callback_xdr.c */ 167f7b422b1SDavid Howells extern struct svc_version nfs4_callback_version1; 16807bccc2dSAlexandros Batsakis extern struct svc_version nfs4_callback_version4; 169f7b422b1SDavid Howells 170f7b422b1SDavid Howells /* pagelist.c */ 171f7b422b1SDavid Howells extern int __init nfs_init_nfspagecache(void); 172266bee88SDavid Brownell extern void nfs_destroy_nfspagecache(void); 173f7b422b1SDavid Howells extern int __init nfs_init_readpagecache(void); 174266bee88SDavid Brownell extern void nfs_destroy_readpagecache(void); 175f7b422b1SDavid Howells extern int __init nfs_init_writepagecache(void); 176266bee88SDavid Brownell extern void nfs_destroy_writepagecache(void); 177f7b422b1SDavid Howells 178f7b422b1SDavid Howells extern int __init nfs_init_directcache(void); 179266bee88SDavid Brownell extern void nfs_destroy_directcache(void); 180f7b422b1SDavid Howells 181f7b422b1SDavid Howells /* nfs2xdr.c */ 1827d4e2747SDavid Howells extern int nfs_stat_to_errno(int); 183f7b422b1SDavid Howells extern struct rpc_procinfo nfs_procedures[]; 1840dbb4c67SAl Viro extern __be32 * nfs_decode_dirent(__be32 *, struct nfs_entry *, int); 185f7b422b1SDavid Howells 186f7b422b1SDavid Howells /* nfs3xdr.c */ 187f7b422b1SDavid Howells extern struct rpc_procinfo nfs3_procedures[]; 1880dbb4c67SAl Viro extern __be32 *nfs3_decode_dirent(__be32 *, struct nfs_entry *, int); 189f7b422b1SDavid Howells 190f7b422b1SDavid Howells /* nfs4xdr.c */ 1917d4e2747SDavid Howells #ifdef CONFIG_NFS_V4 1920dbb4c67SAl Viro extern __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus); 1937d4e2747SDavid Howells #endif 1942449ea2eSAlexandros Batsakis #ifdef CONFIG_NFS_V4_1 1952449ea2eSAlexandros Batsakis extern const u32 nfs41_maxread_overhead; 1962449ea2eSAlexandros Batsakis extern const u32 nfs41_maxwrite_overhead; 1972449ea2eSAlexandros Batsakis #endif 198f7b422b1SDavid Howells 199f7b422b1SDavid Howells /* nfs4proc.c */ 200e608e79fSAndy Adamson extern void nfs4_restart_rpc(struct rpc_task *, const struct nfs_client *, 201e608e79fSAndy Adamson struct nfs4_sequence_res *); 202d75d5414SAndrew Morton #ifdef CONFIG_NFS_V4 203f7b422b1SDavid Howells extern struct rpc_procinfo nfs4_procedures[]; 204d75d5414SAndrew Morton #endif 205f7b422b1SDavid Howells 2067fe5c398STrond Myklebust /* proc.c */ 2077fe5c398STrond Myklebust void nfs_close_context(struct nfs_open_context *ctx, int is_sync); 2087fe5c398STrond Myklebust 209979df72eSTrond Myklebust /* dir.c */ 210979df72eSTrond Myklebust extern int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask); 211979df72eSTrond Myklebust 212f7b422b1SDavid Howells /* inode.c */ 2135746006fSTrond Myklebust extern struct workqueue_struct *nfsiod_workqueue; 214f7b422b1SDavid Howells extern struct inode *nfs_alloc_inode(struct super_block *sb); 215f7b422b1SDavid Howells extern void nfs_destroy_inode(struct inode *); 216f7b422b1SDavid Howells extern int nfs_write_inode(struct inode *,int); 217f7b422b1SDavid Howells extern void nfs_clear_inode(struct inode *); 218f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4 219f7b422b1SDavid Howells extern void nfs4_clear_inode(struct inode *); 220f7b422b1SDavid Howells #endif 221f41f7418STrond Myklebust void nfs_zap_acl_cache(struct inode *inode); 22272cb77f4STrond Myklebust extern int nfs_wait_bit_killable(void *word); 223f7b422b1SDavid Howells 224f7b422b1SDavid Howells /* super.c */ 22554ceac45SDavid Howells extern struct file_system_type nfs_xdev_fs_type; 226f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4 22754ceac45SDavid Howells extern struct file_system_type nfs4_xdev_fs_type; 22854ceac45SDavid Howells extern struct file_system_type nfs4_referral_fs_type; 229f7b422b1SDavid Howells #endif 2304ebd9ab3SDominik Hackl 231f7b422b1SDavid Howells extern struct rpc_stat nfs_rpcstat; 2324ebd9ab3SDominik Hackl 233f7b422b1SDavid Howells extern int __init register_nfs_fs(void); 234f7b422b1SDavid Howells extern void __exit unregister_nfs_fs(void); 2351daef0a8STrond Myklebust extern void nfs_sb_active(struct super_block *sb); 2361daef0a8STrond Myklebust extern void nfs_sb_deactive(struct super_block *sb); 237f7b422b1SDavid Howells 238f7b422b1SDavid Howells /* namespace.c */ 23954ceac45SDavid Howells extern char *nfs_path(const char *base, 24054ceac45SDavid Howells const struct dentry *droot, 24154ceac45SDavid Howells const struct dentry *dentry, 242f7b422b1SDavid Howells char *buffer, ssize_t buflen); 243f7b422b1SDavid Howells 24454ceac45SDavid Howells /* getroot.c */ 24554ceac45SDavid Howells extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *); 2467d4e2747SDavid Howells #ifdef CONFIG_NFS_V4 24754ceac45SDavid Howells extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *); 24854ceac45SDavid Howells 24954ceac45SDavid Howells extern int nfs4_path_walk(struct nfs_server *server, 25054ceac45SDavid Howells struct nfs_fh *mntfh, 25154ceac45SDavid Howells const char *path); 2527d4e2747SDavid Howells #endif 253f7b422b1SDavid Howells 254f11c88afSAndy Adamson /* read.c */ 255f11c88afSAndy Adamson extern void nfs_read_prepare(struct rpc_task *task, void *calldata); 256f11c88afSAndy Adamson 257def6ed7eSAndy Adamson /* write.c */ 258def6ed7eSAndy Adamson extern void nfs_write_prepare(struct rpc_task *task, void *calldata); 259074cc1deSTrond Myklebust #ifdef CONFIG_MIGRATION 260074cc1deSTrond Myklebust extern int nfs_migrate_page(struct address_space *, 261074cc1deSTrond Myklebust struct page *, struct page *); 262074cc1deSTrond Myklebust #else 263074cc1deSTrond Myklebust #define nfs_migrate_page NULL 264074cc1deSTrond Myklebust #endif 265def6ed7eSAndy Adamson 266cccef3b9SAndy Adamson /* nfs4proc.c */ 267cccef3b9SAndy Adamson extern int _nfs4_call_sync(struct nfs_server *server, 268cccef3b9SAndy Adamson struct rpc_message *msg, 269cccef3b9SAndy Adamson struct nfs4_sequence_args *args, 270cccef3b9SAndy Adamson struct nfs4_sequence_res *res, 271cccef3b9SAndy Adamson int cache_reply); 272cccef3b9SAndy Adamson extern int _nfs4_call_sync_session(struct nfs_server *server, 273cccef3b9SAndy Adamson struct rpc_message *msg, 274cccef3b9SAndy Adamson struct nfs4_sequence_args *args, 275cccef3b9SAndy Adamson struct nfs4_sequence_res *res, 276cccef3b9SAndy Adamson int cache_reply); 277cccef3b9SAndy Adamson 27813615871SAndy Adamson #ifdef CONFIG_NFS_V4_1 27913615871SAndy Adamson extern void nfs41_sequence_free_slot(const struct nfs_client *, 28013615871SAndy Adamson struct nfs4_sequence_res *res); 28113615871SAndy Adamson #endif /* CONFIG_NFS_V4_1 */ 28213615871SAndy Adamson 28313615871SAndy Adamson static inline void nfs4_sequence_free_slot(const struct nfs_client *clp, 28413615871SAndy Adamson struct nfs4_sequence_res *res) 28513615871SAndy Adamson { 28613615871SAndy Adamson #ifdef CONFIG_NFS_V4_1 28713615871SAndy Adamson if (nfs4_has_session(clp)) 28813615871SAndy Adamson nfs41_sequence_free_slot(clp, res); 28913615871SAndy Adamson #endif /* CONFIG_NFS_V4_1 */ 29013615871SAndy Adamson } 29113615871SAndy Adamson 292557134a3SAndy Adamson /* 293f7b422b1SDavid Howells * Determine the device name as a string 294f7b422b1SDavid Howells */ 295f7b422b1SDavid Howells static inline char *nfs_devname(const struct vfsmount *mnt_parent, 296f7b422b1SDavid Howells const struct dentry *dentry, 297f7b422b1SDavid Howells char *buffer, ssize_t buflen) 298f7b422b1SDavid Howells { 29954ceac45SDavid Howells return nfs_path(mnt_parent->mnt_devname, mnt_parent->mnt_root, 30054ceac45SDavid Howells dentry, buffer, buflen); 301f7b422b1SDavid Howells } 302f7b422b1SDavid Howells 303f7b422b1SDavid Howells /* 304f7b422b1SDavid Howells * Determine the actual block size (and log2 thereof) 305f7b422b1SDavid Howells */ 306f7b422b1SDavid Howells static inline 307f7b422b1SDavid Howells unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp) 308f7b422b1SDavid Howells { 309f7b422b1SDavid Howells /* make sure blocksize is a power of two */ 310f7b422b1SDavid Howells if ((bsize & (bsize - 1)) || nrbitsp) { 311f7b422b1SDavid Howells unsigned char nrbits; 312f7b422b1SDavid Howells 313f7b422b1SDavid Howells for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--) 314f7b422b1SDavid Howells ; 315f7b422b1SDavid Howells bsize = 1 << nrbits; 316f7b422b1SDavid Howells if (nrbitsp) 317f7b422b1SDavid Howells *nrbitsp = nrbits; 318f7b422b1SDavid Howells } 319f7b422b1SDavid Howells 320f7b422b1SDavid Howells return bsize; 321f7b422b1SDavid Howells } 322f7b422b1SDavid Howells 323f7b422b1SDavid Howells /* 324f7b422b1SDavid Howells * Calculate the number of 512byte blocks used. 325f7b422b1SDavid Howells */ 3269eaa67c6SChuck Lever static inline blkcnt_t nfs_calc_block_size(u64 tsize) 327f7b422b1SDavid Howells { 3289eaa67c6SChuck Lever blkcnt_t used = (tsize + 511) >> 9; 329f7b422b1SDavid Howells return (used > ULONG_MAX) ? ULONG_MAX : used; 330f7b422b1SDavid Howells } 331f7b422b1SDavid Howells 332f7b422b1SDavid Howells /* 333f7b422b1SDavid Howells * Compute and set NFS server blocksize 334f7b422b1SDavid Howells */ 335f7b422b1SDavid Howells static inline 336f7b422b1SDavid Howells unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp) 337f7b422b1SDavid Howells { 338f7b422b1SDavid Howells if (bsize < NFS_MIN_FILE_IO_SIZE) 339f7b422b1SDavid Howells bsize = NFS_DEF_FILE_IO_SIZE; 340f7b422b1SDavid Howells else if (bsize >= NFS_MAX_FILE_IO_SIZE) 341f7b422b1SDavid Howells bsize = NFS_MAX_FILE_IO_SIZE; 342f7b422b1SDavid Howells 343f7b422b1SDavid Howells return nfs_block_bits(bsize, nrbitsp); 344f7b422b1SDavid Howells } 345f7b422b1SDavid Howells 346f7b422b1SDavid Howells /* 347f7b422b1SDavid Howells * Determine the maximum file size for a superblock 348f7b422b1SDavid Howells */ 349f7b422b1SDavid Howells static inline 350f7b422b1SDavid Howells void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize) 351f7b422b1SDavid Howells { 352f7b422b1SDavid Howells sb->s_maxbytes = (loff_t)maxfilesize; 353f7b422b1SDavid Howells if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0) 354f7b422b1SDavid Howells sb->s_maxbytes = MAX_LFS_FILESIZE; 355f7b422b1SDavid Howells } 35649a70f27STrond Myklebust 35749a70f27STrond Myklebust /* 35849a70f27STrond Myklebust * Determine the number of bytes of data the page contains 35949a70f27STrond Myklebust */ 36049a70f27STrond Myklebust static inline 36149a70f27STrond Myklebust unsigned int nfs_page_length(struct page *page) 36249a70f27STrond Myklebust { 36349a70f27STrond Myklebust loff_t i_size = i_size_read(page->mapping->host); 36449a70f27STrond Myklebust 36549a70f27STrond Myklebust if (i_size > 0) { 36649a70f27STrond Myklebust pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; 36749a70f27STrond Myklebust if (page->index < end_index) 36849a70f27STrond Myklebust return PAGE_CACHE_SIZE; 36949a70f27STrond Myklebust if (page->index == end_index) 37049a70f27STrond Myklebust return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1; 37149a70f27STrond Myklebust } 37249a70f27STrond Myklebust return 0; 37349a70f27STrond Myklebust } 3748d5658c9STrond Myklebust 3758d5658c9STrond Myklebust /* 3768d5658c9STrond Myklebust * Determine the number of pages in an array of length 'len' and 3778d5658c9STrond Myklebust * with a base offset of 'base' 3788d5658c9STrond Myklebust */ 3798d5658c9STrond Myklebust static inline 3808d5658c9STrond Myklebust unsigned int nfs_page_array_len(unsigned int base, size_t len) 3818d5658c9STrond Myklebust { 3828d5658c9STrond Myklebust return ((unsigned long)len + (unsigned long)base + 3838d5658c9STrond Myklebust PAGE_SIZE - 1) >> PAGE_SHIFT; 3848d5658c9STrond Myklebust } 385