From owner-freebsd-stable Thu Dec 20 21:28: 9 2001 Delivered-To: freebsd-stable@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id 1593D37B405 for ; Thu, 20 Dec 2001 21:28:07 -0800 (PST) Received: (from dillon@localhost) by apollo.backplane.com (8.11.6/8.9.1) id fBL5S6J84860; Thu, 20 Dec 2001 21:28:06 -0800 (PST) (envelope-from dillon) Date: Thu, 20 Dec 2001 21:28:06 -0800 (PST) From: Matthew Dillon Message-Id: <200112210528.fBL5S6J84860@apollo.backplane.com> To: freebsd-stable@freebsd.org Cc: Kirk McKusick Subject: Proposed FFS fix in filesystem syncing code Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Another program Jordan forwarded to me located another filesystem bug. This one normally wouldn't occur too often. It happens when the filesystem syncing code is updating a VCHR vnode/inode. The vnode can get ripped out from under the ffs_update() code because the sync code doesn't lock or reference the vnode while running UFS_UPDATE() on it. I believe the below is a reasonable fix. Comments? (I've asked Jordan whether posting the source to this second filesystem stress tester is ok). -Matt Index: ffs/ffs_vfsops.c =================================================================== RCS file: /home/ncvs/src/sys/ufs/ffs/ffs_vfsops.c,v retrieving revision 1.117.2.6 diff -u -r1.117.2.6 ffs_vfsops.c --- ffs/ffs_vfsops.c 3 Nov 2001 19:59:28 -0000 1.117.2.6 +++ ffs/ffs_vfsops.c 21 Dec 2001 05:19:11 -0000 @@ -1002,9 +1002,17 @@ simple_lock(&mntvnode_slock); } } else { + /* + * We must reference the vp to prevent it from + * getting ripped out from under UFS_UPDATE, since + * we are not holding a vnode lock. XXX why aren't + * we holding a vnode lock? + */ + VREF(vp); simple_unlock(&mntvnode_slock); /* UFS_UPDATE(vp, waitfor == MNT_WAIT); */ UFS_UPDATE(vp, 0); + vrele(vp); simple_lock(&mntvnode_slock); } if (TAILQ_NEXT(vp, v_nmntvnodes) != nvp) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message