Nandfs use of MNT_VNODE_FOREACH

Konstantin Belousov kostikbel at gmail.com
Mon Dec 31 16:30:44 UTC 2012


On Mon, Dec 31, 2012 at 05:25:40PM +0100, Mateusz Guzik wrote:
> On Mon, Dec 31, 2012 at 05:21:45PM +0100, Mateusz Guzik wrote:
> > Can you adjust this function so that 'if (mp->mnt_syncer == vp)'
> > performs VI_UNLOCK as well?
> > 
> > Something like:
> > if (mp->mnt_syncer == vp || VOP_ISLOCKED(vp)) {
> > 	VI_UNLOCK(mp);
> > 	continue;
> > }
> > 
> > I will have time to dig into this next week.
> 
> Err.. I meant VI_UNLOCK(vp).

This is definitely a bug, thank you for noticing. Updated patch below.

diff --git a/sys/fs/nandfs/nandfs_segment.c b/sys/fs/nandfs/nandfs_segment.c
index 836bead..7433e77 100644
--- a/sys/fs/nandfs/nandfs_segment.c
+++ b/sys/fs/nandfs/nandfs_segment.c
@@ -478,39 +478,19 @@ nandfs_iterate_dirty_vnodes(struct mount *mp, struct nandfs_seginfo *seginfo)
 	struct nandfs_node *nandfs_node;
 	struct vnode *vp, *mvp;
 	struct thread *td;
-	int error, lockreq, update;
+	int error, update;
 
 	td = curthread;
-	lockreq = LK_EXCLUSIVE | LK_INTERLOCK | LK_RETRY;
 
-	MNT_ILOCK(mp);
-
-	MNT_VNODE_FOREACH(vp, mp, mvp) {
+	MNT_VNODE_FOREACH_ACTIVE(vp, mp, mvp) {
 		update = 0;
 
-		if (mp->mnt_syncer == vp)
-			continue;
-		if (VOP_ISLOCKED(vp))
-			continue;
-
-		VI_LOCK(vp);
-		MNT_IUNLOCK(mp);
-		if (vp->v_iflag & VI_DOOMED) {
+		if (mp->mnt_syncer == vp || VOP_ISLOCKED(vp)) {
 			VI_UNLOCK(vp);
-			MNT_ILOCK(mp);
-			continue;
-		}
-
-		if ((error = vget(vp, lockreq, td)) != 0) {
-			MNT_ILOCK(mp);
 			continue;
 		}
-
-		if (vp->v_iflag & VI_DOOMED) {
-			vput(vp);
-			MNT_ILOCK(mp);
+		if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK | LK_NOWAIT, td) != 0)
 			continue;
-		}
 
 		nandfs_node = VTON(vp);
 		if (nandfs_node->nn_flags & IN_MODIFIED) {
@@ -532,12 +512,8 @@ nandfs_iterate_dirty_vnodes(struct mount *mp, struct nandfs_seginfo *seginfo)
 
 		if (update)
 			nandfs_node_update(nandfs_node);
-
-		MNT_ILOCK(mp);
 	}
 
-	MNT_IUNLOCK(mp);
-
 	return (0);
 }
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20121231/20715f26/attachment.sig>


More information about the freebsd-fs mailing list