fatal trap 12

Kostik Belousov kostikbel at gmail.com
Sun Jun 7 13:40:45 UTC 2009


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

On Sun, Jun 07, 2009 at 03:34:52PM +0400, georg at dts.su wrote:
> Hello.
> 
> After patch, whan make kernel I have this:
> /usr/src/sys/kern/vfs_vnops.c:750:37: error: macro "vn_lock" requires 3 arguments, 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
> 
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
===================================================================
--- 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 = va->a_vp;
-	struct pfs_vdata *pvd = vn->v_data;
-	struct pfs_node *pn = pvd->pvd_pn;
+	struct vnode *vn;
+	struct pfs_vdata *pvd;
+	struct pfs_node *pn;
 	struct proc *proc;
+	struct thread *td;
 	int error;
 
+	vn = va->a_vp;
+	td = curthread;
+	vn_lock(vn, LK_SHARED | LK_RETRY, td);
+	if (vn->v_iflag & VI_DOOMED) {
+		VOP_UNLOCK(vn, 0, td);
+		return (EBADF);
+	}
+	pvd = vn->v_data;
+	pn = pvd->pvd_pn;
 	PFS_TRACE(("%s: %lx", pn->pn_name, va->a_command));
 	pfs_assert_not_owned(pn);
 
-	if (vn->v_type != VREG)
+	if (vn->v_type != VREG) {
+		VOP_UNLOCK(vn, 0, td);
 		PFS_RETURN (EINVAL);
+	}
 	KASSERT_PN_IS_FILE(pn);
 
-	if (pn->pn_ioctl == NULL)
+	if (pn->pn_ioctl == NULL) {
+		VOP_UNLOCK(vn, 0, td);
 		PFS_RETURN (ENOTTY);
+	}
 
 	/*
 	 * 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);
+	}
 
 	error = pn_ioctl(curthread, proc, pn, va->a_command, va->a_data);
 
 	if (proc != NULL)
 		PROC_UNLOCK(proc);
 
+	VOP_UNLOCK(vn, 0, td);
 	PFS_RETURN (error);
 }
 
Index: fs/devfs/devfs_vnops.c
===================================================================
--- 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;
 
+	vp = ap->a_vp;
+	td = 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 = 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 = devfs_rules_ioctl(dmp, ap->a_command, ap->a_data, ap->a_td);
+	error = devfs_rules_ioctl(dmp, ap->a_command, ap->a_data, td);
 	sx_xunlock(&dmp->dm_lock);
 	return (error);
 }
Index: fs/cd9660/cd9660_vnops.c
===================================================================
--- 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 = ap->a_vp;
-	struct iso_node *ip = VTOI(vp);
+	struct vnode *vp;
+	struct iso_node *ip;
+	struct thread *td;
+	int error;
 
-	if (vp->v_type == VCHR || vp->v_type == VBLK)
-		return (EOPNOTSUPP);
+	vp = ap->a_vp;
+	td = ap->a_td;
+	vn_lock(vp, LK_SHARED | LK_RETRY, td);
+	if (vp->v_iflag & VI_DOOMED) {
+		error = EBADF;
+		goto out;
+	}
+	ip = VTOI(vp);
+	if (vp->v_type == VCHR || vp->v_type == VBLK) {
+		error = EOPNOTSUPP;
+		goto out;
+	}
 
+	error = 0;
 	switch (ap->a_command) {
-
 	case FIOGETLBA:
 		*(int *)(ap->a_data) = ip->iso_start;
-		return 0;
+		break;
 	default:
-		return (ENOTTY);
+		error = ENOTTY;
+		break;
 	}
+
+out:
+	VOP_UNLOCK(vp, 0, td);
+	return (error);
 }
 
 /*
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20090607/f3274c56/attachment.pgp


More information about the freebsd-fs mailing list