NetBSD Problem Report #54598

From www@netbsd.org  Fri Oct  4 11:36:27 2019
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E26167A17A
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  4 Oct 2019 11:36:27 +0000 (UTC)
Message-Id: <20191004113627.0D3CD7A243@mollari.NetBSD.org>
Date: Fri,  4 Oct 2019 11:36:27 +0000 (UTC)
From: prlw1@cam.ac.uk
Reply-To: prlw1@cam.ac.uk
To: gnats-bugs@NetBSD.org
Subject: mount ntfs panic
X-Send-Pr-Version: www-1.0

>Number:         54598
>Category:       kern
>Synopsis:       mount ntfs panic
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 04 11:40:00 +0000 2019
>Closed-Date:    Tue Nov 05 11:26:08 +0000 2019
>Last-Modified:  Tue Nov 05 11:26:08 +0000 2019
>Originator:     Patrick Welche
>Release:        NetBSD-9.99.15/i386
>Organization:
>Environment:
>Description:
Netbooted a working windows 2000 computer containing a ST380011A.

# disklabel -t wd0
wd0|Automatically generated label:\
        :dt=ESDI:se#512:ns#63:nt#16:sc#1008:nc#155061:\
        :pd#156301488:od#0:\
        :pe#156296322:oe#63:te=NTFS:
disklabel: boot block size 0
disklabel: super block size 0
# mount -t ntfs /dev/wd0e /mnt
[ 311.1069241] ntfs_procfixups: fixup 2 doesn't match
[ 311.1707160] ntfs_loadntnode: BAD MFT RECORD 0
[ 311.2227115] ntfs_loadvnode: CAN'T LOAD ATTRIBUTES FOR INO: 0
[ 311.2903117] panic: kernel diagnostic assertion "fstrans_is_owner(mp)" failed: file "/usr/src/sys/kern/vfs_vnode.c", line 495 
[ 311.4234314] cpu0: Begin traceback...
[ 311.4681513] vpanic(c1071fd0,db094bd8,db094bfc,c09a14fd,c1071fd0,c1071f37,c113746f,c11372ef,1ef,1) at netbsd:vpanic+0x12d
[ 311.5981511] kern_assert(c1071fd0,c1071f37,c113746f,c11372ef,1ef,1,c2dc28c4,c2dc25a4,16,c2dbb2ac) at netbsd:kern_assert+0x23
[ 311.7302771] vrele_flush(c2dc5008,c2dc502c,490,f1086b46,c2dc5008,d,c2dc5008,db094c5c,3,c2dc5008) at netbsd:vrele_flush+0x31d
[ 311.8672308] vflush(c2dc5008,0,0,c2dbb280,0,db094d08,0,c2cc4400,db094d20,c092afa0) at netbsd:vflush+0x21
[ 311.9789408] ntfs_mountfs(c2cc4400,3,fffffffe,0,c10e1381,c2dc5008,c2cc4400,0,3,c2dc25a4) at netbsd:ntfs_mountfs+0x3c1
[ 312.1073217] ntfs_mount(c2dc5008,bfb240d0,c2cd6570,db094f30,c2dc2734,db094e94,c09925e1,c2dc5008,bfb240d0,c2cd6570) at netbsd:ntfs_mount+0x1df
[ 312.2579464] VFS_MOUNT(c2dc5008,bfb240d0,c2cd6570,db094f30,0,c2cd6570,0,c2cd6568,c2dc5d0c,80) at netbsd:VFS_MOUNT+0x39
[ 312.3874609] mount_domount(c2cc4400,db094ed8,c1369e40,bfb240d0,0,c2cd6570,db094f30,0,41ed,c1369e40) at netbsd:mount_domount+0xc9
[ 312.5274927] do_sys_mount(c2cc4400,5b64e2,0,bfb240d0,0,bfb23c50,0,80,db094f60,db094f9c) at netbsd:do_sys_mount+0x26e
[ 312.6487069] sys___mount50(c2cc4400,db094f68,db094f60,3f16a000,3,db094f60,19a,db094f68,0,0) at netbsd:sys___mount50+0x4d
[ 312.7782323] syscall() at netbsd:syscall+0x151
[ 312.8331572] --- syscall (number 410) ---
[ 312.8820391] aec93477:
[ 312.9090780] cpu0: End traceback...
[ 312.9496379] fatal breakpoint trap in supervisor mode
[ 313.0089184] trap type 1 code 0 eip 0xc0115c44 cs 0x8 eflags 0x202 cr2 0xaecadee9 ilevel 0 esp 0xdb094bbc
[ 313.1222803] curlwp 0xc2cc4400 pid 17 lid 1 lowest kstack 0xdb0922c0
Stopped in pid 17.1 (mount_ntfs) at     netbsd:breakpoint+0x4:  popl    %ebp

