Commit 0f3a24b4 authored by Trond Myklebust's avatar Trond Myklebust Committed by J. Bruce Fields

nfsd: Ensure that nfsd_create_setattr commits files to stable storage

Since nfsd_create_setattr strips the mode from the struct iattr, it
is quite possible that it will optimise away the call to nfsd_setattr
altogether.
If this is the case, then we never call commit_metadata() on the
newly created file.

Also ensure that both nfsd_setattr() and nfsd_create_setattr() fail
when the call to commit_metadata fails.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 1e444f5b
...@@ -463,7 +463,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, ...@@ -463,7 +463,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
if (size_change) if (size_change)
put_write_access(inode); put_write_access(inode);
if (!err) if (!err)
commit_metadata(fhp); err = commit_metadata(fhp);
out: out:
return err; return err;
} }
...@@ -1121,7 +1121,8 @@ nfsd_create_setattr(struct svc_rqst *rqstp, struct svc_fh *resfhp, ...@@ -1121,7 +1121,8 @@ nfsd_create_setattr(struct svc_rqst *rqstp, struct svc_fh *resfhp,
iap->ia_valid &= ~(ATTR_UID|ATTR_GID); iap->ia_valid &= ~(ATTR_UID|ATTR_GID);
if (iap->ia_valid) if (iap->ia_valid)
return nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0); return nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
return 0; /* Callers expect file metadata to be committed here */
return commit_metadata(resfhp);
} }
/* HPUX client sometimes creates a file in mode 000, and sets size to 0. /* HPUX client sometimes creates a file in mode 000, and sets size to 0.
...@@ -1253,9 +1254,10 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1253,9 +1254,10 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
err = nfsd_create_setattr(rqstp, resfhp, iap); err = nfsd_create_setattr(rqstp, resfhp, iap);
/* /*
* nfsd_setattr already committed the child. Transactional filesystems * nfsd_create_setattr already committed the child. Transactional
* had a chance to commit changes for both parent and child * filesystems had a chance to commit changes for both parent and
* simultaneously making the following commit_metadata a noop. * child * simultaneously making the following commit_metadata a
* noop.
*/ */
err2 = nfserrno(commit_metadata(fhp)); err2 = nfserrno(commit_metadata(fhp));
if (err2) if (err2)
...@@ -1426,7 +1428,8 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1426,7 +1428,8 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
err = nfsd_create_setattr(rqstp, resfhp, iap); err = nfsd_create_setattr(rqstp, resfhp, iap);
/* /*
* nfsd_setattr already committed the child (and possibly also the parent). * nfsd_create_setattr already committed the child
* (and possibly also the parent).
*/ */
if (!err) if (!err)
err = nfserrno(commit_metadata(fhp)); err = nfserrno(commit_metadata(fhp));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment