Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Jun 2009 16:40:38 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        georg@dts.su
Cc:        freebsd-fs@freebsd.org
Subject:   Re: fatal trap 12
Message-ID:  <20090607134038.GL1927@deviant.kiev.zoral.com.ua>
In-Reply-To: <49009886.20090607153452@dts.su>
References:  <20090606161600.GB61928@dchagin.static.corbina.ru> <20090606175033.GJ1927@deviant.kiev.zoral.com.ua> <49009886.20090607153452@dts.su>

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

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

I asked to remove questions@, isn't it ?

On Sun, Jun 07, 2009 at 03:34:52PM +0400, georg@dts.su wrote:
> Hello.
>=20
> After patch, whan make kernel I have this:
> /usr/src/sys/kern/vfs_vnops.c:750:37: error: macro "vn_lock" requires 3 a=
rguments, but only 2 given
> /usr/src/sys/kern/vfs_vnops.c: In function 'vn_ioctl':
> /usr/src/sys/kern/vfs_vnops.c:750: error: 'vn_lock' undeclared (first use=
 in this function)
> /usr/src/sys/kern/vfs_vnops.c:750: error: (Each undeclared identifier is =
reported only once
> /usr/src/sys/kern/vfs_vnops.c:750: error: for each function it appears in=
.)
> /usr/src/sys/kern/vfs_vnops.c:769: error: too few arguments to function '=
VOP_UNLOCK'
> *** Error code 1
>=20
The patch is for HEAD. You did not specified the version of your system.
For RELENG_7, patch shall be adopted by adding curthread parameter
to several calls, among them are vn_lock, VOP_ISLOCKED and VOP_UNLOCK().

The patch probably cannot be merged to RELENG_7 due to KBI breakage.
There, I think the following workaround for pseudofs might be enough,
but it would be also needed for cd9660 and devfs at least.

Try this.

Index: fs/pseudofs/pseudofs_vnops.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- fs/pseudofs/pseudofs_vnops.c	(revision 193634)
+++ fs/pseudofs/pseudofs_vnops.c	(working copy)
@@ -260,34 +260,51 @@
 static int
 pfs_ioctl(struct vop_ioctl_args *va)
 {
-	struct vnode *vn =3D va->a_vp;
-	struct pfs_vdata *pvd =3D vn->v_data;
-	struct pfs_node *pn =3D pvd->pvd_pn;
+	struct vnode *vn;
+	struct pfs_vdata *pvd;
+	struct pfs_node *pn;
 	struct proc *proc;
+	struct thread *td;
 	int error;
=20
+	vn =3D va->a_vp;
+	td =3D curthread;
+	vn_lock(vn, LK_SHARED | LK_RETRY, td);
+	if (vn->v_iflag & VI_DOOMED) {
+		VOP_UNLOCK(vn, 0, td);
+		return (EBADF);
+	}
+	pvd =3D vn->v_data;
+	pn =3D pvd->pvd_pn;
 	PFS_TRACE(("%s: %lx", pn->pn_name, va->a_command));
 	pfs_assert_not_owned(pn);
=20
-	if (vn->v_type !=3D VREG)
+	if (vn->v_type !=3D VREG) {
+		VOP_UNLOCK(vn, 0, td);
 		PFS_RETURN (EINVAL);
+	}
 	KASSERT_PN_IS_FILE(pn);
=20
-	if (pn->pn_ioctl =3D=3D NULL)
+	if (pn->pn_ioctl =3D=3D NULL) {
+		VOP_UNLOCK(vn, 0, td);
 		PFS_RETURN (ENOTTY);
+	}
=20
 	/*
 	 * This is necessary because process' privileges may
 	 * have changed since the open() call.
 	 */
-	if (!pfs_visible(curthread, pn, pvd->pvd_pid, &proc))
+	if (!pfs_visible(curthread, pn, pvd->pvd_pid, &proc)) {
+		VOP_UNLOCK(vn, 0, td);
 		PFS_RETURN (EIO);
+	}
=20
 	error =3D pn_ioctl(curthread, proc, pn, va->a_command, va->a_data);
=20
 	if (proc !=3D NULL)
 		PROC_UNLOCK(proc);
=20
+	VOP_UNLOCK(vn, 0, td);
 	PFS_RETURN (error);
 }