>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: Patrick Welche <prlw1@cam.ac.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Thu, 3 Oct 2019 21:51:27 +0100

 Just netbooted NetBSD 7.2 from the sets at

   https://cdn.netbsd.org/pub/NetBSD/NetBSD-7.2/i386/binary/sets/

 and successfully mounted the disk, so this is a regression.

From: "J. Hannken-Illjes" <hannken@eis.cs.tu-bs.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Fri, 4 Oct 2019 17:20:07 +0200

 --Apple-Mail=_8FD0C879-2369-4401-AC1C-B4A82072F6F7
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii


 > Just netbooted NetBSD 7.2 from the sets at
 > 
 >   https://cdn.netbsd.org/pub/NetBSD/NetBSD-7.2/i386/binary/sets/
 > 
 > and successfully mounted the disk, so this is a regression.

 Did you get the errors preceding the panic (fixup 2, BAD MFT, ...)
 from 7.2 too?

 --
 J. Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig

 --Apple-Mail=_8FD0C879-2369-4401-AC1C-B4A82072F6F7
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP

 -----BEGIN PGP SIGNATURE-----

 iQEzBAEBCAAdFiEE2BL3ha7Xao4WUZVYKoaVJdNr+uEFAl2XYycACgkQKoaVJdNr
 +uEJNgf6A2LQ3VGpz0M8gkvQBwcjeWL66IpP4qWUAp7BsQnOZ32bD+56wIAgI0SS
 kuBceOm1wSSOeYvGFcsn/rj4VKbwRhxNLlQNnVd5biGSzb8qd55vAeu7C5eJDO0v
 s0JQWSDA8RPpJDVYeDi+fo8slRepMD07jELOIyUR1ej3Ij36vwdSLr1F4BVmh1Qt
 WSS2JPf7j8jWfDHBvivndGzdZtl2LPAhsnujfIrhiFJ7Ftf33eWkYrc3oXKAapG0
 o1yvUV3wul3tdEZ3s+8niI+MmQ3ffMu6j/8SGvCxUV4XJPnBAuGznvb9rD968wYX
 a2XYMLWGvVupu3ShsryWvfrFDobd9w==
 =aGwl
 -----END PGP SIGNATURE-----

 --Apple-Mail=_8FD0C879-2369-4401-AC1C-B4A82072F6F7--

From: Patrick Welche <prlw1@cam.ac.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Fri, 4 Oct 2019 01:15:23 +0100

 On Fri, Oct 04, 2019 at 03:25:01PM +0000, J. Hannken-Illjes wrote:
 >  Did you get the errors preceding the panic (fixup 2, BAD MFT, ...)
 >  from 7.2 too?

 No - nothing in dmesg.

From: Patrick Welche <prlw1@cam.ac.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Fri, 4 Oct 2019 01:20:20 +0100

 It finished uploading

