nfs: ensure that sillyrenames run to completion (try #2)
Subsystems (2)
cover nfs: ensure that sillyrenames run to completion (try #2)
This patchset is pretty much identical to the one that I sent last week. It has one minor fix -- I fixed it to use nfs_free_fattr instead of kfree in nfs_async_rename_release. I also cleaned up the comments a bit.
We had a bug report recently where someone was complaining about silly-renamed files being left around:
https://bugzilla.redhat.com/show_bug.cgi?id=511901
...they attached a reproducer to the bug which involves a pthreads-based program killing a child thread that's unlinking and closing a file.
The unlink triggers a sillyrename (since the file is still open). The parent kills the child thread and if timed just right, the child thread will be killed after the RENAME call is issued but before the reply is processed. The file will end up renamed on the server, but the client won't be aware of it and won't unlink it during dentry_iput.
This patchset is intended to prevent this from happening by having nfs_sillyrename use an asynchronous rename call and simply wait for the call to complete in TASK_KILLABLE sleep before proceeding. If the task is killed while the rename RPC is on the wire, it'll still run to completion even though the thread that initiated it was killed off.
To facilitate this, the set first changes all of the existing rename calls to use standardized argument and response containers. The nfs_sillyrename call is then moved to unlink.c (where the rest of the sillyrename code lives), and then is converted to use an asynchronous RPC call to handle the rename.
I've tested this by running the reproducer in the above bug report in a loop for several hours and never ended up with a leftover .nfs* file.
I'd like to see this in 2.6.37 if possible.
Jeff Layton (8):
nfs: eliminate nfs3_renameargs
nfs: convert nfs_renameargs to use qstr structs
nfs: eliminate nfs4_rename_arg
nfs: standardize the rename response container
nfs: move nfs_sillyrename to unlink.c
nfs: add a rename_setup nfs_rpc_op for async renames
nfs: add rename_done nfs_rpc_op
nfs: make sillyrename an async operation
fs/nfs/dir.c | 70 ------------- fs/nfs/nfs2xdr.c | 8 +- fs/nfs/nfs3proc.c | 62 +++++++++--- fs/nfs/nfs3xdr.c | 16 ++-- fs/nfs/nfs4proc.c | 43 ++++++++- fs/nfs/nfs4xdr.c | 4 +- fs/nfs/proc.c | 34 +++++- fs/nfs/unlink.c | 253 ++++++++++++++++++++++++++++++++++++++++++++++- include/linux/nfs_fs.h | 2 +- include/linux/nfs_xdr.h | 64 +++++-------- 10 files changed, 406 insertions(+), 150 deletions(-)
PATCH 1/8 nfs: eliminate nfs3_renameargs
It's exactly the same as nfs_renameargs, so move it to the area of the header where protocol-neutral defintions live and eliminate the v3 specific variant.
--- fs/nfs/nfs3proc.c | 2 +- fs/nfs/nfs3xdr.c | 2 +- include/linux/nfs_xdr.h | 30 ++++++++++++------------------ 3 files changed, 14 insertions(+), 20 deletions(-)
fs/nfs/nfs3proc.c +1 -1
@@ -442,7 +442,7 @@ static int nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, struct inode *new_dir, struct qstr *new_name) { - struct nfs3_renameargs arg = { + struct nfs_renameargs arg = { .fromfh = NFS_FH(old_dir), .fromname = old_name->name, .fromlen = old_name->len,
fs/nfs/nfs3xdr.c +1 -1
@@ -442,7 +442,7 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req, __be32 *p, struct nfs3_mknodargs *args)* Encode RENAME arguments */ static int -nfs3_xdr_renameargs (struct rpc_rqst *req,__be32 *p,struct nfs3_renameargs *args) +nfs3_xdr_renameargs (struct rpc_rqst *req,__be32 *p,struct nfs_renameargs *args) { p =xdr_encode_fhandle (p, args->fromfh); p =xdr_encode_array (p, args->fromname, args->fromlen);
include/linux/nfs_xdr.h +12 -18
@@ -400,6 +400,18 @@ struct nfs_removeres { };/* +* Common arguments to the rename call +*/ +struct nfs_renameargs { +struct nfs_fh * fromfh; +const char * fromname; +unsigned int fromlen; +struct nfs_fh * tofh; +const char * toname; +unsigned int tolen; +}; + +/* * Argument struct for decode_entry function */ struct nfs_entry {
@@ -434,15 +446,6 @@ struct nfs_createargs {struct iattr * sattr; }; -struct nfs_renameargs { -struct nfs_fh * fromfh; -const char * fromname; -unsigned int fromlen; -struct nfs_fh * tofh; -const char * toname; -unsigned int tolen; -}; -struct nfs_setattrargs {struct nfs_fh * fh;nfs4_stateid stateid;
@@ -586,15 +589,6 @@ struct nfs3_mknodargs {dev_t rdev; }; -struct nfs3_renameargs { -struct nfs_fh * fromfh; -const char * fromname; -unsigned int fromlen; -struct nfs_fh * tofh; -const char * toname; -unsigned int tolen; -}; -struct nfs3_linkargs {struct nfs_fh * fromfh;struct nfs_fh * tofh;
Signature · 1 line
1.7.1
PATCH 2/8 nfs: convert nfs_renameargs to use qstr structs
In reply to Jeff LaytonThe v4 version already does this.
--- fs/nfs/nfs2xdr.c | 8 ++++---- fs/nfs/nfs3proc.c | 10 ++++------ fs/nfs/nfs3xdr.c | 8 ++++---- fs/nfs/proc.c | 10 ++++------ include/linux/nfs_xdr.h | 10 ++++------ 5 files changed, 20 insertions(+), 26 deletions(-)
fs/nfs/nfs2xdr.c +4 -4
@@ -337,10 +337,10 @@ nfs_xdr_createargs(struct rpc_rqst *req, __be32 *p, struct nfs_createargs *args)static int nfs_xdr_renameargs (struct rpc_rqst *req,__be32 *p,struct nfs_renameargs *args) { - p =xdr_encode_fhandle (p, args->fromfh); - p =xdr_encode_array (p, args->fromname, args->fromlen); - p =xdr_encode_fhandle (p, args->tofh); - p =xdr_encode_array (p, args->toname, args->tolen); + p =xdr_encode_fhandle (p, args->old_dir); + p =xdr_encode_array (p, args->old_name->name, args->old_name->len); + p =xdr_encode_fhandle (p, args->new_dir); + p =xdr_encode_array (p, args->new_name->name, args->new_name->len); req->rq_slen =xdr_adjust_iovec (req->rq_svec, p);return 0 ; }
fs/nfs/nfs3proc.c +4 -6
@@ -443,12 +443,10 @@ nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, struct inode *new_dir, struct qstr *new_name) { struct nfs_renameargs arg = { - .fromfh =NFS_FH (old_dir), - .fromname = old_name->name, - .fromlen = old_name->len, - .tofh =NFS_FH (new_dir), - .toname = new_name->name, - .tolen = new_name->len + .old_dir =NFS_FH (old_dir), + .old_name = old_name, + .new_dir =NFS_FH (new_dir), + .new_name = new_name, };struct nfs3_renameres res; struct rpc_message msg = {
fs/nfs/nfs3xdr.c +4 -4
@@ -444,10 +444,10 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req, __be32 *p, struct nfs3_mknodargs *args)static int nfs3_xdr_renameargs (struct rpc_rqst *req,__be32 *p,struct nfs_renameargs *args) { - p =xdr_encode_fhandle (p, args->fromfh); - p =xdr_encode_array (p, args->fromname, args->fromlen); - p =xdr_encode_fhandle (p, args->tofh); - p =xdr_encode_array (p, args->toname, args->tolen); + p =xdr_encode_fhandle (p, args->old_dir); + p =xdr_encode_array (p, args->old_name->name, args->old_name->len); + p =xdr_encode_fhandle (p, args->new_dir); + p =xdr_encode_array (p, args->new_name->name, args->new_name->len); req->rq_slen =xdr_adjust_iovec (req->rq_svec, p);return 0 ; }
fs/nfs/proc.c +4 -6
@@ -370,12 +370,10 @@ nfs_proc_rename(struct inode *old_dir, struct qstr *old_name, struct inode *new_dir, struct qstr *new_name) { struct nfs_renameargs arg = { - .fromfh =NFS_FH (old_dir), - .fromname = old_name->name, - .fromlen = old_name->len, - .tofh =NFS_FH (new_dir), - .toname = new_name->name, - .tolen = new_name->len + .old_dir =NFS_FH (old_dir), + .old_name = old_name, + .new_dir =NFS_FH (new_dir), + .new_name = new_name, }; struct rpc_message msg = { .rpc_proc = &nfs_procedures[NFSPROC_RENAME],
include/linux/nfs_xdr.h +4 -6
@@ -403,12 +403,10 @@ struct nfs_removeres {* Common arguments to the rename call */ struct nfs_renameargs { -struct nfs_fh * fromfh; -const char * fromname; -unsigned int fromlen; -struct nfs_fh * tofh; -const char * toname; -unsigned int tolen; +const struct nfs_fh * old_dir; +const struct nfs_fh * new_dir; +const struct qstr * old_name; +const struct qstr * new_name; };/*
Signature · 1 line
1.7.1
PATCH 3/8 nfs: eliminate nfs4_rename_arg
In reply to Jeff LaytonAdd the missing fields to nfs_renameargs and drop nfs4_rename_arg
--- fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4xdr.c | 2 +- include/linux/nfs_xdr.h | 19 ++++++------------- 3 files changed, 8 insertions(+), 15 deletions(-)
fs/nfs/nfs4proc.c +1 -1
@@ -2675,7 +2675,7 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, struct inode *new_dir, struct qstr *new_name) { struct nfs_server *server = NFS_SERVER(old_dir); - struct nfs4_rename_arg arg = { + struct nfs_renameargs arg = { .old_dir = NFS_FH(old_dir), .new_dir = NFS_FH(new_dir), .old_name = old_name,
fs/nfs/nfs4xdr.c +1 -1
@@ -1823,7 +1823,7 @@ static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs/* * Encode RENAME request */ -static int nfs4_xdr_enc_rename (struct rpc_rqst *req,__be32 *p,const struct nfs4_rename_arg *args) +static int nfs4_xdr_enc_rename (struct rpc_rqst *req,__be32 *p,const struct nfs_renameargs *args) {struct xdr_stream xdr;struct compound_hdr hdr = {
include/linux/nfs_xdr.h +6 -13
@@ -403,10 +403,12 @@ struct nfs_removeres {* Common arguments to the rename call */ struct nfs_renameargs { -const struct nfs_fh * old_dir; -const struct nfs_fh * new_dir; -const struct qstr * old_name; -const struct qstr * new_name; +const struct nfs_fh * old_dir; +const struct nfs_fh * new_dir; +const struct qstr * old_name; +const struct qstr * new_name; +const u32 * bitmask; +struct nfs4_sequence_args seq_args; };/*
@@ -793,15 +795,6 @@ struct nfs4_readlink_res {struct nfs4_sequence_res seq_res; }; -struct nfs4_rename_arg { -const struct nfs_fh * old_dir; -const struct nfs_fh * new_dir; -const struct qstr * old_name; -const struct qstr * new_name; -const u32 * bitmask; -struct nfs4_sequence_args seq_args; -}; -struct nfs4_rename_res {const struct nfs_server * server;struct nfs4_change_info old_cinfo;
Signature · 1 line
1.7.1
Re: [PATCH 3/8] nfs: eliminate nfs4_rename_arg
Quoted 43 lines · Jeff Layton
Add the missing fields to
nfs_renameargsand dropnfs4_rename_argSigned-off-by Jeff Layton <[email protected]>---
fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4xdr.c | 2 +- include/linux/nfs_xdr.h | 19 ++++++------------- 3 files changed, 8 insertions(+), 15 deletions(-)fs/nfs/nfs4proc.c +1
-1@@ -2675,7 +2675,7 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, struct inode *new_dir, struct qstr *new_name) { struct nfs_server *server = NFS_SERVER(old_dir); - struct nfs4_rename_arg arg = { + struct nfs_renameargs arg = { .old_dir = NFS_FH(old_dir), .new_dir = NFS_FH(new_dir), .old_name = old_name,fs/nfs/nfs4xdr.c +1
-1@@ -1823,7 +1823,7 @@ static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs/* * Encode RENAME request */ -static int nfs4_xdr_enc_rename (struct rpc_rqst *req,__be32 *p,const struct nfs4_rename_arg *args) +static int nfs4_xdr_enc_rename (struct rpc_rqst *req,__be32 *p,const struct nfs_renameargs *args) {struct xdr_stream xdr;struct compound_hdr hdr = {include/linux/nfs_xdr.h +0
-0@@ -403,10 +403,12 @@ struct nfs_removeres {* Common arguments to the rename call */ struct nfs_renameargs {
include/linux/nfs_xdr.h struct nfs_removeres { · line 411
Quoted 10 lines
include/linux/nfs_xdr.h +6
-4-const struct nfs_fh * old_dir; -const struct nfs_fh * new_dir; -const struct qstr * old_name; -const struct qstr * new_name; +const struct nfs_fh * old_dir; +const struct nfs_fh * new_dir; +const struct qstr * old_name; +const struct qstr * new_name; +const u32 * bitmask; +struct nfs4_sequence_args seq_args;
Should these new fields be gated by CONFIG_NFS_V4 ?
Quoted 26 lines
include/linux/nfs_xdr.h +0
-9};/* @@ -793,15 +795,6 @@ struct nfs4_readlink_res {struct nfs4_sequence_res seq_res; }; -struct nfs4_rename_arg { -const struct nfs_fh * old_dir; -const struct nfs_fh * new_dir; -const struct qstr * old_name; -const struct qstr * new_name; -const u32 * bitmask; -struct nfs4_sequence_args seq_args; -}; -struct nfs4_rename_res {const struct nfs_server * server;struct nfs4_change_info old_cinfo;Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 3/8] nfs: eliminate nfs4_rename_arg
Quoted 50 lines · On Wed, 15 Sep 2010 11:26:49 -0400 Chuck Lever <[email protected]> wrote:
Quoted 47 lines · Jeff Layton
Add the missing fields to
nfs_renameargsand dropnfs4_rename_argSigned-off-by Jeff Layton <[email protected]>---
fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4xdr.c | 2 +- include/linux/nfs_xdr.h | 19 ++++++------------- 3 files changed, 8 insertions(+), 15 deletions(-)fs/nfs/nfs4proc.c +1
-1@@ -2675,7 +2675,7 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, struct inode *new_dir, struct qstr *new_name) { struct nfs_server *server = NFS_SERVER(old_dir); - struct nfs4_rename_arg arg = { + struct nfs_renameargs arg = { .old_dir = NFS_FH(old_dir), .new_dir = NFS_FH(new_dir), .old_name = old_name,fs/nfs/nfs4xdr.c +1
-1@@ -1823,7 +1823,7 @@ static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs/* * Encode RENAME request */ -static int nfs4_xdr_enc_rename (struct rpc_rqst *req,__be32 *p,const struct nfs4_rename_arg *args) +static int nfs4_xdr_enc_rename (struct rpc_rqst *req,__be32 *p,const struct nfs_renameargs *args) {struct xdr_stream xdr;struct compound_hdr hdr = {include/linux/nfs_xdr.h +0
-4@@ -403,10 +403,12 @@ struct nfs_removeres {* Common arguments to the rename call */ struct nfs_renameargs { -const struct nfs_fh * old_dir; -const struct nfs_fh * new_dir; -const struct qstr * old_name; -const struct qstr * new_name;
Quoted 9 lines
include/linux/nfs_xdr.h struct nfs_removeres { · line 411
Quoted 6 lines
include/linux/nfs_xdr.h +6
-0+const struct nfs_fh * old_dir; +const struct nfs_fh * new_dir; +const struct qstr * old_name; +const struct qstr * new_name; +const u32 * bitmask; +struct nfs4_sequence_args seq_args;Should these new fields be gated by
CONFIG_NFS_V4?
I suppose they could be. nfs_removeargs has the same fields though and is not gated like that.
Quoted 27 lines
Quoted 26 lines
include/linux/nfs_xdr.h +0
-9};/* @@ -793,15 +795,6 @@ struct nfs4_readlink_res {struct nfs4_sequence_res seq_res; }; -struct nfs4_rename_arg { -const struct nfs_fh * old_dir; -const struct nfs_fh * new_dir; -const struct qstr * old_name; -const struct qstr * new_name; -const u32 * bitmask; -struct nfs4_sequence_args seq_args; -}; -struct nfs4_rename_res {const struct nfs_server * server;struct nfs4_change_info old_cinfo;Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH 3/8] nfs: eliminate nfs4_rename_arg
In reply to Chuck LeverQuoted 49 lines · Chuck Lever
Quoted 47 lines · Jeff Layton
Add the missing fields to
nfs_renameargsand dropnfs4_rename_argSigned-off-by Jeff Layton <[email protected]>---
fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4xdr.c | 2 +- include/linux/nfs_xdr.h | 19 ++++++------------- 3 files changed, 8 insertions(+), 15 deletions(-)fs/nfs/nfs4proc.c +1
-1@@ -2675,7 +2675,7 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, struct inode *new_dir, struct qstr *new_name) { struct nfs_server *server = NFS_SERVER(old_dir); - struct nfs4_rename_arg arg = { + struct nfs_renameargs arg = { .old_dir = NFS_FH(old_dir), .new_dir = NFS_FH(new_dir), .old_name = old_name,fs/nfs/nfs4xdr.c +1
-1@@ -1823,7 +1823,7 @@ static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs/* * Encode RENAME request */ -static int nfs4_xdr_enc_rename (struct rpc_rqst *req,__be32 *p,const struct nfs4_rename_arg *args) +static int nfs4_xdr_enc_rename (struct rpc_rqst *req,__be32 *p,const struct nfs_renameargs *args) {struct xdr_stream xdr;struct compound_hdr hdr = {include/linux/nfs_xdr.h +0
-4@@ -403,10 +403,12 @@ struct nfs_removeres {* Common arguments to the rename call */ struct nfs_renameargs { -const struct nfs_fh * old_dir; -const struct nfs_fh * new_dir; -const struct qstr * old_name; -const struct qstr * new_name;
Quoted 8 lines
include/linux/nfs_xdr.h struct nfs_removeres { · line 411
Quoted 6 lines
include/linux/nfs_xdr.h +6
-0+const struct nfs_fh * old_dir; +const struct nfs_fh * new_dir; +const struct qstr * old_name; +const struct qstr * new_name; +const u32 * bitmask; +struct nfs4_sequence_args seq_args;Should these new fields be gated by
CONFIG_NFS_V4?
No. Please don't add any more #ifdef CONFIG_NFS_V4 sections: that just adds to the testing duties. The job now is to get rid of CONFIG_NFS_V..., not to add more to it.
Trond
Re: [PATCH 3/8] nfs: eliminate nfs4_rename_arg
Quoted 59 lines · Trond Myklebust
Quoted 49 lines · Chuck Lever
Quoted 47 lines · Jeff Layton
Add the missing fields to
nfs_renameargsand dropnfs4_rename_argSigned-off-by Jeff Layton <[email protected]>---
fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4xdr.c | 2 +- include/linux/nfs_xdr.h | 19 ++++++------------- 3 files changed, 8 insertions(+), 15 deletions(-)fs/nfs/nfs4proc.c +1
-1@@ -2675,7 +2675,7 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, struct inode *new_dir, struct qstr *new_name) { struct nfs_server *server = NFS_SERVER(old_dir); - struct nfs4_rename_arg arg = { + struct nfs_renameargs arg = { .old_dir = NFS_FH(old_dir), .new_dir = NFS_FH(new_dir), .old_name = old_name,fs/nfs/nfs4xdr.c +1
-1@@ -1823,7 +1823,7 @@ static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs/* * Encode RENAME request */ -static int nfs4_xdr_enc_rename (struct rpc_rqst *req,__be32 *p,const struct nfs4_rename_arg *args) +static int nfs4_xdr_enc_rename (struct rpc_rqst *req,__be32 *p,const struct nfs_renameargs *args) {struct xdr_stream xdr;struct compound_hdr hdr = {include/linux/nfs_xdr.h +0
-4@@ -403,10 +403,12 @@ struct nfs_removeres {* Common arguments to the rename call */ struct nfs_renameargs { -const struct nfs_fh * old_dir; -const struct nfs_fh * new_dir; -const struct qstr * old_name; -const struct qstr * new_name;Quoted 8 lines
include/linux/nfs_xdr.h struct nfs_removeres { · line 411
Quoted 6 lines
include/linux/nfs_xdr.h +6
-0+const struct nfs_fh * old_dir; +const struct nfs_fh * new_dir; +const struct qstr * old_name; +const struct qstr * new_name; +const u32 * bitmask; +struct nfs4_sequence_args seq_args;Should these new fields be gated by
CONFIG_NFS_V4?
Quoted 3 lines
No. Please don't add any more #ifdef
CONFIG_NFS_V4sections: that just adds to the testing duties. The job now is to get rid ofCONFIG_NFS_V..., not to add more to it.
The underlying question was whether this builds when CONFIG_NFS_V4 is disabled, and Jeff has confirmed that it does. Agreed that no change is needed here.
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com
PATCH 4/8 nfs: standardize the rename response container
In reply to Jeff LaytonRight now, v3 and v4 have their own variants and v2 doesn't have one at all. Create a standard struct that will work for v3 and v4.
--- fs/nfs/nfs3proc.c | 16 ++++++++-------- fs/nfs/nfs3xdr.c | 6 +++--- fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4xdr.c | 2 +- include/linux/nfs_xdr.h | 23 +++++++++-------------- 5 files changed, 22 insertions(+), 27 deletions(-)
fs/nfs/nfs3proc.c +8 -8
@@ -448,7 +448,7 @@ nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, .new_dir = NFS_FH(new_dir), .new_name = new_name, }; -struct nfs3_renameres res; +struct nfs_renameres res;struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_RENAME ], .rpc_argp = &arg,
@@ -458,17 +458,17 @@ nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name,dprintk ("NFS call rename %s -> %s\n" , old_name->name, new_name->name); - res.fromattr =nfs_alloc_fattr (); - res.toattr =nfs_alloc_fattr (); -if (res.fromattr ==NULL || res.toattr ==NULL ) + res.old_fattr =nfs_alloc_fattr (); + res.new_fattr =nfs_alloc_fattr (); +if (res.old_fattr ==NULL || res.new_fattr ==NULL ) goto out; status =rpc_call_sync (NFS_CLIENT (old_dir), &msg,0 ); -nfs_post_op_update_inode (old_dir, res.fromattr); -nfs_post_op_update_inode (new_dir, res.toattr); +nfs_post_op_update_inode (old_dir, res.old_fattr); +nfs_post_op_update_inode (new_dir, res.new_fattr); out: -nfs_free_fattr (res.toattr); -nfs_free_fattr (res.fromattr); +nfs_free_fattr (res.old_fattr); +nfs_free_fattr (res.new_fattr);dprintk ("NFS reply rename: %d\n" , status);return status; }
fs/nfs/nfs3xdr.c +3 -3
@@ -970,14 +970,14 @@ nfs3_xdr_createres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)* Decode RENAME reply */ static int -nfs3_xdr_renameres (struct rpc_rqst *req,__be32 *p,struct nfs3_renameres *res) +nfs3_xdr_renameres (struct rpc_rqst *req,__be32 *p,struct nfs_renameres *res) {int status;if ((status =ntohl (*p++)) !=0 ) status =nfs_stat_to_errno (status); - p =xdr_decode_wcc_data (p, res->fromattr); - p =xdr_decode_wcc_data (p, res->toattr); + p =xdr_decode_wcc_data (p, res->old_fattr); + p =xdr_decode_wcc_data (p, res->new_fattr);return status; }
fs/nfs/nfs4proc.c +1 -1
@@ -2682,7 +2682,7 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, .new_name = new_name, .bitmask = server->attr_bitmask, }; -struct nfs4_rename_res res = { +struct nfs_renameres res = { .server = server, };struct rpc_message msg = {
fs/nfs/nfs4xdr.c +1 -1
@@ -4873,7 +4873,7 @@ out:/* * Decode RENAME response */ -static int nfs4_xdr_dec_rename (struct rpc_rqst *rqstp,__be32 *p,struct nfs4_rename_res *res) +static int nfs4_xdr_dec_rename (struct rpc_rqst *rqstp,__be32 *p,struct nfs_renameres *res) {struct xdr_stream xdr;struct compound_hdr hdr;
include/linux/nfs_xdr.h +9 -14
@@ -411,6 +411,15 @@ struct nfs_renameargs {struct nfs4_sequence_args seq_args; }; +struct nfs_renameres { +const struct nfs_server * server; +struct nfs4_change_info old_cinfo; +struct nfs_fattr * old_fattr; +struct nfs4_change_info new_cinfo; +struct nfs_fattr * new_fattr; +struct nfs4_sequence_res seq_res; +}; +/* * Argument struct for decode_entry function */
@@ -623,11 +632,6 @@ struct nfs3_readlinkargs {struct page ** pages; }; -struct nfs3_renameres { -struct nfs_fattr * fromattr; -struct nfs_fattr * toattr; -}; -struct nfs3_linkres {struct nfs_fattr * dir_attr;struct nfs_fattr * fattr;
@@ -795,15 +799,6 @@ struct nfs4_readlink_res {struct nfs4_sequence_res seq_res; }; -struct nfs4_rename_res { -const struct nfs_server * server; -struct nfs4_change_info old_cinfo; -struct nfs_fattr * old_fattr; -struct nfs4_change_info new_cinfo; -struct nfs_fattr * new_fattr; -struct nfs4_sequence_res seq_res; -}; -#define NFS4_SETCLIENTID_NAMELEN (127)struct nfs4_setclientid {const nfs4_verifier * sc_verifier;
Signature · 1 line
1.7.1
Re: [PATCH 4/8] nfs: standardize the rename response container
Quoted 104 lines · Jeff Layton
Right now, v3 and v4 have their own variants and v2 doesn't have one at all. Create a standard struct that will work for v3 and v4.
Signed-off-by Jeff Layton <[email protected]>---
fs/nfs/nfs3proc.c | 16 ++++++++-------- fs/nfs/nfs3xdr.c | 6 +++--- fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4xdr.c | 2 +- include/linux/nfs_xdr.h | 23 +++++++++-------------- 5 files changed, 22 insertions(+), 27 deletions(-)fs/nfs/nfs3proc.c +6
-6@@ -448,7 +448,7 @@ nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, .new_dir = NFS_FH(new_dir), .new_name = new_name, }; -struct nfs3_renameres res; +struct nfs_renameres res;struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_RENAME ], .rpc_argp = &arg,@@ -458,17 +458,17 @@ nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name,dprintk ("NFS call rename %s -> %s\n" , old_name->name, new_name->name); - res.fromattr =nfs_alloc_fattr (); - res.toattr =nfs_alloc_fattr (); -if (res.fromattr ==NULL || res.toattr ==NULL ) + res.old_fattr =nfs_alloc_fattr (); + res.new_fattr =nfs_alloc_fattr (); +if (res.old_fattr ==NULL || res.new_fattr ==NULL ) goto out; status =rpc_call_sync (NFS_CLIENT (old_dir), &msg,0 ); -nfs_post_op_update_inode (old_dir, res.fromattr); -nfs_post_op_update_inode (new_dir, res.toattr); +nfs_post_op_update_inode (old_dir, res.old_fattr); +nfs_post_op_update_inode (new_dir, res.new_fattr);out:
fs/nfs/nfs3proc.c +2
-2-nfs_free_fattr (res.toattr); -nfs_free_fattr (res.fromattr); +nfs_free_fattr (res.old_fattr); +nfs_free_fattr (res.new_fattr);dprintk("NFS reply rename: %d\n", status); return status; }fs/nfs/nfs3xdr.c +0
-0@@ -970,14 +970,14 @@ nfs3_xdr_createres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)* Decode RENAME reply */ static int
fs/nfs/nfs3xdr.c +1
-1-nfs3_xdr_renameres(struct rpc_rqst *req, __be32 *p, struct nfs3_renameres *res) +nfs3_xdr_renameres(struct rpc_rqst *req, __be32 *p, struct nfs_renameres *res){ int status; if ((status = ntohl(*p++)) != 0) status = nfs_stat_to_errno(status);fs/nfs/nfs3xdr.c +2
-2- p =xdr_decode_wcc_data (p, res->fromattr); - p =xdr_decode_wcc_data (p, res->toattr); + p =xdr_decode_wcc_data (p, res->old_fattr); + p =xdr_decode_wcc_data (p, res->new_fattr);return status; }fs/nfs/nfs4proc.c +1
-1@@ -2682,7 +2682,7 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, .new_name = new_name, .bitmask = server->attr_bitmask, }; -struct nfs4_rename_res res = { +struct nfs_renameres res = { .server = server, };struct rpc_message msg = {fs/nfs/nfs4xdr.c +1
-1@@ -4873,7 +4873,7 @@ out:/* * Decode RENAME response */ -static int nfs4_xdr_dec_rename (struct rpc_rqst *rqstp,__be32 *p,struct nfs4_rename_res *res) +static int nfs4_xdr_dec_rename (struct rpc_rqst *rqstp,__be32 *p,struct nfs_renameres *res) {struct xdr_stream xdr;struct compound_hdr hdr;include/linux/nfs_xdr.h +0
-0@@ -411,6 +411,15 @@ struct nfs_renameargs {struct nfs4_sequence_args seq_args;
include/linux/nfs_xdr.h struct nfs_renameargs { · line 421
Quoted 10 lines
include/linux/nfs_xdr.h +8
-0}; +struct nfs_renameres { +const struct nfs_server * server; +struct nfs4_change_info old_cinfo; +struct nfs_fattr * old_fattr; +struct nfs4_change_info new_cinfo; +struct nfs_fattr * new_fattr; +struct nfs4_sequence_res seq_res; +};
Likewise. Is #ifdef CONFIG_NFS_V4 needed here? I guess the question is, have you tried building with CONFIG_NFS_V4 disabled?
Quoted 39 lines
include/linux/nfs_xdr.h +1
-14+/* * Argument struct for decode_entry function */ @@ -623,11 +632,6 @@ struct nfs3_readlinkargs {struct page ** pages; }; -struct nfs3_renameres { -struct nfs_fattr * fromattr; -struct nfs_fattr * toattr; -}; -struct nfs3_linkres {struct nfs_fattr * dir_attr;struct nfs_fattr * fattr;@@ -795,15 +799,6 @@ struct nfs4_readlink_res {struct nfs4_sequence_res seq_res; }; -struct nfs4_rename_res { -const struct nfs_server * server; -struct nfs4_change_info old_cinfo; -struct nfs_fattr * old_fattr; -struct nfs4_change_info new_cinfo; -struct nfs_fattr * new_fattr; -struct nfs4_sequence_res seq_res; -}; -#define NFS4_SETCLIENTID_NAMELEN (127)struct nfs4_setclientid {const nfs4_verifier * sc_verifier;Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 4/8] nfs: standardize the rename response container
Quoted 7 lines · On Wed, 15 Sep 2010 11:29:38 -0400 Chuck Lever <[email protected]> wrote:
Quoted 7 lines
index 60fa509..6265fa8 100644
include/linux/nfs_xdr.h +0
-0@@ -411,6 +411,15 @@ struct nfs_renameargs {struct nfs4_sequence_args seq_args; };
Quoted 11 lines
include/linux/nfs_xdr.h struct nfs_renameargs { · line 421
Quoted 8 lines
include/linux/nfs_xdr.h +8
-0+struct nfs_renameres { +const struct nfs_server * server; +struct nfs4_change_info old_cinfo; +struct nfs_fattr * old_fattr; +struct nfs4_change_info new_cinfo; +struct nfs_fattr * new_fattr; +struct nfs4_sequence_res seq_res; +};Likewise. Is #ifdef
CONFIG_NFS_V4needed here? I guess the question is, have you tried building withCONFIG_NFS_V4disabled?
Yes, I have built this with v4 disabled and it worked just fine. The #ifdef isn't really needed. I suppose we could add that in to save a bit of memory but it's probably not worth it. Note that nfs_removeres has the same sort of fields and they aren't wrapped in #ifdef's.
Signature · 1 line
Jeff Layton <[email protected]>
PATCH 5/8 nfs: move nfs_sillyrename to unlink.c
In reply to Jeff Layton...since that's where most of the sillyrenaming code lives. Also, make nfs_async_unlink static as nfs_sillyrename is the only caller.
--- fs/nfs/dir.c | 70 --------------------------------------- fs/nfs/unlink.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++- include/linux/nfs_fs.h | 2 +- 3 files changed, 85 insertions(+), 72 deletions(-)
fs/nfs/dir.c +0 -70
@@ -1351,76 +1351,6 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry)return error; } -static int nfs_sillyrename (struct inode *dir,struct dentry *dentry) -{ -static unsigned int sillycounter; -const int fileidsize =sizeof (NFS_FILEID (dentry->d_inode))*2 ; -const int countersize =sizeof (sillycounter)*2 ; -const int slen =sizeof (".nfs" )+fileidsize+countersize-1 ; -char silly[slen+1 ]; -struct qstr qsilly; -struct dentry *sdentry; -int error = -EIO ; - -dfprintk (VFS ,"NFS: silly-rename(%s/%s, ct=%d)\n" , - dentry->d_parent->d_name.name, dentry->d_name.name, -atomic_read (&dentry->d_count)); -nfs_inc_stats (dir,NFSIOS_SILLYRENAME ); - -/* -* We don't allow a dentry to be silly-renamed twice. -*/ - error = -EBUSY ; -if (dentry->d_flags &DCACHE_NFSFS_RENAMED ) - goto out; - -sprintf (silly,".nfs%*.*Lx" , - fileidsize, fileidsize, - (unsigned long long )NFS_FILEID (dentry->d_inode)); - -/* Return delegation in anticipation of the rename */ -nfs_inode_return_delegation (dentry->d_inode); - - sdentry =NULL ; -do { -char *suffix = silly + slen - countersize; - -dput (sdentry); - sillycounter++; -sprintf (suffix,"%*.*x" , countersize, countersize, sillycounter); - -dfprintk (VFS ,"NFS: trying to rename %s to %s\n" , - dentry->d_name.name, silly); - - sdentry =lookup_one_len (silly, dentry->d_parent, slen); -/* -* N.B. Better to return EBUSY here ... it could be -* dangerous to delete the file while it's in use. -*/ -if (IS_ERR (sdentry)) - goto out; - }while (sdentry->d_inode !=NULL );/* need negative lookup */ - - qsilly.name = silly; - qsilly.len =strlen (silly); -if (dentry->d_inode) { - error =NFS_PROTO (dir)->rename (dir, &dentry->d_name, - dir, &qsilly); -nfs_mark_for_revalidate (dentry->d_inode); - }else - error =NFS_PROTO (dir)->rename (dir, &dentry->d_name, - dir, &qsilly); -if (!error) { -nfs_set_verifier (dentry,nfs_save_change_attribute (dir)); -d_move (dentry, sdentry); - error =nfs_async_unlink (dir, dentry); -/* If we return 0 we don't unlink */ - } -dput (sdentry); -out: -return error; -} -/* * Remove a file after making sure there are no pending writes, * and after checking that the file has only one user.
fs/nfs/unlink.c +84 -1
103 lines not on this page · raw message
include/linux/nfs_fs.h +1 -1
@@ -479,10 +479,10 @@ extern void nfs_release_automount_timer(void);/* * linux/fs/nfs/unlink.c */ -extern int nfs_async_unlink (struct inode *dir,struct dentry *dentry);extern void nfs_complete_unlink (struct dentry *dentry,struct inode *);extern void nfs_block_sillyrename (struct dentry *dentry);extern void nfs_unblock_sillyrename (struct dentry *dentry); +extern int nfs_sillyrename (struct inode *dir,struct dentry *dentry);/* * linux/fs/nfs/write.c
Signature · 1 line
1.7.1
PATCH 6/8 nfs: add a rename_setup nfs_rpc_op for async renames
In reply to Jeff LaytonAdd a call that can set up the arguments and the response container for an asynchronous rename call.
--- fs/nfs/nfs3proc.c | 18 ++++++++++++++++++ fs/nfs/nfs4proc.c | 21 +++++++++++++++++++++ fs/nfs/proc.c | 12 ++++++++++++ include/linux/nfs_xdr.h | 1 + 4 files changed, 52 insertions(+), 0 deletions(-)
fs/nfs/nfs3proc.c +18 -0
@@ -439,6 +439,23 @@ nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir) }static int +nfs3_proc_rename_setup (struct rpc_message *msg,struct inode *dir) +{ +struct nfs_renameres *res = msg->rpc_resp; + + msg->rpc_proc = &nfs3_procedures[NFS3PROC_RENAME ]; + + res->old_fattr =nfs_alloc_fattr (); + res->new_fattr =nfs_alloc_fattr (); +if (res->old_fattr !=NULL && res->new_fattr !=NULL ) +return 0 ; + +nfs_free_fattr (res->old_fattr); +nfs_free_fattr (res->new_fattr); +return -ENOMEM ; +} + +static int nfs3_proc_rename (struct inode *old_dir,struct qstr *old_name,struct inode *new_dir,struct qstr *new_name) {
@@ -842,6 +859,7 @@ const struct nfs_rpc_ops nfs_v3_clientops = { .unlink_setup = nfs3_proc_unlink_setup, .unlink_done = nfs3_proc_unlink_done, .rename = nfs3_proc_rename, + .rename_setup = nfs3_proc_rename_setup, .link = nfs3_proc_link, .symlink = nfs3_proc_symlink, .mkdir = nfs3_proc_mkdir,
fs/nfs/nfs4proc.c +21 -0
@@ -2671,6 +2671,26 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir)return 1 ; } +static int nfs4_proc_rename_setup (struct rpc_message *msg,struct inode *dir) +{ +struct nfs_server *server =NFS_SERVER (dir); +struct nfs_renameargs *arg = msg->rpc_argp; +struct nfs_renameres *res = msg->rpc_resp; + + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME ]; + arg->bitmask = server->attr_bitmask; + res->server = server; + + res->old_fattr =nfs_alloc_fattr (); + res->new_fattr =nfs_alloc_fattr (); +if (res->old_fattr !=NULL && res->new_fattr !=NULL ) +return 0 ; + +nfs_free_fattr (res->old_fattr); +nfs_free_fattr (res->new_fattr); +return -ENOMEM ; +} +static int _nfs4_proc_rename (struct inode *old_dir,struct qstr *old_name,struct inode *new_dir,struct qstr *new_name) {
@@ -5443,6 +5463,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = { .unlink_setup = nfs4_proc_unlink_setup, .unlink_done = nfs4_proc_unlink_done, .rename = nfs4_proc_rename, + .rename_setup = nfs4_proc_rename_setup, .link = nfs4_proc_link, .symlink = nfs4_proc_symlink, .mkdir = nfs4_proc_mkdir,
fs/nfs/proc.c +12 -0
@@ -366,6 +366,17 @@ static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir) }static int +nfs_proc_rename_setup (struct rpc_message *msg,struct inode *dir) +{ +struct nfs_renameres *res = msg->rpc_resp; + + msg->rpc_proc = &nfs_procedures[NFSPROC_RENAME ]; + res->old_fattr =NULL ; + res->new_fattr =NULL ; +return 0 ; +} + +static int nfs_proc_rename (struct inode *old_dir,struct qstr *old_name,struct inode *new_dir,struct qstr *new_name) {
@@ -703,6 +714,7 @@ const struct nfs_rpc_ops nfs_v2_clientops = { .unlink_setup = nfs_proc_unlink_setup, .unlink_done = nfs_proc_unlink_done, .rename = nfs_proc_rename, + .rename_setup = nfs_proc_rename_setup, .link = nfs_proc_link, .symlink = nfs_proc_symlink, .mkdir = nfs_proc_mkdir,
include/linux/nfs_xdr.h +1 -0
@@ -1018,6 +1018,7 @@ struct nfs_rpc_ops {int (*unlink_done) (struct rpc_task *,struct inode *);int (*rename) (struct inode *,struct qstr *,struct inode *,struct qstr *); +int (*rename_setup) (struct rpc_message *msg,struct inode *dir);int (*link) (struct inode *,struct inode *,struct qstr *);int (*symlink) (struct inode *,struct dentry *,struct page *,unsigned int ,struct iattr *);
Signature · 1 line
1.7.1
Re: [PATCH 6/8] nfs: add a rename_setup nfs_rpc_op for async renames
Quoted 24 lines · Jeff Layton
Add a call that can set up the arguments and the response container for an asynchronous rename call.
Signed-off-by Jeff Layton <[email protected]>---
fs/nfs/nfs3proc.c | 18 ++++++++++++++++++ fs/nfs/nfs4proc.c | 21 +++++++++++++++++++++ fs/nfs/proc.c | 12 ++++++++++++ include/linux/nfs_xdr.h | 1 + 4 files changed, 52 insertions(+), 0 deletions(-)fs/nfs/nfs3proc.c +0
-0@@ -439,6 +439,23 @@ nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir) }static int
fs/nfs/nfs3proc.c +5
-0+nfs3_proc_rename_setup(struct rpc_message *msg, struct inode *dir) +{ + struct nfs_renameres *res = msg->rpc_resp; + + msg->rpc_proc = &nfs3_procedures[NFS3PROC_RENAME ];
fs/nfs/nfs3proc.c nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir) · line 456
Quoted 10 lines
fs/nfs/nfs3proc.c +10
-0+ + res->old_fattr =nfs_alloc_fattr (); + res->new_fattr =nfs_alloc_fattr (); +if (res->old_fattr !=NULL && res->new_fattr !=NULL ) +return 0 ; + +nfs_free_fattr (res->old_fattr); +nfs_free_fattr (res->new_fattr); +return -ENOMEM ; +}
This is just a style nit, but my understanding is that there is a stated preference for the error case to be handled in the statement block after the NULL checks, and the common case should exit through the tail of the function.
I suspect that these last three patches can be merged together for submission. I read somewhere recently that the powers that be do not like patches that introduce new code that isn't used by anything.
Quoted 101 lines
fs/nfs/nfs3proc.c +2
-0+ +static intnfs3_proc_rename(struct inode
*old_dir, struct qstr*old_name,
struct inode*new_dir, struct qstr*new_name)
{fs/nfs/nfs3proc.c +1
-0@@ -842,6 +859,7 @@ const struct nfs_rpc_ops nfs_v3_clientops = { .unlink_setup = nfs3_proc_unlink_setup, .unlink_done = nfs3_proc_unlink_done, .rename = nfs3_proc_rename, + .rename_setup = nfs3_proc_rename_setup, .link = nfs3_proc_link, .symlink = nfs3_proc_symlink, .mkdir = nfs3_proc_mkdir,fs/nfs/nfs4proc.c +21
-0@@ -2671,6 +2671,26 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir)return 1 ; } +static int nfs4_proc_rename_setup (struct rpc_message *msg,struct inode *dir) +{ +struct nfs_server *server =NFS_SERVER (dir); +struct nfs_renameargs *arg = msg->rpc_argp; +struct nfs_renameres *res = msg->rpc_resp; + + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME ]; + arg->bitmask = server->attr_bitmask; + res->server = server; + + res->old_fattr =nfs_alloc_fattr (); + res->new_fattr =nfs_alloc_fattr (); +if (res->old_fattr !=NULL && res->new_fattr !=NULL ) +return 0 ; + +nfs_free_fattr (res->old_fattr); +nfs_free_fattr (res->new_fattr); +return -ENOMEM ; +} +static int _nfs4_proc_rename (struct inode *old_dir,struct qstr *old_name,struct inode *new_dir,struct qstr *new_name) {@@ -5443,6 +5463,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = { .unlink_setup = nfs4_proc_unlink_setup, .unlink_done = nfs4_proc_unlink_done, .rename = nfs4_proc_rename, + .rename_setup = nfs4_proc_rename_setup, .link = nfs4_proc_link, .symlink = nfs4_proc_symlink, .mkdir = nfs4_proc_mkdir,fs/nfs/proc.c +0
-0@@ -366,6 +366,17 @@ static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir) }static int
fs/nfs/proc.c +11
-0+nfs_proc_rename_setup(struct rpc_message *msg, struct inode *dir) +{ + struct nfs_renameres *res = msg->rpc_resp; + + msg->rpc_proc = &nfs_procedures[NFSPROC_RENAME ]; + res->old_fattr =NULL ; + res->new_fattr =NULL ; +return 0 ; +} + +static intnfs_proc_rename(struct inode
*old_dir, struct qstr*old_name,
struct inode*new_dir, struct qstr*new_name)
{fs/nfs/proc.c +1
-0@@ -703,6 +714,7 @@ const struct nfs_rpc_ops nfs_v2_clientops = { .unlink_setup = nfs_proc_unlink_setup, .unlink_done = nfs_proc_unlink_done, .rename = nfs_proc_rename, + .rename_setup = nfs_proc_rename_setup, .link = nfs_proc_link, .symlink = nfs_proc_symlink, .mkdir = nfs_proc_mkdir,include/linux/nfs_xdr.h +1
-0@@ -1018,6 +1018,7 @@ struct nfs_rpc_ops {int (*unlink_done) (struct rpc_task *,struct inode *);int (*rename) (struct inode *,struct qstr *,struct inode *,struct qstr *); +int (*rename_setup) (struct rpc_message *msg,struct inode *dir);int (*link) (struct inode *,struct inode *,struct qstr *);int (*symlink) (struct inode *,struct dentry *,struct page *,unsigned int ,struct iattr *);Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 6/8] nfs: add a rename_setup nfs_rpc_op for async renames
Quoted 31 lines · On Wed, 15 Sep 2010 11:39:38 -0400 Chuck Lever <[email protected]> wrote:
Quoted 28 lines · Jeff Layton
Add a call that can set up the arguments and the response container for an asynchronous rename call.
Signed-off-by Jeff Layton <[email protected]>---
fs/nfs/nfs3proc.c | 18 ++++++++++++++++++ fs/nfs/nfs4proc.c | 21 +++++++++++++++++++++ fs/nfs/proc.c | 12 ++++++++++++ include/linux/nfs_xdr.h | 1 + 4 files changed, 52 insertions(+), 0 deletions(-)fs/nfs/nfs3proc.c +0
-0@@ -439,6 +439,23 @@ nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir) }static int
fs/nfs/nfs3proc.c +9
-0+nfs3_proc_rename_setup(struct rpc_message *msg, struct inode *dir) +{ + struct nfs_renameres *res = msg->rpc_resp; + + msg->rpc_proc = &nfs3_procedures[NFS3PROC_RENAME ]; + + res->old_fattr =nfs_alloc_fattr (); + res->new_fattr =nfs_alloc_fattr (); +if (res->old_fattr !=NULL && res->new_fattr !=NULL )
Quoted 9 lines
fs/nfs/nfs3proc.c nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir) · line 456
Quoted 6 lines
fs/nfs/nfs3proc.c +6
-0+return 0 ; + +nfs_free_fattr (res->old_fattr); +nfs_free_fattr (res->new_fattr); +return -ENOMEM ; +}This is just a style nit, but my understanding is that there is a stated preference for the error case to be handled in the statement block after the NULL checks, and the common case should exit through the tail of the function.
Fair enough. I can change that.
Quoted 2 lines
I suspect that these last three patches can be merged together for submission. I read somewhere recently that the powers that be do not like patches that introduce new code that isn't used by anything.
I can do that. I figured this would make it easier to review, but I'm fine doing it that way too.
Thanks for the review.
Signature · 1 line
Jeff Layton <[email protected]>
PATCH 7/8 nfs: add rename_done nfs_rpc_op
In reply to Jeff Layton...for processing the rename reply.
--- fs/nfs/nfs3proc.c | 16 ++++++++++++++++ fs/nfs/nfs4proc.c | 18 ++++++++++++++++++ fs/nfs/proc.c | 12 ++++++++++++ include/linux/nfs_xdr.h | 1 + 4 files changed, 47 insertions(+), 0 deletions(-)
fs/nfs/nfs3proc.c +16 -0
@@ -456,6 +456,21 @@ nfs3_proc_rename_setup(struct rpc_message *msg, struct inode *dir) }static int +nfs3_proc_rename_done (struct rpc_task *task,struct inode *old_dir, +struct inode *new_dir) +{ +struct nfs_renameres *res; + +if (nfs3_async_handle_jukebox (task, old_dir)) +return 0 ; + res = task->tk_msg.rpc_resp; + +nfs_post_op_update_inode (old_dir, res->old_fattr); +nfs_post_op_update_inode (new_dir, res->new_fattr); +return 1 ; +} + +static int nfs3_proc_rename (struct inode *old_dir,struct qstr *old_name,struct inode *new_dir,struct qstr *new_name) {
@@ -860,6 +875,7 @@ const struct nfs_rpc_ops nfs_v3_clientops = { .unlink_done = nfs3_proc_unlink_done, .rename = nfs3_proc_rename, .rename_setup = nfs3_proc_rename_setup, + .rename_done = nfs3_proc_rename_done, .link = nfs3_proc_link, .symlink = nfs3_proc_symlink, .mkdir = nfs3_proc_mkdir,
fs/nfs/nfs4proc.c +18 -0
@@ -2691,6 +2691,23 @@ static int nfs4_proc_rename_setup(struct rpc_message *msg, struct inode *dir)return -ENOMEM ; } +static int nfs4_proc_rename_done (struct rpc_task *task,struct inode *old_dir, +struct inode *new_dir) +{ +struct nfs_renameres *res = task->tk_msg.rpc_resp; + +if (!nfs4_sequence_done (task, &res->seq_res)) +return 0 ; +if (nfs4_async_handle_error (task, res->server,NULL ) == -EAGAIN ) +return 0 ; + +update_changeattr (old_dir, &res->old_cinfo); +nfs_post_op_update_inode (old_dir, res->old_fattr); +update_changeattr (new_dir, &res->new_cinfo); +nfs_post_op_update_inode (new_dir, res->new_fattr); +return 1 ; +} +static int _nfs4_proc_rename (struct inode *old_dir,struct qstr *old_name,struct inode *new_dir,struct qstr *new_name) {
@@ -5464,6 +5481,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = { .unlink_done = nfs4_proc_unlink_done, .rename = nfs4_proc_rename, .rename_setup = nfs4_proc_rename_setup, + .rename_done = nfs4_proc_rename_done, .link = nfs4_proc_link, .symlink = nfs4_proc_symlink, .mkdir = nfs4_proc_mkdir,
fs/nfs/proc.c +12 -0
@@ -377,6 +377,17 @@ nfs_proc_rename_setup(struct rpc_message *msg, struct inode *dir) }static int +nfs_proc_rename_done (struct rpc_task *task,struct inode *old_dir, +struct inode *new_dir) +{ +if (nfs_async_handle_expired_key (task)) +return 0 ; +nfs_mark_for_revalidate (old_dir); +nfs_mark_for_revalidate (new_dir); +return 1 ; +} + +static int nfs_proc_rename (struct inode *old_dir,struct qstr *old_name,struct inode *new_dir,struct qstr *new_name) {
@@ -715,6 +726,7 @@ const struct nfs_rpc_ops nfs_v2_clientops = { .unlink_done = nfs_proc_unlink_done, .rename = nfs_proc_rename, .rename_setup = nfs_proc_rename_setup, + .rename_done = nfs_proc_rename_done, .link = nfs_proc_link, .symlink = nfs_proc_symlink, .mkdir = nfs_proc_mkdir,
include/linux/nfs_xdr.h +1 -0
@@ -1019,6 +1019,7 @@ struct nfs_rpc_ops {int (*rename) (struct inode *,struct qstr *,struct inode *,struct qstr *);int (*rename_setup) (struct rpc_message *msg,struct inode *dir); +int (*rename_done) (struct rpc_task *task,struct inode *old_dir,struct inode *new_dir);int (*link) (struct inode *,struct inode *,struct qstr *);int (*symlink) (struct inode *,struct dentry *,struct page *,unsigned int ,struct iattr *);
Signature · 1 line
1.7.1
PATCH 8/8 nfs: make sillyrename an async operation
In reply to Jeff LaytonA synchronous rename can be interrupted by a SIGKILL. If that happens during a sillyrename operation, it's possible for the rename call to be sent to the server, but the task exits before processing the reply. If this happens, the sillyrenamed file won't get cleaned up during nfs_dentry_iput and the server is left with a dangling .nfs* file hanging around.
Fix this problem by turning sillyrename into an asynchronous operation and have the task doing the sillyrename just wait on the reply. If the task is killed before the sillyrename completes, it'll still proceed to completion.
--- fs/nfs/unlink.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 183 insertions(+), 15 deletions(-)
fs/nfs/unlink.c +183 -15
@@ -307,6 +307,164 @@ nfs_complete_unlink(struct dentry *dentry, struct inode *inode)nfs_free_unlinkdata (data); } +/* Cancel a queued async unlink. Called when a sillyrename run fails. */ +static void +nfs_cancel_async_unlink (struct dentry *dentry) +{ +spin_lock (&dentry->d_lock); +if (dentry->d_flags &DCACHE_NFSFS_RENAMED ) { + dentry->d_flags &= ~DCACHE_NFSFS_RENAMED ; +nfs_free_unlinkdata (dentry->d_fsdata); + } +spin_unlock (&dentry->d_lock); +} + +struct nfs_renamedata { +struct nfs_renameargs args; +struct nfs_renameres res; +struct rpc_cred * cred; +struct inode * old_dir; +struct inode * new_dir; +struct dentry * old_dentry; +struct dentry * new_dentry; +}; + +/** +* nfs_async_rename_done - Sillyrename post-processing +* @task: rpc_task of the sillyrename +* @calldata: nfs_renamedata for the sillyrename +* +* Do the directory attribute updates and the d_move +*/ +static void nfs_async_rename_done (struct rpc_task *task,void *calldata) +{ +struct nfs_renamedata *data = calldata; +struct inode *old_dir = data->old_dir; +struct inode *new_dir = data->new_dir; + +if (!NFS_PROTO (old_dir)->rename_done (task, old_dir, new_dir)) { +nfs_restart_rpc (task,NFS_SERVER (old_dir)->nfs_client); +return ; + } + +if (task->tk_status !=0 ) +return ; + +nfs_set_verifier (data->old_dentry,nfs_save_change_attribute (old_dir)); +d_move (data->old_dentry, data->new_dentry); +} + +/** +* nfs_async_rename_release - Release the sillyrename data. +* @calldata: the struct nfs_renamedata to be released +*/ +static void nfs_async_rename_release (void *calldata) +{ +struct nfs_renamedata *data = calldata; +struct super_block *sb = data->old_dir->i_sb; + +/* FIXME: is this OK here? Note that call_done will be done first... */ +if (data->old_dentry->d_inode) +nfs_mark_for_revalidate (data->old_dentry->d_inode); + +nfs_free_fattr (data->res.old_fattr); +nfs_free_fattr (data->res.new_fattr); +dput (data->old_dentry); +dput (data->new_dentry); +iput (data->old_dir); +iput (data->new_dir); +nfs_sb_deactive (sb); +put_rpccred (data->cred); +kfree (data); +} + +#if defined(CONFIG_NFS_V4_1 ) +static void nfs_rename_prepare (struct rpc_task *task,void *calldata) +{ +struct nfs_renamedata *data = calldata; +struct nfs_server *server =NFS_SERVER (data->old_dir); + +if (nfs4_setup_sequence (server, &data->args.seq_args, + &data->res.seq_res,1 , task)) +return ; +rpc_call_start (task); +} +#endif /* CONFIG_NFS_V4_1 */ + +static const struct rpc_call_ops nfs_rename_ops = { + .rpc_call_done = nfs_async_rename_done, + .rpc_release = nfs_async_rename_release, +#if defined(CONFIG_NFS_V4_1) + .rpc_call_prepare = nfs_rename_prepare, +#endif /* CONFIG_NFS_V4_1 */ +}; + +/** +* nfs_async_rename - perform an asynchronous rename operation +* @old_dir: directory that currently holds the dentry to be renamed +* @new_dir: target directory for the rename +* @old_dentry: original dentry to be renamed +* @new_dentry: dentry to which the old_dentry should be renamed +*/ +static struct rpc_task * +nfs_async_rename (struct inode *old_dir,struct inode *new_dir, +struct dentry *old_dentry,struct dentry *new_dentry) +{ +int error; +struct nfs_renamedata *data; +struct rpc_message msg = { }; +struct rpc_task_setup task_setup_data = { + .rpc_message = &msg, + .callback_ops = &nfs_rename_ops, + .workqueue = nfsiod_workqueue, + .rpc_client =NFS_CLIENT (old_dir), + .flags =RPC_TASK_ASYNC , + }; +struct rpc_task *task; + + data =kzalloc (sizeof (*data),GFP_KERNEL ); +if (data ==NULL ) +return ERR_PTR (-ENOMEM ); + task_setup_data.callback_data = data, + + data->cred =rpc_lookup_cred (); +if (IS_ERR (data->cred)) { +kfree (data); +return (struct rpc_task *)data->cred; + } + msg.rpc_argp = &data->args, + msg.rpc_resp = &data->res, + msg.rpc_cred = data->cred; + +/* set up nfs_renamedata */ + data->old_dir = old_dir; +atomic_inc (&old_dir->i_count); + data->new_dir = new_dir; +atomic_inc (&new_dir->i_count); + data->old_dentry =dget (old_dentry); + data->new_dentry =dget (new_dentry); + +/* set up nfs_renameargs */ + data->args.old_dir =NFS_FH (old_dir); + data->args.old_name = &old_dentry->d_name; + data->args.new_dir =NFS_FH (new_dir); + data->args.new_name = &new_dentry->d_name; + +nfs_sb_active (old_dir->i_sb); + + error =NFS_PROTO (data->old_dir)->rename_setup (&msg, old_dir); +if (error) { +nfs_async_rename_release (data); +return ERR_PTR (error); + } + + task =rpc_run_task (&task_setup_data); +if (IS_ERR (task)) +nfs_async_rename_release (data); + +return task; +} +/** * nfs_sillyrename - Perform a silly-rename of a dentry * @dir: inode of directory that contains dentry
@@ -314,11 +472,11 @@ nfs_complete_unlink(struct dentry *dentry, struct inode *inode)* * NFSv2/3 is stateless, so the server doesn't know when the client is * holding a file open. To prevent problems when a file is unlinked while -* it's still open, we perform a "silly-rename" -- that is, we rename the -* file to a hidden file in the same directory, and only actually perform -* the unlink once the last reference to it is put. +* it's still open, the client performs a "silly-rename" -- that is, it +* renames the file to a hidden file in the same directory, and only +* performs the unlink once the last reference to it is put. * -* The final cleanup is done via nfs_dentry_iput. +* The final cleanup is done during dentry_iput. */ int nfs_sillyrename (struct inode *dir,struct dentry *dentry)
@@ -328,8 +486,8 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)const int countersize =sizeof (sillycounter)*2 ;const int slen =sizeof (".nfs" )+fileidsize+countersize-1 ;char silly[slen+1 ]; -struct qstr qsilly;struct dentry *sdentry; +struct rpc_task *task;int error = -EIO ; dfprintk(VFS, "NFS: silly-rename(%s/%s, ct=%d)\n",
@@ -371,17 +529,27 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry) goto out; }while (sdentry->d_inode !=NULL );/* need negative lookup */ - qsilly.name = silly; - qsilly.len =strlen (silly); - error =NFS_PROTO (dir)->rename (dir, &dentry->d_name, dir, &qsilly); -if (dentry->d_inode) -nfs_mark_for_revalidate (dentry->d_inode); -if (!error) { -nfs_set_verifier (dentry,nfs_save_change_attribute (dir)); -d_move (dentry, sdentry); - error =nfs_async_unlink (dir, dentry); -/* If we return 0 we don't unlink */ +/* queue unlink first. Can't do this from rpc_release as it +* has to allocate memory +*/ + error =nfs_async_unlink (dir, dentry); +if (error) + goto out_dput; + +/* run the rename task, undo unlink if it fails */ + task =nfs_async_rename (dir, dir, dentry, sdentry); +if (IS_ERR (task)) { + error = -EBUSY ; +nfs_cancel_async_unlink (dentry); + goto out_dput; } + +/* wait for the RPC task to complete, unless a SIGKILL intervenes */ + error =rpc_wait_for_completion_task (task); +if (error ==0 ) + error = task->tk_status; +rpc_put_task (task); +out_dput:dput (sdentry); out:return error;
Signature · 1 line
1.7.1
Re: [PATCH 8/8] nfs: make sillyrename an async operation
Quoted 25 lines · On Wed, 15 Sep 2010 09:24:01 -0400 Jeff Layton <[email protected]> wrote:
fs/nfs/unlink.c +25
-0+/** +* nfs_async_rename - perform an asynchronous rename operation +* @old_dir: directory that currently holds the dentry to be renamed +* @new_dir: target directory for the rename +* @old_dentry: original dentry to be renamed +* @new_dentry: dentry to which the old_dentry should be renamed +*/ +static struct rpc_task * +nfs_async_rename (struct inode *old_dir,struct inode *new_dir, +struct dentry *old_dentry,struct dentry *new_dentry) +{ +int error; +struct nfs_renamedata *data; +struct rpc_message msg = { }; +struct rpc_task_setup task_setup_data = { + .rpc_message = &msg, + .callback_ops = &nfs_rename_ops, + .workqueue = nfsiod_workqueue, + .rpc_client =NFS_CLIENT (old_dir), + .flags =RPC_TASK_ASYNC , + }; +struct rpc_task *task; + + data =kzalloc (sizeof (*data),GFP_KERNEL ); +if (data ==NULL )
fs/nfs/unlink.c nfs_complete_unlink(struct dentry *dentry, struct inode *inode) · line 436
Quoted 10 lines
fs/nfs/unlink.c +10
-0+return ERR_PTR (-ENOMEM ); + task_setup_data.callback_data = data, + + data->cred =rpc_lookup_cred (); +if (IS_ERR (data->cred)) { +kfree (data); +return (struct rpc_task *)data->cred; + } + msg.rpc_argp = &data->args, + msg.rpc_resp = &data->res,
^^^
Eek! Just noticed the commas at the EOL in this patch. Not quite sure how this compiled, but I'll fix, retest and resend. Review of the rest of the patch would be appreciated though.
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH 8/8] nfs: make sillyrename an async operation
Quoted 39 lines · On Wed, 15 Sep 2010 09:37:21 -0400 Jeff Layton <[email protected]> wrote:
Quoted 25 lines · On Wed, 15 Sep 2010 09:24:01 -0400 Jeff Layton <[email protected]> wrote:
fs/nfs/unlink.c +25
-0+/** +* nfs_async_rename - perform an asynchronous rename operation +* @old_dir: directory that currently holds the dentry to be renamed +* @new_dir: target directory for the rename +* @old_dentry: original dentry to be renamed +* @new_dentry: dentry to which the old_dentry should be renamed +*/ +static struct rpc_task * +nfs_async_rename (struct inode *old_dir,struct inode *new_dir, +struct dentry *old_dentry,struct dentry *new_dentry) +{ +int error; +struct nfs_renamedata *data; +struct rpc_message msg = { }; +struct rpc_task_setup task_setup_data = { + .rpc_message = &msg, + .callback_ops = &nfs_rename_ops, + .workqueue = nfsiod_workqueue, + .rpc_client =NFS_CLIENT (old_dir), + .flags =RPC_TASK_ASYNC , + }; +struct rpc_task *task; + + data =kzalloc (sizeof (*data),GFP_KERNEL ); +if (data ==NULL )fs/nfs/unlink.c nfs_complete_unlink(struct dentry *dentry, struct inode *inode) · line 436
Quoted 10 lines
fs/nfs/unlink.c +10
-0+return ERR_PTR (-ENOMEM ); + task_setup_data.callback_data = data, + + data->cred =rpc_lookup_cred (); +if (IS_ERR (data->cred)) { +kfree (data); +return (struct rpc_task *)data->cred; + } + msg.rpc_argp = &data->args, + msg.rpc_resp = &data->res,^^^
Quoted 4 lines
Eek! Just noticed the commas at the EOL in this patch. Not quite sure how this compiled, but I'll fix, retest and resend. Review of the rest of the patch would be appreciated though.
Ahh, false alarm. It's legit if a little weird:
http://en.wikipedia.org/wiki/Comma_operator
Regardless, I've done some other cleanups too so I'll resend the set after I retest it.
Sorry for the noise...
Signature · 1 line
Jeff Layton <[email protected]>