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.
Modified files: Index: src/sys/fs/ntfs/ntfs_subr.c diff -u src/sys/fs/ntfs/ntfs_subr.c:1.61 src/sys/fs/ntfs/ntfs_subr.c:1.61.10.1 --- src/sys/fs/ntfs/ntfs_subr.c:1.61 Sat Mar 28 19:24:05 2015 +++ src/sys/fs/ntfs/ntfs_subr.c Mon Oct 21 17:01:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ntfs_subr.c,v 1.61 2015/03/28 19:24:05 maxv Exp $ */ +/* $NetBSD: ntfs_subr.c,v 1.61.10.1 2019/10/21 17:01:57 martin Exp $ */ /*- * Copyright (c) 1998, 1999 Semen Ustimenko (sem...@freebsd.org) @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.61 2015/03/28 19:24:05 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.61.10.1 2019/10/21 17:01:57 martin Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -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; + } + memcpy(data, (char *)bp->b_data + boff, l); + bqrelse(bp); - error = bread(ntmp->ntm_devvp, bn, ntfs_cntob(1), - 0, &bp); - if (error) { - printf("%s: BREAD FAILED\n", __func__); - goto out; + 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; Index: src/sys/fs/ntfs/ntfs_vfsops.c diff -u src/sys/fs/ntfs/ntfs_vfsops.c:1.107 src/sys/fs/ntfs/ntfs_vfsops.c:1.107.4.1 --- src/sys/fs/ntfs/ntfs_vfsops.c:1.107 Mon Apr 17 08:32:00 2017 +++ src/sys/fs/ntfs/ntfs_vfsops.c Mon Oct 21 17:01:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ntfs_vfsops.c,v 1.107 2017/04/17 08:32:00 hannken Exp $ */ +/* $NetBSD: ntfs_vfsops.c,v 1.107.4.1 2019/10/21 17:01:57 martin Exp $ */ /*- * Copyright (c) 1998, 1999 Semen Ustimenko @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.107 2017/04/17 08:32:00 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.107.4.1 2019/10/21 17:01:57 martin Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -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)