From: "J. Hannken-Illjes" <hannken@eis.cs.tu-bs.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Fri, 4 Oct 2019 17:56:59 +0200

 --Apple-Mail=_F2855E5F-8EC8-4791-A134-87AA0D9D0BC4
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii

 > On 4. Oct 2019, at 17:50, Patrick Welche <prlw1@cam.ac.uk> wrote:
 > On Fri, Oct 04, 2019 at 03:25:01PM +0000, J. Hannken-Illjes wrote:
 >> Did you get the errors preceding the panic (fixup 2, BAD MFT, ...)
 >> from 7.2 too?
 > 
 > No - nothing in dmesg.

 So this is the real problem.  The vflush() in the error path
 is just wrong and must be removed.

 --
 J. Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig

 --Apple-Mail=_F2855E5F-8EC8-4791-A134-87AA0D9D0BC4
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP

 -----BEGIN PGP SIGNATURE-----

 iQEzBAEBCAAdFiEE2BL3ha7Xao4WUZVYKoaVJdNr+uEFAl2Xa8sACgkQKoaVJdNr
 +uGnEAf+O8sRZZ9A6xZuwG+Pstqb65cuA4LosVxdBieAOX888unjg8OKlO1HoX/e
 gn1UvEgoG0Iu7n5Pf4ahEeWNVDjCbXIbAcZlBqL04Sj1sE0AKQvLk2WPVxsl0cNQ
 vaM4JWh9KXikR+LawynocA1ewQFyEIefyEOGpASXuLWBVjgkUCLXUF3lpmnVGIk1
 Ct5eLgrBsokRYOwfY/+Gu5k6WwUHcaw2WjRQLmUSHJjR2VxHGtubMVhxl7uxWAGv
 jQfWg892N/5JLQ2Q4zPR0hmavLprSu3BbMrVHmwCvdxsVceTDuLrhPQnRfAF9uz2
 5rwxdzyZV7Si3+pTnu5EIM804dz6rg==
 =oGss
 -----END PGP SIGNATURE-----

 --Apple-Mail=_F2855E5F-8EC8-4791-A134-87AA0D9D0BC4--

From: Patrick Welche <prlw1@cam.ac.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Fri, 4 Oct 2019 01:44:15 +0100

 On Fri, Oct 04, 2019 at 04:00:02PM +0000, J. Hannken-Illjes wrote:
 >  > On 4. Oct 2019, at 17:50, Patrick Welche <prlw1@cam.ac.uk> wrote:
 >  > On Fri, Oct 04, 2019 at 03:25:01PM +0000, J. Hannken-Illjes wrote:
 >  >> Did you get the errors preceding the panic (fixup 2, BAD MFT, ...)
 >  >> from 7.2 too?
 >  > 
 >  > No - nothing in dmesg.
 >  
 >  So this is the real problem.  The vflush() in the error path
 >  is just wrong and must be removed.

 One more data point

 8.1_STABLE from

 http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-8/201910021700Z/i386/binary/sets

 gives

 ntfs_procfixups: fixup 2 doesn't match
 ntfs_loadntnode: BAD MFT RECORD 0
 ntfs_loadvnode: CAN'T LOAD ATTRIBUTES FOR INO: 0

 in dmesg, refuses to mount, but doesn't panic.

 (7 successfully mounts - about to try 9)

From: Patrick Welche <prlw1@cam.ac.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Fri, 4 Oct 2019 01:49:27 +0100

 9.0_BETA from

 http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-9/201910030600Z/i386/binary/sets
 /

 gives the dmesg messages and panics as per my original report.

From: "J. Hannken-Illjes" <hannken@eis.cs.tu-bs.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Sat, 5 Oct 2019 10:13:13 +0200

 --Apple-Mail=_11C7EA4D-AF70-4907-A182-73FD01DD36B8
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii

 Looks like it is one of these commits:

 https://mail-index.netbsd.org/source-changes/2014/11/13/msg060490.html
 https://mail-index.netbsd.org/source-changes/2014/11/13/msg060491.html
 https://mail-index.netbsd.org/source-changes/2014/11/13/msg060492.html

 Unfortunately my ntfs images used for testing still work so it
 would be nice if you could test after each commit ...

 --
 J. Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig

 --Apple-Mail=_11C7EA4D-AF70-4907-A182-73FD01DD36B8
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP

 -----BEGIN PGP SIGNATURE-----

 iQEzBAEBCAAdFiEE2BL3ha7Xao4WUZVYKoaVJdNr+uEFAl2YUJkACgkQKoaVJdNr
 +uG/fQf/VVerQaQvLwPlVJvcTK9tB+4my/O75emHjt5soSK2/O0uRaUHkaDpW3Wq
 lgUR+/hXzshls1lYuPc2LbcAM4K7SilwYlbnZcAFCMTwM5Ge2w5Ca3EhU67D28fb
 Cz24Uavzya0EyhHj159dxVGF/Sk8ycvrJVhys8R/QEXNYWAxhEce8f1CgmX0rI5B
 WV/dlGf8vNQIRhRnqKqdoP6n51B6NL9X0dPsXvTiI6P2zTHoIQ+TFgOk7pFvFJ6T
 iI5SAor9iYKF2yGA9ckeY7C5aMrfJV05YEUsY2ajxARDCHDvsoBbQvzMK62tKnZa
 76AidBJE8eo/He+l5XAZ4V6i5GEdUw==
 =lkTU
 -----END PGP SIGNATURE-----

 --Apple-Mail=_11C7EA4D-AF70-4907-A182-73FD01DD36B8--

