162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * linux/fs/nfs/nfs4_fs.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2005 Trond Myklebust 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * NFSv4-specific filesystem definitions and declarations 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef __LINUX_FS_NFS_NFS4_FS_H 1162306a36Sopenharmony_ci#define __LINUX_FS_NFS_NFS4_FS_H 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#if defined(CONFIG_NFS_V4_2) 1462306a36Sopenharmony_ci#define NFS4_MAX_MINOR_VERSION 2 1562306a36Sopenharmony_ci#elif defined(CONFIG_NFS_V4_1) 1662306a36Sopenharmony_ci#define NFS4_MAX_MINOR_VERSION 1 1762306a36Sopenharmony_ci#else 1862306a36Sopenharmony_ci#define NFS4_MAX_MINOR_VERSION 0 1962306a36Sopenharmony_ci#endif 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_NFS_V4) 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci#define NFS4_MAX_LOOP_ON_RECOVER (10) 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#include <linux/seqlock.h> 2662306a36Sopenharmony_ci#include <linux/filelock.h> 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_cistruct idmap; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_cienum nfs4_client_state { 3162306a36Sopenharmony_ci NFS4CLNT_MANAGER_RUNNING = 0, 3262306a36Sopenharmony_ci NFS4CLNT_CHECK_LEASE, 3362306a36Sopenharmony_ci NFS4CLNT_LEASE_EXPIRED, 3462306a36Sopenharmony_ci NFS4CLNT_RECLAIM_REBOOT, 3562306a36Sopenharmony_ci NFS4CLNT_RECLAIM_NOGRACE, 3662306a36Sopenharmony_ci NFS4CLNT_DELEGRETURN, 3762306a36Sopenharmony_ci NFS4CLNT_SESSION_RESET, 3862306a36Sopenharmony_ci NFS4CLNT_LEASE_CONFIRM, 3962306a36Sopenharmony_ci NFS4CLNT_SERVER_SCOPE_MISMATCH, 4062306a36Sopenharmony_ci NFS4CLNT_PURGE_STATE, 4162306a36Sopenharmony_ci NFS4CLNT_BIND_CONN_TO_SESSION, 4262306a36Sopenharmony_ci NFS4CLNT_MOVED, 4362306a36Sopenharmony_ci NFS4CLNT_LEASE_MOVED, 4462306a36Sopenharmony_ci NFS4CLNT_DELEGATION_EXPIRED, 4562306a36Sopenharmony_ci NFS4CLNT_RUN_MANAGER, 4662306a36Sopenharmony_ci NFS4CLNT_MANAGER_AVAILABLE, 4762306a36Sopenharmony_ci NFS4CLNT_RECALL_RUNNING, 4862306a36Sopenharmony_ci NFS4CLNT_RECALL_ANY_LAYOUT_READ, 4962306a36Sopenharmony_ci NFS4CLNT_RECALL_ANY_LAYOUT_RW, 5062306a36Sopenharmony_ci NFS4CLNT_DELEGRETURN_DELAYED, 5162306a36Sopenharmony_ci}; 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci#define NFS4_RENEW_TIMEOUT 0x01 5462306a36Sopenharmony_ci#define NFS4_RENEW_DELEGATION_CB 0x02 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_cistruct nfs_seqid_counter; 5762306a36Sopenharmony_cistruct nfs4_minor_version_ops { 5862306a36Sopenharmony_ci u32 minor_version; 5962306a36Sopenharmony_ci unsigned init_caps; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci int (*init_client)(struct nfs_client *); 6262306a36Sopenharmony_ci void (*shutdown_client)(struct nfs_client *); 6362306a36Sopenharmony_ci bool (*match_stateid)(const nfs4_stateid *, 6462306a36Sopenharmony_ci const nfs4_stateid *); 6562306a36Sopenharmony_ci int (*find_root_sec)(struct nfs_server *, struct nfs_fh *, 6662306a36Sopenharmony_ci struct nfs_fsinfo *); 6762306a36Sopenharmony_ci void (*free_lock_state)(struct nfs_server *, 6862306a36Sopenharmony_ci struct nfs4_lock_state *); 6962306a36Sopenharmony_ci int (*test_and_free_expired)(struct nfs_server *, 7062306a36Sopenharmony_ci nfs4_stateid *, const struct cred *); 7162306a36Sopenharmony_ci struct nfs_seqid * 7262306a36Sopenharmony_ci (*alloc_seqid)(struct nfs_seqid_counter *, gfp_t); 7362306a36Sopenharmony_ci void (*session_trunk)(struct rpc_clnt *clnt, 7462306a36Sopenharmony_ci struct rpc_xprt *xprt, void *data); 7562306a36Sopenharmony_ci const struct rpc_call_ops *call_sync_ops; 7662306a36Sopenharmony_ci const struct nfs4_state_recovery_ops *reboot_recovery_ops; 7762306a36Sopenharmony_ci const struct nfs4_state_recovery_ops *nograce_recovery_ops; 7862306a36Sopenharmony_ci const struct nfs4_state_maintenance_ops *state_renewal_ops; 7962306a36Sopenharmony_ci const struct nfs4_mig_recovery_ops *mig_recovery_ops; 8062306a36Sopenharmony_ci}; 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci#define NFS_SEQID_CONFIRMED 1 8362306a36Sopenharmony_cistruct nfs_seqid_counter { 8462306a36Sopenharmony_ci ktime_t create_time; 8562306a36Sopenharmony_ci int owner_id; 8662306a36Sopenharmony_ci int flags; 8762306a36Sopenharmony_ci u32 counter; 8862306a36Sopenharmony_ci spinlock_t lock; /* Protects the list */ 8962306a36Sopenharmony_ci struct list_head list; /* Defines sequence of RPC calls */ 9062306a36Sopenharmony_ci struct rpc_wait_queue wait; /* RPC call delay queue */ 9162306a36Sopenharmony_ci}; 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_cistruct nfs_seqid { 9462306a36Sopenharmony_ci struct nfs_seqid_counter *sequence; 9562306a36Sopenharmony_ci struct list_head list; 9662306a36Sopenharmony_ci struct rpc_task *task; 9762306a36Sopenharmony_ci}; 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_cistatic inline void nfs_confirm_seqid(struct nfs_seqid_counter *seqid, int status) 10062306a36Sopenharmony_ci{ 10162306a36Sopenharmony_ci if (seqid_mutating_err(-status)) 10262306a36Sopenharmony_ci seqid->flags |= NFS_SEQID_CONFIRMED; 10362306a36Sopenharmony_ci} 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci/* 10662306a36Sopenharmony_ci * NFS4 state_owners and lock_owners are simply labels for ordered 10762306a36Sopenharmony_ci * sequences of RPC calls. Their sole purpose is to provide once-only 10862306a36Sopenharmony_ci * semantics by allowing the server to identify replayed requests. 10962306a36Sopenharmony_ci */ 11062306a36Sopenharmony_cistruct nfs4_state_owner { 11162306a36Sopenharmony_ci struct nfs_server *so_server; 11262306a36Sopenharmony_ci struct list_head so_lru; 11362306a36Sopenharmony_ci unsigned long so_expires; 11462306a36Sopenharmony_ci struct rb_node so_server_node; 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci const struct cred *so_cred; /* Associated cred */ 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci spinlock_t so_lock; 11962306a36Sopenharmony_ci atomic_t so_count; 12062306a36Sopenharmony_ci unsigned long so_flags; 12162306a36Sopenharmony_ci struct list_head so_states; 12262306a36Sopenharmony_ci struct nfs_seqid_counter so_seqid; 12362306a36Sopenharmony_ci seqcount_spinlock_t so_reclaim_seqcount; 12462306a36Sopenharmony_ci struct mutex so_delegreturn_mutex; 12562306a36Sopenharmony_ci}; 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_cienum { 12862306a36Sopenharmony_ci NFS_OWNER_RECLAIM_REBOOT, 12962306a36Sopenharmony_ci NFS_OWNER_RECLAIM_NOGRACE 13062306a36Sopenharmony_ci}; 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci#define NFS_LOCK_NEW 0 13362306a36Sopenharmony_ci#define NFS_LOCK_RECLAIM 1 13462306a36Sopenharmony_ci#define NFS_LOCK_EXPIRED 2 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci/* 13762306a36Sopenharmony_ci * struct nfs4_state maintains the client-side state for a given 13862306a36Sopenharmony_ci * (state_owner,inode) tuple (OPEN) or state_owner (LOCK). 13962306a36Sopenharmony_ci * 14062306a36Sopenharmony_ci * OPEN: 14162306a36Sopenharmony_ci * In order to know when to OPEN_DOWNGRADE or CLOSE the state on the server, 14262306a36Sopenharmony_ci * we need to know how many files are open for reading or writing on a 14362306a36Sopenharmony_ci * given inode. This information too is stored here. 14462306a36Sopenharmony_ci * 14562306a36Sopenharmony_ci * LOCK: one nfs4_state (LOCK) to hold the lock stateid nfs4_state(OPEN) 14662306a36Sopenharmony_ci */ 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_cistruct nfs4_lock_state { 14962306a36Sopenharmony_ci struct list_head ls_locks; /* Other lock stateids */ 15062306a36Sopenharmony_ci struct nfs4_state * ls_state; /* Pointer to open state */ 15162306a36Sopenharmony_ci#define NFS_LOCK_INITIALIZED 0 15262306a36Sopenharmony_ci#define NFS_LOCK_LOST 1 15362306a36Sopenharmony_ci#define NFS_LOCK_UNLOCKING 2 15462306a36Sopenharmony_ci unsigned long ls_flags; 15562306a36Sopenharmony_ci struct nfs_seqid_counter ls_seqid; 15662306a36Sopenharmony_ci nfs4_stateid ls_stateid; 15762306a36Sopenharmony_ci refcount_t ls_count; 15862306a36Sopenharmony_ci fl_owner_t ls_owner; 15962306a36Sopenharmony_ci}; 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci/* bits for nfs4_state->flags */ 16262306a36Sopenharmony_cienum { 16362306a36Sopenharmony_ci LK_STATE_IN_USE, 16462306a36Sopenharmony_ci NFS_DELEGATED_STATE, /* Current stateid is delegation */ 16562306a36Sopenharmony_ci NFS_OPEN_STATE, /* OPEN stateid is set */ 16662306a36Sopenharmony_ci NFS_O_RDONLY_STATE, /* OPEN stateid has read-only state */ 16762306a36Sopenharmony_ci NFS_O_WRONLY_STATE, /* OPEN stateid has write-only state */ 16862306a36Sopenharmony_ci NFS_O_RDWR_STATE, /* OPEN stateid has read/write state */ 16962306a36Sopenharmony_ci NFS_STATE_RECLAIM_REBOOT, /* OPEN stateid server rebooted */ 17062306a36Sopenharmony_ci NFS_STATE_RECLAIM_NOGRACE, /* OPEN stateid needs to recover state */ 17162306a36Sopenharmony_ci NFS_STATE_POSIX_LOCKS, /* Posix locks are supported */ 17262306a36Sopenharmony_ci NFS_STATE_RECOVERY_FAILED, /* OPEN stateid state recovery failed */ 17362306a36Sopenharmony_ci NFS_STATE_MAY_NOTIFY_LOCK, /* server may CB_NOTIFY_LOCK */ 17462306a36Sopenharmony_ci NFS_STATE_CHANGE_WAIT, /* A state changing operation is outstanding */ 17562306a36Sopenharmony_ci NFS_CLNT_DST_SSC_COPY_STATE, /* dst server open state on client*/ 17662306a36Sopenharmony_ci NFS_CLNT_SRC_SSC_COPY_STATE, /* src server open state on client*/ 17762306a36Sopenharmony_ci NFS_SRV_SSC_COPY_STATE, /* ssc state on the dst server */ 17862306a36Sopenharmony_ci}; 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_cistruct nfs4_state { 18162306a36Sopenharmony_ci struct list_head open_states; /* List of states for the same state_owner */ 18262306a36Sopenharmony_ci struct list_head inode_states; /* List of states for the same inode */ 18362306a36Sopenharmony_ci struct list_head lock_states; /* List of subservient lock stateids */ 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci struct nfs4_state_owner *owner; /* Pointer to the open owner */ 18662306a36Sopenharmony_ci struct inode *inode; /* Pointer to the inode */ 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci unsigned long flags; /* Do we hold any locks? */ 18962306a36Sopenharmony_ci spinlock_t state_lock; /* Protects the lock_states list */ 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci seqlock_t seqlock; /* Protects the stateid/open_stateid */ 19262306a36Sopenharmony_ci nfs4_stateid stateid; /* Current stateid: may be delegation */ 19362306a36Sopenharmony_ci nfs4_stateid open_stateid; /* OPEN stateid */ 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci /* The following 3 fields are protected by owner->so_lock */ 19662306a36Sopenharmony_ci unsigned int n_rdonly; /* Number of read-only references */ 19762306a36Sopenharmony_ci unsigned int n_wronly; /* Number of write-only references */ 19862306a36Sopenharmony_ci unsigned int n_rdwr; /* Number of read/write references */ 19962306a36Sopenharmony_ci fmode_t state; /* State on the server (R,W, or RW) */ 20062306a36Sopenharmony_ci refcount_t count; 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci wait_queue_head_t waitq; 20362306a36Sopenharmony_ci struct rcu_head rcu_head; 20462306a36Sopenharmony_ci}; 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_cistruct nfs4_exception { 20862306a36Sopenharmony_ci struct nfs4_state *state; 20962306a36Sopenharmony_ci struct inode *inode; 21062306a36Sopenharmony_ci nfs4_stateid *stateid; 21162306a36Sopenharmony_ci long timeout; 21262306a36Sopenharmony_ci unsigned char task_is_privileged : 1; 21362306a36Sopenharmony_ci unsigned char delay : 1, 21462306a36Sopenharmony_ci recovering : 1, 21562306a36Sopenharmony_ci retry : 1; 21662306a36Sopenharmony_ci bool interruptible; 21762306a36Sopenharmony_ci}; 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_cistruct nfs4_state_recovery_ops { 22062306a36Sopenharmony_ci int owner_flag_bit; 22162306a36Sopenharmony_ci int state_flag_bit; 22262306a36Sopenharmony_ci int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *); 22362306a36Sopenharmony_ci int (*recover_lock)(struct nfs4_state *, struct file_lock *); 22462306a36Sopenharmony_ci int (*establish_clid)(struct nfs_client *, const struct cred *); 22562306a36Sopenharmony_ci int (*reclaim_complete)(struct nfs_client *, const struct cred *); 22662306a36Sopenharmony_ci int (*detect_trunking)(struct nfs_client *, struct nfs_client **, 22762306a36Sopenharmony_ci const struct cred *); 22862306a36Sopenharmony_ci}; 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_cistruct nfs4_opendata { 23162306a36Sopenharmony_ci struct kref kref; 23262306a36Sopenharmony_ci struct nfs_openargs o_arg; 23362306a36Sopenharmony_ci struct nfs_openres o_res; 23462306a36Sopenharmony_ci struct nfs_open_confirmargs c_arg; 23562306a36Sopenharmony_ci struct nfs_open_confirmres c_res; 23662306a36Sopenharmony_ci struct nfs4_string owner_name; 23762306a36Sopenharmony_ci struct nfs4_string group_name; 23862306a36Sopenharmony_ci struct nfs4_label *a_label; 23962306a36Sopenharmony_ci struct nfs_fattr f_attr; 24062306a36Sopenharmony_ci struct dentry *dir; 24162306a36Sopenharmony_ci struct dentry *dentry; 24262306a36Sopenharmony_ci struct nfs4_state_owner *owner; 24362306a36Sopenharmony_ci struct nfs4_state *state; 24462306a36Sopenharmony_ci struct iattr attrs; 24562306a36Sopenharmony_ci struct nfs4_layoutget *lgp; 24662306a36Sopenharmony_ci unsigned long timestamp; 24762306a36Sopenharmony_ci bool rpc_done; 24862306a36Sopenharmony_ci bool file_created; 24962306a36Sopenharmony_ci bool is_recover; 25062306a36Sopenharmony_ci bool cancelled; 25162306a36Sopenharmony_ci int rpc_status; 25262306a36Sopenharmony_ci}; 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_cistruct nfs4_add_xprt_data { 25562306a36Sopenharmony_ci struct nfs_client *clp; 25662306a36Sopenharmony_ci const struct cred *cred; 25762306a36Sopenharmony_ci}; 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_cistruct nfs4_state_maintenance_ops { 26062306a36Sopenharmony_ci int (*sched_state_renewal)(struct nfs_client *, const struct cred *, unsigned); 26162306a36Sopenharmony_ci const struct cred * (*get_state_renewal_cred)(struct nfs_client *); 26262306a36Sopenharmony_ci int (*renew_lease)(struct nfs_client *, const struct cred *); 26362306a36Sopenharmony_ci}; 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_cistruct nfs4_mig_recovery_ops { 26662306a36Sopenharmony_ci int (*get_locations)(struct nfs_server *, struct nfs_fh *, 26762306a36Sopenharmony_ci struct nfs4_fs_locations *, struct page *, const struct cred *); 26862306a36Sopenharmony_ci int (*fsid_present)(struct inode *, const struct cred *); 26962306a36Sopenharmony_ci}; 27062306a36Sopenharmony_ci 27162306a36Sopenharmony_ciextern const struct dentry_operations nfs4_dentry_operations; 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci/* dir.c */ 27462306a36Sopenharmony_ciint nfs_atomic_open(struct inode *, struct dentry *, struct file *, 27562306a36Sopenharmony_ci unsigned, umode_t); 27662306a36Sopenharmony_ci 27762306a36Sopenharmony_ci/* fs_context.c */ 27862306a36Sopenharmony_ciextern struct file_system_type nfs4_fs_type; 27962306a36Sopenharmony_ci 28062306a36Sopenharmony_ci/* nfs4namespace.c */ 28162306a36Sopenharmony_cistruct rpc_clnt *nfs4_negotiate_security(struct rpc_clnt *, struct inode *, 28262306a36Sopenharmony_ci const struct qstr *); 28362306a36Sopenharmony_ciint nfs4_submount(struct fs_context *, struct nfs_server *); 28462306a36Sopenharmony_ciint nfs4_replace_transport(struct nfs_server *server, 28562306a36Sopenharmony_ci const struct nfs4_fs_locations *locations); 28662306a36Sopenharmony_cisize_t nfs_parse_server_name(char *string, size_t len, struct sockaddr_storage *ss, 28762306a36Sopenharmony_ci size_t salen, struct net *net, int port); 28862306a36Sopenharmony_ci/* nfs4proc.c */ 28962306a36Sopenharmony_ciextern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *); 29062306a36Sopenharmony_ciextern int nfs4_async_handle_error(struct rpc_task *task, 29162306a36Sopenharmony_ci struct nfs_server *server, 29262306a36Sopenharmony_ci struct nfs4_state *state, long *timeout); 29362306a36Sopenharmony_ciextern int nfs4_call_sync(struct rpc_clnt *, struct nfs_server *, 29462306a36Sopenharmony_ci struct rpc_message *, struct nfs4_sequence_args *, 29562306a36Sopenharmony_ci struct nfs4_sequence_res *, int); 29662306a36Sopenharmony_ciextern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int, int); 29762306a36Sopenharmony_ciextern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, const struct cred *, struct nfs4_setclientid_res *); 29862306a36Sopenharmony_ciextern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, const struct cred *); 29962306a36Sopenharmony_ciextern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *, bool); 30062306a36Sopenharmony_ciextern int nfs4_proc_bind_conn_to_session(struct nfs_client *, const struct cred *cred); 30162306a36Sopenharmony_ciextern int nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred); 30262306a36Sopenharmony_ciextern int nfs4_destroy_clientid(struct nfs_client *clp); 30362306a36Sopenharmony_ciextern int nfs4_init_clientid(struct nfs_client *, const struct cred *); 30462306a36Sopenharmony_ciextern int nfs41_init_clientid(struct nfs_client *, const struct cred *); 30562306a36Sopenharmony_ciextern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait); 30662306a36Sopenharmony_ciextern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); 30762306a36Sopenharmony_ciextern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *, 30862306a36Sopenharmony_ci struct nfs4_fs_locations *, struct page *); 30962306a36Sopenharmony_ciextern int nfs4_proc_get_locations(struct nfs_server *, struct nfs_fh *, 31062306a36Sopenharmony_ci struct nfs4_fs_locations *, 31162306a36Sopenharmony_ci struct page *page, const struct cred *); 31262306a36Sopenharmony_ciextern int nfs4_proc_fsid_present(struct inode *, const struct cred *); 31362306a36Sopenharmony_ciextern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *, 31462306a36Sopenharmony_ci struct dentry *, 31562306a36Sopenharmony_ci struct nfs_fh *, 31662306a36Sopenharmony_ci struct nfs_fattr *); 31762306a36Sopenharmony_ciextern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *); 31862306a36Sopenharmony_ciextern const struct xattr_handler *nfs4_xattr_handlers[]; 31962306a36Sopenharmony_ciextern int nfs4_set_rw_stateid(nfs4_stateid *stateid, 32062306a36Sopenharmony_ci const struct nfs_open_context *ctx, 32162306a36Sopenharmony_ci const struct nfs_lock_context *l_ctx, 32262306a36Sopenharmony_ci fmode_t fmode); 32362306a36Sopenharmony_ciextern void nfs4_bitmask_set(__u32 bitmask[], const __u32 src[], 32462306a36Sopenharmony_ci struct inode *inode, unsigned long cache_validity); 32562306a36Sopenharmony_ciextern int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, 32662306a36Sopenharmony_ci struct nfs_fattr *fattr, struct inode *inode); 32762306a36Sopenharmony_ciextern int update_open_stateid(struct nfs4_state *state, 32862306a36Sopenharmony_ci const nfs4_stateid *open_stateid, 32962306a36Sopenharmony_ci const nfs4_stateid *deleg_stateid, 33062306a36Sopenharmony_ci fmode_t fmode); 33162306a36Sopenharmony_ciextern int nfs4_proc_setlease(struct file *file, int arg, 33262306a36Sopenharmony_ci struct file_lock **lease, void **priv); 33362306a36Sopenharmony_ciextern int nfs4_proc_get_lease_time(struct nfs_client *clp, 33462306a36Sopenharmony_ci struct nfs_fsinfo *fsinfo); 33562306a36Sopenharmony_ciextern void nfs4_update_changeattr(struct inode *dir, 33662306a36Sopenharmony_ci struct nfs4_change_info *cinfo, 33762306a36Sopenharmony_ci unsigned long timestamp, 33862306a36Sopenharmony_ci unsigned long cache_validity); 33962306a36Sopenharmony_ciextern int nfs4_buf_to_pages_noslab(const void *buf, size_t buflen, 34062306a36Sopenharmony_ci struct page **pages); 34162306a36Sopenharmony_ci 34262306a36Sopenharmony_ci#if defined(CONFIG_NFS_V4_1) 34362306a36Sopenharmony_ciextern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *); 34462306a36Sopenharmony_ciextern int nfs4_proc_create_session(struct nfs_client *, const struct cred *); 34562306a36Sopenharmony_ciextern int nfs4_proc_destroy_session(struct nfs4_session *, const struct cred *); 34662306a36Sopenharmony_ciextern int nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, 34762306a36Sopenharmony_ci bool sync); 34862306a36Sopenharmony_ciextern int nfs4_detect_session_trunking(struct nfs_client *clp, 34962306a36Sopenharmony_ci struct nfs41_exchange_id_res *res, struct rpc_xprt *xprt); 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_cistatic inline bool 35262306a36Sopenharmony_ciis_ds_only_client(struct nfs_client *clp) 35362306a36Sopenharmony_ci{ 35462306a36Sopenharmony_ci return (clp->cl_exchange_flags & EXCHGID4_FLAG_MASK_PNFS) == 35562306a36Sopenharmony_ci EXCHGID4_FLAG_USE_PNFS_DS; 35662306a36Sopenharmony_ci} 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_cistatic inline bool 35962306a36Sopenharmony_ciis_ds_client(struct nfs_client *clp) 36062306a36Sopenharmony_ci{ 36162306a36Sopenharmony_ci return clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS; 36262306a36Sopenharmony_ci} 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_cistatic inline bool 36562306a36Sopenharmony_ci_nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode, 36662306a36Sopenharmony_ci struct rpc_clnt **clntp, struct rpc_message *msg) 36762306a36Sopenharmony_ci{ 36862306a36Sopenharmony_ci rpc_authflavor_t flavor; 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ci if (sp4_mode == NFS_SP4_MACH_CRED_CLEANUP || 37162306a36Sopenharmony_ci sp4_mode == NFS_SP4_MACH_CRED_PNFS_CLEANUP) { 37262306a36Sopenharmony_ci /* Using machine creds for cleanup operations 37362306a36Sopenharmony_ci * is only relevent if the client credentials 37462306a36Sopenharmony_ci * might expire. So don't bother for 37562306a36Sopenharmony_ci * RPC_AUTH_UNIX. If file was only exported to 37662306a36Sopenharmony_ci * sec=sys, the PUTFH would fail anyway. 37762306a36Sopenharmony_ci */ 37862306a36Sopenharmony_ci if ((*clntp)->cl_auth->au_flavor == RPC_AUTH_UNIX) 37962306a36Sopenharmony_ci return false; 38062306a36Sopenharmony_ci } 38162306a36Sopenharmony_ci if (test_bit(sp4_mode, &clp->cl_sp4_flags)) { 38262306a36Sopenharmony_ci msg->rpc_cred = rpc_machine_cred(); 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci flavor = clp->cl_rpcclient->cl_auth->au_flavor; 38562306a36Sopenharmony_ci WARN_ON_ONCE(flavor != RPC_AUTH_GSS_KRB5I && 38662306a36Sopenharmony_ci flavor != RPC_AUTH_GSS_KRB5P); 38762306a36Sopenharmony_ci *clntp = clp->cl_rpcclient; 38862306a36Sopenharmony_ci 38962306a36Sopenharmony_ci return true; 39062306a36Sopenharmony_ci } 39162306a36Sopenharmony_ci return false; 39262306a36Sopenharmony_ci} 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_ci/* 39562306a36Sopenharmony_ci * Function responsible for determining if an rpc_message should use the 39662306a36Sopenharmony_ci * machine cred under SP4_MACH_CRED and if so switching the credential and 39762306a36Sopenharmony_ci * authflavor (using the nfs_client's rpc_clnt which will be krb5i/p). 39862306a36Sopenharmony_ci * Should be called before rpc_call_sync/rpc_call_async. 39962306a36Sopenharmony_ci */ 40062306a36Sopenharmony_cistatic inline void 40162306a36Sopenharmony_cinfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode, 40262306a36Sopenharmony_ci struct rpc_clnt **clntp, struct rpc_message *msg) 40362306a36Sopenharmony_ci{ 40462306a36Sopenharmony_ci _nfs4_state_protect(clp, sp4_mode, clntp, msg); 40562306a36Sopenharmony_ci} 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ci/* 40862306a36Sopenharmony_ci * Special wrapper to nfs4_state_protect for write. 40962306a36Sopenharmony_ci * If WRITE can use machine cred but COMMIT cannot, make sure all writes 41062306a36Sopenharmony_ci * that use machine cred use NFS_FILE_SYNC. 41162306a36Sopenharmony_ci */ 41262306a36Sopenharmony_cistatic inline void 41362306a36Sopenharmony_cinfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, 41462306a36Sopenharmony_ci struct rpc_message *msg, struct nfs_pgio_header *hdr) 41562306a36Sopenharmony_ci{ 41662306a36Sopenharmony_ci if (_nfs4_state_protect(clp, NFS_SP4_MACH_CRED_WRITE, clntp, msg) && 41762306a36Sopenharmony_ci !test_bit(NFS_SP4_MACH_CRED_COMMIT, &clp->cl_sp4_flags)) 41862306a36Sopenharmony_ci hdr->args.stable = NFS_FILE_SYNC; 41962306a36Sopenharmony_ci} 42062306a36Sopenharmony_ci#else /* CONFIG_NFS_v4_1 */ 42162306a36Sopenharmony_cistatic inline bool 42262306a36Sopenharmony_ciis_ds_only_client(struct nfs_client *clp) 42362306a36Sopenharmony_ci{ 42462306a36Sopenharmony_ci return false; 42562306a36Sopenharmony_ci} 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_cistatic inline bool 42862306a36Sopenharmony_ciis_ds_client(struct nfs_client *clp) 42962306a36Sopenharmony_ci{ 43062306a36Sopenharmony_ci return false; 43162306a36Sopenharmony_ci} 43262306a36Sopenharmony_ci 43362306a36Sopenharmony_cistatic inline void 43462306a36Sopenharmony_cinfs4_state_protect(struct nfs_client *clp, unsigned long sp4_flags, 43562306a36Sopenharmony_ci struct rpc_clnt **clntp, struct rpc_message *msg) 43662306a36Sopenharmony_ci{ 43762306a36Sopenharmony_ci} 43862306a36Sopenharmony_ci 43962306a36Sopenharmony_cistatic inline void 44062306a36Sopenharmony_cinfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, 44162306a36Sopenharmony_ci struct rpc_message *msg, struct nfs_pgio_header *hdr) 44262306a36Sopenharmony_ci{ 44362306a36Sopenharmony_ci} 44462306a36Sopenharmony_ci#endif /* CONFIG_NFS_V4_1 */ 44562306a36Sopenharmony_ci 44662306a36Sopenharmony_ciextern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[]; 44762306a36Sopenharmony_ci 44862306a36Sopenharmony_ciextern const u32 nfs4_fattr_bitmap[3]; 44962306a36Sopenharmony_ciextern const u32 nfs4_statfs_bitmap[3]; 45062306a36Sopenharmony_ciextern const u32 nfs4_pathconf_bitmap[3]; 45162306a36Sopenharmony_ciextern const u32 nfs4_fsinfo_bitmap[3]; 45262306a36Sopenharmony_ciextern const u32 nfs4_fs_locations_bitmap[3]; 45362306a36Sopenharmony_ci 45462306a36Sopenharmony_civoid nfs40_shutdown_client(struct nfs_client *); 45562306a36Sopenharmony_civoid nfs41_shutdown_client(struct nfs_client *); 45662306a36Sopenharmony_ciint nfs40_init_client(struct nfs_client *); 45762306a36Sopenharmony_ciint nfs41_init_client(struct nfs_client *); 45862306a36Sopenharmony_civoid nfs4_free_client(struct nfs_client *); 45962306a36Sopenharmony_ci 46062306a36Sopenharmony_cistruct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *); 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_ci/* nfs4renewd.c */ 46362306a36Sopenharmony_ciextern void nfs4_schedule_state_renewal(struct nfs_client *); 46462306a36Sopenharmony_ciextern void nfs4_kill_renewd(struct nfs_client *); 46562306a36Sopenharmony_ciextern void nfs4_renew_state(struct work_struct *); 46662306a36Sopenharmony_ciextern void nfs4_set_lease_period(struct nfs_client *clp, unsigned long lease); 46762306a36Sopenharmony_ci 46862306a36Sopenharmony_ci 46962306a36Sopenharmony_ci/* nfs4state.c */ 47062306a36Sopenharmony_ciextern const nfs4_stateid current_stateid; 47162306a36Sopenharmony_ci 47262306a36Sopenharmony_ciconst struct cred *nfs4_get_clid_cred(struct nfs_client *clp); 47362306a36Sopenharmony_ciconst struct cred *nfs4_get_machine_cred(struct nfs_client *clp); 47462306a36Sopenharmony_ciconst struct cred *nfs4_get_renew_cred(struct nfs_client *clp); 47562306a36Sopenharmony_ciint nfs4_discover_server_trunking(struct nfs_client *clp, 47662306a36Sopenharmony_ci struct nfs_client **); 47762306a36Sopenharmony_ciint nfs40_discover_server_trunking(struct nfs_client *clp, 47862306a36Sopenharmony_ci struct nfs_client **, const struct cred *); 47962306a36Sopenharmony_ci#if defined(CONFIG_NFS_V4_1) 48062306a36Sopenharmony_ciint nfs41_discover_server_trunking(struct nfs_client *clp, 48162306a36Sopenharmony_ci struct nfs_client **, const struct cred *); 48262306a36Sopenharmony_ciextern void nfs4_schedule_session_recovery(struct nfs4_session *, int); 48362306a36Sopenharmony_ciextern void nfs41_notify_server(struct nfs_client *); 48462306a36Sopenharmony_cibool nfs4_check_serverowner_major_id(struct nfs41_server_owner *o1, 48562306a36Sopenharmony_ci struct nfs41_server_owner *o2); 48662306a36Sopenharmony_ci#else 48762306a36Sopenharmony_cistatic inline void nfs4_schedule_session_recovery(struct nfs4_session *session, int err) 48862306a36Sopenharmony_ci{ 48962306a36Sopenharmony_ci} 49062306a36Sopenharmony_ci#endif /* CONFIG_NFS_V4_1 */ 49162306a36Sopenharmony_ci 49262306a36Sopenharmony_ciextern struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *, const struct cred *, gfp_t); 49362306a36Sopenharmony_ciextern void nfs4_put_state_owner(struct nfs4_state_owner *); 49462306a36Sopenharmony_ciextern void nfs4_purge_state_owners(struct nfs_server *, struct list_head *); 49562306a36Sopenharmony_ciextern void nfs4_free_state_owners(struct list_head *head); 49662306a36Sopenharmony_ciextern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *); 49762306a36Sopenharmony_ciextern void nfs4_put_open_state(struct nfs4_state *); 49862306a36Sopenharmony_ciextern void nfs4_close_state(struct nfs4_state *, fmode_t); 49962306a36Sopenharmony_ciextern void nfs4_close_sync(struct nfs4_state *, fmode_t); 50062306a36Sopenharmony_ciextern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t); 50162306a36Sopenharmony_ciextern void nfs_inode_find_state_and_recover(struct inode *inode, 50262306a36Sopenharmony_ci const nfs4_stateid *stateid); 50362306a36Sopenharmony_ciextern int nfs4_state_mark_reclaim_nograce(struct nfs_client *, struct nfs4_state *); 50462306a36Sopenharmony_ciextern void nfs4_schedule_lease_recovery(struct nfs_client *); 50562306a36Sopenharmony_ciextern int nfs4_wait_clnt_recover(struct nfs_client *clp); 50662306a36Sopenharmony_ciextern int nfs4_client_recover_expired_lease(struct nfs_client *clp); 50762306a36Sopenharmony_ciextern void nfs4_schedule_state_manager(struct nfs_client *); 50862306a36Sopenharmony_ciextern void nfs4_schedule_path_down_recovery(struct nfs_client *clp); 50962306a36Sopenharmony_ciextern int nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *); 51062306a36Sopenharmony_ciextern int nfs4_schedule_migration_recovery(const struct nfs_server *); 51162306a36Sopenharmony_ciextern void nfs4_schedule_lease_moved_recovery(struct nfs_client *); 51262306a36Sopenharmony_ciextern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags, bool); 51362306a36Sopenharmony_ciextern void nfs41_handle_server_scope(struct nfs_client *, 51462306a36Sopenharmony_ci struct nfs41_server_scope **); 51562306a36Sopenharmony_ciextern void nfs4_put_lock_state(struct nfs4_lock_state *lsp); 51662306a36Sopenharmony_ciextern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); 51762306a36Sopenharmony_ciextern int nfs4_select_rw_stateid(struct nfs4_state *, fmode_t, 51862306a36Sopenharmony_ci const struct nfs_lock_context *, nfs4_stateid *, 51962306a36Sopenharmony_ci const struct cred **); 52062306a36Sopenharmony_ciextern bool nfs4_copy_open_stateid(nfs4_stateid *dst, 52162306a36Sopenharmony_ci struct nfs4_state *state); 52262306a36Sopenharmony_ci 52362306a36Sopenharmony_ciextern struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter, gfp_t gfp_mask); 52462306a36Sopenharmony_ciextern int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task); 52562306a36Sopenharmony_ciextern void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid); 52662306a36Sopenharmony_ciextern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid); 52762306a36Sopenharmony_ciextern void nfs_release_seqid(struct nfs_seqid *seqid); 52862306a36Sopenharmony_ciextern void nfs_free_seqid(struct nfs_seqid *seqid); 52962306a36Sopenharmony_ciextern int nfs4_setup_sequence(struct nfs_client *client, 53062306a36Sopenharmony_ci struct nfs4_sequence_args *args, 53162306a36Sopenharmony_ci struct nfs4_sequence_res *res, 53262306a36Sopenharmony_ci struct rpc_task *task); 53362306a36Sopenharmony_ciextern int nfs4_sequence_done(struct rpc_task *task, 53462306a36Sopenharmony_ci struct nfs4_sequence_res *res); 53562306a36Sopenharmony_ci 53662306a36Sopenharmony_ciextern void nfs4_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp); 53762306a36Sopenharmony_ciextern int nfs4_proc_commit(struct file *dst, __u64 offset, __u32 count, struct nfs_commitres *res); 53862306a36Sopenharmony_ciextern const nfs4_stateid zero_stateid; 53962306a36Sopenharmony_ciextern const nfs4_stateid invalid_stateid; 54062306a36Sopenharmony_ci 54162306a36Sopenharmony_ci/* nfs4super.c */ 54262306a36Sopenharmony_cistruct nfs_mount_info; 54362306a36Sopenharmony_ciextern struct nfs_subversion nfs_v4; 54462306a36Sopenharmony_ciextern bool nfs4_disable_idmapping; 54562306a36Sopenharmony_ciextern unsigned short max_session_slots; 54662306a36Sopenharmony_ciextern unsigned short max_session_cb_slots; 54762306a36Sopenharmony_ciextern unsigned short send_implementation_id; 54862306a36Sopenharmony_ciextern bool recover_lost_locks; 54962306a36Sopenharmony_ci 55062306a36Sopenharmony_ci#define NFS4_CLIENT_ID_UNIQ_LEN (64) 55162306a36Sopenharmony_ciextern char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN]; 55262306a36Sopenharmony_ci 55362306a36Sopenharmony_ciextern int nfs4_try_get_tree(struct fs_context *); 55462306a36Sopenharmony_ciextern int nfs4_get_referral_tree(struct fs_context *); 55562306a36Sopenharmony_ci 55662306a36Sopenharmony_ci/* nfs4sysctl.c */ 55762306a36Sopenharmony_ci#ifdef CONFIG_SYSCTL 55862306a36Sopenharmony_ciint nfs4_register_sysctl(void); 55962306a36Sopenharmony_civoid nfs4_unregister_sysctl(void); 56062306a36Sopenharmony_ci#else 56162306a36Sopenharmony_cistatic inline int nfs4_register_sysctl(void) 56262306a36Sopenharmony_ci{ 56362306a36Sopenharmony_ci return 0; 56462306a36Sopenharmony_ci} 56562306a36Sopenharmony_ci 56662306a36Sopenharmony_cistatic inline void nfs4_unregister_sysctl(void) 56762306a36Sopenharmony_ci{ 56862306a36Sopenharmony_ci} 56962306a36Sopenharmony_ci#endif 57062306a36Sopenharmony_ci 57162306a36Sopenharmony_ci/* nfs4xdr.c */ 57262306a36Sopenharmony_ciextern const struct rpc_procinfo nfs4_procedures[]; 57362306a36Sopenharmony_ci 57462306a36Sopenharmony_ci#ifdef CONFIG_NFS_V4_2 57562306a36Sopenharmony_ciextern const u32 nfs42_maxsetxattr_overhead; 57662306a36Sopenharmony_ciextern const u32 nfs42_maxgetxattr_overhead; 57762306a36Sopenharmony_ciextern const u32 nfs42_maxlistxattrs_overhead; 57862306a36Sopenharmony_ci#endif 57962306a36Sopenharmony_ci 58062306a36Sopenharmony_cistruct nfs4_mount_data; 58162306a36Sopenharmony_ci 58262306a36Sopenharmony_ci/* callback_xdr.c */ 58362306a36Sopenharmony_ciextern const struct svc_version nfs4_callback_version1; 58462306a36Sopenharmony_ciextern const struct svc_version nfs4_callback_version4; 58562306a36Sopenharmony_ci 58662306a36Sopenharmony_cistatic inline void nfs4_stateid_copy(nfs4_stateid *dst, const nfs4_stateid *src) 58762306a36Sopenharmony_ci{ 58862306a36Sopenharmony_ci memcpy(dst->data, src->data, sizeof(dst->data)); 58962306a36Sopenharmony_ci dst->type = src->type; 59062306a36Sopenharmony_ci} 59162306a36Sopenharmony_ci 59262306a36Sopenharmony_cistatic inline bool nfs4_stateid_match(const nfs4_stateid *dst, const nfs4_stateid *src) 59362306a36Sopenharmony_ci{ 59462306a36Sopenharmony_ci if (dst->type != src->type) 59562306a36Sopenharmony_ci return false; 59662306a36Sopenharmony_ci return memcmp(dst->data, src->data, sizeof(dst->data)) == 0; 59762306a36Sopenharmony_ci} 59862306a36Sopenharmony_ci 59962306a36Sopenharmony_cistatic inline bool nfs4_stateid_match_other(const nfs4_stateid *dst, const nfs4_stateid *src) 60062306a36Sopenharmony_ci{ 60162306a36Sopenharmony_ci return memcmp(dst->other, src->other, NFS4_STATEID_OTHER_SIZE) == 0; 60262306a36Sopenharmony_ci} 60362306a36Sopenharmony_ci 60462306a36Sopenharmony_cistatic inline bool nfs4_stateid_is_newer(const nfs4_stateid *s1, const nfs4_stateid *s2) 60562306a36Sopenharmony_ci{ 60662306a36Sopenharmony_ci return (s32)(be32_to_cpu(s1->seqid) - be32_to_cpu(s2->seqid)) > 0; 60762306a36Sopenharmony_ci} 60862306a36Sopenharmony_ci 60962306a36Sopenharmony_cistatic inline bool nfs4_stateid_is_next(const nfs4_stateid *s1, const nfs4_stateid *s2) 61062306a36Sopenharmony_ci{ 61162306a36Sopenharmony_ci u32 seq1 = be32_to_cpu(s1->seqid); 61262306a36Sopenharmony_ci u32 seq2 = be32_to_cpu(s2->seqid); 61362306a36Sopenharmony_ci 61462306a36Sopenharmony_ci return seq2 == seq1 + 1U || (seq2 == 1U && seq1 == 0xffffffffU); 61562306a36Sopenharmony_ci} 61662306a36Sopenharmony_ci 61762306a36Sopenharmony_cistatic inline bool nfs4_stateid_match_or_older(const nfs4_stateid *dst, const nfs4_stateid *src) 61862306a36Sopenharmony_ci{ 61962306a36Sopenharmony_ci return nfs4_stateid_match_other(dst, src) && 62062306a36Sopenharmony_ci !(src->seqid && nfs4_stateid_is_newer(dst, src)); 62162306a36Sopenharmony_ci} 62262306a36Sopenharmony_ci 62362306a36Sopenharmony_cistatic inline void nfs4_stateid_seqid_inc(nfs4_stateid *s1) 62462306a36Sopenharmony_ci{ 62562306a36Sopenharmony_ci u32 seqid = be32_to_cpu(s1->seqid); 62662306a36Sopenharmony_ci 62762306a36Sopenharmony_ci if (++seqid == 0) 62862306a36Sopenharmony_ci ++seqid; 62962306a36Sopenharmony_ci s1->seqid = cpu_to_be32(seqid); 63062306a36Sopenharmony_ci} 63162306a36Sopenharmony_ci 63262306a36Sopenharmony_cistatic inline bool nfs4_valid_open_stateid(const struct nfs4_state *state) 63362306a36Sopenharmony_ci{ 63462306a36Sopenharmony_ci return test_bit(NFS_STATE_RECOVERY_FAILED, &state->flags) == 0; 63562306a36Sopenharmony_ci} 63662306a36Sopenharmony_ci 63762306a36Sopenharmony_cistatic inline bool nfs4_state_match_open_stateid_other(const struct nfs4_state *state, 63862306a36Sopenharmony_ci const nfs4_stateid *stateid) 63962306a36Sopenharmony_ci{ 64062306a36Sopenharmony_ci return test_bit(NFS_OPEN_STATE, &state->flags) && 64162306a36Sopenharmony_ci nfs4_stateid_match_other(&state->open_stateid, stateid); 64262306a36Sopenharmony_ci} 64362306a36Sopenharmony_ci 64462306a36Sopenharmony_ci/* nfs42xattr.c */ 64562306a36Sopenharmony_ci#ifdef CONFIG_NFS_V4_2 64662306a36Sopenharmony_ciextern int __init nfs4_xattr_cache_init(void); 64762306a36Sopenharmony_ciextern void nfs4_xattr_cache_exit(void); 64862306a36Sopenharmony_ciextern void nfs4_xattr_cache_add(struct inode *inode, const char *name, 64962306a36Sopenharmony_ci const char *buf, struct page **pages, 65062306a36Sopenharmony_ci ssize_t buflen); 65162306a36Sopenharmony_ciextern void nfs4_xattr_cache_remove(struct inode *inode, const char *name); 65262306a36Sopenharmony_ciextern ssize_t nfs4_xattr_cache_get(struct inode *inode, const char *name, 65362306a36Sopenharmony_ci char *buf, ssize_t buflen); 65462306a36Sopenharmony_ciextern void nfs4_xattr_cache_set_list(struct inode *inode, const char *buf, 65562306a36Sopenharmony_ci ssize_t buflen); 65662306a36Sopenharmony_ciextern ssize_t nfs4_xattr_cache_list(struct inode *inode, char *buf, 65762306a36Sopenharmony_ci ssize_t buflen); 65862306a36Sopenharmony_ciextern void nfs4_xattr_cache_zap(struct inode *inode); 65962306a36Sopenharmony_ci#else 66062306a36Sopenharmony_cistatic inline void nfs4_xattr_cache_zap(struct inode *inode) 66162306a36Sopenharmony_ci{ 66262306a36Sopenharmony_ci} 66362306a36Sopenharmony_ci#endif /* CONFIG_NFS_V4_2 */ 66462306a36Sopenharmony_ci 66562306a36Sopenharmony_ci#else /* CONFIG_NFS_V4 */ 66662306a36Sopenharmony_ci 66762306a36Sopenharmony_ci#define nfs4_close_state(a, b) do { } while (0) 66862306a36Sopenharmony_ci#define nfs4_close_sync(a, b) do { } while (0) 66962306a36Sopenharmony_ci#define nfs4_state_protect(a, b, c, d) do { } while (0) 67062306a36Sopenharmony_ci#define nfs4_state_protect_write(a, b, c, d) do { } while (0) 67162306a36Sopenharmony_ci 67262306a36Sopenharmony_ci 67362306a36Sopenharmony_ci#endif /* CONFIG_NFS_V4 */ 67462306a36Sopenharmony_ci#endif /* __LINUX_FS_NFS_NFS4_FS.H */ 675