nfs: ensure that sillyrenames run to completion (try #3)
Subsystems (2)
cover nfs: ensure that sillyrenames run to completion (try #3)
Hi Trond,
A few changes to this set since I sent the last one. Notably:
- I merged some of the patches to ensure that we're not adding interfaces that are unused in a particular patch and to minimize "churn" by multiple patches changing the same code
- The fattr structs are allocated now as part of the nfs_renamedata. That eliminates the need to dynamically allocate them and allows rename_setup to be a void return function
- nfs_cancel_async_unlink now drops the d_lock before calling nfs_free_unlinkdata
Also, some other less notable bugs were fixed. I'd like to see this in 2.6.37 if possible.
Original intro email follows:
--------------------------------[snip]--------------------------------
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.
Jeff Layton (4):
nfs: standardize the rename args container
nfs: standardize the rename response container
nfs: move nfs_sillyrename to unlink.c
nfs: make sillyrename an async operation
fs/nfs/dir.c | 70 ------------- fs/nfs/nfs2xdr.c | 8 +- fs/nfs/nfs3proc.c | 51 +++++++--- fs/nfs/nfs3xdr.c | 16 ++-- fs/nfs/nfs4proc.c | 34 ++++++- fs/nfs/nfs4xdr.c | 4 +- fs/nfs/proc.c | 29 ++++- fs/nfs/unlink.c | 263 ++++++++++++++++++++++++++++++++++++++++++++++- include/linux/nfs_fs.h | 2 +- include/linux/nfs_xdr.h | 64 ++++-------- 10 files changed, 391 insertions(+), 150 deletions(-)
PATCH 1/4 nfs: standardize the rename args container
Each NFS version has its own version of the rename args container. Standardize them on a common one that's identical to the one NFSv4 uses.
--- fs/nfs/nfs2xdr.c | 8 ++++---- fs/nfs/nfs3proc.c | 12 +++++------- fs/nfs/nfs3xdr.c | 10 +++++----- fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4xdr.c | 2 +- fs/nfs/proc.c | 10 ++++------ include/linux/nfs_xdr.h | 39 ++++++++++++--------------------------- 7 files changed, 32 insertions(+), 51 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 +5 -7
@@ -442,13 +442,11 @@ 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 = { - .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 + struct nfs_renameargs arg = { + .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 +5 -5
@@ -442,12 +442,12 @@ 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); - 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/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 = {
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 +12 -27
@@ -400,6 +400,18 @@ 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 u32 *bitmask; +struct nfs4_sequence_args seq_args; +}; + +/* * 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;
@@ -801,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
PATCH 2/4 nfs: standardize the rename response container
In reply to Jeff LaytonRight now, v3 and v4 have their own variants. Create a standard struct that will work for v3 and v4. v2 doesn't get anything but a simple error and so isn't affected by this.
--- 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
PATCH 3/4 nfs: move nfs_sillyrename to unlink.c
In reply to Jeff Layton...since that's where most of the sillyrenaming code lives. A comment block is added to the beginning as well to clarify how sillyrenaming works. 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 4/4 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/nfs3proc.c | 23 ++++++ fs/nfs/nfs4proc.c | 30 +++++++ fs/nfs/proc.c | 19 +++++ fs/nfs/unlink.c | 200 ++++++++++++++++++++++++++++++++++++++++++++--- include/linux/nfs_xdr.h | 2 + 5 files changed, 263 insertions(+), 11 deletions(-)
fs/nfs/nfs3proc.c +23 -0
@@ -438,6 +438,27 @@ nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir)return 1 ; } +static void +nfs3_proc_rename_setup (struct rpc_message *msg,struct inode *dir) +{ + msg->rpc_proc = &nfs3_procedures[NFS3PROC_RENAME ]; +} + +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)
@@ -842,6 +863,8 @@ 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, + .rename_done = nfs3_proc_rename_done, .link = nfs3_proc_link, .symlink = nfs3_proc_symlink, .mkdir = nfs3_proc_mkdir,
fs/nfs/nfs4proc.c +30 -0
@@ -2671,6 +2671,34 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir)return 1 ; } +static void 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; +} + +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) {
@@ -5443,6 +5471,8 @@ 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, + .rename_done = nfs4_proc_rename_done, .link = nfs4_proc_link, .symlink = nfs4_proc_symlink, .mkdir = nfs4_proc_mkdir,
fs/nfs/proc.c +19 -0
@@ -365,6 +365,23 @@ static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir)return 1 ; } +static void +nfs_proc_rename_setup (struct rpc_message *msg,struct inode *dir) +{ + msg->rpc_proc = &nfs_procedures[NFSPROC_RENAME ]; +} + +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)
@@ -703,6 +720,8 @@ 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, + .rename_done = nfs_proc_rename_done, .link = nfs_proc_link, .symlink = nfs_proc_symlink, .mkdir = nfs_proc_mkdir,
fs/nfs/unlink.c +189 -11
220 lines not on this page · raw message
include/linux/nfs_xdr.h +2 -0
@@ -1018,6 +1018,8 @@ struct nfs_rpc_ops {int (*unlink_done) (struct rpc_task *,struct inode *);int (*rename) (struct inode *,struct qstr *,struct inode *,struct qstr *); +void (*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
Quoted 57 lines · Jeff Layton
Hi Trond,
A few changes to this set since I sent the last one. Notably:
- I merged some of the patches to ensure that we're not adding interfaces that are unused in a particular patch and to minimize "churn" by multiple patches changing the same code
- The fattr structs are allocated now as part of the
nfs_renamedata. That eliminates the need to dynamically allocate them and allowsrename_setupto be a void return function-
nfs_cancel_async_unlinknow drops thed_lockbefore callingnfs_free_unlinkdataAlso, some other less notable bugs were fixed. I'd like to see this in 2.6.37 if possible.
Original intro email follows:
--------------------------------[snip]--------------------------------
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_sillyrenameuse an asynchronous rename call and simply wait for the call to complete inTASK_KILLABLEsleep 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_sillyrenamecall is then moved tounlink.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.
Jeff Layton (4):
nfs: standardize the rename args container
nfs: standardize the rename response container
nfs: movenfs_sillyrenametounlink.c
nfs: make sillyrename an async operation
Quoted 12 lines
fs/nfs/dir.c | 70 ------------- fs/nfs/nfs2xdr.c | 8 +- fs/nfs/nfs3proc.c | 51 +++++++--- fs/nfs/nfs3xdr.c | 16 ++-- fs/nfs/nfs4proc.c | 34 ++++++- fs/nfs/nfs4xdr.c | 4 +- fs/nfs/proc.c | 29 ++++- fs/nfs/unlink.c | 263 ++++++++++++++++++++++++++++++++++++++++++++++- include/linux/nfs_fs.h | 2 +- include/linux/nfs_xdr.h | 64 ++++-------- 10 files changed, 391 insertions(+), 150 deletions(-)
Thanks! I've queued this up in the nfs-for-2.6.37 branch.
Cheers
Trond