NetBSD Problem Report #39405

From bouyer@antioche.lip6.fr  Mon Aug 25 16:05:19 2008
Return-Path: <bouyer@antioche.lip6.fr>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 4A46663BC3B
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 25 Aug 2008 16:05:19 +0000 (UTC)
Message-Id: <200808251605.m7PG5FC0013802@armandeche.lip6.fr>
Date: Mon, 25 Aug 2008 18:05:15 +0200 (MEST)
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
Reply-To: bouyer@antioche.lip6.fr
To: gnats-bugs@gnats.NetBSD.org
Subject: ffs snapshot triggers KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp)
X-Send-Pr-Version: 3.95

>Number:         39405
>Category:       kern
>Synopsis:       ffs snapshot triggers KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp)
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    hannken
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 25 16:10:00 +0000 2008
>Closed-Date:    Tue Aug 26 13:06:50 +0000 2008
>Last-Modified:  Tue Aug 26 13:06:50 +0000 2008
>Originator:     bouyer@antioche.lip6.fr
>Release:        NetBSD 4.99.72
>Organization:
>Environment:
System: NetBSD borneo 4.99.72 NetBSD 4.99.72 (XEN3_DOM0) #222: Mon Aug 25 16:54:11 CEST 2008  bouyer@rock:/dsk/l1/misc/bouyer/tmp/amd64/obj/dsk/l1/misc/bouyer/current/src/sys/arch/amd64/compile/XEN3_DOM0 amd64
Architecture: amd64
Machine: amd64
>Description:
	I've found another kernel assertion triggered by ffs snapshots.
	This one occurs when taking a snapshot of /, on a filesystem different
	from /.
	(or more specifically, I suspect a storage different from /dev):

	My system has 3 filesystems (but I've also reproduced it with only 2):
borneo:/home/bouyer#df -hl
Filesystem        Size       Used      Avail %Cap Mounted on
/dev/wd0a          35G        33G       251M  99% /
/dev/wd0g          48M        35M        11M  77% /eboot
/dev/wd0h          71G        37G        30G  55% /domains2


dump -ax/snap -f /dev/null /eboot
	works fine
dump -ax/domains2/snap -f /dev/null /eboot
	works fine too
dump -ax/domains2/snap -f /dev/null /
	gives:
panic: kernel diagnostic assertion "vp == vp->v_specnode->sn_dev->sd_bdevvp" failed: file "/dsk/l1/misc/bouyer/current/src/sys/miscfs/specfs/spec_vnops.c", line 670
fatal breakpoint trap in supervisor mode
trap type 1 code 0 rip ffffffff804b82fd cs e030 rflags 246 cr2  7f7ffdb868b0 cpl 0 rsp ffffa0001b2456a0
Stopped in pid 728.1 (dump) at  netbsd:breakpoint+0x5:  leave
breakpoint() at netbsd:breakpoint+0x5
panic() at netbsd:panic+0x255
__kernassert() at netbsd:__kernassert+0x2d
spec_ioctl() at netbsd:spec_ioctl+0x106
VOP_IOCTL() at netbsd:VOP_IOCTL+0x31
fss_ioctl() at netbsd:fss_ioctl+0x6e3
VOP_IOCTL() at netbsd:VOP_IOCTL+0x31
vn_ioctl() at netbsd:vn_ioctl+0x6d
sys_ioctl() at netbsd:sys_ioctl+0x134
syscall() at netbsd:syscall+0x98


>How-To-Repeat:
	have 2 different ffs mounted, say / and /mnt
	try dump -ax/mnt/snap -f /dev/null  /
>Fix:


>Release-Note:

>Audit-Trail:
From: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
To: gnats-bugs@netbsd.org
Cc: Manuel Bouyer <bouyer@antioche.lip6.fr>
Subject: Re: kern/39405: ffs snapshot triggers KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp)
Date: Tue, 26 Aug 2008 12:33:52 +0200

 On Mon, Aug 25, 2008 at 04:10:00PM +0000, Manuel Bouyer wrote:
 > >Number:         39405
 > >Category:       kern
 > >Synopsis:       ffs snapshot triggers KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp)

 Please try the diff attached ...

 -- 
 Juergen Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig (Germany)

 Index: fss.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/fss.c,v
 retrieving revision 1.51
 diff -p -u -2 -r1.51 fss.c
 --- fss.c	15 Aug 2008 10:31:24 -0000	1.51
 +++ fss.c	26 Aug 2008 10:29:40 -0000
 @@ -537,4 +537,5 @@ fss_create_files(struct fss_softc *sc, s
  {
  	int error, bits, fsbsize;
 +	const struct bdevsw *bdev;
  	struct timespec ts;
  	struct partinfo dpart;
 @@ -609,13 +610,19 @@ fss_create_files(struct fss_softc *sc, s
  	}

 -	error = VOP_IOCTL(nd.ni_vp, DIOCGPART, &dpart, FREAD, l->l_cred);
 -	if (error) {
 -		vrele(nd.ni_vp);
 +	sc->sc_bdev = nd.ni_vp->v_rdev;
 +	vrele(nd.ni_vp);
 +
 +	/*
 +	 * Get the block device size.
 +	 */
 +
 +	bdev = bdevsw_lookup(sc->sc_bdev);
 +	if (bdev == NULL)
 +		return ENXIO;
 +	error = (*bdev->d_ioctl)(sc->sc_bdev, DIOCGPART, &dpart, FREAD, l);
 +	if (error)
  		return error;
 -	}

 -	sc->sc_bdev = nd.ni_vp->v_rdev;
  	*bsize = (off_t)dpart.disklab->d_secsize*dpart.part->p_size;
 -	vrele(nd.ni_vp);

  	/*

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/39405: ffs snapshot triggers KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp)
Date: Tue, 26 Aug 2008 13:12:44 +0200

 On Tue, Aug 26, 2008 at 12:33:52PM +0200, Juergen Hannken-Illjes wrote:
 > On Mon, Aug 25, 2008 at 04:10:00PM +0000, Manuel Bouyer wrote:
 > > >Number:         39405
 > > >Category:       kern
 > > >Synopsis:       ffs snapshot triggers KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp)
 > 
 > Please try the diff attached ...

 This fixes the issue for me, thanks.
 And the good news is that I didn't find new bugs when testing this :)

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --

From: Juergen Hannken-Illjes <hannken@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/39405 CVS commit: src/sys/dev
Date: Tue, 26 Aug 2008 13:04:55 +0000 (UTC)

 Module Name:	src
 Committed By:	hannken
 Date:		Tue Aug 26 13:04:55 UTC 2008

 Modified Files:
 	src/sys/dev: fss.c

 Log Message:
 Use (*bdev->d_ioctl)() to get the size of the block device the file system
 is mounted on.  VOP_IOCTL() without VOP_OPEN() is wrong and we cannot
 open a block device twice.

 Fixes PR #39405


 To generate a diff of this commit:
 cvs rdiff -r1.51 -r1.52 src/sys/dev/fss.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

Responsible-Changed-From-To: kern-bug-people->hannken
Responsible-Changed-By: hannken@NetBSD.org
Responsible-Changed-When: Tue, 26 Aug 2008 13:06:50 +0000
Responsible-Changed-Why:
Take.


State-Changed-From-To: open->closed
State-Changed-By: hannken@NetBSD.org
State-Changed-When: Tue, 26 Aug 2008 13:06:50 +0000
State-Changed-Why:
Fixed in tree.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.