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 427ebb9315SBryan Schumaker static inline void nfs_attr_check_mountpoint(struct super_block *parent, struct nfs_fattr *fattr) 437ebb9315SBryan Schumaker { 447ebb9315SBryan Schumaker if (!nfs_fsid_equal(&NFS_SB(parent)->fsid, &fattr->fsid)) 457ebb9315SBryan Schumaker fattr->valid |= NFS_ATTR_FATTR_MOUNTPOINT; 467ebb9315SBryan Schumaker } 477ebb9315SBryan Schumaker 48533eb461SAndy Adamson static inline int nfs_attr_use_mounted_on_fileid(struct nfs_fattr *fattr) 49533eb461SAndy Adamson { 50533eb461SAndy Adamson if (((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) == 0) || 51533eb461SAndy Adamson (((fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT) == 0) && 52533eb461SAndy Adamson ((fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) == 0))) 53533eb461SAndy Adamson return 0; 54533eb461SAndy Adamson 55533eb461SAndy Adamson fattr->fileid = fattr->mounted_on_fileid; 56533eb461SAndy Adamson return 1; 57533eb461SAndy Adamson } 58533eb461SAndy Adamson 59f7b422b1SDavid Howells struct nfs_clone_mount { 60f7b422b1SDavid Howells const struct super_block *sb; 61f7b422b1SDavid Howells const struct dentry *dentry; 62f7b422b1SDavid Howells struct nfs_fh *fh; 63f7b422b1SDavid Howells struct nfs_fattr *fattr; 64f7b422b1SDavid Howells char *hostname; 65f7b422b1SDavid Howells char *mnt_path; 666677d095SChuck Lever struct sockaddr *addr; 676677d095SChuck Lever size_t addrlen; 68f7b422b1SDavid Howells rpc_authflavor_t authflavor; 69f7b422b1SDavid Howells }; 70f7b422b1SDavid Howells 716b18eaa0S\"Talpey, Thomas\ /* 72a14017dbSChuck Lever * Note: RFC 1813 doesn't limit the number of auth flavors that 73a14017dbSChuck Lever * a server can return, so make something up. 74a14017dbSChuck Lever */ 75a14017dbSChuck Lever #define NFS_MAX_SECFLAVORS (12) 76a14017dbSChuck Lever 77a14017dbSChuck Lever /* 784cfd74fcSChuck Lever * Value used if the user did not specify a port value. 794cfd74fcSChuck Lever */ 804cfd74fcSChuck Lever #define NFS_UNSPEC_PORT (-1) 814cfd74fcSChuck Lever 824cfd74fcSChuck Lever /* 8356e4ebf8SBryan Schumaker * Maximum number of pages that readdir can use for creating 8456e4ebf8SBryan Schumaker * a vmapped array of pages. 8556e4ebf8SBryan Schumaker */ 8656e4ebf8SBryan Schumaker #define NFS_MAX_READDIR_PAGES 8 8756e4ebf8SBryan Schumaker 8856e4ebf8SBryan Schumaker /* 896b18eaa0S\"Talpey, Thomas\ * In-kernel mount arguments 906b18eaa0S\"Talpey, Thomas\ */ 916b18eaa0S\"Talpey, Thomas\ struct nfs_parsed_mount_data { 926b18eaa0S\"Talpey, Thomas\ int flags; 936b18eaa0S\"Talpey, Thomas\ int rsize, wsize; 946b18eaa0S\"Talpey, Thomas\ int timeo, retrans; 956b18eaa0S\"Talpey, Thomas\ int acregmin, acregmax, 966b18eaa0S\"Talpey, Thomas\ acdirmin, acdirmax; 976b18eaa0S\"Talpey, Thomas\ int namlen; 98b797cac7SDavid Howells unsigned int options; 996b18eaa0S\"Talpey, Thomas\ unsigned int bsize; 1006b18eaa0S\"Talpey, Thomas\ unsigned int auth_flavor_len; 1016b18eaa0S\"Talpey, Thomas\ rpc_authflavor_t auth_flavors[1]; 1026b18eaa0S\"Talpey, Thomas\ char *client_address; 103764302ccSChuck Lever unsigned int version; 1043fd5be9eSMike Sager unsigned int minorversion; 10508734048SDavid Howells char *fscache_uniq; 106b72e4f42SBryan Schumaker bool need_mount; 1076b18eaa0S\"Talpey, Thomas\ 1086b18eaa0S\"Talpey, Thomas\ struct { 1094c568017SChuck Lever struct sockaddr_storage address; 1104c568017SChuck Lever size_t addrlen; 1116b18eaa0S\"Talpey, Thomas\ char *hostname; 11278fa701fSChuck Lever u32 version; 1134cfd74fcSChuck Lever int port; 11478fa701fSChuck Lever unsigned short protocol; 1156b18eaa0S\"Talpey, Thomas\ } mount_server; 1166b18eaa0S\"Talpey, Thomas\ 1176b18eaa0S\"Talpey, Thomas\ struct { 1184c568017SChuck Lever struct sockaddr_storage address; 1194c568017SChuck Lever size_t addrlen; 1206b18eaa0S\"Talpey, Thomas\ char *hostname; 1216b18eaa0S\"Talpey, Thomas\ char *export_path; 1224cfd74fcSChuck Lever int port; 12378fa701fSChuck Lever unsigned short protocol; 1246b18eaa0S\"Talpey, Thomas\ } nfs_server; 125f9c3a380SEric Paris 126f9c3a380SEric Paris struct security_mnt_opts lsm_opts; 127e50a7a1aSStanislav Kinsbursky struct net *net; 1286b18eaa0S\"Talpey, Thomas\ }; 1296b18eaa0S\"Talpey, Thomas\ 130146ec944SChuck Lever /* mount_clnt.c */ 131c5d120f8SChuck Lever struct nfs_mount_request { 132c5d120f8SChuck Lever struct sockaddr *sap; 133c5d120f8SChuck Lever size_t salen; 134c5d120f8SChuck Lever char *hostname; 135c5d120f8SChuck Lever char *dirpath; 136c5d120f8SChuck Lever u32 version; 137c5d120f8SChuck Lever unsigned short protocol; 138c5d120f8SChuck Lever struct nfs_fh *fh; 13950a737f8SChuck Lever int noresvport; 1408e02f6b9SChuck Lever unsigned int *auth_flav_len; 1418e02f6b9SChuck Lever rpc_authflavor_t *auth_flavs; 1426d59b8d5SStanislav Kinsbursky struct net *net; 143c5d120f8SChuck Lever }; 144c5d120f8SChuck Lever 145c5d120f8SChuck Lever extern int nfs_mount(struct nfs_mount_request *info); 1460b524123SChuck Lever extern void nfs_umount(const struct nfs_mount_request *info); 147146ec944SChuck Lever 14824c8dbbbSDavid Howells /* client.c */ 149a613fa16STrond Myklebust extern const struct rpc_program nfs_program; 1506b13168bSStanislav Kinsbursky extern void nfs_clients_init(struct net *net); 15154ceac45SDavid Howells 15228cd1b3fSStanislav Kinsbursky extern void nfs_cleanup_cb_ident_idr(struct net *); 15324c8dbbbSDavid Howells extern void nfs_put_client(struct nfs_client *); 15428cd1b3fSStanislav Kinsbursky extern struct nfs_client *nfs4_find_client_ident(struct net *, int); 155c36fca52SAndy Adamson extern struct nfs_client * 156c7add9a9SStanislav Kinsbursky nfs4_find_client_sessionid(struct net *, const struct sockaddr *, 157c7add9a9SStanislav Kinsbursky struct nfs4_sessionid *); 1582283f8d6S\"Talpey, Thomas\ extern struct nfs_server *nfs_create_server( 1592283f8d6S\"Talpey, Thomas\ const struct nfs_parsed_mount_data *, 16054ceac45SDavid Howells struct nfs_fh *); 16191ea40b9S\"Talpey, Thomas\ extern struct nfs_server *nfs4_create_server( 16291ea40b9S\"Talpey, Thomas\ const struct nfs_parsed_mount_data *, 16354ceac45SDavid Howells struct nfs_fh *); 16454ceac45SDavid Howells extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *, 16554ceac45SDavid Howells struct nfs_fh *); 16654ceac45SDavid Howells extern void nfs_free_server(struct nfs_server *server); 16754ceac45SDavid Howells extern struct nfs_server *nfs_clone_server(struct nfs_server *, 16854ceac45SDavid Howells struct nfs_fh *, 1697e6eb683SBryan Schumaker struct nfs_fattr *, 1707e6eb683SBryan Schumaker rpc_authflavor_t); 1714697bd5eSTrond Myklebust extern int nfs_wait_client_init_complete(const struct nfs_client *clp); 17276db6d95SAndy Adamson extern void nfs_mark_client_ready(struct nfs_client *clp, int state); 173d83217c1SAndy Adamson extern struct nfs_client *nfs4_set_ds_client(struct nfs_client* mds_clp, 174d83217c1SAndy Adamson const struct sockaddr *ds_addr, 17598fc685aSAndy Adamson int ds_addrlen, int ds_proto, 17698fc685aSAndy Adamson unsigned int ds_timeo, 17798fc685aSAndy Adamson unsigned int ds_retrans); 1786aaca566SDavid Howells #ifdef CONFIG_PROC_FS 1796aaca566SDavid Howells extern int __init nfs_fs_proc_init(void); 1806aaca566SDavid Howells extern void nfs_fs_proc_exit(void); 1816aaca566SDavid Howells #else 1826aaca566SDavid Howells static inline int nfs_fs_proc_init(void) 1836aaca566SDavid Howells { 1846aaca566SDavid Howells return 0; 1856aaca566SDavid Howells } 1866aaca566SDavid Howells static inline void nfs_fs_proc_exit(void) 1876aaca566SDavid Howells { 1886aaca566SDavid Howells } 1896aaca566SDavid Howells #endif 19024c8dbbbSDavid Howells 191f7b422b1SDavid Howells /* callback_xdr.c */ 192f7b422b1SDavid Howells extern struct svc_version nfs4_callback_version1; 19307bccc2dSAlexandros Batsakis extern struct svc_version nfs4_callback_version4; 194f7b422b1SDavid Howells 1954db6e0b7SFred Isaman struct nfs_pageio_descriptor; 196f7b422b1SDavid Howells /* pagelist.c */ 197f7b422b1SDavid Howells extern int __init nfs_init_nfspagecache(void); 198266bee88SDavid Brownell extern void nfs_destroy_nfspagecache(void); 199f7b422b1SDavid Howells extern int __init nfs_init_readpagecache(void); 200266bee88SDavid Brownell extern void nfs_destroy_readpagecache(void); 201f7b422b1SDavid Howells extern int __init nfs_init_writepagecache(void); 202266bee88SDavid Brownell extern void nfs_destroy_writepagecache(void); 203f7b422b1SDavid Howells 204f7b422b1SDavid Howells extern int __init nfs_init_directcache(void); 205266bee88SDavid Brownell extern void nfs_destroy_directcache(void); 20630dd374fSFred Isaman extern bool nfs_pgarray_set(struct nfs_page_array *p, unsigned int pagecount); 2074db6e0b7SFred Isaman extern void nfs_pgheader_init(struct nfs_pageio_descriptor *desc, 2084db6e0b7SFred Isaman struct nfs_pgio_header *hdr, 2094db6e0b7SFred Isaman void (*release)(struct nfs_pgio_header *hdr)); 2104db6e0b7SFred Isaman void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos); 211f7b422b1SDavid Howells 212f7b422b1SDavid Howells /* nfs2xdr.c */ 213f7b422b1SDavid Howells extern struct rpc_procinfo nfs_procedures[]; 214573c4e1eSChuck Lever extern int nfs2_decode_dirent(struct xdr_stream *, 215573c4e1eSChuck Lever struct nfs_entry *, int); 216f7b422b1SDavid Howells 217f7b422b1SDavid Howells /* nfs3xdr.c */ 218f7b422b1SDavid Howells extern struct rpc_procinfo nfs3_procedures[]; 219573c4e1eSChuck Lever extern int nfs3_decode_dirent(struct xdr_stream *, 220573c4e1eSChuck Lever struct nfs_entry *, int); 221f7b422b1SDavid Howells 222f7b422b1SDavid Howells /* nfs4xdr.c */ 2237d4e2747SDavid Howells #ifdef CONFIG_NFS_V4 224573c4e1eSChuck Lever extern int nfs4_decode_dirent(struct xdr_stream *, 225573c4e1eSChuck Lever struct nfs_entry *, int); 2267d4e2747SDavid Howells #endif 2272449ea2eSAlexandros Batsakis #ifdef CONFIG_NFS_V4_1 2282449ea2eSAlexandros Batsakis extern const u32 nfs41_maxread_overhead; 2292449ea2eSAlexandros Batsakis extern const u32 nfs41_maxwrite_overhead; 2302449ea2eSAlexandros Batsakis #endif 231f7b422b1SDavid Howells 232f7b422b1SDavid Howells /* nfs4proc.c */ 233d75d5414SAndrew Morton #ifdef CONFIG_NFS_V4 234f7b422b1SDavid Howells extern struct rpc_procinfo nfs4_procedures[]; 235d75d5414SAndrew Morton #endif 236f7b422b1SDavid Howells 2377b38c368STrond Myklebust extern int nfs4_init_ds_session(struct nfs_client *, unsigned long); 238d83217c1SAndy Adamson 2397fe5c398STrond Myklebust /* proc.c */ 2407fe5c398STrond Myklebust void nfs_close_context(struct nfs_open_context *ctx, int is_sync); 2418cab4c39SChuck Lever extern struct nfs_client *nfs_init_client(struct nfs_client *clp, 24245a52a02SAndy Adamson const struct rpc_timeout *timeparms, 2434bf590e0SChuck Lever const char *ip_addr, rpc_authflavor_t authflavour); 2447fe5c398STrond Myklebust 245979df72eSTrond Myklebust /* dir.c */ 2467f8275d0SDave Chinner extern int nfs_access_cache_shrinker(struct shrinker *shrink, 2471495f230SYing Han struct shrink_control *sc); 248979df72eSTrond Myklebust 249f7b422b1SDavid Howells /* inode.c */ 2505746006fSTrond Myklebust extern struct workqueue_struct *nfsiod_workqueue; 251f7b422b1SDavid Howells extern struct inode *nfs_alloc_inode(struct super_block *sb); 252f7b422b1SDavid Howells extern void nfs_destroy_inode(struct inode *); 253a9185b41SChristoph Hellwig extern int nfs_write_inode(struct inode *, struct writeback_control *); 254b57922d9SAl Viro extern void nfs_evict_inode(struct inode *); 255f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4 256b57922d9SAl Viro extern void nfs4_evict_inode(struct inode *); 257f7b422b1SDavid Howells #endif 258f41f7418STrond Myklebust void nfs_zap_acl_cache(struct inode *inode); 25972cb77f4STrond Myklebust extern int nfs_wait_bit_killable(void *word); 260f7b422b1SDavid Howells 261f7b422b1SDavid Howells /* super.c */ 26254ceac45SDavid Howells extern struct file_system_type nfs_xdev_fs_type; 263f7b422b1SDavid Howells #ifdef CONFIG_NFS_V4 26454ceac45SDavid Howells extern struct file_system_type nfs4_xdev_fs_type; 26554ceac45SDavid Howells extern struct file_system_type nfs4_referral_fs_type; 266f7b422b1SDavid Howells #endif 2674ebd9ab3SDominik Hackl 268f7b422b1SDavid Howells extern struct rpc_stat nfs_rpcstat; 2694ebd9ab3SDominik Hackl 270f7b422b1SDavid Howells extern int __init register_nfs_fs(void); 271f7b422b1SDavid Howells extern void __exit unregister_nfs_fs(void); 2721daef0a8STrond Myklebust extern void nfs_sb_active(struct super_block *sb); 2731daef0a8STrond Myklebust extern void nfs_sb_deactive(struct super_block *sb); 274f7b422b1SDavid Howells 275f7b422b1SDavid Howells /* namespace.c */ 276b514f872SAl Viro extern char *nfs_path(char **p, struct dentry *dentry, 277f7b422b1SDavid Howells char *buffer, ssize_t buflen); 27836d43a43SDavid Howells extern struct vfsmount *nfs_d_automount(struct path *path); 279281cad46SBryan Schumaker struct vfsmount *nfs_submount(struct nfs_server *, struct dentry *, 280281cad46SBryan Schumaker struct nfs_fh *, struct nfs_fattr *); 281281cad46SBryan Schumaker struct vfsmount *nfs_do_submount(struct dentry *, struct nfs_fh *, 282281cad46SBryan Schumaker struct nfs_fattr *, rpc_authflavor_t); 283f7b422b1SDavid Howells 28454ceac45SDavid Howells /* getroot.c */ 2850d5839adSAl Viro extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *, 2860d5839adSAl Viro const char *); 2877d4e2747SDavid Howells #ifdef CONFIG_NFS_V4 2880d5839adSAl Viro extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *, 2890d5839adSAl Viro const char *); 29054ceac45SDavid Howells 291815409d2STrond Myklebust extern int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh); 2927d4e2747SDavid Howells #endif 293f7b422b1SDavid Howells 294061ae2edSFred Isaman struct nfs_pgio_completion_ops; 295f11c88afSAndy Adamson /* read.c */ 2964db6e0b7SFred Isaman extern struct nfs_read_header *nfs_readhdr_alloc(void); 297cd841605SFred Isaman extern void nfs_readhdr_free(struct nfs_pgio_header *hdr); 298584aa810SFred Isaman extern void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, 299584aa810SFred Isaman struct inode *inode, 300584aa810SFred Isaman const struct nfs_pgio_completion_ops *compl_ops); 301c5996c4eSFred Isaman extern int nfs_initiate_read(struct rpc_clnt *clnt, 302c5996c4eSFred Isaman struct nfs_read_data *data, 3039f0ec176SAndy Adamson const struct rpc_call_ops *call_ops, int flags); 304f11c88afSAndy Adamson extern void nfs_read_prepare(struct rpc_task *task, void *calldata); 305493292ddSTrond Myklebust extern int nfs_generic_pagein(struct nfs_pageio_descriptor *desc, 3064db6e0b7SFred Isaman struct nfs_pgio_header *hdr); 30762e4a769STrond Myklebust extern void nfs_pageio_init_read_mds(struct nfs_pageio_descriptor *pgio, 308061ae2edSFred Isaman struct inode *inode, 309061ae2edSFred Isaman const struct nfs_pgio_completion_ops *compl_ops); 310493292ddSTrond Myklebust extern void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio); 311493292ddSTrond Myklebust extern void nfs_readdata_release(struct nfs_read_data *rdata); 312e885de1aSTrond Myklebust 313def6ed7eSAndy Adamson /* write.c */ 3141763da12SFred Isaman extern void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, 3151763da12SFred Isaman struct inode *inode, int ioflags, 3161763da12SFred Isaman const struct nfs_pgio_completion_ops *compl_ops); 3176c75dc0dSFred Isaman extern struct nfs_write_header *nfs_writehdr_alloc(void); 318cd841605SFred Isaman extern void nfs_writehdr_free(struct nfs_pgio_header *hdr); 319dce81290STrond Myklebust extern int nfs_generic_flush(struct nfs_pageio_descriptor *desc, 3206c75dc0dSFred Isaman struct nfs_pgio_header *hdr); 321e2fecb21STrond Myklebust extern void nfs_pageio_init_write_mds(struct nfs_pageio_descriptor *pgio, 322061ae2edSFred Isaman struct inode *inode, int ioflags, 323061ae2edSFred Isaman const struct nfs_pgio_completion_ops *compl_ops); 324dce81290STrond Myklebust extern void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio); 325dce81290STrond Myklebust extern void nfs_writedata_release(struct nfs_write_data *wdata); 3260b7c0153SFred Isaman extern void nfs_commit_free(struct nfs_commit_data *p); 327c5996c4eSFred Isaman extern int nfs_initiate_write(struct rpc_clnt *clnt, 328c5996c4eSFred Isaman struct nfs_write_data *data, 329a69aef14SFred Isaman const struct rpc_call_ops *call_ops, 3309f0ec176SAndy Adamson int how, int flags); 331def6ed7eSAndy Adamson extern void nfs_write_prepare(struct rpc_task *task, void *calldata); 3320b7c0153SFred Isaman extern void nfs_commit_prepare(struct rpc_task *task, void *calldata); 3330b7c0153SFred Isaman extern int nfs_initiate_commit(struct rpc_clnt *clnt, 3340b7c0153SFred Isaman struct nfs_commit_data *data, 335e0c2b380SFred Isaman const struct rpc_call_ops *call_ops, 3369f0ec176SAndy Adamson int how, int flags); 3370b7c0153SFred Isaman extern void nfs_init_commit(struct nfs_commit_data *data, 338e0c2b380SFred Isaman struct list_head *head, 339f453a54aSFred Isaman struct pnfs_layout_segment *lseg, 340f453a54aSFred Isaman struct nfs_commit_info *cinfo); 3411763da12SFred Isaman int nfs_scan_commit_list(struct list_head *src, struct list_head *dst, 3421763da12SFred Isaman struct nfs_commit_info *cinfo, int max); 3431763da12SFred Isaman int nfs_scan_commit(struct inode *inode, struct list_head *dst, 3441763da12SFred Isaman struct nfs_commit_info *cinfo); 3451763da12SFred Isaman void nfs_mark_request_commit(struct nfs_page *req, 3461763da12SFred Isaman struct pnfs_layout_segment *lseg, 3471763da12SFred Isaman struct nfs_commit_info *cinfo); 3481763da12SFred Isaman int nfs_generic_commit_list(struct inode *inode, struct list_head *head, 3491763da12SFred Isaman int how, struct nfs_commit_info *cinfo); 350e0c2b380SFred Isaman void nfs_retry_commit(struct list_head *page_list, 351ea2cf228SFred Isaman struct pnfs_layout_segment *lseg, 352ea2cf228SFred Isaman struct nfs_commit_info *cinfo); 3530b7c0153SFred Isaman void nfs_commitdata_release(struct nfs_commit_data *data); 354ea2cf228SFred Isaman void nfs_request_add_commit_list(struct nfs_page *req, struct list_head *dst, 355ea2cf228SFred Isaman struct nfs_commit_info *cinfo); 356ea2cf228SFred Isaman void nfs_request_remove_commit_list(struct nfs_page *req, 357ea2cf228SFred Isaman struct nfs_commit_info *cinfo); 358ea2cf228SFred Isaman void nfs_init_cinfo(struct nfs_commit_info *cinfo, 359ea2cf228SFred Isaman struct inode *inode, 360ea2cf228SFred Isaman struct nfs_direct_req *dreq); 361e0c2b380SFred Isaman 362074cc1deSTrond Myklebust #ifdef CONFIG_MIGRATION 363074cc1deSTrond Myklebust extern int nfs_migrate_page(struct address_space *, 364a6bc32b8SMel Gorman struct page *, struct page *, enum migrate_mode); 365074cc1deSTrond Myklebust #else 366074cc1deSTrond Myklebust #define nfs_migrate_page NULL 367074cc1deSTrond Myklebust #endif 368def6ed7eSAndy Adamson 3691763da12SFred Isaman /* direct.c */ 3701763da12SFred Isaman void nfs_init_cinfo_from_dreq(struct nfs_commit_info *cinfo, 3711763da12SFred Isaman struct nfs_direct_req *dreq); 3721d59d61fSTrond Myklebust static inline void nfs_inode_dio_wait(struct inode *inode) 3731d59d61fSTrond Myklebust { 3741d59d61fSTrond Myklebust inode_dio_wait(inode); 3751d59d61fSTrond Myklebust } 3761763da12SFred Isaman 377cccef3b9SAndy Adamson /* nfs4proc.c */ 378d20581aaSBenny Halevy extern void __nfs4_read_done_cb(struct nfs_read_data *); 3798cab4c39SChuck Lever extern struct nfs_client *nfs4_init_client(struct nfs_client *clp, 38045a52a02SAndy Adamson const struct rpc_timeout *timeparms, 38145a52a02SAndy Adamson const char *ip_addr, 3824bf590e0SChuck Lever rpc_authflavor_t authflavour); 3837c513058SBryan Schumaker extern int _nfs4_call_sync(struct rpc_clnt *clnt, 3847c513058SBryan Schumaker struct nfs_server *server, 385cccef3b9SAndy Adamson struct rpc_message *msg, 386cccef3b9SAndy Adamson struct nfs4_sequence_args *args, 387cccef3b9SAndy Adamson struct nfs4_sequence_res *res, 388cccef3b9SAndy Adamson int cache_reply); 3897c513058SBryan Schumaker extern int _nfs4_call_sync_session(struct rpc_clnt *clnt, 3907c513058SBryan Schumaker struct nfs_server *server, 391cccef3b9SAndy Adamson struct rpc_message *msg, 392cccef3b9SAndy Adamson struct nfs4_sequence_args *args, 393cccef3b9SAndy Adamson struct nfs4_sequence_res *res, 394cccef3b9SAndy Adamson int cache_reply); 395cccef3b9SAndy Adamson 396557134a3SAndy Adamson /* 397f7b422b1SDavid Howells * Determine the device name as a string 398f7b422b1SDavid Howells */ 399b514f872SAl Viro static inline char *nfs_devname(struct dentry *dentry, 400f7b422b1SDavid Howells char *buffer, ssize_t buflen) 401f7b422b1SDavid Howells { 402b514f872SAl Viro char *dummy; 403b514f872SAl Viro return nfs_path(&dummy, dentry, buffer, buflen); 404f7b422b1SDavid Howells } 405f7b422b1SDavid Howells 406f7b422b1SDavid Howells /* 407f7b422b1SDavid Howells * Determine the actual block size (and log2 thereof) 408f7b422b1SDavid Howells */ 409f7b422b1SDavid Howells static inline 410f7b422b1SDavid Howells unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp) 411f7b422b1SDavid Howells { 412f7b422b1SDavid Howells /* make sure blocksize is a power of two */ 413f7b422b1SDavid Howells if ((bsize & (bsize - 1)) || nrbitsp) { 414f7b422b1SDavid Howells unsigned char nrbits; 415f7b422b1SDavid Howells 416f7b422b1SDavid Howells for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--) 417f7b422b1SDavid Howells ; 418f7b422b1SDavid Howells bsize = 1 << nrbits; 419f7b422b1SDavid Howells if (nrbitsp) 420f7b422b1SDavid Howells *nrbitsp = nrbits; 421f7b422b1SDavid Howells } 422f7b422b1SDavid Howells 423f7b422b1SDavid Howells return bsize; 424f7b422b1SDavid Howells } 425f7b422b1SDavid Howells 426f7b422b1SDavid Howells /* 427f7b422b1SDavid Howells * Calculate the number of 512byte blocks used. 428f7b422b1SDavid Howells */ 4299eaa67c6SChuck Lever static inline blkcnt_t nfs_calc_block_size(u64 tsize) 430f7b422b1SDavid Howells { 4319eaa67c6SChuck Lever blkcnt_t used = (tsize + 511) >> 9; 432f7b422b1SDavid Howells return (used > ULONG_MAX) ? ULONG_MAX : used; 433f7b422b1SDavid Howells } 434f7b422b1SDavid Howells 435f7b422b1SDavid Howells /* 436f7b422b1SDavid Howells * Compute and set NFS server blocksize 437f7b422b1SDavid Howells */ 438f7b422b1SDavid Howells static inline 439f7b422b1SDavid Howells unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp) 440f7b422b1SDavid Howells { 441f7b422b1SDavid Howells if (bsize < NFS_MIN_FILE_IO_SIZE) 442f7b422b1SDavid Howells bsize = NFS_DEF_FILE_IO_SIZE; 443f7b422b1SDavid Howells else if (bsize >= NFS_MAX_FILE_IO_SIZE) 444f7b422b1SDavid Howells bsize = NFS_MAX_FILE_IO_SIZE; 445f7b422b1SDavid Howells 446f7b422b1SDavid Howells return nfs_block_bits(bsize, nrbitsp); 447f7b422b1SDavid Howells } 448f7b422b1SDavid Howells 449f7b422b1SDavid Howells /* 450f7b422b1SDavid Howells * Determine the maximum file size for a superblock 451f7b422b1SDavid Howells */ 452f7b422b1SDavid Howells static inline 453f7b422b1SDavid Howells void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize) 454f7b422b1SDavid Howells { 455f7b422b1SDavid Howells sb->s_maxbytes = (loff_t)maxfilesize; 456f7b422b1SDavid Howells if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0) 457f7b422b1SDavid Howells sb->s_maxbytes = MAX_LFS_FILESIZE; 458f7b422b1SDavid Howells } 45949a70f27STrond Myklebust 46049a70f27STrond Myklebust /* 46149a70f27STrond Myklebust * Determine the number of bytes of data the page contains 46249a70f27STrond Myklebust */ 46349a70f27STrond Myklebust static inline 46449a70f27STrond Myklebust unsigned int nfs_page_length(struct page *page) 46549a70f27STrond Myklebust { 46649a70f27STrond Myklebust loff_t i_size = i_size_read(page->mapping->host); 46749a70f27STrond Myklebust 46849a70f27STrond Myklebust if (i_size > 0) { 46949a70f27STrond Myklebust pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; 47049a70f27STrond Myklebust if (page->index < end_index) 47149a70f27STrond Myklebust return PAGE_CACHE_SIZE; 47249a70f27STrond Myklebust if (page->index == end_index) 47349a70f27STrond Myklebust return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1; 47449a70f27STrond Myklebust } 47549a70f27STrond Myklebust return 0; 47649a70f27STrond Myklebust } 4778d5658c9STrond Myklebust 4788d5658c9STrond Myklebust /* 4790b26a0bfSTrond Myklebust * Convert a umode to a dirent->d_type 4800b26a0bfSTrond Myklebust */ 4810b26a0bfSTrond Myklebust static inline 4820b26a0bfSTrond Myklebust unsigned char nfs_umode_to_dtype(umode_t mode) 4830b26a0bfSTrond Myklebust { 4840b26a0bfSTrond Myklebust return (mode >> 12) & 15; 4850b26a0bfSTrond Myklebust } 4860b26a0bfSTrond Myklebust 4870b26a0bfSTrond Myklebust /* 4888d5658c9STrond Myklebust * Determine the number of pages in an array of length 'len' and 4898d5658c9STrond Myklebust * with a base offset of 'base' 4908d5658c9STrond Myklebust */ 4918d5658c9STrond Myklebust static inline 4928d5658c9STrond Myklebust unsigned int nfs_page_array_len(unsigned int base, size_t len) 4938d5658c9STrond Myklebust { 4948d5658c9STrond Myklebust return ((unsigned long)len + (unsigned long)base + 4958d5658c9STrond Myklebust PAGE_SIZE - 1) >> PAGE_SHIFT; 4968d5658c9STrond Myklebust } 4970110ee15STrond Myklebust 4983a1556e8STrond Myklebust /* 4993a1556e8STrond Myklebust * Convert a struct timespec into a 64-bit change attribute 5003a1556e8STrond Myklebust * 5013a1556e8STrond Myklebust * This does approximately the same thing as timespec_to_ns(), 5023a1556e8STrond Myklebust * but for calculation efficiency, we multiply the seconds by 5033a1556e8STrond Myklebust * 1024*1024*1024. 5043a1556e8STrond Myklebust */ 5053a1556e8STrond Myklebust static inline 5063a1556e8STrond Myklebust u64 nfs_timespec_to_change_attr(const struct timespec *ts) 5073a1556e8STrond Myklebust { 5083a1556e8STrond Myklebust return ((u64)ts->tv_sec << 30) + ts->tv_nsec; 5093a1556e8STrond Myklebust } 510