From owner-freebsd-current@FreeBSD.ORG  Mon Dec  6 16:04:23 2004
Return-Path: <owner-freebsd-current@FreeBSD.ORG>
Delivered-To: freebsd-current@freebsd.org
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id 57D3116A4CE; Mon,  6 Dec 2004 16:04:23 +0000 (GMT)
Received: from smtp.cegetel.net (mf01.sitadelle.com [212.94.174.78])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id A5F8F43D41; Mon,  6 Dec 2004 16:04:22 +0000 (GMT)
	(envelope-from jspedron@club-internet.fr)
Received: from [172.16.142.1] (213-223-184-193.dti.cegetel.net
	[213.223.184.193])
	by smtp.cegetel.net (Postfix) with ESMTP id C8FFA37B6B;
	Mon,  6 Dec 2004 17:04:21 +0100 (CET)
Message-ID: <41B48316.90004@club-internet.fr>
Date: Mon, 06 Dec 2004 17:04:38 +0100
From: =?ISO-8859-1?Q?Jean-S=E9bastien_P=E9dron?= <jspedron@club-internet.fr>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041006
X-Accept-Language: fr, en-us, en
MIME-Version: 1.0
To: Doug Barton <DougB@freebsd.org>
References: <20041204163103.M787@cp254-91.vpnaapncrgbja.pb.mn>
In-Reply-To: <20041204163103.M787@cp254-91.vpnaapncrgbja.pb.mn>
X-Enigmail-Version: 0.86.1.0
X-Enigmail-Supports: pgp-inline, pgp-mime
Content-Type: multipart/signed; micalg=pgp-sha1;
 protocol="application/pgp-signature";
 boundary="------------enig3A01D74E1A78B7D4415D521F"
cc: Poul-Henning Kamp <phk@phk.freebsd.dk>
cc: freebsd-current@freebsd.org
Subject: Re: panic: Inconsistent vnode bufstrategy
X-BeenThere: freebsd-current@freebsd.org
X-Mailman-Version: 2.1.1
Precedence: list
List-Id: Discussions about the use of FreeBSD-current
	<freebsd-current.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-current>,
	<mailto:freebsd-current-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-current>
List-Post: <mailto:freebsd-current@freebsd.org>
List-Help: <mailto:freebsd-current-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-current>,
	<mailto:freebsd-current-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 06 Dec 2004 16:04:23 -0000

This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig3A01D74E1A78B7D4415D521F
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

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

--------------enig3A01D74E1A78B7D4415D521F
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBtIMea+xGJsFYOlMRAmPkAJ9pTEslqM83G0D/W0avM8OzfKlAawCfelA2
jHLFfpaiW5h2CfadoYhuG1g=
=h6t5
-----END PGP SIGNATURE-----

--------------enig3A01D74E1A78B7D4415D521F--