Source-Changes-HG archive

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

[src/trunk]: src/sys Move fstrans_start()/fstrans_done() into genfs_insane_re...



details:   https://anonhg.NetBSD.org/src/rev/957ae9100591
branches:  trunk
changeset: 793337:957ae9100591
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Feb 06 10:57:12 2014 +0000

description:
Move fstrans_start()/fstrans_done() into genfs_insane_rename() to protect
the complete rename operation like we do for all other vnode operations.

diffstat:

 sys/miscfs/genfs/genfs_rename.c |  10 ++++++++--
 sys/ufs/lfs/lfs_rename.c        |  10 ++--------
 sys/ufs/ufs/ufs_rename.c        |  10 +++-------
 3 files changed, 13 insertions(+), 17 deletions(-)

diffs (167 lines):

diff -r 904a4e616152 -r 957ae9100591 sys/miscfs/genfs/genfs_rename.c
--- a/sys/miscfs/genfs/genfs_rename.c   Thu Feb 06 07:36:36 2014 +0000
+++ b/sys/miscfs/genfs/genfs_rename.c   Thu Feb 06 10:57:12 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfs_rename.c,v 1.1 2012/05/08 23:53:26 riastradh Exp $       */
+/*     $NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.1 2012/05/08 23:53:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kauth.h>
@@ -45,6 +45,7 @@
 #include <sys/namei.h>
 #include <sys/stat.h>
 #include <sys/vnode.h>
+#include <sys/fstrans.h>
 #include <sys/types.h>
 
 #include <miscfs/genfs/genfs.h>
@@ -176,6 +177,7 @@
        struct componentname *fcnp = ap->a_fcnp;
        struct vnode *tdvp = ap->a_tdvp;
        struct vnode *tvp = ap->a_tvp;
+       struct mount *mp = fdvp->v_mount;
        struct componentname *tcnp = ap->a_tcnp;
        kauth_cred_t cred;
        int error;
@@ -194,6 +196,8 @@
        KASSERT(fdvp->v_type == VDIR);
        KASSERT(tdvp->v_type == VDIR);
 
+       fstrans_start(mp, FSTRANS_SHARED);
+
        cred = fcnp->cn_cred;
 
        /*
@@ -228,6 +232,8 @@
        vrele(fdvp);
        vrele(tdvp);
 
+       fstrans_done(mp);
+
        return error;
 }
 
diff -r 904a4e616152 -r 957ae9100591 sys/ufs/lfs/lfs_rename.c
--- a/sys/ufs/lfs/lfs_rename.c  Thu Feb 06 07:36:36 2014 +0000
+++ b/sys/ufs/lfs/lfs_rename.c  Thu Feb 06 10:57:12 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_rename.c,v 1.5 2014/01/28 13:12:22 martin Exp $    */
+/*     $NetBSD: lfs_rename.c,v 1.6 2014/02/06 10:57:12 hannken Exp $   */
 /*  from NetBSD: ufs_rename.c,v 1.6 2013/01/22 09:39:18 dholland Exp  */
 
 /*-
@@ -89,7 +89,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.5 2014/01/28 13:12:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.6 2014/02/06 10:57:12 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -108,7 +108,6 @@
 #include <sys/signalvar.h>
 #include <sys/kauth.h>
 #include <sys/syslog.h>
-#include <sys/fstrans.h>
 
 #include <uvm/uvm.h>
 #include <uvm/uvm_pmap.h>
@@ -518,8 +517,6 @@
        KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
        KASSERT(cnp->cn_nameiop == DELETE);
 
-       fstrans_start(mp, FSTRANS_SHARED);
-
        /* XXX ulfs_dirremove decrements vp's link count for us.  */
        error = ulfs_dirremove(dvp, ulr, VTOI(vp), cnp->cn_flags, 0);
        if (error)
@@ -529,7 +526,6 @@
        VN_KNOTE(vp, (VTOI(vp)->i_nlink? NOTE_LINK : NOTE_DELETE));
 
 out1:
-       fstrans_done(mp);
        return error;
 }
 
@@ -831,7 +827,6 @@
         * Commence hacking of the data on disk.
         */
 
-       fstrans_start(mp, FSTRANS_SHARED);
        error = 0;
 
        /*
@@ -1046,7 +1041,6 @@
 
 arghmybrainhurts:
 /*ihateyou:*/
-       fstrans_done(mp);
        return error;
 }
 
diff -r 904a4e616152 -r 957ae9100591 sys/ufs/ufs/ufs_rename.c
--- a/sys/ufs/ufs/ufs_rename.c  Thu Feb 06 07:36:36 2014 +0000
+++ b/sys/ufs/ufs/ufs_rename.c  Thu Feb 06 10:57:12 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_rename.c,v 1.9 2013/11/04 19:58:02 christos Exp $  */
+/*     $NetBSD: ufs_rename.c,v 1.10 2014/02/06 10:57:12 hannken Exp $  */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,12 +34,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_rename.c,v 1.9 2013/11/04 19:58:02 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_rename.c,v 1.10 2014/02/06 10:57:12 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
 #include <sys/errno.h>
-#include <sys/fstrans.h>
 #include <sys/kauth.h>
 #include <sys/mount.h>
 #include <sys/namei.h>
@@ -334,7 +333,6 @@
         * Commence hacking of the data on disk.
         */
 
-       fstrans_start(mp, FSTRANS_SHARED);
        error = UFS_WAPBL_BEGIN(mp);
        if (error)
                goto ihateyou;
@@ -555,7 +553,6 @@
        UFS_WAPBL_END(mp);
 
 ihateyou:
-       fstrans_done(mp);
        return error;
 }
 
@@ -786,7 +783,6 @@
        KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
        KASSERT(cnp->cn_nameiop == DELETE);
 
-       fstrans_start(mp, FSTRANS_SHARED);
        error = UFS_WAPBL_BEGIN(mp);
        if (error)
                goto out0;
@@ -800,7 +796,7 @@
        VN_KNOTE(vp, (VTOI(vp)->i_nlink? NOTE_LINK : NOTE_DELETE));
 
 out1:  UFS_WAPBL_END(mp);
-out0:  fstrans_done(mp);
+out0:
        return error;
 }
 



Home | Main Index | Thread Index | Old Index