From 41bc38d1321bcf7591ac1059cf4f4d7b996bf123 Mon Sep 17 00:00:00 2001 From: Paul Saab Date: Fri, 10 Dec 2004 03:29:02 +0000 Subject: [PATCH] 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! --- sys/nfsclient/nfs_vnops.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index d7f9330da98c..cbe5fd8264bc 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