diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 0e1554fa98bb..7620bcc47272 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95 - * $Id: nfs_vnops.c,v 1.118 1999/01/27 22:45:13 dillon Exp $ + * $Id: nfs_vnops.c,v 1.119 1999/01/27 22:45:49 dillon Exp $ */ @@ -1566,6 +1566,19 @@ nfs_rename(ap) goto out; } + /* + * We have to flush B_DELWRI data prior to renaming + * the file. If we don't, the delayed-write buffers + * can be flushed out later after the file has gone stale + * under NFSV3. NFSV2 does not have this problem because + * ( as far as I can tell ) it flushes dirty buffers more + * often. + */ + + VOP_FSYNC(fvp, fcnp->cn_cred, MNT_WAIT, fcnp->cn_proc); + if (tvp) + VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_proc); + /* * If the tvp exists and is in use, sillyrename it before doing the * rename of the new file over it. diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index 0e1554fa98bb..7620bcc47272 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95 - * $Id: nfs_vnops.c,v 1.118 1999/01/27 22:45:13 dillon Exp $ + * $Id: nfs_vnops.c,v 1.119 1999/01/27 22:45:49 dillon Exp $ */ @@ -1566,6 +1566,19 @@ nfs_rename(ap) goto out; } + /* + * We have to flush B_DELWRI data prior to renaming + * the file. If we don't, the delayed-write buffers + * can be flushed out later after the file has gone stale + * under NFSV3. NFSV2 does not have this problem because + * ( as far as I can tell ) it flushes dirty buffers more + * often. + */ + + VOP_FSYNC(fvp, fcnp->cn_cred, MNT_WAIT, fcnp->cn_proc); + if (tvp) + VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_proc); + /* * If the tvp exists and is in use, sillyrename it before doing the * rename of the new file over it.