Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/ufs In ufs_mkdir(), write the data block *before* up...



details:   https://anonhg.NetBSD.org/src/rev/079db1627b94
branches:  trunk
changeset: 526952:079db1627b94
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Tue May 14 17:37:52 2002 +0000

description:
In ufs_mkdir(), write the data block *before* updating the inode with the
block pointer, to prevent "DIRECTORY CORRUPTED" errors from fsck(8).
Note: The behavior in the softdep case is unchanged, but needs to be fixed.

diffstat:

 sys/ufs/ufs/ufs_vnops.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (44 lines):

diff -r 7063daa6a44c -r 079db1627b94 sys/ufs/ufs/ufs_vnops.c
--- a/sys/ufs/ufs/ufs_vnops.c   Tue May 14 16:21:47 2002 +0000
+++ b/sys/ufs/ufs/ufs_vnops.c   Tue May 14 17:37:52 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_vnops.c,v 1.85 2001/12/23 16:16:59 fvdl Exp $      */
+/*     $NetBSD: ufs_vnops.c,v 1.86 2002/05/14 17:37:52 mycroft Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993, 1995
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.85 2001/12/23 16:16:59 fvdl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.86 2002/05/14 17:37:52 mycroft Exp $");
 
 #include "opt_quota.h"
 #include "fs_lfs.h"
@@ -1282,10 +1282,6 @@
                        blkoff += DIRBLKSIZ;
                }
        }
-       if ((error = VOP_UPDATE(tvp, NULL, NULL, UPDATE_DIROP)) != 0) {
-               (void)VOP_BWRITE(bp);
-               goto bad;
-       }
        /*
         * Directory set up, now install it's entry in the parent directory.
         *
@@ -1297,8 +1293,13 @@
         * an appropriate ordering dependency to the buffer which ensures that
         * the buffer is written before the new name is written in the parent.
         */
-       if (!DOINGSOFTDEP(dvp) && ((error = VOP_BWRITE(bp)) != 0))
+       if (!DOINGSOFTDEP(tvp) && ((error = VOP_BWRITE(bp)) != 0))
                goto bad;
+       if ((error = VOP_UPDATE(tvp, NULL, NULL, UPDATE_DIROP)) != 0) {
+               if (DOINGSOFTDEP(tvp))
+                       (void)VOP_BWRITE(bp);
+               goto bad;
+       }
        ufs_makedirentry(ip, cnp, &newdir);
        error = ufs_direnter(dvp, tvp, &newdir, cnp, bp);
  bad:



Home | Main Index | Thread Index | Old Index