Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Oct 1997 23:06:05 +0900
From:      KATO Takenori <kato@migmatite.eps.nagoya-u.ac.jp>
To:        joerg_wunsch@uriah.heep.sax.de
Cc:        freebsd-current@freebsd.org
Subject:   Re: lockmgr panic
Message-ID:  <199710131406.XAA01515@gneiss.eps.nagoya-u.ac.jp>
In-Reply-To: Your message of "Mon, 13 Oct 1997 08:41:58 %2B0200"
References:  <19971013084158.HG40991@uriah.heep.sax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
> I thought we got rid of this kind of panics finally?  Apparently not:

Problem still exists in both 3.0-current and RELENG_2_2, that is,
2.2.5 will be panic by same reason.  Stack trace shows:

	1. Write a buffer to the ufs on the vn driver.
	2. vnstrategy locks the vnode and calls ffs_write.
	3. ffs_write call ffs_balloc to obtain a buffer.
	4. buffer is not memory resident.
	5. The last used buffer is prepared to reuse.
	6. The last used buffer is a dirty buffer which is used for
	   the ufs on the vn driver.
	7. vnstrategy is called again to flush the dirty buffer.
	8. Because vnode has been already locked, the system panics.

I don't have any idea to solve this problem except:

	a. rewrite delayed write stuff.
	b. rewrite vn driver.
	c. apply the patch included in this mail.

The patch from 3.0-current is as follows:

---------- BEGIN ----------
*** vn.c.ORIG	Mon Oct 13 22:06:06 1997
--- vn.c	Mon Oct 13 22:12:34 1997
***************
*** 228,233 ****
--- 228,234 ----
  	register struct vn_softc *vn = vn_softc[unit];
  	register daddr_t bn;
  	int error;
+ 	int isvplocked;
  	long sz;
  	struct uio auio;
  	struct iovec aiov;
***************
*** 276,287 ****
  			auio.uio_rw = UIO_WRITE;
  		auio.uio_resid = bp->b_bcount;
  		auio.uio_procp = curproc;
! 		vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc);
  		if( bp->b_flags & B_READ)
  			error = VOP_READ(vn->sc_vp, &auio, 0, vn->sc_cred);
  		else
  			error = VOP_WRITE(vn->sc_vp, &auio, 0, vn->sc_cred);
! 		VOP_UNLOCK(vn->sc_vp, 0, curproc);
  		bp->b_resid = auio.uio_resid;
  
  		if( error )
--- 277,294 ----
  			auio.uio_rw = UIO_WRITE;
  		auio.uio_resid = bp->b_bcount;
  		auio.uio_procp = curproc;
! 		if (!VOP_ISLOCKED(vn->sc_vp)) {
! 			isvplocked = 1;
! 			vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc);
! 		}
  		if( bp->b_flags & B_READ)
  			error = VOP_READ(vn->sc_vp, &auio, 0, vn->sc_cred);
  		else
  			error = VOP_WRITE(vn->sc_vp, &auio, 0, vn->sc_cred);
! 		if (isvplocked) {
! 			VOP_UNLOCK(vn->sc_vp, 0, curproc);
! 			isvplocked = 0;
! 		}
  		bp->b_resid = auio.uio_resid;
  
  		if( error )
***************
*** 305,314 ****
  			int off, s, nra;
  
  			nra = 0;
  			vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc);
  			error = VOP_BMAP(vn->sc_vp, (daddr_t)(byten / bsize),
  					 &vp, &nbn, &nra, NULL);
! 			VOP_UNLOCK(vn->sc_vp, 0, curproc);
  			if (error == 0 && nbn == -1)
  				error = EIO;
  
--- 312,328 ----
  			int off, s, nra;
  
  			nra = 0;
+ 			if (!VOP_ISLOCKED(vn->sc_vp)) {
+ 				isvplocked = 1;
+ 				vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc);
+ 			}
  			vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc);
  			error = VOP_BMAP(vn->sc_vp, (daddr_t)(byten / bsize),
  					 &vp, &nbn, &nra, NULL);
! 			if (isvplocked) {
! 				VOP_UNLOCK(vn->sc_vp, 0, curproc);
! 				isvplocked = 0;
! 			}
  			if (error == 0 && nbn == -1)
  				error = EIO;
  
---------- END ----------


----
KATO Takenori <kato@ganko.eps.nagoya-u.ac.jp>
Dept. Earth Planet. Sci., Nagoya Univ.,  Nagoya, 464-01, Japan
PGP public key: finger kato@eclogite.eps.nagoya-u.ac.jp
------------------- Powered by FreeBSD(98) -------------------



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