Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/ufs Change quota1_handle_cmd_quotaon() and q1sync() ...



details:   https://anonhg.NetBSD.org/src/rev/8fea2c51a7e6
branches:  trunk
changeset: 327802:8fea2c51a7e6
user:      hannken <hannken%NetBSD.org@localhost>
date:      Mon Mar 17 09:31:35 2014 +0000

description:
Change quota1_handle_cmd_quotaon() and q1sync() to use vfs_vnode_iterator.

diffstat:

 sys/ufs/ufs/ufs_quota1.c |  109 ++++++++++++++++------------------------------
 1 files changed, 39 insertions(+), 70 deletions(-)

diffs (211 lines):

diff -r b85cdcbe6cd7 -r 8fea2c51a7e6 sys/ufs/ufs/ufs_quota1.c
--- a/sys/ufs/ufs/ufs_quota1.c  Mon Mar 17 09:30:32 2014 +0000
+++ b/sys/ufs/ufs/ufs_quota1.c  Mon Mar 17 09:31:35 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_quota1.c,v 1.18 2012/02/02 03:00:48 matt Exp $     */
+/*     $NetBSD: ufs_quota1.c,v 1.19 2014/03/17 09:31:35 hannken Exp $  */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.18 2012/02/02 03:00:48 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.19 2014/03/17 09:31:35 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -304,7 +304,8 @@
     const char *fname)
 {
        struct mount *mp = ump->um_mountp;
-       struct vnode *vp, **vpp, *mvp;
+       struct vnode *vp, **vpp;
+       struct vnode_iterator *marker;
        struct dquot *dq;
        int error;
        struct pathbuf *pb;
@@ -366,41 +367,33 @@
                        ump->umq1_itime[type] = dq->dq_itime;
                dqrele(NULLVP, dq);
        }
-       /* Allocate a marker vnode. */
-       mvp = vnalloc(mp);
        /*
         * Search vnodes associated with this mount point,
         * adding references to quota file being opened.
         * NB: only need to add dquot's for inodes being modified.
         */
