diff options
author | J. Bruce Fields <bfields@redhat.com> | 2014-01-24 18:04:40 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-01-27 13:59:16 -0500 |
commit | 4335723e8e9fdc6e4bb2555696bc7f1abe75f200 (patch) | |
tree | 047598958f44c9865039f19b8f3d4abfc4b99065 /fs/nfsd/nfs4proc.c | |
parent | c0e6bee480591a78caad5b13bd377948c025d0cd (diff) | |
download | linux-4335723e8e9fdc6e4bb2555696bc7f1abe75f200.tar.bz2 |
nfsd4: fix delegation-unlink/rename race
If a file is unlinked or renamed between the time when we do the local
open and the time when we get the delegation, then we will return to the
client indicating that it holds a delegation even though the file no
longer exists under the name it was open under.
But a client performing an open-by-name, when it is returned a
delegation, must be able to assume that the file is still linked at the
name it was opened under.
So, hold the parent i_mutex for longer to prevent concurrent renames or
unlinks.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4proc.c')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 844813a7e12a..ef76ba632387 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -279,11 +279,15 @@ do_open_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, stru if (open->op_createmode == NFS4_CREATE_EXCLUSIVE && status == 0) open->op_bmval[1] = (FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_MODIFY); - } else { + } else + /* + * Note this may exit with the parent still locked. + * We will hold the lock until nfsd4_open's final + * lookup, to prevent renames or unlinks until we've had + * a chance to an acquire a delegation if appropriate. + */ status = nfsd_lookup(rqstp, current_fh, open->op_fname.data, open->op_fname.len, *resfh); - fh_unlock(current_fh); - } if (status) goto out; status = nfsd_check_obj_isreg(*resfh); |