From e1c6cbef33526d8432d154da9f1789de587e43c3 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Wed, 3 Nov 2004 21:36:41 +0000 Subject: [PATCH] Make a more whole-hearted attempt at GEOM'ifying NTFS. I must have been sleepy when I did the first pass. Spotted by: tegge --- sys/fs/ntfs/ntfs.h | 3 ++- sys/fs/ntfs/ntfs_subr.c | 4 ++-- sys/fs/ntfs/ntfs_vfsops.c | 23 +++++++++++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/sys/fs/ntfs/ntfs.h b/sys/fs/ntfs/ntfs.h index 1940ee9deea0..05560b12433b 100644 --- a/sys/fs/ntfs/ntfs.h +++ b/sys/fs/ntfs/ntfs.h @@ -241,7 +241,8 @@ struct bootfile { struct ntfsmount { struct mount *ntm_mountp; /* filesystem vfs structure */ struct bootfile ntm_bootfile; - struct cdev *ntm_dev; /* device mounted */ + struct g_consumer *ntm_cp; + struct bufobj *ntm_bo; struct vnode *ntm_devvp; /* block device mounted vnode */ struct vnode *ntm_sysvn[NTFS_SYSNODESNUM]; u_int32_t ntm_bpmftrec; diff --git a/sys/fs/ntfs/ntfs_subr.c b/sys/fs/ntfs/ntfs_subr.c index 0b2b53e8b795..1ca9ffaa423a 100644 --- a/sys/fs/ntfs/ntfs_subr.c +++ b/sys/fs/ntfs/ntfs_subr.c @@ -382,7 +382,8 @@ ntfs_ntlookup( dprintf(("ntfs_ntlookup: looking for ntnode %d\n", ino)); do { - if ((ip = ntfs_nthashlookup(ntmp->ntm_dev, ino)) != NULL) { + ip = ntfs_nthashlookup(ntmp->ntm_devvp->v_rdev, ino); + if (ip != NULL) { ntfs_ntget(ip); dprintf(("ntfs_ntlookup: ntnode %d: %p, usecount: %d\n", ino, ip, ip->i_usecount)); @@ -398,7 +399,6 @@ ntfs_ntlookup( /* Generic initialization */ ip->i_devvp = ntmp->ntm_devvp; - ip->i_dev = ntmp->ntm_dev; ip->i_number = ino; ip->i_mp = ntmp; diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c index 4b260cc07164..a1f5347721a6 100644 --- a/sys/fs/ntfs/ntfs_vfsops.c +++ b/sys/fs/ntfs/ntfs_vfsops.c @@ -43,6 +43,9 @@ #include #include +#include +#include + #include #include #include @@ -277,10 +280,15 @@ ntfs_mountfs(devvp, mp, argsp, td) struct cdev *dev = devvp->v_rdev; int error, ronly, i; struct vnode *vp; + struct g_consumer *cp; ronly = (mp->mnt_flag & MNT_RDONLY) != 0; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); - error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td, -1); + DROP_GIANT(); + g_topology_lock(); + error = g_vfs_open(devvp, &cp, "ffs", ronly ? 0 : 1); + g_topology_unlock(); + PICKUP_GIANT(); VOP_UNLOCK(devvp, 0, td); if (error) return (error); @@ -323,12 +331,13 @@ ntfs_mountfs(devvp, mp, argsp, td) (u_int32_t)ntmp->ntm_mftcn,(u_int32_t)ntmp->ntm_mftmirrcn)); ntmp->ntm_mountp = mp; - ntmp->ntm_dev = dev; ntmp->ntm_devvp = devvp; ntmp->ntm_uid = argsp->uid; ntmp->ntm_gid = argsp->gid; ntmp->ntm_mode = argsp->mode; ntmp->ntm_flag = argsp->flag; + ntmp->ntm_cp = cp; + ntmp->ntm_bo = &devvp->v_bufobj; /* Copy in the 8-bit to Unicode conversion table */ /* Initialize Unicode to 8-bit table from 8toU table */ @@ -456,7 +465,7 @@ ntfs_unmount( struct thread *td) { struct ntfsmount *ntmp; - int error, ronly, flags, i; + int error, flags, i; dprintf(("ntfs_unmount: unmounting...\n")); ntmp = VFSTONTFS(mp); @@ -488,9 +497,11 @@ ntfs_unmount( vinvalbuf(ntmp->ntm_devvp, V_SAVE, NOCRED, td, 0, 0); - ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE, - NOCRED, td); + DROP_GIANT(); + g_topology_lock(); + g_wither_geom_close(ntmp->ntm_cp->geom, ENXIO); + g_topology_unlock(); + PICKUP_GIANT(); vrele(ntmp->ntm_devvp);