diff options
author | kib <kib@FreeBSD.org> | 2016-10-01 09:19:43 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2016-10-01 09:19:43 +0000 |
commit | c83481c3142b3f842f75e35f0359ab1e4a918a1c (patch) | |
tree | 65d15e03e0d26f9bad6be5514272c0efe1e8e4cf | |
parent | 5513c4602acb9d1e5d22c58e867ae3714c2ee127 (diff) | |
download | FreeBSD-src-c83481c3142b3f842f75e35f0359ab1e4a918a1c.zip FreeBSD-src-c83481c3142b3f842f75e35f0359ab1e4a918a1c.tar.gz |
MFC r305902:
Reduce size of ufs inode.
MFC r305903:
Fix libprocstat build after r305902.
-rw-r--r-- | lib/libprocstat/common_kvm.c | 9 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 119 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_balloc.c | 12 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 38 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_rawread.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_snapshot.c | 64 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_softdep.c | 335 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_subr.c | 4 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 13 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vnops.c | 19 | ||||
-rw-r--r-- | sys/ufs/ufs/extattr.h | 4 | ||||
-rw-r--r-- | sys/ufs/ufs/inode.h | 94 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_acl.c | 6 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_bmap.c | 4 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_gjournal.c | 8 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_inode.c | 5 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_quota.c | 27 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 21 | ||||
-rw-r--r-- | sys/ufs/ufs/ufsmount.h | 4 |
19 files changed, 426 insertions, 366 deletions
diff --git a/lib/libprocstat/common_kvm.c b/lib/libprocstat/common_kvm.c index be05980..4ca2514 100644 --- a/lib/libprocstat/common_kvm.c +++ b/lib/libprocstat/common_kvm.c @@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$"); #include <sys/mount.h> #include <ufs/ufs/quota.h> #include <ufs/ufs/inode.h> +#include <ufs/ufs/extattr.h> +#include <ufs/ufs/ufsmount.h> #include <fs/devfs/devfs.h> #include <fs/devfs/devfs_int.h> #undef _KERNEL @@ -88,17 +90,22 @@ int ufs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn) { struct inode inode; + struct ufsmount um; if (!kvm_read_all(kd, (unsigned long)VTOI(vp), &inode, sizeof(inode))) { warnx("can't read inode at %p", (void *)VTOI(vp)); return (1); } + if (!kvm_read_all(kd, (unsigned long)inode.i_ump, &um, sizeof(um))) { + warnx("can't read ufsmount at %p", (void *)inode.i_ump); + return (1); + } /* * The st_dev from stat(2) is a dev_t. These kernel structures * contain cdev pointers. We need to convert to dev_t to make * comparisons */ - vn->vn_fsid = dev2udev(kd, inode.i_dev); + vn->vn_fsid = dev2udev(kd, um.um_dev); vn->vn_fileid = inode.i_number; vn->vn_mode = (mode_t)inode.i_mode; vn->vn_size = inode.i_size; diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 0e4dc03..6babbdf 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -163,13 +163,13 @@ ffs_alloc(ip, lbn, bpref, size, flags, cred, bnp) #endif *bnp = 0; - fs = ip->i_fs; - ump = ip->i_ump; + ump = ITOUMP(ip); + fs = ump->um_fs; mtx_assert(UFS_MTX(ump), MA_OWNED); #ifdef INVARIANTS if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) { printf("dev = %s, bsize = %ld, size = %d, fs = %s\n", - devtoname(ip->i_dev), (long)fs->fs_bsize, size, + devtoname(ump->um_dev), (long)fs->fs_bsize, size, fs->fs_fsmnt); panic("ffs_alloc: bad size"); } @@ -260,9 +260,9 @@ ffs_realloccg(ip, lbprev, bprev, bpref, osize, nsize, flags, cred, bpp) int64_t delta; vp = ITOV(ip); - fs = ip->i_fs; + ump = ITOUMP(ip); + fs = ump->um_fs; bp = NULL; - ump = ip->i_ump; gbflags = (flags & BA_UNMAPPED) != 0 ? GB_UNMAPPED : 0; mtx_assert(UFS_MTX(ump), MA_OWNED); @@ -273,7 +273,7 @@ ffs_realloccg(ip, lbprev, bprev, bpref, osize, nsize, flags, cred, bpp) (u_int)nsize > fs->fs_bsize || fragoff(fs, nsize) != 0) { printf( "dev = %s, bsize = %ld, osize = %d, nsize = %d, fs = %s\n", - devtoname(ip->i_dev), (long)fs->fs_bsize, osize, + devtoname(ump->um_dev), (long)fs->fs_bsize, osize, nsize, fs->fs_fsmnt); panic("ffs_realloccg: bad size"); } @@ -288,7 +288,7 @@ retry: } if (bprev == 0) { printf("dev = %s, bsize = %ld, bprev = %jd, fs = %s\n", - devtoname(ip->i_dev), (long)fs->fs_bsize, (intmax_t)bprev, + devtoname(ump->um_dev), (long)fs->fs_bsize, (intmax_t)bprev, fs->fs_fsmnt); panic("ffs_realloccg: bad bprev"); } @@ -383,7 +383,7 @@ retry: break; default: printf("dev = %s, optim = %ld, fs = %s\n", - devtoname(ip->i_dev), (long)fs->fs_optim, fs->fs_fsmnt); + devtoname(ump->um_dev), (long)fs->fs_optim, fs->fs_fsmnt); panic("ffs_realloccg: bad optim"); /* NOTREACHED */ } @@ -391,7 +391,7 @@ retry: if (bno > 0) { bp->b_blkno = fsbtodb(fs, bno); if (!DOINGSOFTDEP(vp)) - ffs_blkfree(ump, fs, ip->i_devvp, bprev, (long)osize, + ffs_blkfree(ump, fs, ump->um_devvp, bprev, (long)osize, ip->i_number, vp->v_type, NULL); delta = btodb(nsize - osize); DIP_SET(ip, i_blocks, DIP(ip, i_blocks) + delta); @@ -490,7 +490,7 @@ ffs_reallocblks(ap) * These devices are flash and therefore work less well with this * optimization. Also skip if reallocblks has been disabled globally. */ - ump = VTOI(ap->a_vp)->i_ump; + ump = ap->a_vp->v_mount->mnt_data; if (ump->um_candelete || doreallocblks == 0) return (ENOSPC); @@ -529,8 +529,8 @@ ffs_reallocblks_ufs1(ap) vp = ap->a_vp; ip = VTOI(vp); - fs = ip->i_fs; - ump = ip->i_ump; + ump = ITOUMP(ip); + fs = ump->um_fs; /* * If we are not tracking block clusters or if we have less than 4% * free blocks left, then do not attempt to cluster. Running with @@ -727,7 +727,7 @@ ffs_reallocblks_ufs1(ap) #endif for (blkno = newblk, i = 0; i < len; i++, blkno += fs->fs_frag) { if (!DOINGSOFTDEP(vp)) - ffs_blkfree(ump, fs, ip->i_devvp, + ffs_blkfree(ump, fs, ump->um_devvp, dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize, ip->i_number, vp->v_type, NULL); buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno); @@ -778,8 +778,8 @@ ffs_reallocblks_ufs2(ap) vp = ap->a_vp; ip = VTOI(vp); - fs = ip->i_fs; - ump = ip->i_ump; + ump = ITOUMP(ip); + fs = ump->um_fs; /* * If we are not tracking block clusters or if we have less than 4% * free blocks left, then do not attempt to cluster. Running with @@ -975,7 +975,7 @@ ffs_reallocblks_ufs2(ap) #endif for (blkno = newblk, i = 0; i < len; i++, blkno += fs->fs_frag) { if (!DOINGSOFTDEP(vp)) - ffs_blkfree(ump, fs, ip->i_devvp, + ffs_blkfree(ump, fs, ump->um_devvp, dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize, ip->i_number, vp->v_type, NULL); buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno); @@ -1040,8 +1040,8 @@ ffs_valloc(pvp, mode, cred, vpp) *vpp = NULL; pip = VTOI(pvp); - fs = pip->i_fs; - ump = pip->i_ump; + ump = ITOUMP(pip); + fs = ump->um_fs; UFS_LOCK(ump); reclaimed = 0; @@ -1114,10 +1114,12 @@ dup_alloc: ip->i_flag = 0; (*vpp)->v_vflag = 0; (*vpp)->v_type = VNON; - if (fs->fs_magic == FS_UFS2_MAGIC) + if (fs->fs_magic == FS_UFS2_MAGIC) { (*vpp)->v_op = &ffs_vnodeops2; - else + ip->i_flag |= IN_UFS2; + } else { (*vpp)->v_op = &ffs_vnodeops1; + } return (0); noinodes: if (reclaimed == 0) { @@ -1158,8 +1160,8 @@ ffs_dirpref(pip) u_int mincg, minndir; u_int maxcontigdirs; - mtx_assert(UFS_MTX(pip->i_ump), MA_OWNED); - fs = pip->i_fs; + mtx_assert(UFS_MTX(ITOUMP(pip)), MA_OWNED); + fs = ITOFS(pip); avgifree = fs->fs_cstotal.cs_nifree / fs->fs_ncg; avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg; @@ -1307,8 +1309,8 @@ ffs_blkpref_ufs1(ip, lbn, indx, bap) ufs2_daddr_t pref; KASSERT(indx <= 0 || bap != NULL, ("need non-NULL bap")); - mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED); - fs = ip->i_fs; + mtx_assert(UFS_MTX(ITOUMP(ip)), MA_OWNED); + fs = ITOFS(ip); /* * Allocation of indirect blocks is indicated by passing negative * values in indx: -1 for single indirect, -2 for double indirect, @@ -1412,8 +1414,8 @@ ffs_blkpref_ufs2(ip, lbn, indx, bap) ufs2_daddr_t pref; KASSERT(indx <= 0 || bap != NULL, ("need non-NULL bap")); - mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED); - fs = ip->i_fs; + mtx_assert(UFS_MTX(ITOUMP(ip)), MA_OWNED); + fs = ITOFS(ip); /* * Allocation of indirect blocks is indicated by passing negative * values in indx: -1 for single indirect, -2 for double indirect, @@ -1526,12 +1528,12 @@ ffs_hashalloc(ip, cg, pref, size, rsize, allocator) ufs2_daddr_t result; u_int i, icg = cg; - mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED); + mtx_assert(UFS_MTX(ITOUMP(ip)), MA_OWNED); #ifdef INVARIANTS if (ITOV(ip)->v_mount->mnt_kern_flag & MNTK_SUSPENDED) panic("ffs_hashalloc: allocation on suspended filesystem"); #endif - fs = ip->i_fs; + fs = ITOFS(ip); /* * 1: preferred cylinder group */ @@ -1589,8 +1591,8 @@ ffs_fragextend(ip, cg, bprev, osize, nsize) int i, error; u_int8_t *blksfree; - ump = ip->i_ump; - fs = ip->i_fs; + ump = ITOUMP(ip); + fs = ump->um_fs; if (fs->fs_cs(fs, cg).cs_nffree < numfrags(fs, nsize - osize)) return (0); frags = numfrags(fs, nsize); @@ -1600,8 +1602,8 @@ ffs_fragextend(ip, cg, bprev, osize, nsize) return (0); } UFS_UNLOCK(ump); - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), - (int)fs->fs_cgsize, NOCRED, &bp); + error = bread(ump->um_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NOCRED, &bp); if (error) goto fail; cgp = (struct cg *)bp->b_data; @@ -1673,13 +1675,13 @@ ffs_alloccg(ip, cg, bpref, size, rsize) int i, allocsiz, error, frags; u_int8_t *blksfree; - ump = ip->i_ump; - fs = ip->i_fs; + ump = ITOUMP(ip); + fs = ump->um_fs; if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize) return (0); UFS_UNLOCK(ump); - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), - (int)fs->fs_cgsize, NOCRED, &bp); + error = bread(ump->um_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NOCRED, &bp); if (error) goto fail; cgp = (struct cg *)bp->b_data; @@ -1775,8 +1777,8 @@ ffs_alloccgblk(ip, bp, bpref, size) u_int8_t *blksfree; int i, cgbpref; - fs = ip->i_fs; - ump = ip->i_ump; + ump = ITOUMP(ip); + fs = ump->um_fs; mtx_assert(UFS_MTX(ump), MA_OWNED); cgp = (struct cg *)bp->b_data; blksfree = cg_blksfree(cgp); @@ -1861,12 +1863,12 @@ ffs_clusteralloc(ip, cg, bpref, len) int32_t *lp; u_int8_t *blksfree; - fs = ip->i_fs; - ump = ip->i_ump; + ump = ITOUMP(ip); + fs = ump->um_fs; if (fs->fs_maxcluster[cg] < len) return (0); UFS_UNLOCK(ump); - if (bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, + if (bread(ump->um_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NOCRED, &bp)) goto fail_lock; cgp = (struct cg *)bp->b_data; @@ -1965,8 +1967,8 @@ getinobuf(struct inode *ip, u_int cg, u_int32_t cginoblk, int gbflags) { struct fs *fs; - fs = ip->i_fs; - return (getblk(ip->i_devvp, fsbtodb(fs, ino_to_fsba(fs, + fs = ITOFS(ip); + return (getblk(ITODEVVP(ip), fsbtodb(fs, ino_to_fsba(fs, cg * fs->fs_ipg + cginoblk)), (int)fs->fs_bsize, 0, 0, gbflags)); } @@ -1997,13 +1999,13 @@ ffs_nodealloccg(ip, cg, ipref, mode, unused) int error, start, len, i; u_int32_t old_initediblk; - fs = ip->i_fs; - ump = ip->i_ump; + ump = ITOUMP(ip); + fs = ump->um_fs; check_nifree: if (fs->fs_cs(fs, cg).cs_nifree == 0) return (0); UFS_UNLOCK(ump); - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + error = bread(ump->um_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NOCRED, &bp); if (error) { brelse(bp); @@ -2101,7 +2103,7 @@ gotit: * to it, then leave it unchanged as the other thread * has already set it correctly. */ - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + error = bread(ump->um_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NOCRED, &bp); UFS_LOCK(ump); ACTIVECLEAR(fs, cg); @@ -2166,7 +2168,8 @@ ffs_blkfree_cg(ump, fs, devvp, bno, size, inum, dephd) cg = dtog(fs, bno); if (devvp->v_type == VREG) { /* devvp is a snapshot */ - dev = VTOI(devvp)->i_devvp->v_rdev; + MPASS(devvp->v_mount->mnt_data == ump); + dev = ump->um_devvp->v_rdev; cgblkno = fragstoblks(fs, cgtod(fs, cg)); } else { /* devvp is a normal disk device */ @@ -2396,7 +2399,7 @@ ffs_checkblk(ip, bno, size) int i, error, frags, free; u_int8_t *blksfree; - fs = ip->i_fs; + fs = ITOFS(ip); if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) { printf("bsize = %ld, size = %ld, fs = %s\n", (long)fs->fs_bsize, size, fs->fs_fsmnt); @@ -2404,7 +2407,7 @@ ffs_checkblk(ip, bno, size) } if ((u_int)bno >= fs->fs_size) panic("ffs_checkblk: bad block %jd", (intmax_t)bno); - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, dtog(fs, bno))), + error = bread(ITODEVVP(ip), fsbtodb(fs, cgtod(fs, dtog(fs, bno))), (int)fs->fs_cgsize, NOCRED, &bp); if (error) panic("ffs_checkblk: cg bread failed"); @@ -2438,6 +2441,7 @@ ffs_vfree(pvp, ino, mode) ino_t ino; int mode; { + struct ufsmount *ump; struct inode *ip; if (DOINGSOFTDEP(pvp)) { @@ -2445,8 +2449,8 @@ ffs_vfree(pvp, ino, mode) return (0); } ip = VTOI(pvp); - return (ffs_freefile(ip->i_ump, ip->i_fs, ip->i_devvp, ino, mode, - NULL)); + ump = VFSTOUFS(pvp->v_mount); + return (ffs_freefile(ump, ump->um_fs, ump->um_devvp, ino, mode, NULL)); } /* @@ -2473,7 +2477,8 @@ ffs_freefile(ump, fs, devvp, ino, mode, wkhd) cg = ino_to_cg(fs, ino); if (devvp->v_type == VREG) { /* devvp is a snapshot */ - dev = VTOI(devvp)->i_devvp->v_rdev; + MPASS(devvp->v_mount->mnt_data == ump); + dev = ump->um_devvp->v_rdev; cgbno = fragstoblks(fs, cgtod(fs, cg)); } else { /* devvp is a normal disk device */ @@ -3056,7 +3061,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) break; AUDIT_ARG_VNODE1(vp); ip = VTOI(vp); - if (ip->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(ip)) error = copyin((void *)(intptr_t)cmd.size, ip->i_din1, sizeof(struct ufs1_dinode)); else @@ -3076,7 +3081,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) error = EPERM; break; } - if (VTOI(vp)->i_ump != ump) { + if (ITOUMP(VTOI(vp)) != ump) { error = EINVAL; break; } @@ -3173,11 +3178,11 @@ buffered_write(fp, uio, active_cred, flags, td) return (EINVAL); } ip = VTOI(vp); - if (ip->i_devvp != devvp) { + if (ITODEVVP(ip) != devvp) { vput(vp); return (EINVAL); } - fs = ip->i_fs; + fs = ITOFS(ip); vput(vp); foffset_lock_uio(fp, uio, flags); vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index 04e0ae9..64211d9 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -111,8 +111,8 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size, ip = VTOI(vp); dp = ip->i_din1; - fs = ip->i_fs; - ump = ip->i_ump; + fs = ITOFS(ip); + ump = ITOUMP(ip); lbn = lblkno(fs, startoffset); size = blkoff(fs, startoffset) + size; reclaimed = 0; @@ -548,7 +548,7 @@ fail: } lbns_remfree++; #endif - ffs_blkfree(ump, fs, ip->i_devvp, *blkp, fs->fs_bsize, + ffs_blkfree(ump, fs, ump->um_devvp, *blkp, fs->fs_bsize, ip->i_number, vp->v_type, NULL); } return (error); @@ -584,8 +584,8 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size, ip = VTOI(vp); dp = ip->i_din2; - fs = ip->i_fs; - ump = ip->i_ump; + fs = ITOFS(ip); + ump = ITOUMP(ip); lbn = lblkno(fs, startoffset); size = blkoff(fs, startoffset) + size; reclaimed = 0; @@ -1143,7 +1143,7 @@ fail: } lbns_remfree++; #endif - ffs_blkfree(ump, fs, ip->i_devvp, *blkp, fs->fs_bsize, + ffs_blkfree(ump, fs, ump->um_devvp, *blkp, fs->fs_bsize, ip->i_number, vp->v_type, NULL); } return (error); diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 50b456b..f6f0eb1 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -92,8 +92,8 @@ ffs_update(vp, waitfor) if ((ip->i_flag & IN_MODIFIED) == 0 && waitfor == 0) return (0); ip->i_flag &= ~(IN_LAZYACCESS | IN_LAZYMOD | IN_MODIFIED); - fs = ip->i_fs; - if (fs->fs_ronly && ip->i_ump->um_fsckpid == 0) + fs = ITOFS(ip); + if (fs->fs_ronly && ITOUMP(ip)->um_fsckpid == 0) return (0); /* * If we are updating a snapshot and another process is currently @@ -110,7 +110,7 @@ ffs_update(vp, waitfor) if (IS_SNAPSHOT(ip)) flags = GB_LOCK_NOWAIT; loop: - error = breadn_flags(ip->i_devvp, + error = breadn_flags(ITODEVVP(ip), fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), (int) fs->fs_bsize, 0, 0, 0, NOCRED, flags, &bp); if (error != 0) { @@ -143,7 +143,7 @@ loop: softdep_update_inodeblock(ip, bp, waitfor); else if (ip->i_effnlink != ip->i_nlink) panic("ffs_update: bad link cnt"); - if (ip->i_ump->um_fstype == UFS1) { + if (I_IS_UFS1(ip)) { *((struct ufs1_dinode *)bp->b_data + ino_to_fsbo(fs, ip->i_number)) = *ip->i_din1; /* XXX: FIX? The entropy here is desirable, but the harvesting may be expensive */ @@ -197,8 +197,8 @@ ffs_truncate(vp, length, flags, cred) off_t osize; ip = VTOI(vp); - fs = ip->i_fs; - ump = ip->i_ump; + ump = VFSTOUFS(vp->v_mount); + fs = ump->um_fs; bo = &vp->v_bufobj; ASSERT_VOP_LOCKED(vp, "ffs_truncate"); @@ -269,7 +269,7 @@ ffs_truncate(vp, length, flags, cred) for (i = 0; i < NXADDR; i++) { if (oldblks[i] == 0) continue; - ffs_blkfree(ump, fs, ip->i_devvp, oldblks[i], + ffs_blkfree(ump, fs, ITODEVVP(ip), oldblks[i], sblksize(fs, osize, i), ip->i_number, vp->v_type, NULL); } @@ -345,7 +345,7 @@ ffs_truncate(vp, length, flags, cred) if (error) return (error); indiroff = (lbn - NDADDR) % NINDIR(fs); - if (ip->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(ip)) blkno = ((ufs1_daddr_t *)(bp->b_data))[indiroff]; else blkno = ((ufs2_daddr_t *)(bp->b_data))[indiroff]; @@ -517,7 +517,7 @@ ffs_truncate(vp, length, flags, cred) blocksreleased += count; if (lastiblock[level] < 0) { DIP_SET(ip, i_ib[level], 0); - ffs_blkfree(ump, fs, ip->i_devvp, bn, + ffs_blkfree(ump, fs, ump->um_devvp, bn, fs->fs_bsize, ip->i_number, vp->v_type, NULL); blocksreleased += nblocks; @@ -538,7 +538,7 @@ ffs_truncate(vp, length, flags, cred) continue; DIP_SET(ip, i_db[i], 0); bsize = blksize(fs, ip, i); - ffs_blkfree(ump, fs, ip->i_devvp, bn, bsize, ip->i_number, + ffs_blkfree(ump, fs, ump->um_devvp, bn, bsize, ip->i_number, vp->v_type, NULL); blocksreleased += btodb(bsize); } @@ -570,7 +570,7 @@ ffs_truncate(vp, length, flags, cred) * required for the storage we're keeping. */ bn += numfrags(fs, newspace); - ffs_blkfree(ump, fs, ip->i_devvp, bn, + ffs_blkfree(ump, fs, ump->um_devvp, bn, oldspace - newspace, ip->i_number, vp->v_type, NULL); blocksreleased += btodb(oldspace - newspace); } @@ -629,7 +629,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp) ufs2_daddr_t *countp; { struct buf *bp; - struct fs *fs = ip->i_fs; + struct fs *fs; struct vnode *vp; caddr_t copy = NULL; int i, nblocks, error = 0, allerror = 0; @@ -637,7 +637,9 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp) ufs2_daddr_t blkcount, factor, blocksreleased = 0; ufs1_daddr_t *bap1 = NULL; ufs2_daddr_t *bap2 = NULL; -# define BAP(ip, i) (((ip)->i_ump->um_fstype == UFS1) ? bap1[i] : bap2[i]) +#define BAP(ip, i) (I_IS_UFS1(ip) ? bap1[i] : bap2[i]) + + fs = ITOFS(ip); /* * Calculate index in current block of last @@ -685,7 +687,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp) return (error); } - if (ip->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(ip)) bap1 = (ufs1_daddr_t *)bp->b_data; else bap2 = (ufs2_daddr_t *)bp->b_data; @@ -693,7 +695,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp) copy = malloc(fs->fs_bsize, M_TEMP, M_WAITOK); bcopy((caddr_t)bp->b_data, copy, (u_int)fs->fs_bsize); for (i = last + 1; i < NINDIR(fs); i++) - if (ip->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(ip)) bap1[i] = 0; else bap2[i] = 0; @@ -704,7 +706,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp) if (error) allerror = error; } - if (ip->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(ip)) bap1 = (ufs1_daddr_t *)copy; else bap2 = (ufs2_daddr_t *)copy; @@ -724,7 +726,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp) allerror = error; blocksreleased += blkcount; } - ffs_blkfree(ip->i_ump, fs, ip->i_devvp, nb, fs->fs_bsize, + ffs_blkfree(ITOUMP(ip), fs, ITODEVVP(ip), nb, fs->fs_bsize, ip->i_number, vp->v_type, NULL); blocksreleased += nblocks; } @@ -758,6 +760,6 @@ int ffs_rdonly(struct inode *ip) { - return (ip->i_ump->um_fs->fs_ronly != 0); + return (ITOFS(ip)->fs_ronly != 0); } diff --git a/sys/ufs/ffs/ffs_rawread.c b/sys/ufs/ffs/ffs_rawread.c index 84fa0db..e1fc346 100644 --- a/sys/ufs/ffs/ffs_rawread.c +++ b/sys/ufs/ffs/ffs_rawread.c @@ -204,7 +204,7 @@ ffs_rawread_readahead(struct vnode *vp, bsize = vp->v_mount->mnt_stat.f_iosize; ip = VTOI(vp); - dp = ip->i_devvp; + dp = ITODEVVP(ip); iolen = ((vm_offset_t) udata) & PAGE_MASK; bp->b_bcount = len; @@ -440,7 +440,7 @@ ffs_rawread(struct vnode *vp, /* Only handle sector aligned reads */ ip = VTOI(vp); - secsize = ip->i_devvp->v_bufobj.bo_bsize; + secsize = ITODEVVP(ip)->v_bufobj.bo_bsize; if ((uio->uio_offset & (secsize - 1)) == 0 && (uio->uio_resid & (secsize - 1)) == 0) { @@ -460,7 +460,7 @@ ffs_rawread(struct vnode *vp, } partialbytes = ((unsigned int) ip->i_size) % - ip->i_fs->fs_bsize; + ITOFS(ip)->fs_bsize; blockbytes = (int) filebytes - partialbytes; if (blockbytes > 0) { skipbytes = uio->uio_resid - diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 5ef439f..a303c8d 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -302,7 +302,7 @@ restart: vp = nd.ni_vp; vp->v_vflag |= VV_SYSTEM; ip = VTOI(vp); - devvp = ip->i_devvp; + devvp = ITODEVVP(ip); /* * Allocate and copy the last block contents so as to be able * to set size to that of the filesystem. @@ -587,7 +587,7 @@ loop: } } snaplistsize += 1; - if (xp->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(xp)) error = expunge_ufs1(vp, xp, copy_fs, fullacct_ufs1, BLK_NOCOPY, 1); else @@ -620,7 +620,7 @@ loop: goto out1; } xp = VTOI(xvp); - if (xp->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(xp)) error = expunge_ufs1(vp, xp, copy_fs, fullacct_ufs1, BLK_NOCOPY, 0); else @@ -706,7 +706,7 @@ out1: TAILQ_FOREACH(xp, &sn->sn_head, i_nextsnap) { if (xp == ip) break; - if (xp->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(xp)) error = expunge_ufs1(vp, xp, fs, snapacct_ufs1, BLK_SNAP, 0); else @@ -735,7 +735,7 @@ out1: * blocks marked as used in the snapshot bitmaps. Also, collect * the list of allocated blocks in i_snapblklist. */ - if (ip->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(ip)) error = expunge_ufs1(vp, ip, copy_fs, mapacct_ufs1, BLK_SNAP, 0); else @@ -887,9 +887,9 @@ cgaccount(cg, vp, nbp, passno) int error, len, loc, indiroff; ip = VTOI(vp); - fs = ip->i_fs; - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), - (int)fs->fs_cgsize, KERNCRED, &bp); + fs = ITOFS(ip); + error = bread(ITODEVVP(ip), fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, KERNCRED, &bp); if (error) { brelse(bp); return (error); @@ -899,7 +899,7 @@ cgaccount(cg, vp, nbp, passno) brelse(bp); return (EIO); } - UFS_LOCK(ip->i_ump); + UFS_LOCK(ITOUMP(ip)); ACTIVESET(fs, cg); /* * Recomputation of summary information might not have been performed @@ -908,7 +908,7 @@ cgaccount(cg, vp, nbp, passno) * fsck is slightly more consistent. */ fs->fs_cs(fs, cg) = cgp->cg_cs; - UFS_UNLOCK(ip->i_ump); + UFS_UNLOCK(ITOUMP(ip)); bcopy(bp->b_data, nbp->b_data, fs->fs_cgsize); if (fs->fs_cgsize < fs->fs_bsize) bzero(&nbp->b_data[fs->fs_cgsize], @@ -952,7 +952,7 @@ cgaccount(cg, vp, nbp, passno) } indiroff = 0; } - if (ip->i_ump->um_fstype == UFS1) { + if (I_IS_UFS1(ip)) { if (ffs_isblock(fs, cg_blksfree(cgp), loc)) ((ufs1_daddr_t *)(ibp->b_data))[indiroff] = BLK_NOCOPY; @@ -1257,7 +1257,7 @@ mapacct_ufs1(vp, oldblkp, lastblkp, fs, lblkno, expungetype) *ip->i_snapblklist++ = lblkno; if (blkno == BLK_SNAP) blkno = blkstofrags(fs, lblkno); - ffs_blkfree(ip->i_ump, fs, vp, blkno, fs->fs_bsize, inum, + ffs_blkfree(ITOUMP(ip), fs, vp, blkno, fs->fs_bsize, inum, vp->v_type, NULL); } return (0); @@ -1541,7 +1541,7 @@ mapacct_ufs2(vp, oldblkp, lastblkp, fs, lblkno, expungetype) *ip->i_snapblklist++ = lblkno; if (blkno == BLK_SNAP) blkno = blkstofrags(fs, lblkno); - ffs_blkfree(ip->i_ump, fs, vp, blkno, fs->fs_bsize, inum, + ffs_blkfree(ITOUMP(ip), fs, vp, blkno, fs->fs_bsize, inum, vp->v_type, NULL); } return (0); @@ -1565,7 +1565,7 @@ ffs_snapgone(ip) * Find snapshot in incore list. */ xp = NULL; - sn = ip->i_devvp->v_rdev->si_snapdata; + sn = ITODEVVP(ip)->v_rdev->si_snapdata; if (sn != NULL) TAILQ_FOREACH(xp, &sn->sn_head, i_nextsnap) if (xp == ip) @@ -1578,8 +1578,8 @@ ffs_snapgone(ip) /* * Delete snapshot inode from superblock. Keep list dense. */ - fs = ip->i_fs; - ump = ip->i_ump; + ump = ITOUMP(ip); + fs = ump->um_fs; UFS_LOCK(ump); for (snaploc = 0; snaploc < FSMAXSNAP; snaploc++) if (fs->fs_snapinum[snaploc] == ip->i_number) @@ -1611,8 +1611,8 @@ ffs_snapremove(vp) struct snapdata *sn; ip = VTOI(vp); - fs = ip->i_fs; - devvp = ip->i_devvp; + fs = ITOFS(ip); + devvp = ITODEVVP(ip); /* * If active, delete from incore list (this snapshot may * already have been in the process of being deleted, so @@ -1646,7 +1646,7 @@ ffs_snapremove(vp) if (dblk == BLK_NOCOPY || dblk == BLK_SNAP) DIP_SET(ip, i_db[blkno], 0); else if ((dblk == blkstofrags(fs, blkno) && - ffs_snapblkfree(fs, ip->i_devvp, dblk, fs->fs_bsize, + ffs_snapblkfree(fs, ITODEVVP(ip), dblk, fs->fs_bsize, ip->i_number, vp->v_type, NULL))) { DIP_SET(ip, i_blocks, DIP(ip, i_blocks) - btodb(fs->fs_bsize)); @@ -1664,14 +1664,14 @@ ffs_snapremove(vp) else last = fs->fs_size - blkno; for (loc = 0; loc < last; loc++) { - if (ip->i_ump->um_fstype == UFS1) { + if (I_IS_UFS1(ip)) { dblk = ((ufs1_daddr_t *)(ibp->b_data))[loc]; if (dblk == 0) continue; if (dblk == BLK_NOCOPY || dblk == BLK_SNAP) ((ufs1_daddr_t *)(ibp->b_data))[loc]= 0; else if ((dblk == blkstofrags(fs, blkno) && - ffs_snapblkfree(fs, ip->i_devvp, dblk, + ffs_snapblkfree(fs, ITODEVVP(ip), dblk, fs->fs_bsize, ip->i_number, vp->v_type, NULL))) { ip->i_din1->di_blocks -= @@ -1686,7 +1686,7 @@ ffs_snapremove(vp) if (dblk == BLK_NOCOPY || dblk == BLK_SNAP) ((ufs2_daddr_t *)(ibp->b_data))[loc] = 0; else if ((dblk == blkstofrags(fs, blkno) && - ffs_snapblkfree(fs, ip->i_devvp, dblk, + ffs_snapblkfree(fs, ITODEVVP(ip), dblk, fs->fs_bsize, ip->i_number, vp->v_type, NULL))) { ip->i_din2->di_blocks -= btodb(fs->fs_bsize); ((ufs2_daddr_t *)(ibp->b_data))[loc] = 0; @@ -1781,7 +1781,7 @@ retry: if (error) break; indiroff = (lbn - NDADDR) % NINDIR(fs); - if (ip->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(ip)) blkno=((ufs1_daddr_t *)(ibp->b_data))[indiroff]; else blkno=((ufs2_daddr_t *)(ibp->b_data))[indiroff]; @@ -1806,7 +1806,7 @@ retry: if (lbn < NDADDR) { DIP_SET(ip, i_db[lbn], BLK_NOCOPY); ip->i_flag |= IN_CHANGE | IN_UPDATE; - } else if (ip->i_ump->um_fstype == UFS1) { + } else if (I_IS_UFS1(ip)) { ((ufs1_daddr_t *)(ibp->b_data))[indiroff] = BLK_NOCOPY; bdwrite(ibp); @@ -1854,7 +1854,7 @@ retry: } if (lbn < NDADDR) { DIP_SET(ip, i_db[lbn], bno); - } else if (ip->i_ump->um_fstype == UFS1) { + } else if (I_IS_UFS1(ip)) { ((ufs1_daddr_t *)(ibp->b_data))[indiroff] = bno; bdwrite(ibp); } else { @@ -2136,7 +2136,7 @@ ffs_bp_snapblk(devvp, bp) sn = devvp->v_rdev->si_snapdata; if (sn == NULL || TAILQ_FIRST(&sn->sn_head) == NULL) return (0); - fs = TAILQ_FIRST(&sn->sn_head)->i_fs; + fs = ITOFS(TAILQ_FIRST(&sn->sn_head)); lbn = fragstoblks(fs, dbtofsb(fs, bp->b_blkno)); snapblklist = sn->sn_blklist; upper = sn->sn_listsize - 1; @@ -2263,7 +2263,7 @@ ffs_copyonwrite(devvp, bp) return (0); /* No snapshot */ } ip = TAILQ_FIRST(&sn->sn_head); - fs = ip->i_fs; + fs = ITOFS(ip); lbn = fragstoblks(fs, dbtofsb(fs, bp->b_blkno)); snapblklist = sn->sn_blklist; upper = sn->sn_listsize - 1; @@ -2337,7 +2337,7 @@ ffs_copyonwrite(devvp, bp) if (error) break; indiroff = (lbn - NDADDR) % NINDIR(fs); - if (ip->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(ip)) blkno=((ufs1_daddr_t *)(ibp->b_data))[indiroff]; else blkno=((ufs2_daddr_t *)(ibp->b_data))[indiroff]; @@ -2493,15 +2493,19 @@ readblock(vp, bp, lbn) { struct inode *ip = VTOI(vp); struct bio *bip; + struct fs *fs; + + ip = VTOI(vp); + fs = ITOFS(ip); bip = g_alloc_bio(); bip->bio_cmd = BIO_READ; - bip->bio_offset = dbtob(fsbtodb(ip->i_fs, blkstofrags(ip->i_fs, lbn))); + bip->bio_offset = dbtob(fsbtodb(fs, blkstofrags(fs, lbn))); bip->bio_data = bp->b_data; bip->bio_length = bp->b_bcount; bip->bio_done = NULL; - g_io_request(bip, ip->i_devvp->v_bufobj.bo_private); + g_io_request(bip, ITODEVVP(ip)->v_bufobj.bo_private); bp->b_error = biowait(bip, "snaprdb"); g_destroy_bio(bip); return (bp->b_error); diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 9819cf7..494ec1b 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -3998,7 +3998,7 @@ newjmvref(dp, ino, oldoff, newoff) struct jmvref *jmvref; jmvref = malloc(sizeof(*jmvref), M_JMVREF, M_SOFTDEP_FLAGS); - workitem_alloc(&jmvref->jm_list, D_JMVREF, UFSTOVFS(dp->i_ump)); + workitem_alloc(&jmvref->jm_list, D_JMVREF, ITOVFS(dp)); jmvref->jm_list.wk_state = ATTACHED | DEPCOMPLETE; jmvref->jm_parent = dp->i_number; jmvref->jm_ino = ino; @@ -4025,7 +4025,7 @@ newjremref(struct dirrem *dirrem, struct inode *dp, struct inode *ip, struct jremref *jremref; jremref = malloc(sizeof(*jremref), M_JREMREF, M_SOFTDEP_FLAGS); - workitem_alloc(&jremref->jr_list, D_JREMREF, UFSTOVFS(dp->i_ump)); + workitem_alloc(&jremref->jr_list, D_JREMREF, ITOVFS(dp)); jremref->jr_state = ATTACHED; newinoref(&jremref->jr_ref, ip->i_number, dp->i_number, diroff, nlink, ip->i_mode); @@ -4061,7 +4061,7 @@ newjaddref(struct inode *dp, ino_t ino, off_t diroff, int16_t nlink, struct jaddref *jaddref; jaddref = malloc(sizeof(*jaddref), M_JADDREF, M_SOFTDEP_FLAGS); - workitem_alloc(&jaddref->ja_list, D_JADDREF, UFSTOVFS(dp->i_ump)); + workitem_alloc(&jaddref->ja_list, D_JADDREF, ITOVFS(dp)); jaddref->ja_state = ATTACHED; jaddref->ja_mkdir = NULL; newinoref(&jaddref->ja_ref, ino, dp->i_number, diroff, nlink, mode); @@ -4649,7 +4649,7 @@ inodedep_lookup_ip(ip) KASSERT(ip->i_nlink >= ip->i_effnlink, ("inodedep_lookup_ip: bad delta")); - (void) inodedep_lookup(UFSTOVFS(ip->i_ump), ip->i_number, DEPALLOC, + (void) inodedep_lookup(ITOVFS(ip), ip->i_number, DEPALLOC, &inodedep); inodedep->id_nlinkdelta = ip->i_nlink - ip->i_effnlink; KASSERT((inodedep->id_state & UNLINKED) == 0, ("inode unlinked")); @@ -4672,12 +4672,12 @@ softdep_setup_create(dp, ip) struct jaddref *jaddref; struct vnode *dvp; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(dp->i_ump)) != 0, + KASSERT(MOUNTEDSOFTDEP(ITOVFS(dp)) != 0, ("softdep_setup_create called on non-softdep filesystem")); KASSERT(ip->i_nlink == 1, ("softdep_setup_create: Invalid link count.")); dvp = ITOV(dp); - ACQUIRE_LOCK(dp->i_ump); + ACQUIRE_LOCK(ITOUMP(dp)); inodedep = inodedep_lookup_ip(ip); if (DOINGSUJ(dvp)) { jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst, @@ -4686,7 +4686,7 @@ softdep_setup_create(dp, ip) ("softdep_setup_create: No addref structure present.")); } softdep_prelink(dvp, NULL); - FREE_LOCK(dp->i_ump); + FREE_LOCK(ITOUMP(dp)); } /* @@ -4704,7 +4704,7 @@ softdep_setup_dotdot_link(dp, ip) struct jaddref *jaddref; struct vnode *dvp; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(dp->i_ump)) != 0, + KASSERT(MOUNTEDSOFTDEP(ITOVFS(dp)) != 0, ("softdep_setup_dotdot_link called on non-softdep filesystem")); dvp = ITOV(dp); jaddref = NULL; @@ -4715,13 +4715,13 @@ softdep_setup_dotdot_link(dp, ip) if (DOINGSUJ(dvp)) jaddref = newjaddref(ip, dp->i_number, DOTDOT_OFFSET, dp->i_effnlink - 1, dp->i_mode); - ACQUIRE_LOCK(dp->i_ump); + ACQUIRE_LOCK(ITOUMP(dp)); inodedep = inodedep_lookup_ip(dp); if (jaddref) TAILQ_INSERT_TAIL(&inodedep->id_inoreflst, &jaddref->ja_ref, if_deps); softdep_prelink(dvp, ITOV(ip)); - FREE_LOCK(dp->i_ump); + FREE_LOCK(ITOUMP(dp)); } /* @@ -4739,20 +4739,20 @@ softdep_setup_link(dp, ip) struct jaddref *jaddref; struct vnode *dvp; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(dp->i_ump)) != 0, + KASSERT(MOUNTEDSOFTDEP(ITOVFS(dp)) != 0, ("softdep_setup_link called on non-softdep filesystem")); dvp = ITOV(dp); jaddref = NULL; if (DOINGSUJ(dvp)) jaddref = newjaddref(dp, ip->i_number, 0, ip->i_effnlink - 1, ip->i_mode); - ACQUIRE_LOCK(dp->i_ump); + ACQUIRE_LOCK(ITOUMP(dp)); inodedep = inodedep_lookup_ip(ip); if (jaddref) TAILQ_INSERT_TAIL(&inodedep->id_inoreflst, &jaddref->ja_ref, if_deps); softdep_prelink(dvp, ITOV(ip)); - FREE_LOCK(dp->i_ump); + FREE_LOCK(ITOUMP(dp)); } /* @@ -4772,7 +4772,7 @@ softdep_setup_mkdir(dp, ip) struct jaddref *jaddref; struct vnode *dvp; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(dp->i_ump)) != 0, + KASSERT(MOUNTEDSOFTDEP(ITOVFS(dp)) != 0, ("softdep_setup_mkdir called on non-softdep filesystem")); dvp = ITOV(dp); dotaddref = dotdotaddref = NULL; @@ -4784,7 +4784,7 @@ softdep_setup_mkdir(dp, ip) dp->i_effnlink - 1, dp->i_mode); dotdotaddref->ja_state |= MKDIR_PARENT; } - ACQUIRE_LOCK(dp->i_ump); + ACQUIRE_LOCK(ITOUMP(dp)); inodedep = inodedep_lookup_ip(ip); if (DOINGSUJ(dvp)) { jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst, @@ -4802,7 +4802,7 @@ softdep_setup_mkdir(dp, ip) TAILQ_INSERT_TAIL(&inodedep->id_inoreflst, &dotdotaddref->ja_ref, if_deps); softdep_prelink(ITOV(dp), NULL); - FREE_LOCK(dp->i_ump); + FREE_LOCK(ITOUMP(dp)); } /* @@ -4816,14 +4816,14 @@ softdep_setup_rmdir(dp, ip) { struct vnode *dvp; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(dp->i_ump)) != 0, + KASSERT(MOUNTEDSOFTDEP(ITOVFS(dp)) != 0, ("softdep_setup_rmdir called on non-softdep filesystem")); dvp = ITOV(dp); - ACQUIRE_LOCK(dp->i_ump); + ACQUIRE_LOCK(ITOUMP(dp)); (void) inodedep_lookup_ip(ip); (void) inodedep_lookup_ip(dp); softdep_prelink(dvp, ITOV(ip)); - FREE_LOCK(dp->i_ump); + FREE_LOCK(ITOUMP(dp)); } /* @@ -4837,14 +4837,14 @@ softdep_setup_unlink(dp, ip) { struct vnode *dvp; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(dp->i_ump)) != 0, + KASSERT(MOUNTEDSOFTDEP(ITOVFS(dp)) != 0, ("softdep_setup_unlink called on non-softdep filesystem")); dvp = ITOV(dp); - ACQUIRE_LOCK(dp->i_ump); + ACQUIRE_LOCK(ITOUMP(dp)); (void) inodedep_lookup_ip(ip); (void) inodedep_lookup_ip(dp); softdep_prelink(dvp, ITOV(ip)); - FREE_LOCK(dp->i_ump); + FREE_LOCK(ITOUMP(dp)); } /* @@ -4860,10 +4860,10 @@ softdep_revert_create(dp, ip) struct jaddref *jaddref; struct vnode *dvp; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(dp->i_ump)) != 0, + KASSERT(MOUNTEDSOFTDEP(ITOVFS((dp))) != 0, ("softdep_revert_create called on non-softdep filesystem")); dvp = ITOV(dp); - ACQUIRE_LOCK(dp->i_ump); + ACQUIRE_LOCK(ITOUMP(dp)); inodedep = inodedep_lookup_ip(ip); if (DOINGSUJ(dvp)) { jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst, @@ -4872,7 +4872,7 @@ softdep_revert_create(dp, ip) ("softdep_revert_create: addref parent mismatch")); cancel_jaddref(jaddref, inodedep, &inodedep->id_inowait); } - FREE_LOCK(dp->i_ump); + FREE_LOCK(ITOUMP(dp)); } /* @@ -4888,10 +4888,10 @@ softdep_revert_link(dp, ip) struct jaddref *jaddref; struct vnode *dvp; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(dp->i_ump)) != 0, + KASSERT(MOUNTEDSOFTDEP(ITOVFS(dp)) != 0, ("softdep_revert_link called on non-softdep filesystem")); dvp = ITOV(dp); - ACQUIRE_LOCK(dp->i_ump); + ACQUIRE_LOCK(ITOUMP(dp)); inodedep = inodedep_lookup_ip(ip); if (DOINGSUJ(dvp)) { jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst, @@ -4900,7 +4900,7 @@ softdep_revert_link(dp, ip) ("softdep_revert_link: addref parent mismatch")); cancel_jaddref(jaddref, inodedep, &inodedep->id_inowait); } - FREE_LOCK(dp->i_ump); + FREE_LOCK(ITOUMP(dp)); } /* @@ -4917,11 +4917,11 @@ softdep_revert_mkdir(dp, ip) struct jaddref *dotaddref; struct vnode *dvp; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(dp->i_ump)) != 0, + KASSERT(MOUNTEDSOFTDEP(ITOVFS(dp)) != 0, ("softdep_revert_mkdir called on non-softdep filesystem")); dvp = ITOV(dp); - ACQUIRE_LOCK(dp->i_ump); + ACQUIRE_LOCK(ITOUMP(dp)); inodedep = inodedep_lookup_ip(dp); if (DOINGSUJ(dvp)) { jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst, @@ -4943,7 +4943,7 @@ softdep_revert_mkdir(dp, ip) ("softdep_revert_mkdir: dot addref parent mismatch")); cancel_jaddref(dotaddref, inodedep, &inodedep->id_inowait); } - FREE_LOCK(dp->i_ump); + FREE_LOCK(ITOUMP(dp)); } /* @@ -4955,12 +4955,12 @@ softdep_revert_rmdir(dp, ip) struct inode *ip; { - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(dp->i_ump)) != 0, + KASSERT(MOUNTEDSOFTDEP(ITOVFS(dp)) != 0, ("softdep_revert_rmdir called on non-softdep filesystem")); - ACQUIRE_LOCK(dp->i_ump); + ACQUIRE_LOCK(ITOUMP(dp)); (void) inodedep_lookup_ip(ip); (void) inodedep_lookup_ip(dp); - FREE_LOCK(dp->i_ump); + FREE_LOCK(ITOUMP(dp)); } /* @@ -5011,10 +5011,10 @@ softdep_setup_inomapdep(bp, ip, newinum, mode) struct mount *mp; struct fs *fs; - mp = UFSTOVFS(ip->i_ump); + mp = ITOVFS(ip); KASSERT(MOUNTEDSOFTDEP(mp) != 0, ("softdep_setup_inomapdep called on non-softdep filesystem")); - fs = ip->i_ump->um_fs; + fs = VFSTOUFS(mp)->um_fs; jaddref = NULL; /* @@ -5046,7 +5046,7 @@ softdep_setup_inomapdep(bp, ip, newinum, mode) bmsafemap = malloc(sizeof(struct bmsafemap), M_BMSAFEMAP, M_SOFTDEP_FLAGS); workitem_alloc(&bmsafemap->sm_list, D_BMSAFEMAP, mp); - ACQUIRE_LOCK(ip->i_ump); + ACQUIRE_LOCK(ITOUMP(ip)); if ((inodedep_lookup(mp, newinum, DEPALLOC, &inodedep))) panic("softdep_setup_inomapdep: dependency %p for new" "inode already exists", inodedep); @@ -5061,7 +5061,7 @@ softdep_setup_inomapdep(bp, ip, newinum, mode) } inodedep->id_bmsafemap = bmsafemap; inodedep->id_state &= ~DEPCOMPLETE; - FREE_LOCK(ip->i_ump); + FREE_LOCK(ITOUMP(ip)); } /* @@ -5283,7 +5283,7 @@ softdep_setup_allocdirect(ip, off, newblkno, oldblkno, newsize, oldsize, bp) ufs_lbn_t lbn; lbn = bp->b_lblkno; - mp = UFSTOVFS(ip->i_ump); + mp = ITOVFS(ip); KASSERT(MOUNTEDSOFTDEP(mp) != 0, ("softdep_setup_allocdirect called on non-softdep filesystem")); if (oldblkno && oldblkno != newblkno) @@ -5295,7 +5295,7 @@ softdep_setup_allocdirect(ip, off, newblkno, oldblkno, newsize, oldsize, bp) "softdep_setup_allocdirect: ino %d blkno %jd oldblkno %jd " "off %jd newsize %ld oldsize %d", ip->i_number, newblkno, oldblkno, off, newsize, oldsize); - ACQUIRE_LOCK(ip->i_ump); + ACQUIRE_LOCK(ITOUMP(ip)); if (off >= NDADDR) { if (lbn > 0) panic("softdep_setup_allocdirect: bad lbn %jd, off %jd", @@ -5367,7 +5367,7 @@ softdep_setup_allocdirect(ip, off, newblkno, oldblkno, newsize, oldsize, bp) TAILQ_INSERT_TAIL(adphead, adp, ad_next); if (oldadp != NULL && oldadp->ad_offset == off) allocdirect_merge(adphead, adp, oldadp); - FREE_LOCK(ip->i_ump); + FREE_LOCK(ITOUMP(ip)); return; } TAILQ_FOREACH(oldadp, adphead, ad_next) { @@ -5381,7 +5381,7 @@ softdep_setup_allocdirect(ip, off, newblkno, oldblkno, newsize, oldsize, bp) if (oldadp->ad_offset == off) allocdirect_merge(adphead, adp, oldadp); - FREE_LOCK(ip->i_ump); + FREE_LOCK(ITOUMP(ip)); } /* @@ -5545,10 +5545,10 @@ newjfreefrag(freefrag, ip, blkno, size, lbn) struct jfreefrag *jfreefrag; struct fs *fs; - fs = ip->i_fs; + fs = ITOFS(ip); jfreefrag = malloc(sizeof(struct jfreefrag), M_JFREEFRAG, M_SOFTDEP_FLAGS); - workitem_alloc(&jfreefrag->fr_list, D_JFREEFRAG, UFSTOVFS(ip->i_ump)); + workitem_alloc(&jfreefrag->fr_list, D_JFREEFRAG, ITOVFS(ip)); jfreefrag->fr_jsegdep = newjsegdep(&jfreefrag->fr_list); jfreefrag->fr_state = ATTACHED | DEPCOMPLETE; jfreefrag->fr_ino = ip->i_number; @@ -5571,16 +5571,18 @@ newfreefrag(ip, blkno, size, lbn) ufs_lbn_t lbn; { struct freefrag *freefrag; + struct ufsmount *ump; struct fs *fs; CTR4(KTR_SUJ, "newfreefrag: ino %d blkno %jd size %ld lbn %jd", ip->i_number, blkno, size, lbn); - fs = ip->i_fs; + ump = ITOUMP(ip); + fs = ump->um_fs; if (fragnum(fs, blkno) + numfrags(fs, size) > fs->fs_frag) panic("newfreefrag: frag size"); freefrag = malloc(sizeof(struct freefrag), M_FREEFRAG, M_SOFTDEP_FLAGS); - workitem_alloc(&freefrag->ff_list, D_FREEFRAG, UFSTOVFS(ip->i_ump)); + workitem_alloc(&freefrag->ff_list, D_FREEFRAG, UFSTOVFS(ump)); freefrag->ff_state = ATTACHED; LIST_INIT(&freefrag->ff_jwork); freefrag->ff_inum = ip->i_number; @@ -5588,7 +5590,7 @@ newfreefrag(ip, blkno, size, lbn) freefrag->ff_blkno = blkno; freefrag->ff_fragsize = size; - if (MOUNTEDSUJ(UFSTOVFS(ip->i_ump))) { + if (MOUNTEDSUJ(UFSTOVFS(ump))) { freefrag->ff_jdep = (struct worklist *) newjfreefrag(freefrag, ip, blkno, size, lbn); } else { @@ -5660,9 +5662,11 @@ softdep_setup_allocext(ip, off, newblkno, oldblkno, newsize, oldsize, bp) struct jnewblk *jnewblk; struct newblk *newblk; struct mount *mp; + struct ufsmount *ump; ufs_lbn_t lbn; - mp = UFSTOVFS(ip->i_ump); + mp = ITOVFS(ip); + ump = VFSTOUFS(mp); KASSERT(MOUNTEDSOFTDEP(mp) != 0, ("softdep_setup_allocext called on non-softdep filesystem")); KASSERT(off < NXADDR, ("softdep_setup_allocext: lbn %lld > NXADDR", @@ -5674,7 +5678,7 @@ softdep_setup_allocext(ip, off, newblkno, oldblkno, newsize, oldsize, bp) else freefrag = NULL; - ACQUIRE_LOCK(ip->i_ump); + ACQUIRE_LOCK(ump); if (newblk_lookup(mp, newblkno, 0, &newblk) == 0) panic("softdep_setup_allocext: lost block"); KASSERT(newblk->nb_list.wk_type == D_NEWBLK, @@ -5725,7 +5729,7 @@ softdep_setup_allocext(ip, off, newblkno, oldblkno, newsize, oldsize, bp) TAILQ_INSERT_TAIL(adphead, adp, ad_next); if (oldadp != NULL && oldadp->ad_offset == off) allocdirect_merge(adphead, adp, oldadp); - FREE_LOCK(ip->i_ump); + FREE_LOCK(ump); return; } TAILQ_FOREACH(oldadp, adphead, ad_next) { @@ -5738,7 +5742,7 @@ softdep_setup_allocext(ip, off, newblkno, oldblkno, newsize, oldsize, bp) TAILQ_INSERT_BEFORE(oldadp, adp, ad_next); if (oldadp->ad_offset == off) allocdirect_merge(adphead, adp, oldadp); - FREE_LOCK(ip->i_ump); + FREE_LOCK(ump); } /* @@ -5783,11 +5787,11 @@ newallocindir(ip, ptrno, newblkno, oldblkno, lbn) struct jnewblk *jnewblk; if (oldblkno) - freefrag = newfreefrag(ip, oldblkno, ip->i_fs->fs_bsize, lbn); + freefrag = newfreefrag(ip, oldblkno, ITOFS(ip)->fs_bsize, lbn); else freefrag = NULL; - ACQUIRE_LOCK(ip->i_ump); - if (newblk_lookup(UFSTOVFS(ip->i_ump), newblkno, 0, &newblk) == 0) + ACQUIRE_LOCK(ITOUMP(ip)); + if (newblk_lookup(ITOVFS(ip), newblkno, 0, &newblk) == 0) panic("new_allocindir: lost block"); KASSERT(newblk->nb_list.wk_type == D_NEWBLK, ("newallocindir: newblk already initialized")); @@ -5827,8 +5831,10 @@ softdep_setup_allocindir_page(ip, lbn, bp, ptrno, newblkno, oldblkno, nbp) struct allocindir *aip; struct pagedep *pagedep; struct mount *mp; + struct ufsmount *ump; - mp = UFSTOVFS(ip->i_ump); + mp = ITOVFS(ip); + ump = VFSTOUFS(mp); KASSERT(MOUNTEDSOFTDEP(mp) != 0, ("softdep_setup_allocindir_page called on non-softdep filesystem")); KASSERT(lbn == nbp->b_lblkno, @@ -5849,7 +5855,7 @@ softdep_setup_allocindir_page(ip, lbn, bp, ptrno, newblkno, oldblkno, nbp) pagedep_lookup(mp, nbp, ip->i_number, lbn, DEPALLOC, &pagedep); WORKLIST_INSERT(&nbp->b_dep, &aip->ai_block.nb_list); freefrag = setup_allocindir_phase2(bp, ip, inodedep, aip, lbn); - FREE_LOCK(ip->i_ump); + FREE_LOCK(ump); if (freefrag) handle_workitem_freefrag(freefrag); } @@ -5868,9 +5874,11 @@ softdep_setup_allocindir_meta(nbp, ip, bp, ptrno, newblkno) { struct inodedep *inodedep; struct allocindir *aip; + struct ufsmount *ump; ufs_lbn_t lbn; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ip->i_ump)) != 0, + ump = ITOUMP(ip); + KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ump)) != 0, ("softdep_setup_allocindir_meta called on non-softdep filesystem")); CTR3(KTR_SUJ, "softdep_setup_allocindir_meta: ino %d blkno %jd ptrno %d", @@ -5878,12 +5886,11 @@ softdep_setup_allocindir_meta(nbp, ip, bp, ptrno, newblkno) lbn = nbp->b_lblkno; ASSERT_VOP_LOCKED(ITOV(ip), "softdep_setup_allocindir_meta"); aip = newallocindir(ip, ptrno, newblkno, 0, lbn); - inodedep_lookup(UFSTOVFS(ip->i_ump), ip->i_number, DEPALLOC, - &inodedep); + inodedep_lookup(UFSTOVFS(ump), ip->i_number, DEPALLOC, &inodedep); WORKLIST_INSERT(&nbp->b_dep, &aip->ai_block.nb_list); if (setup_allocindir_phase2(bp, ip, inodedep, aip, lbn)) panic("softdep_setup_allocindir_meta: Block already existed"); - FREE_LOCK(ip->i_ump); + FREE_LOCK(ump); } static void @@ -5925,7 +5932,7 @@ indirdep_lookup(mp, ip, bp) LOCK_OWNED(ump); indirdep = NULL; newindirdep = NULL; - fs = ip->i_fs; + fs = ump->um_fs; for (;;) { LIST_FOREACH(wk, &bp->b_dep, wk_list) { if (wk->wk_type != D_INDIRDEP) @@ -5947,7 +5954,7 @@ indirdep_lookup(mp, ip, bp) M_INDIRDEP, M_SOFTDEP_FLAGS); workitem_alloc(&newindirdep->ir_list, D_INDIRDEP, mp); newindirdep->ir_state = ATTACHED; - if (ip->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(ip)) newindirdep->ir_state |= UFS1FMT; TAILQ_INIT(&newindirdep->ir_trunc); newindirdep->ir_saveddata = NULL; @@ -5962,7 +5969,7 @@ indirdep_lookup(mp, ip, bp) } newindirdep->ir_freeblks = NULL; newindirdep->ir_savebp = - getblk(ip->i_devvp, bp->b_blkno, bp->b_bcount, 0, 0, 0); + getblk(ump->um_devvp, bp->b_blkno, bp->b_bcount, 0, 0, 0); newindirdep->ir_bp = bp; BUF_KERNPROC(newindirdep->ir_savebp); bcopy(bp->b_data, newindirdep->ir_savebp->b_data, bp->b_bcount); @@ -6000,10 +6007,12 @@ setup_allocindir_phase2(bp, ip, inodedep, aip, lbn) struct allocindir *oldaip; struct freefrag *freefrag; struct mount *mp; + struct ufsmount *ump; - LOCK_OWNED(ip->i_ump); - mp = UFSTOVFS(ip->i_ump); - fs = ip->i_fs; + mp = ITOVFS(ip); + ump = VFSTOUFS(mp); + LOCK_OWNED(ump); + fs = ump->um_fs; if (bp->b_lblkno >= 0) panic("setup_allocindir_phase2: not indir blk"); KASSERT(aip->ai_offset >= 0 && aip->ai_offset < NINDIR(fs), @@ -6088,6 +6097,7 @@ setup_freedirect(freeblks, ip, i, needj) int i; int needj; { + struct ufsmount *ump; ufs2_daddr_t blkno; int frags; @@ -6095,9 +6105,10 @@ setup_freedirect(freeblks, ip, i, needj) if (blkno == 0) return; DIP_SET(ip, i_db[i], 0); - frags = sblksize(ip->i_fs, ip->i_size, i); - frags = numfrags(ip->i_fs, frags); - newfreework(ip->i_ump, freeblks, NULL, i, blkno, frags, 0, needj); + ump = ITOUMP(ip); + frags = sblksize(ump->um_fs, ip->i_size, i); + frags = numfrags(ump->um_fs, frags); + newfreework(ump, freeblks, NULL, i, blkno, frags, 0, needj); } static inline void @@ -6107,6 +6118,7 @@ setup_freeext(freeblks, ip, i, needj) int i; int needj; { + struct ufsmount *ump; ufs2_daddr_t blkno; int frags; @@ -6114,9 +6126,10 @@ setup_freeext(freeblks, ip, i, needj) if (blkno == 0) return; ip->i_din2->di_extb[i] = 0; - frags = sblksize(ip->i_fs, ip->i_din2->di_extsize, i); - frags = numfrags(ip->i_fs, frags); - newfreework(ip->i_ump, freeblks, NULL, -1 - i, blkno, frags, 0, needj); + ump = ITOUMP(ip); + frags = sblksize(ump->um_fs, ip->i_din2->di_extsize, i); + frags = numfrags(ump->um_fs, frags); + newfreework(ump, freeblks, NULL, -1 - i, blkno, frags, 0, needj); } static inline void @@ -6127,13 +6140,15 @@ setup_freeindir(freeblks, ip, i, lbn, needj) ufs_lbn_t lbn; int needj; { + struct ufsmount *ump; ufs2_daddr_t blkno; blkno = DIP(ip, i_ib[i]); if (blkno == 0) return; DIP_SET(ip, i_ib[i], 0); - newfreework(ip->i_ump, freeblks, NULL, lbn, blkno, ip->i_fs->fs_frag, + ump = ITOUMP(ip); + newfreework(ump, freeblks, NULL, lbn, blkno, ump->um_fs->fs_frag, 0, needj); } @@ -6156,7 +6171,7 @@ newfreeblks(mp, ip) freeblks->fb_inum = ip->i_number; freeblks->fb_vtype = ITOV(ip)->v_type; freeblks->fb_modrev = DIP(ip, i_modrev); - freeblks->fb_devvp = ip->i_devvp; + freeblks->fb_devvp = ITODEVVP(ip); freeblks->fb_chkcnt = 0; freeblks->fb_len = 0; @@ -6211,6 +6226,7 @@ setup_trunc_indir(freeblks, ip, lbn, lastlbn, blkno) struct freework *freework; struct newblk *newblk; struct mount *mp; + struct ufsmount *ump; struct buf *bp; uint8_t *start; uint8_t *end; @@ -6224,6 +6240,7 @@ setup_trunc_indir(freeblks, ip, lbn, lastlbn, blkno) if (blkno == 0) return (0); mp = freeblks->fb_list.wk_mp; + ump = VFSTOUFS(mp); bp = getblk(ITOV(ip), lbn, mp->mnt_stat.f_iosize, 0, 0, 0); if ((bp->b_flags & B_CACHE) == 0) { bp->b_blkno = blkptrtodb(VFSTOUFS(mp), blkno); @@ -6248,22 +6265,21 @@ setup_trunc_indir(freeblks, ip, lbn, lastlbn, blkno) } } level = lbn_level(lbn); - lbnadd = lbn_offset(ip->i_fs, level); + lbnadd = lbn_offset(ump->um_fs, level); /* * Compute the offset of the last block we want to keep. Store * in the freework the first block we want to completely free. */ off = (lastlbn - -(lbn + level)) / lbnadd; - if (off + 1 == NINDIR(ip->i_fs)) + if (off + 1 == NINDIR(ump->um_fs)) goto nowork; - freework = newfreework(ip->i_ump, freeblks, NULL, lbn, blkno, 0, off+1, - 0); + freework = newfreework(ump, freeblks, NULL, lbn, blkno, 0, off + 1, 0); /* * Link the freework into the indirdep. This will prevent any new * allocations from proceeding until we are finished with the * truncate and the block is written. */ - ACQUIRE_LOCK(ip->i_ump); + ACQUIRE_LOCK(ump); indirdep = indirdep_lookup(mp, ip, bp); if (indirdep->ir_freeblks) panic("setup_trunc_indir: indirdep already truncated."); @@ -6275,12 +6291,12 @@ setup_trunc_indir(freeblks, ip, lbn, lastlbn, blkno) * live on this newblk. */ if ((indirdep->ir_state & DEPCOMPLETE) == 0) { - newblk_lookup(mp, dbtofsb(ip->i_fs, bp->b_blkno), 0, &newblk); + newblk_lookup(mp, dbtofsb(ump->um_fs, bp->b_blkno), 0, &newblk); LIST_FOREACH(indirn, &newblk->nb_indirdeps, ir_next) trunc_indirdep(indirn, freeblks, bp, off); } else trunc_indirdep(indirdep, freeblks, bp, off); - FREE_LOCK(ip->i_ump); + FREE_LOCK(ump); /* * Creation is protected by the buf lock. The saveddata is only * needed if a full truncation follows a partial truncation but it @@ -6291,7 +6307,7 @@ setup_trunc_indir(freeblks, ip, lbn, lastlbn, blkno) M_SOFTDEP_FLAGS); nowork: /* Fetch the blkno of the child and the zero start offset. */ - if (ip->i_ump->um_fstype == UFS1) { + if (I_IS_UFS1(ip)) { blkno = ((ufs1_daddr_t *)bp->b_data)[off]; start = (uint8_t *)&((ufs1_daddr_t *)bp->b_data)[off+1]; } else { @@ -6501,9 +6517,9 @@ softdep_journal_freeblocks(ip, cred, length, flags) ufs_lbn_t tmpval, lbn, lastlbn; int frags, lastoff, iboff, allocblock, needj, error, i; - fs = ip->i_fs; - ump = ip->i_ump; + ump = ITOUMP(ip); mp = UFSTOVFS(ump); + fs = ump->um_fs; KASSERT(MOUNTEDSOFTDEP(mp) != 0, ("softdep_journal_freeblocks called on non-softdep filesystem")); vp = ITOV(ip); @@ -6583,13 +6599,13 @@ softdep_journal_freeblocks(ip, cred, length, flags) blkno = DIP(ip, i_db[lastlbn]); if (blkno && oldfrags != frags) { oldfrags -= frags; - oldfrags = numfrags(ip->i_fs, oldfrags); - blkno += numfrags(ip->i_fs, frags); + oldfrags = numfrags(fs, oldfrags); + blkno += numfrags(fs, frags); newfreework(ump, freeblks, NULL, lastlbn, blkno, oldfrags, 0, needj); if (needj) adjust_newfreework(freeblks, - numfrags(ip->i_fs, frags)); + numfrags(fs, frags)); } else if (blkno == 0) allocblock = 1; } @@ -6606,7 +6622,7 @@ softdep_journal_freeblocks(ip, cred, length, flags) DIP_SET(ip, i_size, ip->i_size); datablocks = DIP(ip, i_blocks) - extblocks; if (length != 0) - datablocks = blkcount(ip->i_fs, datablocks, length); + datablocks = blkcount(fs, datablocks, length); freeblks->fb_len = length; } if ((flags & IO_EXT) != 0) { @@ -6633,7 +6649,7 @@ softdep_journal_freeblocks(ip, cred, length, flags) */ ufs_itimes(vp); ip->i_flag &= ~(IN_LAZYACCESS | IN_LAZYMOD | IN_MODIFIED); - error = bread(ip->i_devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), + error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), (int)fs->fs_bsize, cred, &bp); if (error) { brelse(bp); @@ -6773,20 +6789,22 @@ softdep_journal_fsync(ip) struct inode *ip; { struct jfsync *jfsync; + struct ufsmount *ump; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ip->i_ump)) != 0, + ump = ITOUMP(ip); + KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ump)) != 0, ("softdep_journal_fsync called on non-softdep filesystem")); if ((ip->i_flag & IN_TRUNCATED) == 0) return; ip->i_flag &= ~IN_TRUNCATED; jfsync = malloc(sizeof(*jfsync), M_JFSYNC, M_SOFTDEP_FLAGS | M_ZERO); - workitem_alloc(&jfsync->jfs_list, D_JFSYNC, UFSTOVFS(ip->i_ump)); + workitem_alloc(&jfsync->jfs_list, D_JFSYNC, UFSTOVFS(ump)); jfsync->jfs_size = ip->i_size; jfsync->jfs_ino = ip->i_number; - ACQUIRE_LOCK(ip->i_ump); + ACQUIRE_LOCK(ump); add_to_journal(&jfsync->jfs_list); jwait(&jfsync->jfs_list, MNT_WAIT); - FREE_LOCK(ip->i_ump); + FREE_LOCK(ump); } /* @@ -6838,15 +6856,15 @@ softdep_setup_freeblocks(ip, length, flags) ufs_lbn_t tmpval; ufs_lbn_t lbn; - ump = ip->i_ump; + ump = ITOUMP(ip); mp = UFSTOVFS(ump); KASSERT(MOUNTEDSOFTDEP(mp) != 0, ("softdep_setup_freeblocks called on non-softdep filesystem")); CTR2(KTR_SUJ, "softdep_setup_freeblks: ip %d length %ld", ip->i_number, length); KASSERT(length == 0, ("softdep_setup_freeblocks: non-zero length")); - fs = ip->i_fs; - if ((error = bread(ip->i_devvp, + fs = ump->um_fs; + if ((error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), (int)fs->fs_bsize, NOCRED, &bp)) != 0) { brelse(bp); @@ -6981,7 +6999,7 @@ trunc_pages(ip, length, extblocks, flags) off_t end, extend; vp = ITOV(ip); - fs = ip->i_fs; + fs = ITOFS(ip); extend = OFF_TO_IDX(lblktosize(fs, -extblocks)); if ((flags & IO_EXT) != 0) vn_pages_remove(vp, extend, 0); @@ -7517,7 +7535,7 @@ softdep_freefile(pvp, ino, mode) struct freeblks *freeblks; struct ufsmount *ump; - ump = ip->i_ump; + ump = ITOUMP(ip); KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ump)) != 0, ("softdep_freefile called on non-softdep filesystem")); /* @@ -7528,10 +7546,10 @@ softdep_freefile(pvp, ino, mode) workitem_alloc(&freefile->fx_list, D_FREEFILE, pvp->v_mount); freefile->fx_mode = mode; freefile->fx_oldinum = ino; - freefile->fx_devvp = ip->i_devvp; + freefile->fx_devvp = ump->um_devvp; LIST_INIT(&freefile->fx_jwork); UFS_LOCK(ump); - ip->i_fs->fs_pendinginodes += 1; + ump->um_fs->fs_pendinginodes += 1; UFS_UNLOCK(ump); /* @@ -8451,8 +8469,8 @@ softdep_setup_directory_add(bp, dp, diroffset, newinum, newdirbp, isnewblk) struct mount *mp; int isindir; - ump = dp->i_ump; - mp = UFSTOVFS(ump); + mp = ITOVFS(dp); + ump = VFSTOUFS(mp); KASSERT(MOUNTEDSOFTDEP(mp) != 0, ("softdep_setup_directory_add called on non-softdep filesystem")); /* @@ -8465,7 +8483,7 @@ softdep_setup_directory_add(bp, dp, diroffset, newinum, newdirbp, isnewblk) } jaddref = NULL; mkdir1 = mkdir2 = NULL; - fs = dp->i_fs; + fs = ump->um_fs; lbn = lblkno(fs, diroffset); offset = blkoff(fs, diroffset); dap = malloc(sizeof(struct diradd), M_DIRADD, @@ -8618,10 +8636,12 @@ softdep_change_directoryentry_offset(bp, dp, base, oldloc, newloc, entrysize) struct diradd *dap; struct direct *de; struct mount *mp; + struct ufsmount *ump; ufs_lbn_t lbn; int flags; - mp = UFSTOVFS(dp->i_ump); + mp = ITOVFS(dp); + ump = VFSTOUFS(mp); KASSERT(MOUNTEDSOFTDEP(mp) != 0, ("softdep_change_directoryentry_offset called on " "non-softdep filesystem")); @@ -8639,11 +8659,11 @@ softdep_change_directoryentry_offset(bp, dp, base, oldloc, newloc, entrysize) dp->i_offset + (oldloc - base), dp->i_offset + (newloc - base)); } - lbn = lblkno(dp->i_fs, dp->i_offset); - offset = blkoff(dp->i_fs, dp->i_offset); + lbn = lblkno(ump->um_fs, dp->i_offset); + offset = blkoff(ump->um_fs, dp->i_offset); oldoffset = offset + (oldloc - base); newoffset = offset + (newloc - base); - ACQUIRE_LOCK(dp->i_ump); + ACQUIRE_LOCK(ump); if (pagedep_lookup(mp, bp, dp->i_number, lbn, flags, &pagedep) == 0) goto done; dap = diradd_lookup(pagedep, oldoffset); @@ -8665,7 +8685,7 @@ done: add_to_journal(&jmvref->jm_list); } bcopy(oldloc, newloc, entrysize); - FREE_LOCK(dp->i_ump); + FREE_LOCK(ump); } /* @@ -8908,9 +8928,11 @@ softdep_setup_remove(bp, dp, ip, isrmdir) { struct dirrem *dirrem, *prevdirrem; struct inodedep *inodedep; + struct ufsmount *ump; int direct; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ip->i_ump)) != 0, + ump = ITOUMP(ip); + KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ump)) != 0, ("softdep_setup_remove called on non-softdep filesystem")); /* * Allocate a new dirrem if appropriate and ACQUIRE_LOCK. We want @@ -8922,8 +8944,7 @@ softdep_setup_remove(bp, dp, ip, isrmdir) * Add the dirrem to the inodedep's pending remove list for quick * discovery later. */ - if (inodedep_lookup(UFSTOVFS(ip->i_ump), ip->i_number, 0, - &inodedep) == 0) + if (inodedep_lookup(UFSTOVFS(ump), ip->i_number, 0, &inodedep) == 0) panic("softdep_setup_remove: Lost inodedep."); KASSERT((inodedep->id_state & UNLINKED) == 0, ("inode unlinked")); dirrem->dm_state |= ONDEPLIST; @@ -8943,14 +8964,14 @@ softdep_setup_remove(bp, dp, ip, isrmdir) if ((dirrem->dm_state & COMPLETE) == 0) { LIST_INSERT_HEAD(&dirrem->dm_pagedep->pd_dirremhd, dirrem, dm_next); - FREE_LOCK(ip->i_ump); + FREE_LOCK(ump); } else { if (prevdirrem != NULL) LIST_INSERT_HEAD(&dirrem->dm_pagedep->pd_dirremhd, prevdirrem, dm_next); dirrem->dm_dirinum = dirrem->dm_pagedep->pd_ino; direct = LIST_EMPTY(&dirrem->dm_jremrefhd); - FREE_LOCK(ip->i_ump); + FREE_LOCK(ump); if (direct) handle_workitem_remove(dirrem, 0); } @@ -8992,8 +9013,7 @@ cancel_diradd_dotdot(ip, dirrem, jremref) struct diradd *dap; struct worklist *wk; - if (pagedep_lookup(UFSTOVFS(ip->i_ump), NULL, ip->i_number, 0, 0, - &pagedep) == 0) + if (pagedep_lookup(ITOVFS(ip), NULL, ip->i_number, 0, 0, &pagedep) == 0) return (jremref); dap = diradd_lookup(pagedep, DOTDOT_OFFSET); if (dap == NULL) @@ -9025,9 +9045,10 @@ cancel_mkdir_dotdot(ip, dirrem, jremref) struct ufsmount *ump; struct mkdir *mkdir; struct diradd *dap; + struct mount *mp; - if (inodedep_lookup(UFSTOVFS(ip->i_ump), ip->i_number, 0, - &inodedep) == 0) + mp = ITOVFS(ip); + if (inodedep_lookup(mp, ip->i_number, 0, &inodedep) == 0) return (jremref); dap = inodedep->id_mkdiradd; if (dap == NULL || (dap->da_state & MKDIR_PARENT) == 0) @@ -9042,8 +9063,7 @@ cancel_mkdir_dotdot(ip, dirrem, jremref) if ((jaddref = mkdir->md_jaddref) != NULL) { mkdir->md_jaddref = NULL; jaddref->ja_state &= ~MKDIR_PARENT; - if (inodedep_lookup(UFSTOVFS(ip->i_ump), jaddref->ja_ino, 0, - &inodedep) == 0) + if (inodedep_lookup(mp, jaddref->ja_ino, 0, &inodedep) == 0) panic("cancel_mkdir_dotdot: Lost parent inodedep"); if (cancel_jaddref(jaddref, inodedep, &dirrem->dm_jwork)) { journal_jremref(dirrem, jremref, inodedep); @@ -9114,6 +9134,7 @@ newdirrem(bp, dp, ip, isrmdir, prevdirremp) struct jremref *dotremref; struct jremref *dotdotremref; struct vnode *dvp; + struct ufsmount *ump; /* * Whiteouts have no deletion dependencies. @@ -9121,6 +9142,8 @@ newdirrem(bp, dp, ip, isrmdir, prevdirremp) if (ip == NULL) panic("newdirrem: whiteout"); dvp = ITOV(dp); + ump = ITOUMP(dp); + /* * If the system is over its limit and our filesystem is * responsible for more than our share of that usage and @@ -9128,11 +9151,11 @@ newdirrem(bp, dp, ip, isrmdir, prevdirremp) * Limiting the number of dirrem structures will also limit * the number of freefile and freeblks structures. */ - ACQUIRE_LOCK(ip->i_ump); - if (!IS_SNAPSHOT(ip) && softdep_excess_items(ip->i_ump, D_DIRREM)) - schedule_cleanup(ITOV(dp)->v_mount); + ACQUIRE_LOCK(ump); + if (!IS_SNAPSHOT(ip) && softdep_excess_items(ump, D_DIRREM)) + schedule_cleanup(UFSTOVFS(ump)); else - FREE_LOCK(ip->i_ump); + FREE_LOCK(ump); dirrem = malloc(sizeof(struct dirrem), M_DIRREM, M_SOFTDEP_FLAGS | M_ZERO); workitem_alloc(&dirrem->dm_list, D_DIRREM, dvp->v_mount); @@ -9162,10 +9185,10 @@ newdirrem(bp, dp, ip, isrmdir, prevdirremp) jremref = newjremref(dirrem, dp, ip, dp->i_offset, ip->i_effnlink + 1); } - ACQUIRE_LOCK(ip->i_ump); - lbn = lblkno(dp->i_fs, dp->i_offset); - offset = blkoff(dp->i_fs, dp->i_offset); - pagedep_lookup(UFSTOVFS(dp->i_ump), bp, dp->i_number, lbn, DEPALLOC, + ACQUIRE_LOCK(ump); + lbn = lblkno(ump->um_fs, dp->i_offset); + offset = blkoff(ump->um_fs, dp->i_offset); + pagedep_lookup(UFSTOVFS(ump), bp, dp->i_number, lbn, DEPALLOC, &pagedep); dirrem->dm_pagedep = pagedep; dirrem->dm_offset = offset; @@ -9272,9 +9295,11 @@ softdep_setup_directory_change(bp, dp, ip, newinum, isrmdir) struct inodedep *inodedep; struct jaddref *jaddref; struct mount *mp; + struct ufsmount *ump; - offset = blkoff(dp->i_fs, dp->i_offset); - mp = UFSTOVFS(dp->i_ump); + mp = ITOVFS(dp); + ump = VFSTOUFS(mp); + offset = blkoff(ump->um_fs, dp->i_offset); KASSERT(MOUNTEDSOFTDEP(mp) != 0, ("softdep_setup_directory_change called on non-softdep filesystem")); @@ -9324,7 +9349,7 @@ softdep_setup_directory_change(bp, dp, ip, newinum, isrmdir) if (LIST_EMPTY(&dirrem->dm_jremrefhd)) add_to_worklist(&dirrem->dm_list, 0); } - FREE_LOCK(dp->i_ump); + FREE_LOCK(ump); return; } /* @@ -9398,7 +9423,7 @@ softdep_setup_directory_change(bp, dp, ip, newinum, isrmdir) */ if (inodedep->id_mkdiradd && dp->i_offset != DOTDOT_OFFSET) merge_diradd(inodedep, dap); - FREE_LOCK(dp->i_ump); + FREE_LOCK(ump); } /* @@ -9412,16 +9437,17 @@ softdep_change_linkcnt(ip) struct inode *ip; /* the inode with the increased link count */ { struct inodedep *inodedep; + struct ufsmount *ump; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ip->i_ump)) != 0, + ump = ITOUMP(ip); + KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ump)) != 0, ("softdep_change_linkcnt called on non-softdep filesystem")); - ACQUIRE_LOCK(ip->i_ump); - inodedep_lookup(UFSTOVFS(ip->i_ump), ip->i_number, DEPALLOC, - &inodedep); + ACQUIRE_LOCK(ump); + inodedep_lookup(UFSTOVFS(ump), ip->i_number, DEPALLOC, &inodedep); if (ip->i_nlink < ip->i_effnlink) panic("softdep_change_linkcnt: bad delta"); inodedep->id_nlinkdelta = ip->i_nlink - ip->i_effnlink; - FREE_LOCK(ip->i_ump); + FREE_LOCK(ump); } /* @@ -12014,21 +12040,22 @@ softdep_load_inodeblock(ip) struct inode *ip; /* the "in_core" copy of the inode */ { struct inodedep *inodedep; + struct ufsmount *ump; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ip->i_ump)) != 0, + ump = ITOUMP(ip); + KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ump)) != 0, ("softdep_load_inodeblock called on non-softdep filesystem")); /* * Check for alternate nlink count. */ ip->i_effnlink = ip->i_nlink; - ACQUIRE_LOCK(ip->i_ump); - if (inodedep_lookup(UFSTOVFS(ip->i_ump), ip->i_number, 0, - &inodedep) == 0) { - FREE_LOCK(ip->i_ump); + ACQUIRE_LOCK(ump); + if (inodedep_lookup(UFSTOVFS(ump), ip->i_number, 0, &inodedep) == 0) { + FREE_LOCK(ump); return; } ip->i_effnlink -= inodedep->id_nlinkdelta; - FREE_LOCK(ip->i_ump); + FREE_LOCK(ump); } /* @@ -12056,11 +12083,11 @@ softdep_update_inodeblock(ip, bp, waitfor) struct fs *fs; int error; - ump = ip->i_ump; + ump = ITOUMP(ip); mp = UFSTOVFS(ump); KASSERT(MOUNTEDSOFTDEP(mp) != 0, ("softdep_update_inodeblock called on non-softdep filesystem")); - fs = ip->i_fs; + fs = ump->um_fs; /* * Preserve the freelink that is on disk. clear_unlinked_inodedep() * does not have access to the in-core ip so must write directly into @@ -12225,9 +12252,9 @@ softdep_fsync(vp) ufs_lbn_t lbn; ip = VTOI(vp); - fs = ip->i_fs; - ump = ip->i_ump; mp = vp->v_mount; + ump = VFSTOUFS(mp); + fs = ump->um_fs; if (MOUNTEDSOFTDEP(mp) == 0) return (0); ACQUIRE_LOCK(ump); @@ -12500,13 +12527,13 @@ softdep_sync_metadata(struct vnode *vp) int error; ip = VTOI(vp); - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ip->i_ump)) != 0, + KASSERT(MOUNTEDSOFTDEP(vp->v_mount) != 0, ("softdep_sync_metadata called on non-softdep filesystem")); /* * Ensure that any direct block dependencies have been cleared, * truncations are started, and inode references are journaled. */ - ACQUIRE_LOCK(ip->i_ump); + ACQUIRE_LOCK(VFSTOUFS(vp->v_mount)); /* * Write all journal records to prevent rollbacks on devvp. */ @@ -12518,7 +12545,7 @@ softdep_sync_metadata(struct vnode *vp) * indirect blocks. */ process_truncates(vp); - FREE_LOCK(ip->i_ump); + FREE_LOCK(VFSTOUFS(vp->v_mount)); return (error); } @@ -12553,7 +12580,7 @@ softdep_sync_buf(struct vnode *vp, struct buf *bp, int waitfor) return (EBUSY); return (0); } - ump = VTOI(vp)->i_ump; + ump = VFSTOUFS(vp->v_mount); ACQUIRE_LOCK(ump); /* * As we hold the buffer locked, none of its dependencies @@ -13674,12 +13701,14 @@ softdep_inode_append(ip, cred, wkhd) { struct buf *bp; struct fs *fs; + struct ufsmount *ump; int error; - KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ip->i_ump)) != 0, + ump = ITOUMP(ip); + KASSERT(MOUNTEDSOFTDEP(UFSTOVFS(ump)) != 0, ("softdep_inode_append called on non-softdep filesystem")); - fs = ip->i_fs; - error = bread(ip->i_devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), + fs = ump->um_fs; + error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), (int)fs->fs_bsize, cred, &bp); if (error) { bqrelse(bp); diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index 67f7e5c..cabed2b 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -74,7 +74,7 @@ ffs_blkatoff(vp, offset, res, bpp) int bsize, error; ip = VTOI(vp); - fs = ip->i_fs; + fs = ITOFS(ip); lbn = lblkno(fs, offset); bsize = blksize(fs, ip, lbn); @@ -102,7 +102,7 @@ ffs_load_inode(bp, ip, fs, ino) ino_t ino; { - if (ip->i_ump->um_fstype == UFS1) { + if (I_IS_UFS1(ip)) { *ip->i_din1 = *((struct ufs1_dinode *)bp->b_data + ino_to_fsbo(fs, ino)); ip->i_mode = ip->i_din1->di_mode; diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index b28b742..d8790d1 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1652,7 +1652,6 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags) struct ufsmount *ump; struct buf *bp; struct vnode *vp; - struct cdev *dev; int error; error = vfs_hash_get(mp, ino, flags, curthread, vpp, NULL, NULL); @@ -1676,7 +1675,6 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags) */ ump = VFSTOUFS(mp); - dev = ump->um_dev; fs = ump->um_fs; ip = uma_zalloc(uma_inode, M_WAITOK | M_ZERO); @@ -1697,11 +1695,10 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags) vp->v_bufobj.bo_bsize = fs->fs_bsize; ip->i_vnode = vp; ip->i_ump = ump; - ip->i_fs = fs; - ip->i_dev = dev; ip->i_number = ino; ip->i_ea_refs = 0; ip->i_nextclustercg = -1; + ip->i_flag = fs->fs_magic == FS_UFS1_MAGIC ? 0 : IN_UFS2; #ifdef QUOTA { int i; @@ -1738,7 +1735,7 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags) *vpp = NULL; return (error); } - if (ip->i_ump->um_fstype == UFS1) + if (I_IS_UFS1(ip)) ip->i_din1 = uma_zalloc(uma_ufs1, M_WAITOK); else ip->i_din2 = uma_zalloc(uma_ufs2, M_WAITOK); @@ -1753,10 +1750,8 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags) * Initialize the vnode from the inode, check for aliases. * Note that the underlying vnode may have changed. */ - if (ip->i_ump->um_fstype == UFS1) - error = ufs_vinit(mp, &ffs_fifoops1, &vp); - else - error = ufs_vinit(mp, &ffs_fifoops2, &vp); + error = ufs_vinit(mp, I_IS_UFS1(ip) ? &ffs_fifoops1 : &ffs_fifoops2, + &vp); if (error) { vput(vp); *vpp = NULL; diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 2765480..cdcff7e 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -244,7 +244,7 @@ ffs_syncvnode(struct vnode *vp, int waitfor, int flags) error = 0; passes = 0; wait = false; /* Always do an async pass first. */ - lbn = lblkno(ip->i_fs, (ip->i_size + ip->i_fs->fs_bsize - 1)); + lbn = lblkno(ITOFS(ip), (ip->i_size + ITOFS(ip)->fs_bsize - 1)); BO_LOCK(bo); loop: TAILQ_FOREACH(bp, &bo->bo_dirty.bv_hd, b_bobufs) @@ -518,7 +518,7 @@ ffs_read(ap) if (orig_resid == 0) return (0); KASSERT(uio->uio_offset >= 0, ("ffs_read: uio->uio_offset < 0")); - fs = ip->i_fs; + fs = ITOFS(ip); if (uio->uio_offset < ip->i_size && uio->uio_offset >= fs->fs_maxfilesize) return (EOVERFLOW); @@ -741,7 +741,7 @@ ffs_write(ap) KASSERT(uio->uio_resid >= 0, ("ffs_write: uio->uio_resid < 0")); KASSERT(uio->uio_offset >= 0, ("ffs_write: uio->uio_offset < 0")); - fs = ip->i_fs; + fs = ITOFS(ip); if ((uoff_t)uio->uio_offset + uio->uio_resid > fs->fs_maxfilesize) return (EFBIG); /* @@ -905,7 +905,7 @@ ffs_extread(struct vnode *vp, struct uio *uio, int ioflag) int error; ip = VTOI(vp); - fs = ip->i_fs; + fs = ITOFS(ip); dp = ip->i_din2; #ifdef INVARIANTS @@ -1059,7 +1059,7 @@ ffs_extwrite(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *ucred) int blkoffset, error, flags, size, xfersize; ip = VTOI(vp); - fs = ip->i_fs; + fs = ITOFS(ip); dp = ip->i_din2; #ifdef INVARIANTS @@ -1231,7 +1231,7 @@ ffs_rdextattr(u_char **p, struct vnode *vp, struct thread *td, int extra) u_char *eae; ip = VTOI(vp); - fs = ip->i_fs; + fs = ITOFS(ip); dp = ip->i_din2; easize = dp->di_extsize; if ((uoff_t)easize + extra > NXADDR * fs->fs_bsize) @@ -1385,8 +1385,7 @@ struct vop_strategy_args { vp = ap->a_vp; lbn = ap->a_bp->b_lblkno; - if (VTOI(vp)->i_fs->fs_magic == FS_UFS2_MAGIC && - lbn < 0 && lbn >= -NXADDR) + if (I_IS_UFS2(VTOI(vp)) && lbn < 0 && lbn >= -NXADDR) return (VOP_STRATEGY_APV(&ufs_vnodeops, ap)); if (vp->v_type == VFIFO) return (VOP_STRATEGY_APV(&ufs_fifoops, ap)); @@ -1462,7 +1461,7 @@ vop_deleteextattr { u_char *eae, *p; ip = VTOI(ap->a_vp); - fs = ip->i_fs; + fs = ITOFS(ip); if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) return (EOPNOTSUPP); @@ -1665,7 +1664,7 @@ vop_setextattr { u_char *eae, *p; ip = VTOI(ap->a_vp); - fs = ip->i_fs; + fs = ITOFS(ip); if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) return (EOPNOTSUPP); diff --git a/sys/ufs/ufs/extattr.h b/sys/ufs/ufs/extattr.h index 1e5152c..6b4987c 100644 --- a/sys/ufs/ufs/extattr.h +++ b/sys/ufs/ufs/extattr.h @@ -133,6 +133,10 @@ struct ufs_extattr_per_mount { int uepm_flags; }; +struct vop_getextattr_args; +struct vop_deleteextattr_args; +struct vop_setextattr_args; + void ufs_extattr_uepm_init(struct ufs_extattr_per_mount *uepm); void ufs_extattr_uepm_destroy(struct ufs_extattr_per_mount *uepm); int ufs_extattr_start(struct mount *mp, struct thread *td); diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index cd7c472..e44cae5 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -66,14 +66,25 @@ struct inode { TAILQ_ENTRY(inode) i_nextsnap; /* snapshot file list. */ struct vnode *i_vnode;/* Vnode associated with this inode. */ - struct ufsmount *i_ump;/* Ufsmount point associated with this inode. */ - u_int32_t i_flag; /* flags, see below */ - struct cdev *i_dev; /* Device associated with the inode. */ + struct ufsmount *i_ump;/* Ufsmount point associated with this inode. */ + struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ + union { + struct dirhash *dirhash; /* Hashing for large directories. */ + daddr_t *snapblklist; /* Collect expunged snapshot blocks. */ + } i_un; + /* + * The real copy of the on-disk inode. + */ + union { + struct ufs1_dinode *din1; /* UFS1 on-disk dinode. */ + struct ufs2_dinode *din2; /* UFS2 on-disk dinode. */ + } dinode_u; + ino_t i_number; /* The identity of the inode. */ + u_int32_t i_flag; /* flags, see below */ int i_effnlink; /* i_nlink when I/O completes */ - struct fs *i_fs; /* Associated filesystem superblock. */ - struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ + /* * Side effects; used during directory lookup. */ @@ -82,11 +93,6 @@ struct inode { doff_t i_diroff; /* Offset in dir, where we found last entry. */ doff_t i_offset; /* Offset of free space in directory. */ - union { - struct dirhash *dirhash; /* Hashing for large directories. */ - daddr_t *snapblklist; /* Collect expunged snapshot blocks. */ - } i_un; - int i_nextclustercg; /* last cg searched for cluster */ /* @@ -100,20 +106,13 @@ struct inode { /* * Copies from the on-disk dinode itself. */ - u_int16_t i_mode; /* IFMT, permissions; see below. */ - int16_t i_nlink; /* File link count. */ u_int64_t i_size; /* File byte count. */ - u_int32_t i_flags; /* Status flags (chflags). */ u_int64_t i_gen; /* Generation number. */ + u_int32_t i_flags; /* Status flags (chflags). */ u_int32_t i_uid; /* File owner. */ u_int32_t i_gid; /* File group. */ - /* - * The real copy of the on-disk inode. - */ - union { - struct ufs1_dinode *din1; /* UFS1 on-disk dinode. */ - struct ufs2_dinode *din2; /* UFS2 on-disk dinode. */ - } dinode_u; + u_int16_t i_mode; /* IFMT, permissions; see below. */ + int16_t i_nlink; /* File link count. */ }; /* * These flags are kept in i_flag. @@ -123,39 +122,58 @@ struct inode { #define IN_UPDATE 0x0004 /* Modification time update request. */ #define IN_MODIFIED 0x0008 /* Inode has been modified. */ #define IN_NEEDSYNC 0x0010 /* Inode requires fsync. */ -#define IN_LAZYMOD 0x0040 /* Modified, but don't write yet. */ -#define IN_LAZYACCESS 0x0100 /* Process IN_ACCESS after the +#define IN_LAZYMOD 0x0020 /* Modified, but don't write yet. */ +#define IN_LAZYACCESS 0x0040 /* Process IN_ACCESS after the suspension finished */ -#define IN_EA_LOCKED 0x0200 -#define IN_EA_LOCKWAIT 0x0400 +#define IN_EA_LOCKED 0x0080 +#define IN_EA_LOCKWAIT 0x0100 -#define IN_TRUNCATED 0x0800 /* Journaled truncation pending. */ +#define IN_TRUNCATED 0x0200 /* Journaled truncation pending. */ + +#define IN_UFS2 0x0400 /* UFS2 vs UFS1 */ -#define i_devvp i_ump->um_devvp -#define i_umbufobj i_ump->um_bo #define i_dirhash i_un.dirhash #define i_snapblklist i_un.snapblklist #define i_din1 dinode_u.din1 #define i_din2 dinode_u.din2 #ifdef _KERNEL + +#define ITOUMP(ip) ((ip)->i_ump) +#define ITODEV(ip) (ITOUMP(ip)->um_dev) +#define ITODEVVP(ip) (ITOUMP(ip)->um_devvp) +#define ITOFS(ip) (ITOUMP(ip)->um_fs) +#define ITOVFS(ip) ((ip)->i_vnode->v_mount) + +static inline _Bool +I_IS_UFS1(const struct inode *ip) +{ + + return ((ip->i_flag & IN_UFS2) == 0); +} + +static inline _Bool +I_IS_UFS2(const struct inode *ip) +{ + + return ((ip->i_flag & IN_UFS2) != 0); +} + /* * The DIP macro is used to access fields in the dinode that are * not cached in the inode itself. */ -#define DIP(ip, field) \ - (((ip)->i_ump->um_fstype == UFS1) ? \ - (ip)->i_din1->d##field : (ip)->i_din2->d##field) -#define DIP_SET(ip, field, val) do { \ - if ((ip)->i_ump->um_fstype == UFS1) \ - (ip)->i_din1->d##field = (val); \ - else \ - (ip)->i_din2->d##field = (val); \ +#define DIP(ip, field) (I_IS_UFS1(ip) ? (ip)->i_din1->d##field : \ + (ip)->i_din2->d##field) +#define DIP_SET(ip, field, val) do { \ + if (I_IS_UFS1(ip)) \ + (ip)->i_din1->d##field = (val); \ + else \ + (ip)->i_din2->d##field = (val); \ } while (0) -#define SHORTLINK(ip) \ - (((ip)->i_ump->um_fstype == UFS1) ? \ - (caddr_t)(ip)->i_din1->di_db : (caddr_t)(ip)->i_din2->di_db) +#define SHORTLINK(ip) (I_IS_UFS1(ip) ? \ + (caddr_t)(ip)->i_din1->di_db : (caddr_t)(ip)->i_din2->di_db) #define IS_SNAPSHOT(ip) ((ip)->i_flags & SF_SNAPSHOT) /* diff --git a/sys/ufs/ufs/ufs_acl.c b/sys/ufs/ufs/ufs_acl.c index 836b2c0..86f4270 100644 --- a/sys/ufs/ufs/ufs_acl.c +++ b/sys/ufs/ufs/ufs_acl.c @@ -184,7 +184,7 @@ ufs_getacl_nfs4_internal(struct vnode *vp, struct acl *aclp, struct thread *td) */ printf("ufs_getacl_nfs4(): Loaded invalid ACL (" "%d bytes), inumber %ju on %s\n", len, - (uintmax_t)ip->i_number, ip->i_fs->fs_fsmnt); + (uintmax_t)ip->i_number, ITOFS(ip)->fs_fsmnt); return (EPERM); } @@ -193,7 +193,7 @@ ufs_getacl_nfs4_internal(struct vnode *vp, struct acl *aclp, struct thread *td) if (error) { printf("ufs_getacl_nfs4(): Loaded invalid ACL " "(failed acl_nfs4_check), inumber %ju on %s\n", - (uintmax_t)ip->i_number, ip->i_fs->fs_fsmnt); + (uintmax_t)ip->i_number, ITOFS(ip)->fs_fsmnt); return (EPERM); } @@ -261,7 +261,7 @@ ufs_get_oldacl(acl_type_t type, struct oldacl *old, struct vnode *vp, */ printf("ufs_get_oldacl(): Loaded invalid ACL " "(len = %d), inumber %ju on %s\n", len, - (uintmax_t)ip->i_number, ip->i_fs->fs_fsmnt); + (uintmax_t)ip->i_number, ITOFS(ip)->fs_fsmnt); return (EPERM); } diff --git a/sys/ufs/ufs/ufs_bmap.c b/sys/ufs/ufs/ufs_bmap.c index 768298f..f6a774a 100644 --- a/sys/ufs/ufs/ufs_bmap.c +++ b/sys/ufs/ufs/ufs_bmap.c @@ -78,7 +78,7 @@ ufs_bmap(ap) * to physical mapping is requested. */ if (ap->a_bop != NULL) - *ap->a_bop = &VTOI(ap->a_vp)->i_devvp->v_bufobj; + *ap->a_bop = &VFSTOUFS(ap->a_vp->v_mount)->um_devvp->v_bufobj; if (ap->a_bnp == NULL) return (0); @@ -239,7 +239,7 @@ ufs_bmaparray(vp, bn, bnp, nbp, runp, runb) } } - if (ip->i_ump->um_fstype == UFS1) { + if (I_IS_UFS1(ip)) { daddr = ((ufs1_daddr_t *)bp->b_data)[ap->in_off]; if (num == 1 && daddr && runp) { for (bn = ap->in_off + 1; diff --git a/sys/ufs/ufs/ufs_gjournal.c b/sys/ufs/ufs/ufs_gjournal.c index 4d6fb0e..ecac26c 100644 --- a/sys/ufs/ufs/ufs_gjournal.c +++ b/sys/ufs/ufs/ufs_gjournal.c @@ -65,15 +65,15 @@ ufs_gjournal_modref(struct vnode *vp, int count) ino_t ino; ip = VTOI(vp); - ump = ip->i_ump; - fs = ip->i_fs; - devvp = ip->i_devvp; + ump = VFSTOUFS(vp->v_mount); + fs = ump->um_fs; + devvp = ump->um_devvp; ino = ip->i_number; cg = ino_to_cg(fs, ino); if (devvp->v_type != VCHR) { /* devvp is a snapshot */ - dev = VTOI(devvp)->i_devvp->v_rdev; + dev = VFSTOUFS(devvp->v_mount)->um_devvp->v_rdev; cgbno = fragstoblks(fs, cgtod(fs, cg)); } else { /* devvp is a normal disk device */ diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index e2825b5..aeaa7c8 100644 --- a/sys/ufs/ufs/ufs_inode.c +++ b/sys/ufs/ufs/ufs_inode.c @@ -125,7 +125,7 @@ ufs_inactive(ap) } } isize = ip->i_size; - if (ip->i_ump->um_fstype == UFS2) + if (I_IS_UFS2(ip)) isize += ip->i_din2->di_extsize; if (ip->i_effnlink <= 0 && isize && !UFS_RDONLY(ip)) error = UFS_TRUNCATE(vp, (off_t)0, IO_EXT | IO_NORMAL, NOCRED); @@ -214,7 +214,6 @@ ufs_reclaim(ap) { struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); - struct ufsmount *ump = ip->i_ump; ufs_prepare_reclaim(vp); @@ -233,6 +232,6 @@ ufs_reclaim(ap) VI_LOCK(vp); vp->v_data = 0; VI_UNLOCK(vp); - UFS_IFREE(ump, ip); + UFS_IFREE(ITOUMP(ip), ip); return (0); } diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c index ccc4962..fe8a283 100644 --- a/sys/ufs/ufs/ufs_quota.c +++ b/sys/ufs/ufs/ufs_quota.c @@ -232,13 +232,13 @@ chkdq(struct inode *ip, ufs2_daddr_t change, struct ucred *cred, int flags) /* Reset timer when crossing soft limit */ if (dq->dq_curblocks + change >= dq->dq_bsoftlimit && dq->dq_curblocks < dq->dq_bsoftlimit) - dq->dq_btime = time_second + ip->i_ump->um_btime[i]; + dq->dq_btime = time_second + ITOUMP(ip)->um_btime[i]; dq->dq_curblocks += change; dq->dq_flags |= DQ_MOD; DQI_UNLOCK(dq); if (warn) uprintf("\n%s: warning, %s disk quota exceeded\n", - ITOV(ip)->v_mount->mnt_stat.f_mntonname, + ITOVFS(ip)->mnt_stat.f_mntonname, quotatypes[i]); } return (0); @@ -264,7 +264,7 @@ chkdqchg(struct inode *ip, ufs2_daddr_t change, struct ucred *cred, dq->dq_flags |= DQ_BLKS; DQI_UNLOCK(dq); uprintf("\n%s: write failed, %s disk limit reached\n", - ITOV(ip)->v_mount->mnt_stat.f_mntonname, + ITOVFS(ip)->mnt_stat.f_mntonname, quotatypes[type]); return (EDQUOT); } @@ -277,7 +277,7 @@ chkdqchg(struct inode *ip, ufs2_daddr_t change, struct ucred *cred, */ if (ncurblocks >= dq->dq_bsoftlimit && dq->dq_bsoftlimit) { if (dq->dq_curblocks < dq->dq_bsoftlimit) { - dq->dq_btime = time_second + ip->i_ump->um_btime[type]; + dq->dq_btime = time_second + ITOUMP(ip)->um_btime[type]; if (ip->i_uid == cred->cr_uid) *warn = 1; return (0); @@ -289,7 +289,7 @@ chkdqchg(struct inode *ip, ufs2_daddr_t change, struct ucred *cred, DQI_UNLOCK(dq); uprintf("\n%s: write failed, %s " "disk quota exceeded for too long\n", - ITOV(ip)->v_mount->mnt_stat.f_mntonname, + ITOVFS(ip)->mnt_stat.f_mntonname, quotatypes[type]); return (EDQUOT); } @@ -370,13 +370,13 @@ chkiq(struct inode *ip, int change, struct ucred *cred, int flags) /* Reset timer when crossing soft limit */ if (dq->dq_curinodes + change >= dq->dq_isoftlimit && dq->dq_curinodes < dq->dq_isoftlimit) - dq->dq_itime = time_second + ip->i_ump->um_itime[i]; + dq->dq_itime = time_second + ITOUMP(ip)->um_itime[i]; dq->dq_curinodes += change; dq->dq_flags |= DQ_MOD; DQI_UNLOCK(dq); if (warn) uprintf("\n%s: warning, %s inode quota exceeded\n", - ITOV(ip)->v_mount->mnt_stat.f_mntonname, + ITOVFS(ip)->mnt_stat.f_mntonname, quotatypes[i]); } return (0); @@ -401,7 +401,7 @@ chkiqchg(struct inode *ip, int change, struct ucred *cred, int type, int *warn) dq->dq_flags |= DQ_INODS; DQI_UNLOCK(dq); uprintf("\n%s: write failed, %s inode limit reached\n", - ITOV(ip)->v_mount->mnt_stat.f_mntonname, + ITOVFS(ip)->mnt_stat.f_mntonname, quotatypes[type]); return (EDQUOT); } @@ -414,7 +414,7 @@ chkiqchg(struct inode *ip, int change, struct ucred *cred, int type, int *warn) */ if (ncurinodes >= dq->dq_isoftlimit && dq->dq_isoftlimit) { if (dq->dq_curinodes < dq->dq_isoftlimit) { - dq->dq_itime = time_second + ip->i_ump->um_itime[type]; + dq->dq_itime = time_second + ITOUMP(ip)->um_itime[type]; if (ip->i_uid == cred->cr_uid) *warn = 1; return (0); @@ -426,7 +426,7 @@ chkiqchg(struct inode *ip, int change, struct ucred *cred, int type, int *warn) DQI_UNLOCK(dq); uprintf("\n%s: write failed, %s " "inode quota exceeded for too long\n", - ITOV(ip)->v_mount->mnt_stat.f_mntonname, + ITOVFS(ip)->mnt_stat.f_mntonname, quotatypes[type]); return (EDQUOT); } @@ -445,10 +445,13 @@ chkiqchg(struct inode *ip, int change, struct ucred *cred, int type, int *warn) static void chkdquot(struct inode *ip) { - struct ufsmount *ump = ip->i_ump; - struct vnode *vp = ITOV(ip); + struct ufsmount *ump; + struct vnode *vp; int i; + ump = ITOUMP(ip); + vp = ITOV(ip); + /* * Disk quotas must be turned off for system files. Currently * these are snapshots and quota files. diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 07e59aa..5d5a93d 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -456,7 +456,7 @@ ufs_getattr(ap) VI_LOCK(vp); ufs_itimes_locked(vp); - if (ip->i_ump->um_fstype == UFS1) { + if (I_IS_UFS1(ip)) { vap->va_atime.tv_sec = ip->i_din1->di_atime; vap->va_atime.tv_nsec = ip->i_din1->di_atimensec; } else { @@ -467,13 +467,13 @@ ufs_getattr(ap) /* * Copy from inode table */ - vap->va_fsid = dev2udev(ip->i_dev); + vap->va_fsid = dev2udev(ITOUMP(ip)->um_dev); vap->va_fileid = ip->i_number; vap->va_mode = ip->i_mode & ~IFMT; vap->va_nlink = ip->i_effnlink; vap->va_uid = ip->i_uid; vap->va_gid = ip->i_gid; - if (ip->i_ump->um_fstype == UFS1) { + if (I_IS_UFS1(ip)) { vap->va_rdev = ip->i_din1->di_rdev; vap->va_size = ip->i_din1->di_size; vap->va_mtime.tv_sec = ip->i_din1->di_mtime; @@ -651,8 +651,7 @@ ufs_setattr(ap) DIP_SET(ip, i_mtime, vap->va_mtime.tv_sec); DIP_SET(ip, i_mtimensec, vap->va_mtime.tv_nsec); } - if (vap->va_birthtime.tv_sec != VNOVAL && - ip->i_ump->um_fstype == UFS2) { + if (vap->va_birthtime.tv_sec != VNOVAL && I_IS_UFS2(ip)) { ip->i_din2->di_birthtime = vap->va_birthtime.tv_sec; ip->i_din2->di_birthnsec = vap->va_birthtime.tv_nsec; } @@ -1347,7 +1346,7 @@ relock: * expunge the original entry's existence. */ if (tip == NULL) { - if (tdp->i_dev != fip->i_dev) + if (ITODEV(tdp) != ITODEV(fip)) panic("ufs_rename: EXDEV"); if (doingdirectory && newparent) { /* @@ -1371,7 +1370,7 @@ relock: tdp->i_endoff < tdp->i_size) endoff = tdp->i_endoff; } else { - if (tip->i_dev != tdp->i_dev || tip->i_dev != fip->i_dev) + if (ITODEV(tip) != ITODEV(tdp) || ITODEV(tip) != ITODEV(fip)) panic("ufs_rename: EXDEV"); /* * Short circuit rename(foo, foo). @@ -2301,12 +2300,9 @@ ufs_strategy(ap) { struct buf *bp = ap->a_bp; struct vnode *vp = ap->a_vp; - struct bufobj *bo; - struct inode *ip; ufs2_daddr_t blkno; int error; - ip = VTOI(vp); if (bp->b_blkno == bp->b_lblkno) { error = ufs_bmaparray(vp, bp->b_lblkno, &blkno, bp, NULL, NULL); bp->b_blkno = blkno; @@ -2324,8 +2320,7 @@ ufs_strategy(ap) return (0); } bp->b_iooffset = dbtob(bp->b_blkno); - bo = ip->i_umbufobj; - BO_STRATEGY(bo, bp); + BO_STRATEGY(VFSTOUFS(vp->v_mount)->um_bo, bp); return (0); } @@ -2342,7 +2337,7 @@ ufs_print(ap) struct inode *ip = VTOI(vp); printf("\tino %lu, on dev %s", (u_long)ip->i_number, - devtoname(ip->i_dev)); + devtoname(ITODEV(ip))); if (vp->v_type == VFIFO) fifo_printinfo(vp); printf("\n"); diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h index 838c1e3..e0212e0 100644 --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -108,8 +108,8 @@ struct ufsmount { #define UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd) #define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc) #define UFS_IFREE(aa, bb) ((aa)->um_ifree(aa, bb)) -#define UFS_RDONLY(aa) ((aa)->i_ump->um_rdonly(aa)) -#define UFS_SNAPGONE(aa) ((aa)->i_ump->um_snapgone(aa)) +#define UFS_RDONLY(aa) (ITOUMP(aa)->um_rdonly(aa)) +#define UFS_SNAPGONE(aa) (ITOUMP(aa)->um_snapgone(aa)) #define UFS_LOCK(aa) mtx_lock(&(aa)->um_lock) #define UFS_UNLOCK(aa) mtx_unlock(&(aa)->um_lock) |