-       mutex_enter(&mntvnode_lock);
-again:
-       for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = vunmark(mvp)) {
-               vmark(mvp, vp);
-               mutex_enter(vp->v_interlock);
-               if (VTOI(vp) == NULL || vp->v_mount != mp || vismarker(vp) ||
-                   vp->v_type == VNON || vp->v_writecount == 0 ||
-                   (vp->v_iflag & (VI_XLOCK | VI_CLEAN)) != 0) {
-                       mutex_exit(vp->v_interlock);
+       vfs_vnode_iterator_init(mp, &marker);
+       while (vfs_vnode_iterator_next(marker, &vp)) {
+               error = vn_lock(vp, LK_EXCLUSIVE);
+               if (error) {
+                       vrele(vp);
                        continue;
                }
-               mutex_exit(&mntvnode_lock);
-               if (vget(vp, LK_EXCLUSIVE)) {
-                       mutex_enter(&mntvnode_lock);
-                       (void)vunmark(mvp);
-                       goto again;
+               mutex_enter(vp->v_interlock);
+               if (VTOI(vp) == NULL || vp->v_type == VNON ||
+                   vp->v_writecount == 0) {
+                       mutex_exit(vp->v_interlock);
+                       vput(vp);
+                       continue;
                }
+               mutex_exit(vp->v_interlock);
                if ((error = getinoquota(VTOI(vp))) != 0) {
                        vput(vp);
-                       mutex_enter(&mntvnode_lock);
-                       (void)vunmark(mvp);
                        break;
                }
                vput(vp);
-               mutex_enter(&mntvnode_lock);
        }
-       mutex_exit(&mntvnode_lock);
-       vnfree(mvp);
+       vfs_vnode_iterator_destroy(marker);
 
        mutex_enter(&dqlock);
        ump->umq1_qflags[type] &= ~QTF_OPENING;
@@ -421,21 +414,18 @@
 {
        struct mount *mp = ump->um_mountp;
        struct vnode *vp;
-       struct vnode *qvp, *mvp;
+       struct vnode *qvp;
+       struct vnode_iterator *marker;
        struct dquot *dq;
        struct inode *ip;
        kauth_cred_t cred;
        int i, error;
 
-       /* Allocate a marker vnode. */
-       mvp = vnalloc(mp);
-
        mutex_enter(&dqlock);
        while ((ump->umq1_qflags[type] & (QTF_CLOSING | QTF_OPENING)) != 0)
                cv_wait(&dqcv, &dqlock);
        if ((qvp = ump->um_quotas[type]) == NULLVP) {
                mutex_exit(&dqlock);
-               vnfree(mvp);
                return (0);
        }
        ump->umq1_qflags[type] |= QTF_CLOSING;
@@ -445,31 +435,24 @@
         * Search vnodes associated with this mount point,
         * deleting any references to quota file being closed.
         */
-       mutex_enter(&mntvnode_lock);
-again:
-       for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = vunmark(mvp)) {
-               vmark(mvp, vp);
-               mutex_enter(vp->v_interlock);
-               if (VTOI(vp) == NULL || vp->v_mount != mp || vismarker(vp) ||
-                   vp->v_type == VNON ||
-                   (vp->v_iflag & (VI_XLOCK | VI_CLEAN)) != 0) {
-                       mutex_exit(vp->v_interlock);
+       vfs_vnode_iterator_init(mp, &marker);
+       while (vfs_vnode_iterator_next(marker, &vp)) {
+               error = vn_lock(vp, LK_EXCLUSIVE);
+               if (error) {
+                       vrele(vp);
                        continue;
                }
-               mutex_exit(&mntvnode_lock);
-               if (vget(vp, LK_EXCLUSIVE)) {
-                       mutex_enter(&mntvnode_lock);
-                       (void)vunmark(mvp);
-                       goto again;
+               ip = VTOI(vp);
+               if (ip == NULL || vp->v_type == VNON) {
+                       vput(vp);
+                       continue;
                }
-               ip = VTOI(vp);
                dq = ip->i_dquot[type];
                ip->i_dquot[type] = NODQUOT;
                dqrele(vp, dq);
                vput(vp);
-               mutex_enter(&mntvnode_lock);
        }
-       mutex_exit(&mntvnode_lock);
+       vfs_vnode_iterator_destroy(marker);
 #ifdef DIAGNOSTIC
        dqflush(qvp);
 #endif
@@ -759,7 +742,8 @@
 q1sync(struct mount *mp)
 {
        struct ufsmount *ump = VFSTOUFS(mp);
-       struct vnode *vp, *mvp;
+       struct vnode *vp;
+       struct vnode_iterator *marker;
        struct dquot *dq;
        int i, error;
 
@@ -773,32 +757,19 @@
        if (i == MAXQUOTAS)
                return (0);
 
-       /* Allocate a marker vnode. */
-       mvp = vnalloc(mp);
-
        /*
         * Search vnodes associated with this mount point,
         * synchronizing any modified dquot structures.
         */
-       mutex_enter(&mntvnode_lock);
- again:
-       for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = vunmark(mvp)) {
-               vmark(mvp, vp);
-               mutex_enter(vp->v_interlock);
-               if (VTOI(vp) == NULL || vp->v_mount != mp || vismarker(vp) ||
-                   vp->v_type == VNON ||
-                   (vp->v_iflag & (VI_XLOCK | VI_CLEAN)) != 0) {
-                       mutex_exit(vp->v_interlock);
+       vfs_vnode_iterator_init(mp, &marker);
+       while (vfs_vnode_iterator_next(marker, &vp)) {
+               error = vn_lock(vp, LK_EXCLUSIVE);
+               if (error) {
+                       vrele(vp);
                        continue;
                }
-               mutex_exit(&mntvnode_lock);
-               error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT);
-               if (error) {
-                       mutex_enter(&mntvnode_lock);
-                       if (error == ENOENT) {
-                               (void)vunmark(mvp);
-                               goto again;
-                       }
+               if (VTOI(vp) == NULL || vp->v_type == VNON) {
+                       vput(vp);
                        continue;
                }
                for (i = 0; i < MAXQUOTAS; i++) {
@@ -811,10 +782,8 @@
                        mutex_exit(&dq->dq_interlock);
                }
                vput(vp);
-               mutex_enter(&mntvnode_lock);
        }
-       mutex_exit(&mntvnode_lock);
-       vnfree(mvp);
+       vfs_vnode_iterator_destroy(marker);
        return (0);
 }
 



Home | Main Index | Thread Index | Old Index