=20
Index: fs/devfs/devfs_vnops.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- fs/devfs/devfs_vnops.c	(revision 193634)
+++ fs/devfs/devfs_vnops.c	(working copy)
@@ -1240,11 +1240,21 @@
 static int
 devfs_rioctl(struct vop_ioctl_args *ap)
 {
+	struct vnode *vp;
+	struct devfs_mount *dmp;
+	struct thread *td;
 	int error;
-	struct devfs_mount *dmp;
=20
+	vp =3D ap->a_vp;
+	td =3D ap->a_td;
+	vn_lock(vp, LK_SHARED | LK_RETRY, td);
+	if (vp->v_iflag & VI_DOOMED) {
+		VOP_UNLOCK(vp, 0, td);
+		return (EBADF);
+	}
 	dmp =3D VFSTODEVFS(ap->a_vp->v_mount);
 	sx_xlock(&dmp->dm_lock);
+	VOP_UNLOCK(vp, 0, td);
 	DEVFS_DMP_HOLD(dmp);
 	devfs_populate(dmp);
 	if (DEVFS_DMP_DROP(dmp)) {
@@ -1252,7 +1262,7 @@
 		devfs_unmount_final(dmp);
 		return (ENOENT);
 	}
-	error =3D devfs_rules_ioctl(dmp, ap->a_command, ap->a_data, ap->a_td);
+	error =3D devfs_rules_ioctl(dmp, ap->a_command, ap->a_data, td);
 	sx_xunlock(&dmp->dm_lock);
 	return (error);
 }
Index: fs/cd9660/cd9660_vnops.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- fs/cd9660/cd9660_vnops.c	(revision 193634)
+++ fs/cd9660/cd9660_vnops.c	(working copy)
@@ -253,20 +253,37 @@
 		struct thread *a_td;
 	} */ *ap;
 {
-	struct vnode *vp =3D ap->a_vp;
-	struct iso_node *ip =3D VTOI(vp);
+	struct vnode *vp;
+	struct iso_node *ip;
+	struct thread *td;
+	int error;
=20
-	if (vp->v_type =3D=3D VCHR || vp->v_type =3D=3D VBLK)
-		return (EOPNOTSUPP);
+	vp =3D ap->a_vp;
+	td =3D ap->a_td;
+	vn_lock(vp, LK_SHARED | LK_RETRY, td);
+	if (vp->v_iflag & VI_DOOMED) {
+		error =3D EBADF;
+		goto out;
+	}
+	ip =3D VTOI(vp);
+	if (vp->v_type =3D=3D VCHR || vp->v_type =3D=3D VBLK) {
+		error =3D EOPNOTSUPP;
+		goto out;
+	}
=20
+	error =3D 0;
 	switch (ap->a_command) {
-
 	case FIOGETLBA:
 		*(int *)(ap->a_data) =3D ip->iso_start;
-		return 0;
+		break;
 	default:
-		return (ENOTTY);
+		error =3D ENOTTY;
+		break;
 	}
+
+out:
+	VOP_UNLOCK(vp, 0, td);
+	return (error);
 }
=20
 /*

--w7hfNuAEqLXjQNlZ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)

iEYEARECAAYFAkorw1YACgkQC3+MBN1Mb4jcfgCgoe1ex+B/sAhalWfsrwYsTg/A
Jw8AoIb9Rr3Lc9GwuKQ4X/8xQ9TEFhAf
=9YF5
-----END PGP SIGNATURE-----

--w7hfNuAEqLXjQNlZ--



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