Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/lfs Remove now redundant calls to fstrans_start()/fs...



details:   https://anonhg.NetBSD.org/src/rev/e86fb3ba929b
branches:  trunk
changeset: 352394:e86fb3ba929b
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Mar 30 09:10:08 2017 +0000

description:
Remove now redundant calls to fstrans_start()/fstrans_done().

Add fstrans_start()/fstrans_done() to lfs_putpages().

diffstat:

 sys/ufs/lfs/lfs_pages.c      |  53 ++++++++++++++++++++++++++++++++++++++-----
 sys/ufs/lfs/lfs_vnops.c      |  30 +-----------------------
 sys/ufs/lfs/ulfs_bmap.c      |   7 +----
 sys/ufs/lfs/ulfs_inode.c     |   9 +-----
 sys/ufs/lfs/ulfs_lookup.c    |   8 +----
 sys/ufs/lfs/ulfs_quota2.c    |   5 +--
 sys/ufs/lfs/ulfs_readwrite.c |  16 +-----------
 sys/ufs/lfs/ulfs_vnops.c     |  32 +++-----------------------
 8 files changed, 62 insertions(+), 98 deletions(-)

diffs (truncated from 739 to 300 lines):

diff -r 3c9552d5b31a -r e86fb3ba929b sys/ufs/lfs/lfs_pages.c
--- a/sys/ufs/lfs/lfs_pages.c   Thu Mar 30 09:09:26 2017 +0000
+++ b/sys/ufs/lfs/lfs_pages.c   Thu Mar 30 09:10:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_pages.c,v 1.9 2016/10/04 16:46:20 christos Exp $   */
+/*     $NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $   */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.9 2016/10/04 16:46:20 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -466,6 +466,7 @@
        bool seglocked, sync, pagedaemon, reclaim;
        struct vm_page *pg, *busypg;
        UVMHIST_FUNC("lfs_putpages"); UVMHIST_CALLED(ubchist);
+       struct mount *trans_mp;
        int oreclaim = 0;
        int donewriting = 0;
 #ifdef DEBUG
@@ -478,6 +479,7 @@
        sync = (ap->a_flags & PGO_SYNCIO) != 0;
        reclaim = (ap->a_flags & PGO_RECLAIM) != 0;
        pagedaemon = (curlwp == uvm.pagedaemon_lwp);
+       trans_mp = NULL;
 
        KASSERT(mutex_owned(vp->v_interlock));
 
@@ -487,6 +489,7 @@
                return 0;
        }
 
+retry:
        /*
         * If there are no pages, don't do anything.
         */
@@ -497,6 +500,8 @@
                        vp->v_iflag &= ~VI_WRMAPDIRTY;
                        vn_syncer_remove_from_worklist(vp);
                }
+               if (trans_mp)
+                       fstrans_done(trans_mp);
                mutex_exit(vp->v_interlock);
                
                /* Remove us from paging queue, if we were on it */
@@ -587,6 +592,33 @@
                return r;
        }
 
+       if (trans_mp /* && (ap->a_flags & PGO_CLEANIT) != 0 */) {
+               if (pagedaemon) {
+                       /* Pagedaemon must not sleep here. */
+                       trans_mp = vp->v_mount;
+                       error = fstrans_start_nowait(trans_mp, FSTRANS_SHARED);
+                       if (error) {
+                               mutex_exit(vp->v_interlock);
+                               return error;
+                       }
+               } else {
+                       /*
+                        * Cannot use vdeadcheck() here as this operation
+                        * usually gets used from VOP_RECLAIM().  Test for
+                        * change of v_mount instead and retry on change.
+                        */
+                       mutex_exit(vp->v_interlock);
+                       trans_mp = vp->v_mount;
+                       fstrans_start(trans_mp, FSTRANS_SHARED);
+                       if (vp->v_mount != trans_mp) {
+                               fstrans_done(trans_mp);
+                               trans_mp = NULL;
+                       }
+               }
+               mutex_enter(vp->v_interlock);
+               goto retry;
+       }
+
        /* Set PGO_BUSYFAIL to avoid deadlocks */
        ap->a_flags |= PGO_BUSYFAIL;
 
@@ -607,7 +639,8 @@
                if (r < 0) {
                        /* Pages are busy with another process */
                        mutex_exit(vp->v_interlock);
-                       return EDEADLK;
+                       error = EDEADLK;
+                       goto out;
                }
                if (r > 0) /* Some pages are dirty */
                        break;
@@ -624,7 +657,8 @@
                ip->i_lfs_iflags &= ~LFSI_NO_GOP_WRITE;
                if (r != EDEADLK) {
                        KASSERT(!mutex_owned(vp->v_interlock));
-                       return r;
+                       error = r;
+                       goto out;
                }
 
                /* One of the pages was busy.  Start over. */
@@ -662,7 +696,8 @@
                mutex_exit(&lfs_lock);
                preempt();
                KASSERT(!mutex_owned(vp->v_interlock));
-               return EWOULDBLOCK;
+               error = EWOULDBLOCK;
+               goto out;
        }
 
        /*
@@ -724,7 +759,7 @@
                error = lfs_seglock(fs, SEGM_PROT | (sync ? SEGM_SYNC : 0));
                if (error != 0) {
                        KASSERT(!mutex_owned(vp->v_interlock));
-                       return error;
+                       goto out;
                }
                mutex_enter(vp->v_interlock);
                lfs_acquire_finfo(fs, ip->i_number, ip->i_gen);
@@ -851,7 +886,7 @@
         */
        if (seglocked) {
                KASSERT(!mutex_owned(vp->v_interlock));
-               return error;
+               goto out;
        }
 
        /* Clean up FIP and send it to disk. */