From: Patrick Welche <prlw1@cam.ac.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Tue, 8 Oct 2019 15:33:09 +0100

 On Sat, Oct 05, 2019 at 08:15:01AM +0000, J. Hannken-Illjes wrote:
 >  Looks like it is one of these commits:
 >  
 >  https://mail-index.netbsd.org/source-changes/2014/11/13/msg060490.html
 >  https://mail-index.netbsd.org/source-changes/2014/11/13/msg060491.html
 >  https://mail-index.netbsd.org/source-changes/2014/11/13/msg060492.html

 It appears to already be the first one. (no panics though)

 # ident /netbsd_94 | grep ntfs_vfsops.c
      $NetBSD: ntfs_vfsops.c,v 1.94 2014/04/16 18:55:18 maxv Exp $
 # mount /dev/wd0e /mnt
 # ls /mnt
 $AttrDef
 $BadClus
 $Bitmap
 ...
 # ident /netbsd_95 | grep ntfs_vfsops.c
      $NetBSD: ntfs_vfsops.c,v 1.95 2014/11/13 16:49:56 hannken Exp $
 swan# mount /dev/wd0e /mnt
 ntfs_procfixups: fixup 2 doesn't match
 ntfs_loadntnode: BAD MFT RECORD 0
 ntfs_vget: CAN'T LOAD ATTRIBUTES FOR INO: 0
 mount_ntfs: /dev/wd0e on /mnt: Invalid argument
 # ls /mnt
 #

