Source-Changes-HG archive

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

[src/trunk]: src/sys ext2fs, ffs: free on disk inodes in the reclaim routine.



details:   https://anonhg.NetBSD.org/src/rev/bf8390cb2ac0
branches:  trunk
changeset: 756672:bf8390cb2ac0
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed Jul 28 11:03:47 2010 +0000

description:
ext2fs,ffs: free on disk inodes in the reclaim routine.
Remove now unneeded vnode flag VI_FREEING.

Welcome to 5.99.38.

Ok: Andrew Doran <ad%netbsd.org@localhost>

diffstat:

 sys/kern/vfs_subr.c           |  14 +++++++-------
 sys/sys/param.h               |   4 ++--
 sys/sys/vnode.h               |   5 ++---
 sys/ufs/ext2fs/ext2fs_inode.c |   9 +++------
 sys/ufs/ext2fs/ext2fs_vnops.c |  11 +++++++++--
 sys/ufs/ffs/ffs_vnops.c       |  17 +++++++++++++++--
 sys/ufs/ufs/inode.h           |   3 ++-
 sys/ufs/ufs/ufs_inode.c       |  12 ++++++------
 8 files changed, 46 insertions(+), 29 deletions(-)

diffs (250 lines):

diff -r bdf735cefae5 -r bf8390cb2ac0 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Wed Jul 28 09:32:13 2010 +0000
+++ b/sys/kern/vfs_subr.c       Wed Jul 28 11:03:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_subr.c,v 1.412 2010/07/26 15:22:16 hannken Exp $   */
+/*     $NetBSD: vfs_subr.c,v 1.413 2010/07/28 11:03:47 hannken Exp $   */
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.412 2010/07/26 15:22:16 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.413 2010/07/28 11:03:47 hannken Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -1252,7 +1252,7 @@
         * for vclean() by adding another reference without waiting.
         * This is not strictly necessary, but we'll do it anyway.
         */