@@ -892,6 +927,10 @@
                }
                mutex_exit(vp->v_interlock);
        }
+
+out:;
+       if (trans_mp)
+               fstrans_done(trans_mp);
        KASSERT(!mutex_owned(vp->v_interlock));
        return error;
 }
diff -r 3c9552d5b31a -r e86fb3ba929b sys/ufs/lfs/lfs_vnops.c
--- a/sys/ufs/lfs/lfs_vnops.c   Thu Mar 30 09:09:26 2017 +0000
+++ b/sys/ufs/lfs/lfs_vnops.c   Thu Mar 30 09:10:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_vnops.c,v 1.306 2017/03/16 01:09:24 maya Exp $     */
+/*     $NetBSD: lfs_vnops.c,v 1.307 2017/03/30 09:10:08 hannken Exp $  */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.306 2017/03/16 01:09:24 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.307 2017/03/30 09:10:08 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -147,7 +147,6 @@
 #include <sys/signalvar.h>
 #include <sys/kauth.h>
 #include <sys/syslog.h>
-#include <sys/fstrans.h>
 
 #include <miscfs/fifofs/fifo.h>
 #include <miscfs/genfs/genfs.h>
@@ -721,7 +720,6 @@
        if (error)
                return error;
 
-       fstrans_start(dvp->v_mount, FSTRANS_SHARED);
        error = lfs_makeinode(ap->a_vap, dvp, ulr, vpp, ap->a_cnp);
        if (error) {
                goto out;
@@ -757,8 +755,6 @@
                vrele(*vpp);
 
 out:
-       fstrans_done(dvp->v_mount);
-
        UNMARK_VNODE(dvp);
        /* XXX: is it even possible for the symlink to get MARK'd? */
        UNMARK_VNODE(*vpp);
@@ -809,7 +805,6 @@
        if (error)
                return error;
 
-       fstrans_start(dvp->v_mount, FSTRANS_SHARED);
        error = lfs_makeinode(vap, dvp, ulr, vpp, ap->a_cnp);
 
        /* Either way we're done with the dirop at this point */
@@ -818,7 +813,6 @@
        lfs_unset_dirop(fs, dvp, "mknod");
 
        if (error) {
-               fstrans_done(dvp->v_mount);
                vrele(dvp);
                *vpp = NULL;
                return (error);
@@ -843,7 +837,6 @@
                /* return (error); */
        }
 
-       fstrans_done(dvp->v_mount);
        vrele(dvp);
        KASSERT(error == 0);
        VOP_UNLOCK(*vpp);
@@ -889,13 +882,10 @@
        if (error)
                return error;
 
-       fstrans_start(dvp->v_mount, FSTRANS_SHARED);
        error = lfs_makeinode(vap, dvp, ulr, vpp, ap->a_cnp);
        if (error) {
-               fstrans_done(dvp->v_mount);
                goto out;
        }
-       fstrans_done(dvp->v_mount);
        VN_KNOTE(dvp, NOTE_WRITE);
        VOP_UNLOCK(*vpp);
 
@@ -962,8 +952,6 @@
        if (error)
                return error;
 
-       fstrans_start(dvp->v_mount, FSTRANS_SHARED);
-
        if ((nlink_t)dp->i_nlink >= LINK_MAX) {
                error = EMLINK;
                goto out;
@@ -1066,8 +1054,6 @@
        }
 
 out:
-       fstrans_done(dvp->v_mount);
-
        UNMARK_VNODE(dvp);
        UNMARK_VNODE(*vpp);
        if (error) {
@@ -1207,7 +1193,6 @@
        struct vattr *vap = ap->a_vap;
        struct lfs *fs = ip->i_lfs;
 
-       fstrans_start(vp->v_mount, FSTRANS_SHARED);
        /*
         * Copy from inode table
         */
@@ -1245,7 +1230,6 @@
        vap->va_bytes = lfs_fsbtob(fs, ip->i_lfs_effnblks);
        vap->va_type = vp->v_type;
        vap->va_filerev = ip->i_modrev;
-       fstrans_done(vp->v_mount);
        return (0);
 }
 
@@ -1329,11 +1313,9 @@
            vp->v_mount->mnt_iflag & IMNT_UNMOUNT)
                return 0;
 
-       fstrans_start(vp->v_mount, FSTRANS_SHARED);
        if (vp->v_usecount > 1 && vp != ip->i_lfs->lfs_ivnode) {
                LFS_ITIMES(ip, NULL, NULL, NULL);
        }
-       fstrans_done(vp->v_mount);
        return (0);
 }
 
@@ -2266,9 +2248,7 @@
 
        if (ump->um_fstype == ULFS1) {
 #ifdef LFS_EXTATTR
-               fstrans_start(vp->v_mount, FSTRANS_SHARED);
                error = ulfs_getextattr(ap);
-               fstrans_done(vp->v_mount);
 #else
                error = EOPNOTSUPP;
 #endif
@@ -2298,9 +2278,7 @@
 
        if (ump->um_fstype == ULFS1) {
 #ifdef LFS_EXTATTR
-               fstrans_start(vp->v_mount, FSTRANS_SHARED);
                error = ulfs_setextattr(ap);
-               fstrans_done(vp->v_mount);
 #else
                error = EOPNOTSUPP;
 #endif
@@ -2330,9 +2308,7 @@
 
        if (ump->um_fstype == ULFS1) {
 #ifdef LFS_EXTATTR
-               fstrans_start(vp->v_mount, FSTRANS_SHARED);
                error = ulfs_listextattr(ap);
-               fstrans_done(vp->v_mount);
 #else
                error = EOPNOTSUPP;



Home | Main Index | Thread Index | Old Index