Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Dec 2012 18:30:39 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Mateusz Guzik <mjguzik@gmail.com>
Cc:        gber@freebsd.org, cognet@freebsd.org, fs@freebsd.org, Ronald Klop <ronald-freebsd8@klop.yi.org>
Subject:   Re: Nandfs use of MNT_VNODE_FOREACH
Message-ID:  <20121231163039.GN82219@kib.kiev.ua>
In-Reply-To: <20121231162540.GB29588@dft-labs.eu>
References:  <20121227230223.GN82219@kib.kiev.ua> <op.wp6d7vdo8527sy@212-182-167-131.ip.telfort.nl> <20121231162145.GA29588@dft-labs.eu> <20121231162540.GB29588@dft-labs.eu>

next in thread | previous in thread | raw e-mail | index | archive | help

--MgcI0aUO3vrRQI/Z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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 =3D=3D vp)'
> > performs VI_UNLOCK as well?
> >=20
> > Something like:
> > if (mp->mnt_syncer =3D=3D vp || VOP_ISLOCKED(vp)) {
> > 	VI_UNLOCK(mp);
> > 	continue;
> > }
> >=20
> > I will have time to dig into this next week.
>=20
> 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;
=20
 	td =3D curthread;
-	lockreq =3D LK_EXCLUSIVE | LK_INTERLOCK | LK_RETRY;
=20
-	MNT_ILOCK(mp);
-
-	MNT_VNODE_FOREACH(vp, mp, mvp) {
+	MNT_VNODE_FOREACH_ACTIVE(vp, mp, mvp) {
 		update =3D 0;
=20
-		if (mp->mnt_syncer =3D=3D vp)
-			continue;
-		if (VOP_ISLOCKED(vp))
-			continue;
-
-		VI_LOCK(vp);
-		MNT_IUNLOCK(mp);
-		if (vp->v_iflag & VI_DOOMED) {
+		if (mp->mnt_syncer =3D=3D vp || VOP_ISLOCKED(vp)) {
 			VI_UNLOCK(vp);
-			MNT_ILOCK(mp);
-			continue;
-		}
-
-		if ((error =3D vget(vp, lockreq, td)) !=3D 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) !=3D 0)
 			continue;
-		}
=20
 		nandfs_node =3D VTON(vp);
 		if (nandfs_node->nn_flags & IN_MODIFIED) {
@@ -532,12 +512,8 @@ nandfs_iterate_dirty_vnodes(struct mount *mp, struct n=
andfs_seginfo *seginfo)
=20
 		if (update)
 			nandfs_node_update(nandfs_node);
-
-		MNT_ILOCK(mp);
 	}
=20
-	MNT_IUNLOCK(mp);
-
 	return (0);
 }
=20

--MgcI0aUO3vrRQI/Z
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)

iQIcBAEBAgAGBQJQ4b2uAAoJEJDCuSvBvK1BirsP/j49Hr3KDA75njTYexQ25KkS
UzHLOHxh2xz+NZNhxfkQpYyucW3lZfz66yozWDKUazM3JJ5rqxXr2iFhZgoEB39q
ezOtmNShrobbTDMDDnd5pL+WgldLUQj24wIsMJFBoJObkoirlj9MFWmvM0mt4gqn
CAdRm7VtIzaMqYjcHmyuQZD+2D4Ez0iOCPw+4E63rdeAbQN6BMiXiudiJVLa7vuS
ROUe5yLwePc62X1mYIpO8OwKY6DAECDAsSMyzx0g/L8t9/i9vbmTjZKMxb9H7LWU
ZlN2XFOm3VB/E4N4PPPVKZT28EP3sNdG66sFBTFeAbp0eC5wAO41hcuKAN4oTJhw
GCRwSbeZ5eysxslJLoWdbI6sBK7G5cBjKrQ762oWpMbwBTFomy1qZ9zAUJodn9Yo
Ga1hni+qpjV9srCLYkgV+lu722oa4XLZL6PV+0Yxr0PqzCYtitGgcqFPLhGjW3Wf
UkyN2/2gM27Jse3awuzhf7I7tfiRPu6dDDuZcS5z9P/vvf1a989xMcznN4yEStpJ
D41zV3bmnUkYgeXGdct5TU8U4O6zaXmFK32UZhgdlQQ2Jy3vAIQ3xxy83PsF3O2j
PinHTNLFCfkv69sxgTGED6JfyAKHvSVvY6ULz7UlaZxLiokHjuREVZzUsdKN2mxT
8UYORwzW/G90namk7KaO
=MCgR
-----END PGP SIGNATURE-----

--MgcI0aUO3vrRQI/Z--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121231163039.GN82219>