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 /* 6656e4ebf8SBryan Schumaker * Maximum number of pages that readdir can use for creating 6756e4ebf8SBryan Schumaker * a vmapped array of pages. 6856e4ebf8SBryan Schumaker */ 6956e4ebf8SBryan Schumaker #define NFS_MAX_READDIR_PAGES 8 7056e4ebf8SBryan Schumaker 7156e4ebf8SBryan Schumaker /* 726b18eaa0S\"Talpey, Thomas\ * In-kernel mount arguments 736b18eaa0S\"Talpey, Thomas\ */ 746b18eaa0S\"Talpey, Thomas\ struct nfs_parsed_mount_data { 756b18eaa0S\"Talpey, Thomas\ int flags; 766b18eaa0S\"Talpey, Thomas\ int rsize, wsize; 776b18eaa0S\"Talpey, Thomas\ int timeo, retrans; 786b18eaa0S\"Talpey, Thomas\ int acregmin, acregmax, 796b18eaa0S\"Talpey, Thomas\ acdirmin, acdirmax; 806b18eaa0S\"Talpey, Thomas\ int namlen; 81b797cac7SDavid Howells unsigned int options; 826b18eaa0S\"Talpey, Thomas\ unsigned int bsize; 836b18eaa0S\"Talpey, Thomas\ unsigned int auth_flavor_len; 846b18eaa0S\"Talpey, Thomas\ rpc_authflavor_t auth_flavors[1]; 856b18eaa0S\"Talpey, Thomas\ char *client_address; 86764302ccSChuck Lever unsigned int version; 873fd5be9eSMike Sager unsigned int minorversion; 8808734048SDavid Howells char *fscache_uniq; 896b18eaa0S\"Talpey, Thomas\ 906b18eaa0S\"Talpey, Thomas\ struct { 914c568017SChuck Lever struct sockaddr_storage address; 924c568017SChuck Lever size_t addrlen; 936b18eaa0S\"Talpey, Thomas\ char *hostname; 9478fa701fSChuck Lever u32 version; 954cfd74fcSChuck Lever int port; 9678fa701fSChuck Lever unsigned short protocol; 976b18eaa0S\"Talpey, Thomas\ } mount_server; 986b18eaa0S\"Talpey, Thomas\ 996b18eaa0S\"Talpey, Thomas\ struct { 1004c568017SChuck Lever struct sockaddr_storage address; 1014c568017SChuck Lever size_t addrlen; 1026b18eaa0S\"Talpey, Thomas\ char *hostname; 1036b18eaa0S\"Talpey, Thomas\ char *export_path; 1044cfd74fcSChuck Lever int port; 10578fa701fSChuck Lever unsigned short protocol; 1066b18eaa0S\"Talpey, Thomas\ } nfs_server; 107f9c3a380SEric Paris 108f9c3a380SEric Paris struct security_mnt_opts lsm_opts; 1096b18eaa0S\"Talpey, Thomas\ }; 1106b18eaa0S\"Talpey, Thomas\ 111146ec944SChuck Lever /* mount_clnt.c */ 112c5d120f8SChuck Lever struct nfs_mount_request { 113c5d120f8SChuck Lever struct sockaddr *sap; 114c5d120f8SChuck Lever size_t salen; 115c5d120f8SChuck Lever char *hostname; 116c5d120f8SChuck Lever char *dirpath; 117c5d120f8SChuck Lever u32 version; 118c5d120f8SChuck Lever unsigned short protocol; 119c5d120f8SChuck Lever struct nfs_fh *fh; 12050a737f8SChuck Lever int noresvport; 1218e02f6b9SChuck Lever unsigned int *auth_flav_len; 1228e02f6b9SChuck Lever rpc_authflavor_t *auth_flavs; 123c5d120f8SChuck Lever }; 124c5d120f8SChuck Lever 125c5d120f8SChuck Lever extern int nfs_mount(struct nfs_mount_request *info); 1260b524123SChuck Lever extern void nfs_umount(const struct nfs_mount_request *info); 127146ec944SChuck Lever 12824c8dbbbSDavid Howells /* client.c */ 12954ceac45SDavid Howells extern struct rpc_program nfs_program; 13054ceac45SDavid Howells 13124c8dbbbSDavid Howells extern void nfs_put_client(struct nfs_client *); 132ff052645SChuck Lever extern struct nfs_client *nfs_find_client(const struct sockaddr *, u32); 1333fbd67adSTrond Myklebust extern struct nfs_client *nfs_find_client_next(struct nfs_client *); 1342283f8d6S\"Talpey, Thomas\ extern struct nfs_server *nfs_create_server( 1352283f8d6S\"Talpey, Thomas\ const struct nfs_parsed_mount_data *, 13654ceac45SDavid Howells struct nfs_fh *); 13791ea40b9S\"Talpey, Thomas\ extern struct nfs_server *nfs4_create_server( 13891ea40b9S\"Talpey, Thomas\ const struct nfs_parsed_mount_data *, 13954ceac45SDavid Howells struct nfs_fh *); 14054ceac45SDavid Howells extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *, 14154ceac45SDavid Howells struct nfs_fh *); 14254ceac45SDavid Howells extern void nfs_free_server(struct nfs_server *server); 14354ceac45SDavid Howells extern struct nfs_server *nfs_clone_server(struct nfs_server *, 14454ceac45SDavid Howells struct nfs_fh *, 14554ceac45SDavid Howells struct nfs_fattr *); 14676db6d95SAndy Adamson extern void nfs_mark_client_ready(struct nfs_client *clp, int state); 147008f55d0SBenny Halevy extern int nfs4_check_client_ready(struct nfs_client *clp); 1486aaca566SDavid Howells #ifdef CONFIG_PROC_FS 1496aaca566SDavid Howells extern int __init nfs_fs_proc_init(void); 1506aaca566SDavid Howells extern void nfs_fs_proc_exit(void); 1516aaca566SDavid Howells #else 1526aaca566SDavid Howells static inline int nfs_fs_proc_init(void) 1536aaca566SDavid Howells { 1546aaca566SDavid Howells return 0; 1556aaca566SDavid Howells } 1566aaca566SDavid Howells static inline void nfs_fs_proc_exit(void) 1576aaca566SDavid Howells { 1586aaca566SDavid Howells } 1596aaca566SDavid Howells #endif 16024c8dbbbSDavid Howells 1617d4e2747SDavid Howells /* nfs4namespace.c */ 162f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4 163f7b422b1SDavid Howells extern struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry); 164f7b422b1SDavid Howells #else 165f7b422b1SDavid Howells static inline 166f7b422b1SDavid Howells struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry) 167f7b422b1SDavid Howells { 168f7b422b1SDavid Howells return ERR_PTR(-ENOENT); 169f7b422b1SDavid Howells } 170f7b422b1SDavid Howells #endif 171f7b422b1SDavid Howells 172f7b422b1SDavid Howells /* callback_xdr.c */ 173f7b422b1SDavid Howells extern struct svc_version nfs4_callback_version1; 17407bccc2dSAlexandros Batsakis extern struct svc_version nfs4_callback_version4; 175f7b422b1SDavid Howells 176f7b422b1SDavid Howells /* pagelist.c */ 177f7b422b1SDavid Howells extern int __init nfs_init_nfspagecache(void); 178266bee88SDavid Brownell extern void nfs_destroy_nfspagecache(void); 179f7b422b1SDavid Howells extern int __init nfs_init_readpagecache(void); 180266bee88SDavid Brownell extern void nfs_destroy_readpagecache(void); 181f7b422b1SDavid Howells extern int __init nfs_init_writepagecache(void); 182266bee88SDavid Brownell extern void nfs_destroy_writepagecache(void); 183f7b422b1SDavid Howells 184f7b422b1SDavid Howells extern int __init nfs_init_directcache(void); 185266bee88SDavid Brownell extern void nfs_destroy_directcache(void); 186f7b422b1SDavid Howells 187f7b422b1SDavid Howells /* nfs2xdr.c */ 18885828493SChuck Lever extern int nfs_stat_to_errno(enum nfs_stat); 189f7b422b1SDavid Howells extern struct rpc_procinfo nfs_procedures[]; 190573c4e1eSChuck Lever extern int nfs2_decode_dirent(struct xdr_stream *, 191573c4e1eSChuck Lever struct nfs_entry *, int); 192f7b422b1SDavid Howells 193f7b422b1SDavid Howells /* nfs3xdr.c */ 194f7b422b1SDavid Howells extern struct rpc_procinfo nfs3_procedures[]; 195573c4e1eSChuck Lever extern int nfs3_decode_dirent(struct xdr_stream *, 196573c4e1eSChuck Lever struct nfs_entry *, int); 197f7b422b1SDavid Howells 198f7b422b1SDavid Howells /* nfs4xdr.c */ 1997d4e2747SDavid Howells #ifdef CONFIG_NFS_V4 200573c4e1eSChuck Lever extern int nfs4_decode_dirent(struct xdr_stream *, 201573c4e1eSChuck Lever struct nfs_entry *, int); 2027d4e2747SDavid Howells #endif 2032449ea2eSAlexandros Batsakis #ifdef CONFIG_NFS_V4_1 2042449ea2eSAlexandros Batsakis extern const u32 nfs41_maxread_overhead; 2052449ea2eSAlexandros Batsakis extern const u32 nfs41_maxwrite_overhead; 2062449ea2eSAlexandros Batsakis #endif 207f7b422b1SDavid Howells 208f7b422b1SDavid Howells /* nfs4proc.c */ 209d75d5414SAndrew Morton #ifdef CONFIG_NFS_V4 210f7b422b1SDavid Howells extern struct rpc_procinfo nfs4_procedures[]; 211d75d5414SAndrew Morton #endif 212f7b422b1SDavid Howells 2137fe5c398STrond Myklebust /* proc.c */ 2147fe5c398STrond Myklebust void nfs_close_context(struct nfs_open_context *ctx, int is_sync); 2157fe5c398STrond Myklebust 216979df72eSTrond Myklebust /* dir.c */ 2177f8275d0SDave Chinner extern int nfs_access_cache_shrinker(struct shrinker *shrink, 2187f8275d0SDave Chinner int nr_to_scan, gfp_t gfp_mask); 219979df72eSTrond Myklebust 220f7b422b1SDavid Howells /* inode.c */ 2215746006fSTrond Myklebust extern struct workqueue_struct *nfsiod_workqueue; 222f7b422b1SDavid Howells extern struct inode *nfs_alloc_inode(struct super_block *sb); 223f7b422b1SDavid Howells extern void nfs_destroy_inode(struct inode *); 224a9185b41SChristoph Hellwig extern int nfs_write_inode(struct inode *, struct writeback_control *); 225b57922d9SAl Viro extern void nfs_evict_inode(struct inode *); 226f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4 227b57922d9SAl Viro extern void nfs4_evict_inode(struct inode *); 228f7b422b1SDavid Howells #endif 229f41f7418STrond Myklebust void nfs_zap_acl_cache(struct inode *inode); 23072cb77f4STrond Myklebust extern int nfs_wait_bit_killable(void *word); 231f7b422b1SDavid Howells 232f7b422b1SDavid Howells /* super.c */ 23354ceac45SDavid Howells extern struct file_system_type nfs_xdev_fs_type; 234f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4 23554ceac45SDavid Howells extern struct file_system_type nfs4_xdev_fs_type; 23654ceac45SDavid Howells extern struct file_system_type nfs4_referral_fs_type; 237f7b422b1SDavid Howells #endif 2384ebd9ab3SDominik Hackl 239f7b422b1SDavid Howells extern struct rpc_stat nfs_rpcstat; 2404ebd9ab3SDominik Hackl 241f7b422b1SDavid Howells extern int __init register_nfs_fs(void); 242f7b422b1SDavid Howells extern void __exit unregister_nfs_fs(void); 2431daef0a8STrond Myklebust extern void nfs_sb_active(struct super_block *sb); 2441daef0a8STrond Myklebust extern void nfs_sb_deactive(struct super_block *sb); 245f7b422b1SDavid Howells 246f7b422b1SDavid Howells /* namespace.c */ 24754ceac45SDavid Howells extern char *nfs_path(const char *base, 24854ceac45SDavid Howells const struct dentry *droot, 24954ceac45SDavid Howells const struct dentry *dentry, 250f7b422b1SDavid Howells char *buffer, ssize_t buflen); 251f7b422b1SDavid Howells 25254ceac45SDavid Howells /* getroot.c */ 25354ceac45SDavid Howells extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *); 2547d4e2747SDavid Howells #ifdef CONFIG_NFS_V4 25554ceac45SDavid Howells extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *); 25654ceac45SDavid Howells 257815409d2STrond Myklebust extern int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh); 2587d4e2747SDavid Howells #endif 259f7b422b1SDavid Howells 260f11c88afSAndy Adamson /* read.c */ 261f11c88afSAndy Adamson extern void nfs_read_prepare(struct rpc_task *task, void *calldata); 262f11c88afSAndy Adamson 263def6ed7eSAndy Adamson /* write.c */ 264def6ed7eSAndy Adamson extern void nfs_write_prepare(struct rpc_task *task, void *calldata); 265074cc1deSTrond Myklebust #ifdef CONFIG_MIGRATION 266074cc1deSTrond Myklebust extern int nfs_migrate_page(struct address_space *, 267074cc1deSTrond Myklebust struct page *, struct page *); 268074cc1deSTrond Myklebust #else 269074cc1deSTrond Myklebust #define nfs_migrate_page NULL 270074cc1deSTrond Myklebust #endif 271def6ed7eSAndy Adamson 272cccef3b9SAndy Adamson /* nfs4proc.c */ 273cccef3b9SAndy Adamson extern int _nfs4_call_sync(struct nfs_server *server, 274cccef3b9SAndy Adamson struct rpc_message *msg, 275cccef3b9SAndy Adamson struct nfs4_sequence_args *args, 276cccef3b9SAndy Adamson struct nfs4_sequence_res *res, 277cccef3b9SAndy Adamson int cache_reply); 278cccef3b9SAndy Adamson extern int _nfs4_call_sync_session(struct nfs_server *server, 279cccef3b9SAndy Adamson struct rpc_message *msg, 280cccef3b9SAndy Adamson struct nfs4_sequence_args *args, 281cccef3b9SAndy Adamson struct nfs4_sequence_res *res, 282cccef3b9SAndy Adamson int cache_reply); 283cccef3b9SAndy Adamson 284557134a3SAndy Adamson /* 285f7b422b1SDavid Howells * Determine the device name as a string 286f7b422b1SDavid Howells */ 287f7b422b1SDavid Howells static inline char *nfs_devname(const struct vfsmount *mnt_parent, 288f7b422b1SDavid Howells const struct dentry *dentry, 289f7b422b1SDavid Howells char *buffer, ssize_t buflen) 290f7b422b1SDavid Howells { 29154ceac45SDavid Howells return nfs_path(mnt_parent->mnt_devname, mnt_parent->mnt_root, 29254ceac45SDavid Howells dentry, buffer, buflen); 293f7b422b1SDavid Howells } 294f7b422b1SDavid Howells 295f7b422b1SDavid Howells /* 296f7b422b1SDavid Howells * Determine the actual block size (and log2 thereof) 297f7b422b1SDavid Howells */ 298f7b422b1SDavid Howells static inline 299f7b422b1SDavid Howells unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp) 300f7b422b1SDavid Howells { 301f7b422b1SDavid Howells /* make sure blocksize is a power of two */ 302f7b422b1SDavid Howells if ((bsize & (bsize - 1)) || nrbitsp) { 303f7b422b1SDavid Howells unsigned char nrbits; 304f7b422b1SDavid Howells 305f7b422b1SDavid Howells for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--) 306f7b422b1SDavid Howells ; 307f7b422b1SDavid Howells bsize = 1 << nrbits; 308f7b422b1SDavid Howells if (nrbitsp) 309f7b422b1SDavid Howells *nrbitsp = nrbits; 310f7b422b1SDavid Howells } 311f7b422b1SDavid Howells 312f7b422b1SDavid Howells return bsize; 313f7b422b1SDavid Howells } 314f7b422b1SDavid Howells 315f7b422b1SDavid Howells /* 316f7b422b1SDavid Howells * Calculate the number of 512byte blocks used. 317f7b422b1SDavid Howells */ 3189eaa67c6SChuck Lever static inline blkcnt_t nfs_calc_block_size(u64 tsize) 319f7b422b1SDavid Howells { 3209eaa67c6SChuck Lever blkcnt_t used = (tsize + 511) >> 9; 321f7b422b1SDavid Howells return (used > ULONG_MAX) ? ULONG_MAX : used; 322f7b422b1SDavid Howells } 323f7b422b1SDavid Howells 324f7b422b1SDavid Howells /* 325f7b422b1SDavid Howells * Compute and set NFS server blocksize 326f7b422b1SDavid Howells */ 327f7b422b1SDavid Howells static inline 328f7b422b1SDavid Howells unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp) 329f7b422b1SDavid Howells { 330f7b422b1SDavid Howells if (bsize < NFS_MIN_FILE_IO_SIZE) 331f7b422b1SDavid Howells bsize = NFS_DEF_FILE_IO_SIZE; 332f7b422b1SDavid Howells else if (bsize >= NFS_MAX_FILE_IO_SIZE) 333f7b422b1SDavid Howells bsize = NFS_MAX_FILE_IO_SIZE; 334f7b422b1SDavid Howells 335f7b422b1SDavid Howells return nfs_block_bits(bsize, nrbitsp); 336f7b422b1SDavid Howells } 337f7b422b1SDavid Howells 338f7b422b1SDavid Howells /* 339f7b422b1SDavid Howells * Determine the maximum file size for a superblock 340f7b422b1SDavid Howells */ 341f7b422b1SDavid Howells static inline 342f7b422b1SDavid Howells void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize) 343f7b422b1SDavid Howells { 344f7b422b1SDavid Howells sb->s_maxbytes = (loff_t)maxfilesize; 345f7b422b1SDavid Howells if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0) 346f7b422b1SDavid Howells sb->s_maxbytes = MAX_LFS_FILESIZE; 347f7b422b1SDavid Howells } 34849a70f27STrond Myklebust 34949a70f27STrond Myklebust /* 35049a70f27STrond Myklebust * Determine the number of bytes of data the page contains 35149a70f27STrond Myklebust */ 35249a70f27STrond Myklebust static inline 35349a70f27STrond Myklebust unsigned int nfs_page_length(struct page *page) 35449a70f27STrond Myklebust { 35549a70f27STrond Myklebust loff_t i_size = i_size_read(page->mapping->host); 35649a70f27STrond Myklebust 35749a70f27STrond Myklebust if (i_size > 0) { 35849a70f27STrond Myklebust pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; 35949a70f27STrond Myklebust if (page->index < end_index) 36049a70f27STrond Myklebust return PAGE_CACHE_SIZE; 36149a70f27STrond Myklebust if (page->index == end_index) 36249a70f27STrond Myklebust return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1; 36349a70f27STrond Myklebust } 36449a70f27STrond Myklebust return 0; 36549a70f27STrond Myklebust } 3668d5658c9STrond Myklebust 3678d5658c9STrond Myklebust /* 3680b26a0bfSTrond Myklebust * Convert a umode to a dirent->d_type 3690b26a0bfSTrond Myklebust */ 3700b26a0bfSTrond Myklebust static inline 3710b26a0bfSTrond Myklebust unsigned char nfs_umode_to_dtype(umode_t mode) 3720b26a0bfSTrond Myklebust { 3730b26a0bfSTrond Myklebust return (mode >> 12) & 15; 3740b26a0bfSTrond Myklebust } 3750b26a0bfSTrond Myklebust 3760b26a0bfSTrond Myklebust /* 3778d5658c9STrond Myklebust * Determine the number of pages in an array of length 'len' and 3788d5658c9STrond Myklebust * with a base offset of 'base' 3798d5658c9STrond Myklebust */ 3808d5658c9STrond Myklebust static inline 3818d5658c9STrond Myklebust unsigned int nfs_page_array_len(unsigned int base, size_t len) 3828d5658c9STrond Myklebust { 3838d5658c9STrond Myklebust return ((unsigned long)len + (unsigned long)base + 3848d5658c9STrond Myklebust PAGE_SIZE - 1) >> PAGE_SHIFT; 3858d5658c9STrond Myklebust } 3860110ee15STrond Myklebust 3870110ee15STrond Myklebust /* 3880110ee15STrond Myklebust * Helper for restarting RPC calls in the possible presence of NFSv4.1 3890110ee15STrond Myklebust * sessions. 3900110ee15STrond Myklebust */ 391d05dd4e9STrond Myklebust static inline int nfs_restart_rpc(struct rpc_task *task, const struct nfs_client *clp) 3920110ee15STrond Myklebust { 3930110ee15STrond Myklebust if (nfs4_has_session(clp)) 394d05dd4e9STrond Myklebust return rpc_restart_call_prepare(task); 395d05dd4e9STrond Myklebust return rpc_restart_call(task); 3960110ee15STrond Myklebust } 397