Re: panic: Inconsistent vnode bufstrategy

From: Jean-Sébastien Pédron <jspedron_at_club-internet.fr>
Date: Mon, 06 Dec 2004 17:04:38 +0100
Doug Barton wrote:
> I'm using mount_ntfs to read data off my winxp partition on a dual boot 
> system. For a week or so I've been getting a panic, which I've finally 
> been able to get a dump for:
> 
> [stack trace]

I get exactly the same panic() with NTFS and ReiserFS.

I think it's related with phk's commit about:
"Make VOP_BMAP return a struct bufobj for the underlying storage device
instead of a vnode for it." (dated Mon Nov 15 09:18:26 2004 UTC)

The panic() occurs with mmap(2), for example while cp(1)'ing files 
smaller than 8 MB.

In file systems like ufs, msdosfs or ext2fs, VOP_BMAP will do:
	*ap->a_bop = &VTOI(ap->a_vp)->i_devvp->v_bufobj;
So the vm will call the device bo_strategy callback, and everything works.

In NTFS, VOP_BMAP is different:
	*ap->a_bop = &ap->a_vp->v_bufobj;
The goal is that the vm should call the file system's VOP_STRATEGY, not 
the device directly (that's what I guess, I'm not familiar with this fs :-).

Here is what I understand in the code, when the vm read a page:
1) vnode_pager_generic_getpages prepare a new struct buf *bp 
(sys/vm/vnode_pager.c:817) and, twice, will KASSERT() that bp->b_vp is 
NULL (in initpbuf, called by getpbuf, and in pbgetbo).
2) in pbgetbo, bp->b_bufobj = bo (bo is "returned" by file system's 
VOP_BMAP; see the "*ap->a_bop = ..." lines above)
2) vnode_pager_generic_getpages call bstrategy, which in turn call 
bp->b_bufobj->bo_ops->bop_strategy(). For NTFS, the callback is 
bufstrategy (sys/kern/vfs_bio.c:3826)
3) in bufstrategy, KASSERT(bp->b_vp == bo->bo_private, ("Inconsistent 
vnode bufstrategy")); but bp->b_vp is NULL.

In ReiserFS, because small files are not 512b-aligned on the device and 
the vm must call the fs' VOP_STRATEGY, I did the same thing in VOP_BMAP, 
which triggered this panic().

Cc'd to phk, he surely know the internals better than me :-)

Jean-Seb

Received on Mon Dec 06 2004 - 15:04:23 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:23 UTC