Module Name:    src
Committed By:   hannken
Date:           Thu Apr 13 09:57:28 UTC 2017

Modified Files:
        src/sys/ufs/lfs: lfs_bio.c lfs_vfsops.c

Log Message:
Switch lfs_flush() and lfs_writerd() to mountlist iterator.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/ufs/lfs/lfs_bio.c
cvs rdiff -u -r1.356 -r1.357 src/sys/ufs/lfs/lfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/lfs/lfs_bio.c
diff -u src/sys/ufs/lfs/lfs_bio.c:1.137 src/sys/ufs/lfs/lfs_bio.c:1.138
--- src/sys/ufs/lfs/lfs_bio.c:1.137	Sat Apr  1 17:34:21 2017
+++ src/sys/ufs/lfs/lfs_bio.c	Thu Apr 13 09:57:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_bio.c,v 1.137 2017/04/01 17:34:21 maya Exp $	*/
+/*	$NetBSD: lfs_bio.c,v 1.138 2017/04/13 09:57:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.137 2017/04/01 17:34:21 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.138 2017/04/13 09:57:28 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -514,7 +514,8 @@ void
 lfs_flush(struct lfs *fs, int flags, int only_onefs)
 {
 	extern u_int64_t locked_fakequeue_count;
-	struct mount *mp, *nmp;
+	mount_iterator_t *iter;
+	struct mount *mp;
 	struct lfs *tfs;
 
 	KASSERT(mutex_owned(&lfs_lock));
@@ -543,12 +544,8 @@ lfs_flush(struct lfs *fs, int flags, int
 		vfs_unbusy(fs->lfs_ivnode->v_mount, false, NULL);
 	} else {
 		locked_fakequeue_count = 0;
-		mutex_enter(&mountlist_lock);
-		for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
-			if (vfs_busy(mp, &nmp)) {
-				DLOG((DLOG_FLUSH, "lfs_flush: fs vfs_busy\n"));
-				continue;
-			}
+		mountlist_iterator_init(&iter);
+		while ((mp = mountlist_iterator_next(iter)) != NULL) {
 			if (strncmp(&mp->mnt_stat.f_fstypename[0], MOUNT_LFS,
 			    sizeof(mp->mnt_stat.f_fstypename)) == 0) {
 				tfs = VFSTOULFS(mp)->um_lfs;
@@ -556,9 +553,8 @@ lfs_flush(struct lfs *fs, int flags, int
 				lfs_flush_fs(tfs, flags);
 				mutex_exit(&lfs_lock);
 			}
-			vfs_unbusy(mp, false, &nmp);
 		}
-		mutex_exit(&mountlist_lock);
+		mountlist_iterator_destroy(iter);
 	}
 	LFS_DEBUG_COUNTLOCKED("flush");
 	wakeup(&lfs_subsys_pages);

Index: src/sys/ufs/lfs/lfs_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.356 src/sys/ufs/lfs/lfs_vfsops.c:1.357
--- src/sys/ufs/lfs/lfs_vfsops.c:1.356	Sat Apr  1 17:34:21 2017
+++ src/sys/ufs/lfs/lfs_vfsops.c	Thu Apr 13 09:57:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vfsops.c,v 1.356 2017/04/01 17:34:21 maya Exp $	*/
+/*	$NetBSD: lfs_vfsops.c,v 1.357 2017/04/13 09:57:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.356 2017/04/01 17:34:21 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.357 2017/04/13 09:57:28 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -387,11 +387,11 @@ struct pool lfs_lbnentry_pool;
 static void
 lfs_writerd(void *arg)
 {
- 	struct mount *mp, *nmp;
+	mount_iterator_t *iter;
+ 	struct mount *mp;
  	struct lfs *fs;
 	struct vfsops *vfs = NULL;
  	int fsflags;
-	int skipc;
 	int lfsc;
 	int wrote_something = 0;
  
@@ -446,14 +446,9 @@ lfs_writerd(void *arg)
  		 * Look through the list of LFSs to see if any of them
  		 * have requested pageouts.
  		 */
- 		mutex_enter(&mountlist_lock);
+ 		mountlist_iterator_init(&iter);
 		lfsc = 0;
-		skipc = 0;
- 		for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
- 			if (vfs_busy(mp, &nmp)) {
-				++skipc;
- 				continue;
- 			}
+		while ((mp = mountlist_iterator_next(iter)) != NULL) {
 			KASSERT(!mutex_owned(&lfs_lock));
  			if (strncmp(mp->mnt_stat.f_fstypename, MOUNT_LFS,
  			    sizeof(mp->mnt_stat.f_fstypename)) == 0) {
@@ -468,7 +463,6 @@ lfs_writerd(void *arg)
 				if (lfs_sb_getnextseg(fs) < lfs_sb_getcurseg(fs) && fs->lfs_nowrap) {
 					/* Don't try to write if we're suspended */
 					mutex_exit(&lfs_lock);
-					vfs_unbusy(mp, false, &nmp);
 					continue;
 				}
 				if (LFS_STARVED_FOR_SEGS(fs)) {
@@ -476,7 +470,6 @@ lfs_writerd(void *arg)
 
 					DLOG((DLOG_FLUSH, "lfs_writerd: need cleaning before writing possible\n"));
 					lfs_wakeup_cleaner(fs);
-					vfs_unbusy(mp, false, &nmp);
 					continue;
 				}
 
@@ -503,21 +496,19 @@ lfs_writerd(void *arg)
 				mutex_exit(&lfs_lock);
  			}
 			KASSERT(!mutex_owned(&lfs_lock));
- 			vfs_unbusy(mp, false, &nmp);
  		}
-		if (lfsc + skipc == 0) {
+		if (lfsc == 0) {
 			mutex_enter(&lfs_lock);
 			lfs_writer_daemon = NULL;
 			mutex_exit(&lfs_lock);
-			mutex_exit(&mountlist_lock);
+			mountlist_iterator_destroy(iter);
 			break;
 		}
- 		mutex_exit(&mountlist_lock);
+ 		mountlist_iterator_destroy(iter);
  
  		mutex_enter(&lfs_lock);
  	}
 	KASSERT(!mutex_owned(&lfs_lock));
-	KASSERT(!mutex_owned(&mountlist_lock));
 
 	/* Give up our extra reference so the module can be unloaded. */
 	mutex_enter(&vfs_list_lock);

Reply via email to