diff options
author | ps <ps@FreeBSD.org> | 2004-12-10 03:29:02 +0000 |
---|---|---|
committer | ps <ps@FreeBSD.org> | 2004-12-10 03:29:02 +0000 |
commit | b4a200824aca72378670e1eb21f493a8d24eda39 (patch) | |
tree | 889b6f766f0fc74262c9b197f639baf29977cb0c | |
parent | f46c52047f3fcd319847f2c25bb66800bb5d6b2d (diff) | |
download | FreeBSD-src-b4a200824aca72378670e1eb21f493a8d24eda39.zip FreeBSD-src-b4a200824aca72378670e1eb21f493a8d24eda39.tar.gz |
In nfs_rename(), skip the otw rename operation if the fsync (to
either src or dst) fails. This closes a potential data loss case
(where the fsync failed with ENOSPC, for example).
Submitted by: Mohan Srinivasan mohans at yahoo-inc dot com
Obtained from: Yahoo!
-rw-r--r-- | sys/nfsclient/nfs_vnops.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index d7f9330..cbe5fd8 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -1540,11 +1540,18 @@ nfs_rename(struct vop_rename_args *ap) * under NFSV3. NFSV2 does not have this problem because * ( as far as I can tell ) it flushes dirty buffers more * often. + * + * Skip the rename operation if the fsync fails, this can happen + * due to the server's volume being full, when we pushed out data + * that was written back to our cache earlier. Not checking for + * this condition can result in potential (silent) data loss. */ - VOP_FSYNC(fvp, fcnp->cn_cred, MNT_WAIT, fcnp->cn_thread); + error = VOP_FSYNC(fvp, fcnp->cn_cred, MNT_WAIT, fcnp->cn_thread); VOP_UNLOCK(fvp, 0, fcnp->cn_thread); - if (tvp) - VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_thread); + if (!error && tvp) + error = VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_thread); + if (error) + goto out; /* * If the tvp exists and is in use, sillyrename it before doing the |