From: "J. Hannken-Illjes" <hannken@eis.cs.tu-bs.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Tue, 8 Oct 2019 17:27:45 +0200

 --Apple-Mail=_A9636ED6-63D7-470E-8BD2-92E659ED4D07
 Content-Type: multipart/mixed;
 	boundary="Apple-Mail=_85111805-9127-466E-A614-995DB4BC4CA3"


 --Apple-Mail=_85111805-9127-466E-A614-995DB4BC4CA3
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii

 > On 8. Oct 2019, at 16:35, Patrick Welche <prlw1@cam.ac.uk> wrote:
 <snip>
 > 
 > It appears to already be the first one. (no panics though)

 Part of ntfs_subr.c Rev. 1.52 looks suspect.  Please try
 after the first commit with the attached diff reversed.

 --
 J. Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig


 --Apple-Mail=_85111805-9127-466E-A614-995DB4BC4CA3
 Content-Disposition: attachment;
 	filename=ntfs_subr.c.diff
 Content-Type: application/octet-stream;
 	x-unix-mode=0644;
 	name="ntfs_subr.c.diff"
 Content-Transfer-Encoding: 7bit

 --- ntfs_subr.c	28 Jun 2013 17:13:34 -0000	1.51
 +++ ntfs_subr.c	13 Nov 2014 16:49:56 -0000	1.52
 @@ -275,5 +275,4 @@ ntfs_loadntnode(
  {
  	struct filerec  *mfrp;
 -	daddr_t         bn;
  	int		error,off;
  	struct attr    *ap;
 @@ -287,12 +286,19 @@ ntfs_loadntnode(
  	if (ip->i_number < NTFS_SYSNODESNUM) {
  		struct buf     *bp;
 +		daddr_t         bn;
 +		off_t           boff;

  		dprintf(("%s: read system node\n", __func__));

 -		bn = ntfs_cntobn(ntmp->ntm_mftcn) +
 -			ntmp->ntm_bpmftrec * ip->i_number;
 +		/*
 +		 * Make sure we always read full cluster to
 +		 * prevent buffer cache inconsistency.
 +		 */
 +		boff = ntfs_cntob(ntmp->ntm_mftcn) +
 +		    ntfs_bntob(ntmp->ntm_bpmftrec) * ip->i_number;
 +		bn = ntfs_cntobn(ntfs_btocn(boff));
 +		off = ntfs_btocnoff(boff);

 -		error = bread(ntmp->ntm_devvp,
 -			      bn, ntfs_bntob(ntmp->ntm_bpmftrec),
 +		error = bread(ntmp->ntm_devvp, bn, ntfs_cntob(1),
  			      NOCRED, 0, &bp);
  		if (error) {
 @@ -300,5 +306,6 @@ ntfs_loadntnode(
  			goto out;
  		}
 -		memcpy(mfrp, bp->b_data, ntfs_bntob(ntmp->ntm_bpmftrec));
 +		memcpy(mfrp, (char *)bp->b_data + off,
 +		    ntfs_bntob(ntmp->ntm_bpmftrec));
  		bqrelse(bp);
  	} else {

 --Apple-Mail=_85111805-9127-466E-A614-995DB4BC4CA3--

 --Apple-Mail=_A9636ED6-63D7-470E-8BD2-92E659ED4D07
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP

 -----BEGIN PGP SIGNATURE-----

 iQEzBAEBCAAdFiEE2BL3ha7Xao4WUZVYKoaVJdNr+uEFAl2cqvEACgkQKoaVJdNr
 +uE4Ngf/fRVcRrbuLZnlEUGFV3SONdDEPz07+Z4AK5AKKFe+sbJQd20cw1RyqJLu
 WzFiJE+45Si4JDeARQtGVbuf/Ix3GNS+/5tT1MBYIwTNKUvqXX9EFRDUjCRNHz/m
 mMPjjKE1s9Sfd5XQXBjj3/Symahxb+Q59QkNUo/FDEMO2kNFu5E0kH0qlPU878xj
 7qbTf50s3sXuPqHWLXL86bGCPGrJC/RmYY4wMb9jq6zp29wEnMfNDEabSte+LJ68
 9nAsGwctvNK4eHW1aNIO0VOycd4L88rKTIN6EDvjpHG2Utq/MT5TtNEwUY/h5RAl
 fBpRAylSfgwuSXa6q37ht2V6O/HV2A==
 =miP4
 -----END PGP SIGNATURE-----

 --Apple-Mail=_A9636ED6-63D7-470E-8BD2-92E659ED4D07--

From: Patrick Welche <prlw1@cam.ac.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Tue, 8 Oct 2019 17:19:46 +0100

 On Tue, Oct 08, 2019 at 03:30:02PM +0000, J. Hannken-Illjes wrote:
 >  Part of ntfs_subr.c Rev. 1.52 looks suspect.  Please try
 >  after the first commit with the attached diff reversed.

 Yes, that did the trick!

From: "J. Hannken-Illjes" <hannken@eis.cs.tu-bs.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Sun, 13 Oct 2019 10:46:00 +0200

 --Apple-Mail=_7736D1A9-8622-4179-A730-149A3CFDCA9A
 Content-Type: multipart/mixed;
 	boundary="Apple-Mail=_781B5E70-6FB5-424C-BC70-36ED85885172"


 --Apple-Mail=_781B5E70-6FB5-424C-BC70-36ED85885172
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii

 Please try the attached diff.  It should fix this PR.

 --
 J. Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig

 --Apple-Mail=_781B5E70-6FB5-424C-BC70-36ED85885172
 Content-Disposition: attachment;
 	filename=ntfs.diff
 Content-Type: application/octet-stream;
 	x-unix-mode=0644;
 	name="ntfs.diff"
 Content-Transfer-Encoding: 7bit

 ntfs_vflush

 It is not possible to call vflush() from xxx_mount().

 Replace with a vnode iterator and use vrecycle().

 diff -r 42546c91626f -r 04476c96f69d sys/fs/ntfs/ntfs_vfsops.c
 --- sys/fs/ntfs/ntfs_vfsops.c
 +++ sys/fs/ntfs/ntfs_vfsops.c
 @@ -322,6 +322,7 @@ ntfs_mountfs(struct vnode *devvp, struct
  	dev_t dev = devvp->v_rdev;
  	int error, i;
  	struct vnode *vp;
 +	struct vnode_iterator *marker;

  	ntmp = NULL;

 @@ -471,9 +472,13 @@ out1:
  		if (ntmp->ntm_sysvn[i])
  			vrele(ntmp->ntm_sysvn[i]);

 -	if (vflush(mp, NULLVP, 0)) {
 -		dprintf(("ntfs_mountfs: vflush failed\n"));
 +	vfs_vnode_iterator_init(mp, &marker);
 +	while ((vp = vfs_vnode_iterator_next(marker, NULL, NULL))) {
 +		if (vrecycle(vp))
 +			continue;
 +		panic("%s: cannot recycle vnode %p", __func__, vp);
  	}
 +	vfs_vnode_iterator_destroy(marker);
  out:
  	spec_node_setmountedfs(devvp, NULL);
  	if (bp)

 ntfs_loadntnode

 When the MFT record size is lower than the cluster size we have
 to read consecutive clusters to fill the MFT record.

 Should fix PR kern/54598: mount ntfs panic

 diff -r eef88ca51266 -r 4fe2b5ac31e9 sys/fs/ntfs/ntfs_subr.c
 --- sys/fs/ntfs/ntfs_subr.c
 +++ sys/fs/ntfs/ntfs_subr.c
 @@ -271,6 +271,8 @@ ntfs_loadntnode(struct ntfsmount *ntmp, 
  		struct buf *bp;
  		daddr_t bn;
  		off_t boff;
 +		size_t resid, l;
 +		char *data;

  		dprintf(("%s: read system node\n", __func__));

 @@ -281,17 +283,26 @@ ntfs_loadntnode(struct ntfsmount *ntmp, 
  		boff = ntfs_cntob(ntmp->ntm_mftcn) +
  		    ntfs_bntob(ntmp->ntm_bpmftrec) * ip->i_number;
  		bn = ntfs_cntobn(ntfs_btocn(boff));
 -		off = ntfs_btocnoff(boff);
 +		boff = ntfs_btocnoff(boff);
 +		resid = ntfs_bntob(ntmp->ntm_bpmftrec);
 +		data = (char *)mfrp;
 +		while (resid > 0) {
 +			l = MIN(resid, ntfs_cntob(1) - boff);

 -		error = bread(ntmp->ntm_devvp, bn, ntfs_cntob(1),
 -		    0, &bp);
 -		if (error) {
 -			printf("%s: BREAD FAILED\n", __func__);
 -			goto out;
 +			error = bread(ntmp->ntm_devvp, bn, ntfs_cntob(1),
 +			    0, &bp);
 +			if (error) {
 +				printf("%s: BREAD FAILED\n", __func__);
 +				goto out;
 +			}
 +			memcpy(data, (char *)bp->b_data + boff, l);
 +			bqrelse(bp);
 +
 +			bn += ntfs_cntobn(1);
 +			boff = 0;
 +			data += l;
 +			resid -= l;
  		}
 -		memcpy(mfrp, (char *)bp->b_data + off,
 -		    ntfs_bntob(ntmp->ntm_bpmftrec));
 -		bqrelse(bp);
  	} else {
  		struct vnode   *vp;


 --Apple-Mail=_781B5E70-6FB5-424C-BC70-36ED85885172--

 --Apple-Mail=_7736D1A9-8622-4179-A730-149A3CFDCA9A
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP

 -----BEGIN PGP SIGNATURE-----

 iQEzBAEBCAAdFiEE2BL3ha7Xao4WUZVYKoaVJdNr+uEFAl2i5EgACgkQKoaVJdNr
 +uGdCgf/dQwJBGexAQKj4XME/g/lCL08uD7KgrPtqT/8lgjnU10FEmo18BxALwc5
 fxFDpxC82xzNZQgMlUwm0ZPnhd3LL7gjUAmMqzUsHIAIEI4HNIlWx1Gz3g22iDTB
 RM+ZDOlp5TPbPPaFCinKN8QJmzPcGB1wexH+FZJXnQkM5nVLlHCErxQDjvwlIdFy
 4QbnnnOoX8KBKvGB3hceInj2XXDJ9JehMvLqTibBUxBRu/+3HnWd1NrW9IWx/RTk
 /TSKfq2FN4rhT1daemDP9XNHjvZr8YLcELvH+fMrtur8iuO5skOK45w5sYXk1V3f
 OHTeo+7UOOuW4ob79j9exSWyiWhjNA==
 =T1AV
 -----END PGP SIGNATURE-----

 --Apple-Mail=_7736D1A9-8622-4179-A730-149A3CFDCA9A--

From: Patrick Welche <prlw1@cam.ac.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54598: mount ntfs panic
Date: Thu, 17 Oct 2019 16:52:01 +0100

 Presumably, as you predicted, just adding the ntfs_vfsops.c prevents
 the panic, and keeps the

  ntfs_procfixups: fixup 2 doesn't match
  ntfs_loadntnode: BAD MFT RECORD 0
  ntfs_loadvnode: CAN'T LOAD ATTRIBUTES FOR INO: 0
  mount_ntfs: /dev/wd0e on /mnt: Invalid argument

 and in addition, adding the ntfs_subr.c patch
 allows a successful mount, and everything works!

From: "Juergen Hannken-Illjes" <hannken@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54598 CVS commit: src/sys/fs/ntfs
Date: Fri, 18 Oct 2019 08:19:33 +0000

 Module Name:	src
 Committed By:	hannken
 Date:		Fri Oct 18 08:19:33 UTC 2019

 Modified Files:
 	src/sys/fs/ntfs: ntfs_subr.c

 Log Message:
 When the MFT record size is lower than the cluster size we have
 to read consecutive clusters to fill the MFT record.

 Should fix PR kern/54598: mount ntfs panic


 To generate a diff of this commit:
 cvs rdiff -u -r1.61 -r1.62 src/sys/fs/ntfs/ntfs_subr.c

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

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54598 CVS commit: [netbsd-8] src/sys/fs/ntfs
Date: Mon, 21 Oct 2019 17:01:57 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Oct 21 17:01:57 UTC 2019

 Modified Files:
 	src/sys/fs/ntfs [netbsd-8]: ntfs_subr.c ntfs_vfsops.c

 Log Message:
 Pull up following revision(s) (requested by hannken in ticket #1410):

 	sys/fs/ntfs/ntfs_vfsops.c: revision 1.108
 	sys/fs/ntfs/ntfs_subr.c: revision 1.62

 It is not possible to call vflush() from xxx_mount().
 Replace with a vnode iterator and use vrecycle().

  -

 When the MFT record size is lower than the cluster size we have
 to read consecutive clusters to fill the MFT record.
 Should fix PR kern/54598: mount ntfs panic


 To generate a diff of this commit:
 cvs rdiff -u -r1.61 -r1.61.10.1 src/sys/fs/ntfs/ntfs_subr.c
 cvs rdiff -u -r1.107 -r1.107.4.1 src/sys/fs/ntfs/ntfs_vfsops.c

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

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54598 CVS commit: [netbsd-9] src/sys/fs/ntfs
Date: Mon, 21 Oct 2019 20:15:03 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Oct 21 20:15:03 UTC 2019

 Modified Files:
 	src/sys/fs/ntfs [netbsd-9]: ntfs_subr.c ntfs_vfsops.c

 Log Message:
 Pull up following revision(s) (requested by hannken in ticket #354):

 	sys/fs/ntfs/ntfs_vfsops.c: revision 1.108
 	sys/fs/ntfs/ntfs_subr.c: revision 1.62

 It is not possible to call vflush() from xxx_mount().
 Replace with a vnode iterator and use vrecycle().

  -

 When the MFT record size is lower than the cluster size we have
 to read consecutive clusters to fill the MFT record.
 Should fix PR kern/54598: mount ntfs panic


 To generate a diff of this commit:
 cvs rdiff -u -r1.61 -r1.61.22.1 src/sys/fs/ntfs/ntfs_subr.c
 cvs rdiff -u -r1.107 -r1.107.16.1 src/sys/fs/ntfs/ntfs_vfsops.c

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

State-Changed-From-To: open->closed
State-Changed-By: prlw1@NetBSD.org
State-Changed-When: Tue, 05 Nov 2019 11:26:08 +0000
State-Changed-Why:
Bug fixed, and fix pulled up to NetBSD 8 and 9 - thank you hannken@!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.