Subject: kern/19134: lfs cleaner deadlocks in segunlock
To: None <gnats-bugs@gnats.netbsd.org>
From: None <yamt@mwd.biglobe.ne.jp>
List: netbsd-bugs
Date: 11/22/2002 22:35:14
>Number:         19134
>Category:       kern
>Synopsis:       lfs cleaner deadlocks in seglock
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 22 08:37:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
>Release:        NetBSD 1.6K
>Organization:

>Environment:
	
	
System: NetBSD kaeru 1.6K NetBSD 1.6K (build.kaeru) #216: Fri Nov 22 14:43:30 JST 2002 takashi@kaeru:/usr/home/takashi/work/kernel/build.kaeru i386
Architecture: i386
Machine: i386
>Description:
	when lfs_avail is very low:

	lfs_markv -> lfs_segunlock -> vrele -> lfs_inactive
	-> ... -> lfs_reserve => deadlock

>How-To-Repeat:
	
>Fix:
	apply following.
	(note that no one is using lfs_unlockvp currently.
	i guess Konrad forgot to commit something...)

Index: lfs_bio.c
===================================================================
RCS file: /cvs/NetBSD/syssrc/sys/ufs/lfs/lfs_bio.c,v
retrieving revision 1.44
diff -u -p -r1.44 lfs_bio.c
--- lfs_bio.c	2002/06/20 22:10:24	1.44
+++ lfs_bio.c	2002/11/22 13:26:36
@@ -122,6 +122,11 @@ lfs_reserve(struct lfs *fs, struct vnode
 	struct buf *bp;
 	int error, slept;
 
+	if (fs->lfs_unlockvp == vp) {
+		printf("lfs_reserve: unlockvp: vp=%p\n", vp);
+		goto ok;
+	}
+
 	slept = 0;
 	while (fsb > 0 && !lfs_fits(fs, fsb + fs->lfs_ravail)) {
 		VOP_UNLOCK(vp, 0);
@@ -152,6 +157,7 @@ lfs_reserve(struct lfs *fs, struct vnode
 	if (slept)
 		printf("lfs_reserve: woke up\n");
 #endif
+ok:
 	fs->lfs_ravail += fsb;
 	return 0;
 }
>Release-Note:
>Audit-Trail:
>Unformatted: