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[]; 19082f2e547SBryan Schumaker extern __be32 *nfs_decode_dirent(struct xdr_stream *, struct nfs_entry *, struct nfs_server *, int); 191f7b422b1SDavid Howells 192f7b422b1SDavid Howells /* nfs3xdr.c */ 193f7b422b1SDavid Howells extern struct rpc_procinfo nfs3_procedures[]; 19482f2e547SBryan Schumaker extern __be32 *nfs3_decode_dirent(struct xdr_stream *, struct nfs_entry *, struct nfs_server *, int); 195f7b422b1SDavid Howells 196f7b422b1SDavid Howells /* nfs4xdr.c */ 1977d4e2747SDavid Howells #ifdef CONFIG_NFS_V4 19882f2e547SBryan Schumaker extern __be32 *nfs4_decode_dirent(struct xdr_stream *, struct nfs_entry *, struct nfs_server *, int); 1997d4e2747SDavid Howells #endif 2002449ea2eSAlexandros Batsakis #ifdef CONFIG_NFS_V4_1 2012449ea2eSAlexandros Batsakis extern const u32 nfs41_maxread_overhead; 2022449ea2eSAlexandros Batsakis extern const u32 nfs41_maxwrite_overhead; 2032449ea2eSAlexandros Batsakis #endif 204f7b422b1SDavid Howells 205f7b422b1SDavid Howells /* nfs4proc.c */ 206d75d5414SAndrew Morton #ifdef CONFIG_NFS_V4 207f7b422b1SDavid Howells extern struct rpc_procinfo nfs4_procedures[]; 208d75d5414SAndrew Morton #endif 209f7b422b1SDavid Howells 2107fe5c398STrond Myklebust /* proc.c */ 2117fe5c398STrond Myklebust void nfs_close_context(struct nfs_open_context *ctx, int is_sync); 2127fe5c398STrond Myklebust 213979df72eSTrond Myklebust /* dir.c */ 2147f8275d0SDave Chinner extern int nfs_access_cache_shrinker(struct shrinker *shrink, 2157f8275d0SDave Chinner int nr_to_scan, gfp_t gfp_mask); 216979df72eSTrond Myklebust 217f7b422b1SDavid Howells /* inode.c */ 2185746006fSTrond Myklebust extern struct workqueue_struct *nfsiod_workqueue; 219f7b422b1SDavid Howells extern struct inode *nfs_alloc_inode(struct super_block *sb); 220f7b422b1SDavid Howells extern void nfs_destroy_inode(struct inode *); 221a9185b41SChristoph Hellwig extern int nfs_write_inode(struct inode *, struct writeback_control *); 222b57922d9SAl Viro extern void nfs_evict_inode(struct inode *); 223f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4 224b57922d9SAl Viro extern void nfs4_evict_inode(struct inode *); 225f7b422b1SDavid Howells #endif 226f41f7418STrond Myklebust void nfs_zap_acl_cache(struct inode *inode); 22772cb77f4STrond Myklebust extern int nfs_wait_bit_killable(void *word); 228f7b422b1SDavid Howells 229f7b422b1SDavid Howells /* super.c */ 23054ceac45SDavid Howells extern struct file_system_type nfs_xdev_fs_type; 231f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4 23254ceac45SDavid Howells extern struct file_system_type nfs4_xdev_fs_type; 23354ceac45SDavid Howells extern struct file_system_type nfs4_referral_fs_type; 234f7b422b1SDavid Howells #endif 2354ebd9ab3SDominik Hackl 236f7b422b1SDavid Howells extern struct rpc_stat nfs_rpcstat; 2374ebd9ab3SDominik Hackl 238f7b422b1SDavid Howells extern int __init register_nfs_fs(void); 239f7b422b1SDavid Howells extern void __exit unregister_nfs_fs(void); 2401daef0a8STrond Myklebust extern void nfs_sb_active(struct super_block *sb); 2411daef0a8STrond Myklebust extern void nfs_sb_deactive(struct super_block *sb); 242f7b422b1SDavid Howells 243f7b422b1SDavid Howells /* namespace.c */ 24454ceac45SDavid Howells extern char *nfs_path(const char *base, 24554ceac45SDavid Howells const struct dentry *droot, 24654ceac45SDavid Howells const struct dentry *dentry, 247f7b422b1SDavid Howells char *buffer, ssize_t buflen); 248f7b422b1SDavid Howells 24954ceac45SDavid Howells /* getroot.c */ 25054ceac45SDavid Howells extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *); 2517d4e2747SDavid Howells #ifdef CONFIG_NFS_V4 25254ceac45SDavid Howells extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *); 25354ceac45SDavid Howells 254815409d2STrond Myklebust extern int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh); 2557d4e2747SDavid Howells #endif 256f7b422b1SDavid Howells 257f11c88afSAndy Adamson /* read.c */ 258f11c88afSAndy Adamson extern void nfs_read_prepare(struct rpc_task *task, void *calldata); 259f11c88afSAndy Adamson 260def6ed7eSAndy Adamson /* write.c */ 261def6ed7eSAndy Adamson extern void nfs_write_prepare(struct rpc_task *task, void *calldata); 262074cc1deSTrond Myklebust #ifdef CONFIG_MIGRATION 263074cc1deSTrond Myklebust extern int nfs_migrate_page(struct address_space *, 264074cc1deSTrond Myklebust struct page *, struct page *); 265074cc1deSTrond Myklebust #else 266074cc1deSTrond Myklebust #define nfs_migrate_page NULL 267074cc1deSTrond Myklebust #endif 268def6ed7eSAndy Adamson 269cccef3b9SAndy Adamson /* nfs4proc.c */ 270cccef3b9SAndy Adamson extern int _nfs4_call_sync(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 extern int _nfs4_call_sync_session(struct nfs_server *server, 276cccef3b9SAndy Adamson struct rpc_message *msg, 277cccef3b9SAndy Adamson struct nfs4_sequence_args *args, 278cccef3b9SAndy Adamson struct nfs4_sequence_res *res, 279cccef3b9SAndy Adamson int cache_reply); 280cccef3b9SAndy Adamson 281557134a3SAndy Adamson /* 282f7b422b1SDavid Howells * Determine the device name as a string 283f7b422b1SDavid Howells */ 284f7b422b1SDavid Howells static inline char *nfs_devname(const struct vfsmount *mnt_parent, 285f7b422b1SDavid Howells const struct dentry *dentry, 286f7b422b1SDavid Howells char *buffer, ssize_t buflen) 287f7b422b1SDavid Howells { 28854ceac45SDavid Howells return nfs_path(mnt_parent->mnt_devname, mnt_parent->mnt_root, 28954ceac45SDavid Howells dentry, buffer, buflen); 290f7b422b1SDavid Howells } 291f7b422b1SDavid Howells 292f7b422b1SDavid Howells /* 293f7b422b1SDavid Howells * Determine the actual block size (and log2 thereof) 294f7b422b1SDavid Howells */ 295f7b422b1SDavid Howells static inline 296f7b422b1SDavid Howells unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp) 297f7b422b1SDavid Howells { 298f7b422b1SDavid Howells /* make sure blocksize is a power of two */ 299f7b422b1SDavid Howells if ((bsize & (bsize - 1)) || nrbitsp) { 300f7b422b1SDavid Howells unsigned char nrbits; 301f7b422b1SDavid Howells 302f7b422b1SDavid Howells for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--) 303f7b422b1SDavid Howells ; 304f7b422b1SDavid Howells bsize = 1 << nrbits; 305f7b422b1SDavid Howells if (nrbitsp) 306f7b422b1SDavid Howells *nrbitsp = nrbits; 307f7b422b1SDavid Howells } 308f7b422b1SDavid Howells 309f7b422b1SDavid Howells return bsize; 310f7b422b1SDavid Howells } 311f7b422b1SDavid Howells 312f7b422b1SDavid Howells /* 313f7b422b1SDavid Howells * Calculate the number of 512byte blocks used. 314f7b422b1SDavid Howells */ 3159eaa67c6SChuck Lever static inline blkcnt_t nfs_calc_block_size(u64 tsize) 316f7b422b1SDavid Howells { 3179eaa67c6SChuck Lever blkcnt_t used = (tsize + 511) >> 9; 318f7b422b1SDavid Howells return (used > ULONG_MAX) ? ULONG_MAX : used; 319f7b422b1SDavid Howells } 320f7b422b1SDavid Howells 321f7b422b1SDavid Howells /* 322f7b422b1SDavid Howells * Compute and set NFS server blocksize 323f7b422b1SDavid Howells */ 324f7b422b1SDavid Howells static inline 325f7b422b1SDavid Howells unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp) 326f7b422b1SDavid Howells { 327f7b422b1SDavid Howells if (bsize < NFS_MIN_FILE_IO_SIZE) 328f7b422b1SDavid Howells bsize = NFS_DEF_FILE_IO_SIZE; 329f7b422b1SDavid Howells else if (bsize >= NFS_MAX_FILE_IO_SIZE) 330f7b422b1SDavid Howells bsize = NFS_MAX_FILE_IO_SIZE; 331f7b422b1SDavid Howells 332f7b422b1SDavid Howells return nfs_block_bits(bsize, nrbitsp); 333f7b422b1SDavid Howells } 334f7b422b1SDavid Howells 335f7b422b1SDavid Howells /* 336f7b422b1SDavid Howells * Determine the maximum file size for a superblock 337f7b422b1SDavid Howells */ 338f7b422b1SDavid Howells static inline 339f7b422b1SDavid Howells void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize) 340f7b422b1SDavid Howells { 341f7b422b1SDavid Howells sb->s_maxbytes = (loff_t)maxfilesize; 342f7b422b1SDavid Howells if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0) 343f7b422b1SDavid Howells sb->s_maxbytes = MAX_LFS_FILESIZE; 344f7b422b1SDavid Howells } 34549a70f27STrond Myklebust 34649a70f27STrond Myklebust /* 34749a70f27STrond Myklebust * Determine the number of bytes of data the page contains 34849a70f27STrond Myklebust */ 34949a70f27STrond Myklebust static inline 35049a70f27STrond Myklebust unsigned int nfs_page_length(struct page *page) 35149a70f27STrond Myklebust { 35249a70f27STrond Myklebust loff_t i_size = i_size_read(page->mapping->host); 35349a70f27STrond Myklebust 35449a70f27STrond Myklebust if (i_size > 0) { 35549a70f27STrond Myklebust pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; 35649a70f27STrond Myklebust if (page->index < end_index) 35749a70f27STrond Myklebust return PAGE_CACHE_SIZE; 35849a70f27STrond Myklebust if (page->index == end_index) 35949a70f27STrond Myklebust return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1; 36049a70f27STrond Myklebust } 36149a70f27STrond Myklebust return 0; 36249a70f27STrond Myklebust } 3638d5658c9STrond Myklebust 3648d5658c9STrond Myklebust /* 3650b26a0bfSTrond Myklebust * Convert a umode to a dirent->d_type 3660b26a0bfSTrond Myklebust */ 3670b26a0bfSTrond Myklebust static inline 3680b26a0bfSTrond Myklebust unsigned char nfs_umode_to_dtype(umode_t mode) 3690b26a0bfSTrond Myklebust { 3700b26a0bfSTrond Myklebust return (mode >> 12) & 15; 3710b26a0bfSTrond Myklebust } 3720b26a0bfSTrond Myklebust 3730b26a0bfSTrond 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 } 3830110ee15STrond Myklebust 3840110ee15STrond Myklebust /* 3850110ee15STrond Myklebust * Helper for restarting RPC calls in the possible presence of NFSv4.1 3860110ee15STrond Myklebust * sessions. 3870110ee15STrond Myklebust */ 388d05dd4e9STrond Myklebust static inline int nfs_restart_rpc(struct rpc_task *task, const struct nfs_client *clp) 3890110ee15STrond Myklebust { 3900110ee15STrond Myklebust if (nfs4_has_session(clp)) 391d05dd4e9STrond Myklebust return rpc_restart_call_prepare(task); 392d05dd4e9STrond Myklebust return rpc_restart_call(task); 3930110ee15STrond Myklebust } 394