-       if (__predict_false((vp->v_iflag & (VI_XLOCK | VI_FREEING)) != 0)) {
+       if (__predict_false((vp->v_iflag & VI_XLOCK) != 0)) {
                return false;
        }
        for (use = vp->v_usecount;; use = next) {
@@ -1300,14 +1300,14 @@
         * If the vnode is in the process of being cleaned out for
         * another use, we wait for the cleaning to finish and then
         * return failure.  Cleaning is determined by checking if
-        * the VI_XLOCK or VI_FREEING flags are set.
+        * the VI_XLOCK flag is set.
         */
-       if ((vp->v_iflag & (VI_XLOCK | VI_FREEING)) != 0) {
+       if ((vp->v_iflag & VI_XLOCK) != 0) {
                if ((flags & LK_NOWAIT) != 0) {
                        vrelel(vp, 0);
                        return EBUSY;
                }
-               vwait(vp, VI_XLOCK | VI_FREEING);
+               vwait(vp, VI_XLOCK);
                vrelel(vp, 0);
                return ENOENT;
        }
@@ -1944,7 +1944,7 @@
        vp->v_op = dead_vnodeop_p;
        vp->v_tag = VT_NON;
        KNOTE(&vp->v_klist, NOTE_REVOKE);
-       vp->v_iflag &= ~(VI_XLOCK | VI_FREEING);
+       vp->v_iflag &= ~VI_XLOCK;
        vp->v_vflag &= ~VV_LOCKSWORK;
        if ((flags & DOCLOSE) != 0) {
                vp->v_iflag |= VI_CLEAN;
diff -r bdf735cefae5 -r bf8390cb2ac0 sys/sys/param.h
--- a/sys/sys/param.h   Wed Jul 28 09:32:13 2010 +0000
+++ b/sys/sys/param.h   Wed Jul 28 11:03:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: param.h,v 1.372 2010/07/21 09:06:37 hannken Exp $      */
+/*     $NetBSD: param.h,v 1.373 2010/07/28 11:03:47 hannken Exp $      */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -63,7 +63,7 @@
  *     2.99.9          (299000900)
  */
 
-#define        __NetBSD_Version__      599003700       /* NetBSD 5.99.37 */
+#define        __NetBSD_Version__      599003800       /* NetBSD 5.99.38 */
 
 #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
     (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
diff -r bdf735cefae5 -r bf8390cb2ac0 sys/sys/vnode.h
--- a/sys/sys/vnode.h   Wed Jul 28 09:32:13 2010 +0000
+++ b/sys/sys/vnode.h   Wed Jul 28 11:03:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vnode.h,v 1.222 2010/07/28 09:31:00 hannken Exp $      */
+/*     $NetBSD: vnode.h,v 1.223 2010/07/28 11:03:47 hannken Exp $      */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -211,7 +211,6 @@
 #define        VI_CLEAN        0x00080000      /* has been reclaimed */
 #define        VI_INACTPEND    0x00100000      /* inactivation is pending */
 #define        VI_INACTREDO    0x00200000      /* need to redo VOP_INACTIVE() */
-#define        VI_FREEING      0x00400000      /* vnode is being freed */
 #define        VI_INACTNOW     0x00800000      /* VOP_INACTIVE() in progress */
 
 /*
@@ -222,7 +221,7 @@
 #define        VNODE_FLAGBITS \
     "\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \
     "\13WRMAP\14WRMAPDIRTY\15XLOCK\17ONWORKLST\20MARKER" \
-    "\22LAYER\24CLEAN\25INACTPEND\26INACTREDO\27FREEING" \
+    "\22LAYER\24CLEAN\25INACTPEND\26INACTREDO" \
     "\30INACTNOW\31DIROP" 
 
 #define        VSIZENOTSET     ((voff_t)-1)
diff -r bdf735cefae5 -r bf8390cb2ac0 sys/ufs/ext2fs/ext2fs_inode.c
--- a/sys/ufs/ext2fs/ext2fs_inode.c     Wed Jul 28 09:32:13 2010 +0000
+++ b/sys/ufs/ext2fs/ext2fs_inode.c     Wed Jul 28 11:03:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ext2fs_inode.c,v 1.72 2010/06/24 13:03:18 hannken Exp $        */
+/*     $NetBSD: ext2fs_inode.c,v 1.73 2010/07/28 11:03:48 hannken Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.72 2010/06/24 13:03:18 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.73 2010/07/28 11:03:48 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -156,10 +156,7 @@
                }
                ip->i_e2fs_dtime = time_second;
                ip->i_flag |= IN_CHANGE | IN_UPDATE;
-               mutex_enter(&vp->v_interlock);
-               vp->v_iflag |= VI_FREEING;
-               mutex_exit(&vp->v_interlock);
-               ext2fs_vfree(vp, ip->i_number, ip->i_e2fs_mode);
+               ip->i_omode = 1;
        }
        if (ip->i_flag & (IN_CHANGE | IN_UPDATE | IN_MODIFIED)) {
                ext2fs_update(vp, NULL, NULL, 0);
diff -r bdf735cefae5 -r bf8390cb2ac0 sys/ufs/ext2fs/ext2fs_vnops.c
--- a/sys/ufs/ext2fs/ext2fs_vnops.c     Wed Jul 28 09:32:13 2010 +0000
+++ b/sys/ufs/ext2fs/ext2fs_vnops.c     Wed Jul 28 11:03:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ext2fs_vnops.c,v 1.93 2010/06/24 13:03:18 hannken Exp $        */
+/*     $NetBSD: ext2fs_vnops.c,v 1.94 2010/07/28 11:03:48 hannken Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.93 2010/06/24 13:03:18 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.94 2010/07/28 11:03:48 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1502,6 +1502,13 @@
        struct inode *ip = VTOI(vp);
        int error;
 
+       /*
+        * The inode must be freed and updated before being removed
+        * from its hash chain.  Other threads trying to gain a hold
+        * on the inode will be stalled because it is locked (VI_XLOCK).
+        */
+       if (ip->i_omode == 1 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
+               ext2fs_vfree(vp, ip->i_number, ip->i_e2fs_mode);
        if ((error = ufs_reclaim(vp)) != 0)
                return (error);
        if (ip->i_din.e2fs_din != NULL)
diff -r bdf735cefae5 -r bf8390cb2ac0 sys/ufs/ffs/ffs_vnops.c
--- a/sys/ufs/ffs/ffs_vnops.c   Wed Jul 28 09:32:13 2010 +0000
+++ b/sys/ufs/ffs/ffs_vnops.c   Wed Jul 28 11:03:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_vnops.c,v 1.114 2010/03/29 13:11:33 pooka Exp $    */
+/*     $NetBSD: ffs_vnops.c,v 1.115 2010/07/28 11:03:48 hannken Exp $  */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.114 2010/03/29 13:11:33 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.115 2010/07/28 11:03:48 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -584,6 +584,19 @@
        int error;
 
        fstrans_start(mp, FSTRANS_LAZY);
+       /*
+        * The inode must be freed and updated before being removed
+        * from its hash chain.  Other threads trying to gain a hold
+        * on the inode will be stalled because it is locked (VI_XLOCK).
+        */
+       error = UFS_WAPBL_BEGIN(mp);
+       if (error) {
+               fstrans_done(mp);
+               return error;
+       }
+       if (ip->i_nlink <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
+               ffs_vfree(vp, ip->i_number, ip->i_omode);
+       UFS_WAPBL_END(mp);
        if ((error = ufs_reclaim(vp)) != 0) {
                fstrans_done(mp);
                return (error);
diff -r bdf735cefae5 -r bf8390cb2ac0 sys/ufs/ufs/inode.h
--- a/sys/ufs/ufs/inode.h       Wed Jul 28 09:32:13 2010 +0000
+++ b/sys/ufs/ufs/inode.h       Wed Jul 28 11:03:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inode.h,v 1.56 2009/02/22 20:28:07 ad Exp $    */
+/*     $NetBSD: inode.h,v 1.57 2010/07/28 11:03:48 hannken Exp $       */
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -133,6 +133,7 @@
        int32_t   i_gen;        /* Generation number. */
        u_int32_t i_uid;        /* File owner. */
        u_int32_t i_gid;        /* File group. */
+       u_int16_t i_omode;      /* Old mode, for ufs_reclaim. */
 
        struct dirhash *i_dirhash;      /* Hashing for large directories */
 
diff -r bdf735cefae5 -r bf8390cb2ac0 sys/ufs/ufs/ufs_inode.c
--- a/sys/ufs/ufs/ufs_inode.c   Wed Jul 28 09:32:13 2010 +0000
+++ b/sys/ufs/ufs/ufs_inode.c   Wed Jul 28 11:03:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_inode.c,v 1.81 2010/06/24 13:03:20 hannken Exp $   */
+/*     $NetBSD: ufs_inode.c,v 1.82 2010/07/28 11:03:48 hannken Exp $   */
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.81 2010/06/24 13:03:20 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.82 2010/07/28 11:03:48 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -143,12 +143,12 @@
                DIP_ASSIGN(ip, rdev, 0);
                mode = ip->i_mode;
                ip->i_mode = 0;
+               ip->i_omode = mode;
                DIP_ASSIGN(ip, mode, 0);
                ip->i_flag |= IN_CHANGE | IN_UPDATE;
-               mutex_enter(&vp->v_interlock);
-               vp->v_iflag |= VI_FREEING;
-               mutex_exit(&vp->v_interlock);
-               UFS_VFREE(vp, ip->i_number, mode);
+               /*
+                * Defer final inode free and update to ufs_reclaim().
+                */
        }
 
        if (ip->i_flag & (IN_CHANGE | IN_UPDATE | IN_MODIFIED)) {



Home | Main Index | Thread Index | Old Index