NFS: Call nfs4_state_protect{_write}() from the NFSv4 module
Subsystems (2)
PATCH 1/2 NFS: Call nfs4_state_protect{_write}() from the NFSv4 module
The generic client doesn't need to know about these calls, and we can handle them from the write and commit setup functions easily enough.
--- fs/nfs/nfs3proc.c | 7 +++++-- fs/nfs/nfs4proc.c | 11 +++++++++-- fs/nfs/proc.c | 6 ++++-- fs/nfs/write.c | 10 ++-------- include/linux/nfs_xdr.h | 6 ++++-- 5 files changed, 24 insertions(+), 16 deletions(-)
fs/nfs/nfs3proc.c +5 -2
@@ -838,7 +838,8 @@ static int nfs3_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr)return 0 ; } -static void nfs3_proc_write_setup (struct nfs_pgio_header *hdr, +static void nfs3_proc_write_setup (struct rpc_clnt **clnt, +struct nfs_pgio_header *hdr,struct rpc_message *msg) { msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE ];
@@ -860,7 +861,9 @@ static int nfs3_commit_done(struct rpc_task *task, struct nfs_commit_data *data)return 0 ; } -static void nfs3_proc_commit_setup (struct nfs_commit_data *data,struct rpc_message *msg) +static void nfs3_proc_commit_setup (struct rpc_clnt **clnt, +struct nfs_commit_data *data, +struct rpc_message *msg) { msg->rpc_proc = &nfs3_procedures[NFS3PROC_COMMIT ]; }
fs/nfs/nfs4proc.c +9 -2
@@ -4448,7 +4448,8 @@ bool nfs4_write_need_cache_consistency_data(struct nfs_pgio_header *hdr)return nfs4_have_delegation (hdr->inode,FMODE_READ ) ==0 ; } -static void nfs4_proc_write_setup (struct nfs_pgio_header *hdr, +static void nfs4_proc_write_setup (struct rpc_clnt **clnt, +struct nfs_pgio_header *hdr,struct rpc_message *msg) {struct nfs_server *server =NFS_SERVER (hdr->inode);
@@ -4466,6 +4467,8 @@ static void nfs4_proc_write_setup(struct nfs_pgio_header *hdr, msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_WRITE ];nfs4_init_sequence (&hdr->args.seq_args, &hdr->res.seq_res,1 ); +nfs4_state_protect_write (NFS_SERVER (hdr->inode)->nfs_client, + clnt, msg, hdr); }static void nfs4_proc_commit_rpc_prepare (struct rpc_task *task,struct nfs_commit_data *data)
@@ -4496,7 +4499,9 @@ static int nfs4_commit_done(struct rpc_task *task, struct nfs_commit_data *data)return data->commit_done_cb (task, data); } -static void nfs4_proc_commit_setup (struct nfs_commit_data *data,struct rpc_message *msg) +static void nfs4_proc_commit_setup (struct rpc_clnt **clnt, +struct nfs_commit_data *data, +struct rpc_message *msg) {struct nfs_server *server =NFS_SERVER (data->inode);
@@ -4505,6 +4510,8 @@ static void nfs4_proc_commit_setup(struct nfs_commit_data *data, struct rpc_mess data->res.server = server; msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT ];nfs4_init_sequence (&data->args.seq_args, &data->res.seq_res,1 ); +nfs4_state_protect (NFS_SERVER (data->inode)->nfs_client, +NFS_SP4_MACH_CRED_COMMIT , clnt, msg); }struct nfs4_renewdata {
fs/nfs/proc.c +4 -2
@@ -614,7 +614,8 @@ static int nfs_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr)return 0 ; } -static void nfs_proc_write_setup (struct nfs_pgio_header *hdr, +static void nfs_proc_write_setup (struct rpc_clnt **clnt, +struct nfs_pgio_header *hdr,struct rpc_message *msg) {/* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */
@@ -628,7 +629,8 @@ static void nfs_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit }static void -nfs_proc_commit_setup (struct nfs_commit_data *data,struct rpc_message *msg) +nfs_proc_commit_setup (struct rpc_clnt **clnt,struct nfs_commit_data *data, +struct rpc_message *msg) {BUG (); }
fs/nfs/write.c +2 -8
@@ -1323,10 +1323,7 @@ static void nfs_initiate_write(struct nfs_pgio_header *hdr,int priority =flush_task_priority (how); task_setup_data->priority = priority; - rpc_ops->write_setup (hdr, msg); - -nfs4_state_protect_write (NFS_SERVER (hdr->inode)->nfs_client, - &task_setup_data->rpc_client, msg, hdr); + rpc_ops->write_setup (&task_setup_data->rpc_client, hdr, msg); }/* If a nfs_flush_* function fails, it should remove reqs from @head and
@@ -1609,13 +1606,10 @@ int nfs_initiate_commit(struct rpc_clnt *clnt, struct nfs_commit_data *data, .priority = priority, };/* Set up the initial task struct. */ - nfs_ops->commit_setup (data, &msg); + nfs_ops->commit_setup (&task_setup_data.rpc_client, data, &msg);dprintk ("NFS: initiated commit call\n" ); -nfs4_state_protect (NFS_SERVER (data->inode)->nfs_client, -NFS_SP4_MACH_CRED_COMMIT , &task_setup_data.rpc_client, &msg); - task =rpc_run_task (&task_setup_data);if (IS_ERR (task))return PTR_ERR (task);
include/linux/nfs_xdr.h +4 -2
@@ -1555,9 +1555,11 @@ struct nfs_rpc_ops { struct nfs_pgio_header *);void (*read_setup)(struct nfs_pgio_header *,struct rpc_message *);int (*read_done)(struct rpc_task *,struct nfs_pgio_header *); -void (*write_setup)(struct nfs_pgio_header *,struct rpc_message *); +void (*write_setup)(struct rpc_clnt **,struct nfs_pgio_header *, +struct rpc_message *);int (*write_done)(struct rpc_task *,struct nfs_pgio_header *); -void (*commit_setup) (struct nfs_commit_data *,struct rpc_message *); +void (*commit_setup) (struct rpc_clnt **,struct nfs_commit_data *, +struct rpc_message *);void (*commit_rpc_prepare)(struct rpc_task *,struct nfs_commit_data *);int (*commit_done) (struct rpc_task *,struct nfs_commit_data *);int (*lock)(struct file *,int ,struct file_lock *);
Signature · 1 line
2.8.2
PATCH 2/2 NFS: Merge _nfs4_state_protect() and nfs4_state_protect()
We can have nfs4_state_protect() do the work directly, rather than passing through the arguments without adding or modifying anything.
--- fs/nfs/nfs4_fs.h | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
fs/nfs/nfs4_fs.h +9 -16
@@ -290,9 +290,15 @@ is_ds_client(struct nfs_client *clp)return clp->cl_exchange_flags &EXCHGID4_FLAG_USE_PNFS_DS ; } +/* +* Function responsible for determining if an rpc_message should use the +* machine cred under SP4_MACH_CRED and if so switching the credential and +* authflavor (using the nfs_client's rpc_clnt which will be krb5i/p). +* Should be called before rpc_call_sync/rpc_call_async. +*/ static inline bool -_nfs4_state_protect (struct nfs_client *clp,unsigned long sp4_mode, -struct rpc_clnt **clntp,struct rpc_message *msg) +nfs4_state_protect (struct nfs_client *clp,unsigned long sp4_mode, +struct rpc_clnt **clntp,struct rpc_message *msg) {struct rpc_cred *newcred =NULL ;rpc_authflavor_t flavor;
@@ -317,19 +323,6 @@ _nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode, }/* -* Function responsible for determining if an rpc_message should use the -* machine cred under SP4_MACH_CRED and if so switching the credential and -* authflavor (using the nfs_client's rpc_clnt which will be krb5i/p). -* Should be called before rpc_call_sync/rpc_call_async. -*/ -static inline void -nfs4_state_protect (struct nfs_client *clp,unsigned long sp4_mode, -struct rpc_clnt **clntp,struct rpc_message *msg) -{ -_nfs4_state_protect (clp, sp4_mode, clntp, msg); -} - -/* * Special wrapper to nfs4_state_protect for write. * If WRITE can use machine cred but COMMIT cannot, make sure all writes * that use machine cred use NFS_FILE_SYNC.
@@ -338,7 +331,7 @@ static inline void nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, struct rpc_message *msg, struct nfs_pgio_header *hdr) { - if (_nfs4_state_protect(clp, NFS_SP4_MACH_CRED_WRITE, clntp, msg) && + if (nfs4_state_protect(clp, NFS_SP4_MACH_CRED_WRITE, clntp, msg) && !test_bit(NFS_SP4_MACH_CRED_COMMIT, &clp->cl_sp4_flags)) hdr->args.stable = NFS_FILE_SYNC; }
Signature · 1 line
2.8.2
DQoNCg0KDQoNCk9uIDUvMy8xNiwgMTQ6MjksICJBbm5hIFNjaHVtYWtlciIgPEFubmEuU2NodW1h a2VyQG5ldGFwcC5jb20+IHdyb3RlOg0KDQo+VGhlIGdlbmVyaWMgY2xpZW50IGRvZXNuJ3QgbmVl ZCB0byBrbm93IGFib3V0IHRoZXNlIGNhbGxzLCBhbmQgd2UgY2FuDQo+aGFuZGxlIHRoZW0gZnJv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