summaryrefslogtreecommitdiff
path: root/sys/ufs/ffs
diff options
context:
space:
mode:
authorPedro Martelletto <pedro@cvs.openbsd.org>2005-12-28 20:48:19 +0000
committerPedro Martelletto <pedro@cvs.openbsd.org>2005-12-28 20:48:19 +0000
commit1b49ee3eb8c877858a1f6aed46946e85333e60d6 (patch)
tree6384a28ddd41cb6cdd7d6ac636ee373a55a31ff8 /sys/ufs/ffs
parent3f0c4ca6296d5ec4706edf6976987328f125adb2 (diff)
Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.
Diffstat (limited to 'sys/ufs/ffs')
-rw-r--r--sys/ufs/ffs/ffs_alloc.c52
-rw-r--r--sys/ufs/ffs/ffs_balloc.c35
-rw-r--r--sys/ufs/ffs/ffs_inode.c94
-rw-r--r--sys/ufs/ffs/ffs_softdep.c58
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c25
-rw-r--r--sys/ufs/ffs/fs.h6
6 files changed, 154 insertions, 116 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index df0d2d1a1aa..4a05ecc521b 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_alloc.c,v 1.58 2005/11/06 13:22:39 pedro Exp $ */
+/* $OpenBSD: ffs_alloc.c,v 1.59 2005/12/28 20:48:17 pedro Exp $ */
/* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */
/*
@@ -129,7 +129,7 @@ ffs_alloc(struct inode *ip, daddr_t lbn, daddr_t bpref, int size,
cg = dtog(fs, bpref);
bno = (daddr_t)ffs_hashalloc(ip, cg, (long)bpref, size, ffs_alloccg);
if (bno > 0) {
- ip->i_ffs_blocks += btodb(size);
+ DIP_ADD(ip, blocks, btodb(size));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
*bnp = bno;
return (0);
@@ -180,11 +180,15 @@ ffs_realloccg(struct inode *ip, daddr_t lbprev, daddr_t bpref, int osize,
#endif /* DIAGNOSTIC */
if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) <= 0)
goto nospace;
- if ((bprev = ip->i_ffs_db[lbprev]) == 0) {
+
+ bprev = DIP(ip, db[lbprev]);
+
+ if (bprev == 0) {
printf("dev = 0x%x, bsize = %d, bprev = %d, fs = %s\n",
ip->i_dev, fs->fs_bsize, bprev, fs->fs_fsmnt);
panic("ffs_realloccg: bad bprev");
}
+
/*
* Allocate the extra space in the buffer.
*/
@@ -203,7 +207,7 @@ ffs_realloccg(struct inode *ip, daddr_t lbprev, daddr_t bpref, int osize,
*/
cg = dtog(fs, bprev);
if ((bno = ffs_fragextend(ip, cg, (long)bprev, osize, nsize)) != 0) {
- ip->i_ffs_blocks += btodb(nsize - osize);
+ DIP_ADD(ip, blocks, btodb(nsize - osize));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp != NULL) {
if (bp->b_blkno != fsbtodb(fs, bno))
@@ -277,7 +281,7 @@ ffs_realloccg(struct inode *ip, daddr_t lbprev, daddr_t bpref, int osize,
if (nsize < request)
ffs_blkfree(ip, bno + numfrags(fs, nsize),
(long)(request - nsize));
- ip->i_ffs_blocks += btodb(nsize - osize);
+ DIP_ADD(ip, blocks, btodb(nsize - osize));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp != NULL) {
bp->b_blkno = fsbtodb(fs, bno);
@@ -394,7 +398,7 @@ ffs_reallocblks(void *v)
* Get the starting offset and block map for the first block.
*/
if (start_lvl == 0) {
- sbap = &ip->i_ffs_db[0];
+ sbap = &ip->i_ffs1_db[0];
soff = start_lbn;
} else {
idp = &start_ap[start_lvl - 1];
@@ -461,7 +465,7 @@ ffs_reallocblks(void *v)
printf(" %d,", *bap);
#endif
if (DOINGSOFTDEP(vp)) {
- if (sbap == &ip->i_ffs_db[0] && i < ssize)
+ if (sbap == &ip->i_ffs1_db[0] && i < ssize)
softdep_setup_allocdirect(ip, start_lbn + i,
blkno, *bap, fs->fs_bsize, fs->fs_bsize,
buflist->bs_children[i]);
@@ -487,7 +491,7 @@ ffs_reallocblks(void *v)
* We can then check below to see if it is set, and do the
* synchronous write only when it has been cleared.
*/
- if (sbap != &ip->i_ffs_db[0]) {
+ if (sbap != &ip->i_ffs1_db[0]) {
if (doasyncfree)
bdwrite(sbp);
else
@@ -536,7 +540,7 @@ ffs_reallocblks(void *v)
fail:
if (ssize < len)
brelse(ebp);
- if (sbap != &ip->i_ffs_db[0])
+ if (sbap != &ip->i_ffs1_db[0])
brelse(sbp);
return (ENOSPC);
}
@@ -598,28 +602,36 @@ ffs_inode_alloc(struct inode *pip, mode_t mode, struct ucred *cred,
ffs_inode_free(pip, ino, mode);
return (error);
}
+
ip = VTOI(*vpp);
- if (ip->i_ffs_mode) {
+
+ if (DIP(ip, mode)) {
printf("mode = 0%o, inum = %d, fs = %s\n",
- ip->i_ffs_mode, ip->i_number, fs->fs_fsmnt);
+ DIP(ip, mode), ip->i_number, fs->fs_fsmnt);
panic("ffs_valloc: dup alloc");
}
- if (ip->i_ffs_blocks) { /* XXX */
+
+ if (DIP(ip, blocks)) {
printf("free inode %s/%d had %d blocks\n",
- fs->fs_fsmnt, ino, ip->i_ffs_blocks);
- ip->i_ffs_blocks = 0;
+ fs->fs_fsmnt, ino, DIP(ip, blocks));
+ DIP_ASSIGN(ip, blocks, 0);
}
- ip->i_ffs_flags = 0;
+
+ DIP_ASSIGN(ip, flags, 0);
+
/*
* Set up a new generation number for this inode.
* XXX - just increment for now, this is wrong! (millert)
* Need a way to preserve randomization.
*/
- if (ip->i_ffs_gen == 0 || ++(ip->i_ffs_gen) == 0)
- ip->i_ffs_gen = arc4random() & INT_MAX;
- if (ip->i_ffs_gen == 0 || ip->i_ffs_gen == -1)
- ip->i_ffs_gen = 1; /* shouldn't happen */
+ if (DIP(ip, gen) == 0 || ++(DIP(ip, gen)) == 0)
+ DIP_ASSIGN(ip, gen, arc4random() & INT_MAX);
+
+ if (DIP(ip, gen) == 0 || DIP(ip, gen) == -1)
+ DIP_ASSIGN(ip, gen, 1); /* Shouldn't happen */
+
return (0);
+
noinodes:
ffs_fserr(fs, cred->cr_uid, "out of inodes");
uprintf("\n%s: create/symlink failed, no inodes free\n", fs->fs_fsmnt);
@@ -1417,7 +1429,7 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size)
cg = dtog(fs, bno);
if ((u_int)bno >= fs->fs_size) {
printf("bad block %d, ino %u\n", bno, ip->i_number);
- ffs_fserr(fs, ip->i_ffs_uid, "bad block");
+ ffs_fserr(fs, DIP(ip, uid), "bad block");
return;
}
error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c
index 7d3334a9c62..d0f58eb633a 100644
--- a/sys/ufs/ffs/ffs_balloc.c
+++ b/sys/ufs/ffs/ffs_balloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_balloc.c,v 1.24 2003/06/02 23:28:22 millert Exp $ */
+/* $OpenBSD: ffs_balloc.c,v 1.25 2005/12/28 20:48:17 pedro Exp $ */
/* $NetBSD: ffs_balloc.c,v 1.3 1996/02/09 22:22:21 christos Exp $ */
/*
@@ -44,6 +44,7 @@
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
+#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/ufs_extern.h>
#include <ufs/ffs/fs.h>
@@ -85,23 +86,23 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred,
* and the file is currently composed of a fragment
* this fragment has to be extended to be a full block.
*/
- nb = lblkno(fs, ip->i_ffs_size);
+ nb = lblkno(fs, ip->i_ffs1_size);
if (nb < NDADDR && nb < lbn) {
osize = blksize(fs, ip, nb);
if (osize < fs->fs_bsize && osize > 0) {
error = ffs_realloccg(ip, nb,
- ffs_blkpref(ip, nb, (int)nb, &ip->i_ffs_db[0]),
+ ffs_blkpref(ip, nb, (int)nb, &ip->i_ffs1_db[0]),
osize, (int)fs->fs_bsize, cred, bpp, &newb);
if (error)
return (error);
if (DOINGSOFTDEP(vp))
softdep_setup_allocdirect(ip, nb, newb,
- ip->i_ffs_db[nb], fs->fs_bsize, osize,
+ ip->i_ffs1_db[nb], fs->fs_bsize, osize,
bpp ? *bpp : NULL);
- ip->i_ffs_size = lblktosize(fs, nb + 1);
- uvm_vnp_setsize(vp, ip->i_ffs_size);
- ip->i_ffs_db[nb] = newb;
+ ip->i_ffs1_size = lblktosize(fs, nb + 1);
+ uvm_vnp_setsize(vp, ip->i_ffs1_size);
+ ip->i_ffs1_db[nb] = newb;
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp != NULL) {
if (flags & B_SYNC)
@@ -115,8 +116,8 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred,
* The first NDADDR blocks are direct blocks
*/
if (lbn < NDADDR) {
- nb = ip->i_ffs_db[lbn];
- if (nb != 0 && ip->i_ffs_size >= lblktosize(fs, lbn + 1)) {
+ nb = ip->i_ffs1_db[lbn];
+ if (nb != 0 && ip->i_ffs1_size >= lblktosize(fs, lbn + 1)) {
/*
* The block is an already-allocated direct block
* and the file already extends past this block,
@@ -138,7 +139,7 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred,
/*
* Consider need to reallocate a fragment.
*/
- osize = fragroundup(fs, blkoff(fs, ip->i_ffs_size));
+ osize = fragroundup(fs, blkoff(fs, ip->i_ffs1_size));
nsize = fragroundup(fs, size);
if (nsize <= osize) {
/*
@@ -162,7 +163,7 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred,
*/
error = ffs_realloccg(ip, lbn,
ffs_blkpref(ip, lbn, (int)lbn,
- &ip->i_ffs_db[0]),
+ &ip->i_ffs1_db[0]),
osize, nsize, cred, bpp, &newb);
if (error)
return (error);
@@ -177,12 +178,12 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred,
* allocate a new block or fragment.
*/
- if (ip->i_ffs_size < lblktosize(fs, lbn + 1))
+ if (ip->i_ffs1_size < lblktosize(fs, lbn + 1))
nsize = fragroundup(fs, size);
else
nsize = fs->fs_bsize;
error = ffs_alloc(ip, lbn,
- ffs_blkpref(ip, lbn, (int)lbn, &ip->i_ffs_db[0]),
+ ffs_blkpref(ip, lbn, (int)lbn, &ip->i_ffs1_db[0]),
nsize, cred, &newb);
if (error)
return (error);
@@ -196,7 +197,7 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred,
softdep_setup_allocdirect(ip, lbn, newb, 0,
nsize, 0, bpp ? *bpp : NULL);
}
- ip->i_ffs_db[lbn] = newb;
+ ip->i_ffs1_db[lbn] = newb;
ip->i_flag |= IN_CHANGE | IN_UPDATE;
return (0);
}
@@ -215,7 +216,7 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred,
* Fetch the first indirect block allocating if necessary.
*/
--num;
- nb = ip->i_ffs_ib[indirs[0].in_off];
+ nb = ip->i_ffs1_ib[indirs[0].in_off];
allocib = NULL;
allocblk = allociblk;
@@ -244,7 +245,7 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred,
if ((error = bwrite(bp)) != 0)
goto fail;
}
- allocib = &ip->i_ffs_ib[indirs[0].in_off];
+ allocib = &ip->i_ffs1_ib[indirs[0].in_off];
*allocib = nb;
ip->i_flag |= IN_CHANGE | IN_UPDATE;
}
@@ -392,7 +393,7 @@ fail:
*/
(void)ufs_quota_free_blocks(ip, btodb(deallocated), cred);
- ip->i_ffs_blocks -= btodb(deallocated);
+ ip->i_ffs1_blocks -= btodb(deallocated);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
}
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c
index b0adb471c54..abe597fb0bc 100644
--- a/sys/ufs/ffs/ffs_inode.c
+++ b/sys/ufs/ffs/ffs_inode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_inode.c,v 1.41 2005/12/17 13:56:01 pedro Exp $ */
+/* $OpenBSD: ffs_inode.c,v 1.42 2005/12/28 20:48:17 pedro Exp $ */
/* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */
/*
@@ -95,19 +95,19 @@ ffs_update(struct inode *ip, struct timespec *atime,
getnanotime(&ts);
if (ip->i_flag & IN_ACCESS) {
- ip->i_ffs_atime = atime ? atime->tv_sec : ts.tv_sec;
- ip->i_ffs_atimensec = atime ? atime->tv_nsec : ts.tv_nsec;
+ DIP_ASSIGN(ip, atime, atime ? atime->tv_sec : ts.tv_sec);
+ DIP_ASSIGN(ip, atimensec, atime ? atime->tv_nsec : ts.tv_nsec);
}
if (ip->i_flag & IN_UPDATE) {
- ip->i_ffs_mtime = mtime ? mtime->tv_sec : ts.tv_sec;
- ip->i_ffs_mtimensec = mtime ? mtime->tv_nsec : ts.tv_nsec;
+ DIP_ASSIGN(ip, mtime, mtime ? mtime->tv_sec : ts.tv_sec);
+ DIP_ASSIGN(ip, mtimensec, mtime ? mtime->tv_nsec : ts.tv_nsec);
ip->i_modrev++;
}
if (ip->i_flag & IN_CHANGE) {
- ip->i_ffs_ctime = ts.tv_sec;
- ip->i_ffs_ctimensec = ts.tv_nsec;
+ DIP_ASSIGN(ip, ctime, ts.tv_sec);
+ DIP_ASSIGN(ip, ctimensec, ts.tv_nsec);
}
ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE);
@@ -117,9 +117,9 @@ ffs_update(struct inode *ip, struct timespec *atime,
* Ensure that uid and gid are correct. This is a temporary
* fix until fsck has been changed to do the update.
*/
- if (fs->fs_inodefmt < FS_44INODEFMT) {
- ip->i_din1->di_ouid = ip->i_ffs_uid;
- ip->i_din1->di_ogid = ip->i_ffs_gid;
+ if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_inodefmt < FS_44INODEFMT) {
+ ip->i_din1->di_ouid = ip->i_ffs1_uid;
+ ip->i_din1->di_ogid = ip->i_ffs1_gid;
}
error = bread(ip->i_devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)),
@@ -131,7 +131,7 @@ ffs_update(struct inode *ip, struct timespec *atime,
if (DOINGSOFTDEP(vp))
softdep_update_inodeblock(ip, bp, waitfor);
- else if (ip->i_effnlink != ip->i_ffs_nlink)
+ else if (ip->i_effnlink != DIP(ip, nlink))
panic("ffs_update: bad link cnt");
*((struct ufs1_dinode *)bp->b_data +
@@ -175,18 +175,19 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
ovp->v_type != VLNK)
return (0);
- if (oip->i_ffs_size == length)
+ if (DIP(oip, size) == length)
return (0);
+
if (ovp->v_type == VLNK &&
- (oip->i_ffs_size < ovp->v_mount->mnt_maxsymlinklen ||
+ (DIP(oip, size) < ovp->v_mount->mnt_maxsymlinklen ||
(ovp->v_mount->mnt_maxsymlinklen == 0 &&
oip->i_din1->di_blocks == 0))) {
#ifdef DIAGNOSTIC
if (length != 0)
panic("ffs_truncate: partial truncate of symlink");
#endif
- bzero((char *)&oip->i_ffs_shortlink, (u_int)oip->i_ffs_size);
- oip->i_ffs_size = 0;
+ memset(SHORTLINK(oip), 0, (size_t) DIP(oip, size));
+ DIP_ASSIGN(oip, size, 0);
oip->i_flag |= IN_CHANGE | IN_UPDATE;
return (UFS_UPDATE(oip, MNT_WAIT));
}
@@ -213,7 +214,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
curproc)) != 0)
return (error);
} else {
- (void)ufs_quota_free_blocks(oip, oip->i_ffs_blocks,
+ (void)ufs_quota_free_blocks(oip, DIP(oip, blocks),
NOCRED);
softdep_setup_freeblocks(oip, length);
(void) vinvalbuf(ovp, 0, cred, curproc, 0, 0);
@@ -223,7 +224,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
}
fs = oip->i_fs;
- osize = oip->i_ffs_size;
+ osize = DIP(oip, size);
/*
* Lengthen the size of the file. We must ensure that the
* last byte of the file is allocated. Since the smallest
@@ -239,7 +240,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
cred, aflags, &bp);
if (error)
return (error);
- oip->i_ffs_size = length;
+ DIP_ASSIGN(oip, size, length);
uvm_vnp_setsize(ovp, length);
(void) uvm_vnp_uncache(ovp);
if (aflags & B_SYNC)
@@ -261,7 +262,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
*/
offset = blkoff(fs, length);
if (offset == 0) {
- oip->i_ffs_size = length;
+ DIP_ASSIGN(oip, size, length);
} else {
lbn = lblkno(fs, length);
aflags = B_CLRBUF;
@@ -283,7 +284,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
fragroundup(fs, blkoff(fs, length)) < fs->fs_bsize &&
(error = VOP_FSYNC(ovp, cred, MNT_WAIT, curproc)) != 0)
return (error);
- oip->i_ffs_size = length;
+ DIP_ASSIGN(oip, size, length);
size = blksize(fs, oip, lbn);
(void) uvm_vnp_uncache(ovp);
if (ovp->v_type != VDIR)
@@ -306,32 +307,48 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
lastiblock[DOUBLE] = lastiblock[SINGLE] - NINDIR(fs);
lastiblock[TRIPLE] = lastiblock[DOUBLE] - NINDIR(fs) * NINDIR(fs);
nblocks = btodb(fs->fs_bsize);
+
/*
* Update file and block pointers on disk before we start freeing
* blocks. If we crash before free'ing blocks below, the blocks
* will be returned to the free list. lastiblock values are also
* normalized to -1 for calls to ffs_indirtrunc below.
*/
- bcopy((caddr_t)&oip->i_ffs_db[0], (caddr_t)oldblks, sizeof oldblks);
+
+ if (fs->fs_magic == FS_UFS2_MAGIC)
+ bcopy(&oip->i_ffs2_db[0], oldblks, sizeof(oldblks));
+ else
+ bcopy(&oip->i_ffs1_db[0], oldblks, sizeof(oldblks));
+
for (level = TRIPLE; level >= SINGLE; level--)
if (lastiblock[level] < 0) {
- oip->i_ffs_ib[level] = 0;
+ DIP_ASSIGN(oip, ib[level], 0);
lastiblock[level] = -1;
}
+
for (i = NDADDR - 1; i > lastblock; i--)
- oip->i_ffs_db[i] = 0;
+ DIP_ASSIGN(oip, db[i], 0);
+
oip->i_flag |= IN_CHANGE | IN_UPDATE;
if ((error = UFS_UPDATE(oip, MNT_WAIT)) != 0)
allerror = error;
+
/*
* Having written the new inode to disk, save its new configuration
* and put back the old block pointers long enough to process them.
* Note that we save the new block configuration so we can check it
* when we are done.
*/
- bcopy((caddr_t)&oip->i_ffs_db[0], (caddr_t)newblks, sizeof newblks);
- bcopy((caddr_t)oldblks, (caddr_t)&oip->i_ffs_db[0], sizeof oldblks);
- oip->i_ffs_size = osize;
+
+ if (fs->fs_magic == FS_UFS2_MAGIC) {
+ bcopy(&oip->i_ffs2_db[0], newblks, sizeof(newblks));
+ bcopy(oldblks, &oip->i_ffs2_db[0], sizeof(oldblks));
+ } else {
+ bcopy(&oip->i_ffs1_db[0], newblks, sizeof(newblks));
+ bcopy(oldblks, &oip->i_ffs1_db[0], sizeof(oldblks));
+ }
+
+ DIP_ASSIGN(oip, size, osize);
vflags = ((length > 0) ? V_SAVE : 0) | V_SAVEMETA;
allerror = vinvalbuf(ovp, vflags, cred, curproc, 0, 0);
@@ -342,7 +359,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
indir_lbn[DOUBLE] = indir_lbn[SINGLE] - NINDIR(fs) - 1;
indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - NINDIR(fs) * NINDIR(fs) - 1;
for (level = TRIPLE; level >= SINGLE; level--) {
- bn = oip->i_ffs_ib[level];
+ bn = DIP(oip, ib[level]);
if (bn != 0) {
error = ffs_indirtrunc(oip, indir_lbn[level],
fsbtodb(fs, bn), lastiblock[level], level, &count);
@@ -350,7 +367,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
allerror = error;
blocksreleased += count;
if (lastiblock[level] < 0) {
- oip->i_ffs_ib[level] = 0;
+ DIP_ASSIGN(oip, ib[level], 0);
ffs_blkfree(oip, bn, fs->fs_bsize);
blocksreleased += nblocks;
}
@@ -365,10 +382,11 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
for (i = NDADDR - 1; i > lastblock; i--) {
long bsize;
- bn = oip->i_ffs_db[i];
+ bn = DIP(oip, db[i]);
if (bn == 0)
continue;
- oip->i_ffs_db[i] = 0;
+
+ DIP_ASSIGN(oip, db[i], 0);
bsize = blksize(fs, oip, i);
ffs_blkfree(oip, bn, bsize);
blocksreleased += btodb(bsize);
@@ -380,7 +398,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
* Finally, look for a change in size of the
* last direct block; release any frags.
*/
- bn = oip->i_ffs_db[lastblock];
+ bn = DIP(oip, db[lastblock]);
if (bn != 0) {
long oldspace, newspace;
@@ -389,7 +407,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
* back as old block size minus new block size.
*/
oldspace = blksize(fs, oip, lastblock);
- oip->i_ffs_size = length;
+ DIP_ASSIGN(oip, size, length);
newspace = blksize(fs, oip, lastblock);
if (newspace == 0)
panic("ffs_truncate: newspace");
@@ -407,19 +425,19 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred)
done:
#ifdef DIAGNOSTIC
for (level = SINGLE; level <= TRIPLE; level++)
- if (newblks[NDADDR + level] != oip->i_ffs_ib[level])
+ if (newblks[NDADDR + level] != DIP(oip, ib[level]))
panic("ffs_truncate1");
for (i = 0; i < NDADDR; i++)
- if (newblks[i] != oip->i_ffs_db[i])
+ if (newblks[i] != DIP(oip, db[i]))
panic("ffs_truncate2");
#endif /* DIAGNOSTIC */
/*
* Put back the real size.
*/
- oip->i_ffs_size = length;
- oip->i_ffs_blocks -= blocksreleased;
- if (oip->i_ffs_blocks < 0) /* sanity */
- oip->i_ffs_blocks = 0;
+ DIP_ASSIGN(oip, size, length);
+ DIP_ADD(oip, blocks, -blocksreleased);
+ if (DIP(oip, blocks) < 0) /* Sanity */
+ DIP_ASSIGN(oip, blocks, 0);
oip->i_flag |= IN_CHANGE;
(void)ufs_quota_free_blocks(oip, blocksreleased, NOCRED);
return (allerror);
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 747ed4fe0b8..092cb161f63 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_softdep.c,v 1.66 2005/12/17 13:56:01 pedro Exp $ */
+/* $OpenBSD: ffs_softdep.c,v 1.67 2005/12/28 20:48:17 pedro Exp $ */
/*
* Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved.
*
@@ -1505,7 +1505,7 @@ softdep_setup_allocdirect(ip, lbn, newblkno, oldblkno, newsize, oldsize, bp)
* allocate an associated pagedep to track additions and
* deletions.
*/
- if ((ip->i_ffs_mode & IFMT) == IFDIR &&
+ if ((DIP(ip, mode) & IFMT) == IFDIR &&
pagedep_lookup(ip, lbn, DEPALLOC, &pagedep) == 0)
WORKLIST_INSERT(&bp->b_dep, &pagedep->pd_list);
}
@@ -1630,7 +1630,7 @@ newfreefrag(ip, blkno, size)
panic("newfreefrag: frag size");
freefrag = pool_get(&freefrag_pool, PR_WAITOK);
freefrag->ff_list.wk_type = D_FREEFRAG;
- freefrag->ff_state = ip->i_ffs_uid & ~ONWORKLIST; /* used below */
+ freefrag->ff_state = DIP(ip, uid) & ~ONWORKLIST; /* used below */
freefrag->ff_inum = ip->i_number;
freefrag->ff_mnt = ITOV(ip)->v_mount;
freefrag->ff_devvp = ip->i_devvp;
@@ -1656,7 +1656,7 @@ handle_workitem_freefrag(freefrag)
tip.i_ump = VFSTOUFS(freefrag->ff_mnt);
tip.i_dev = freefrag->ff_devvp->v_rdev;
tip.i_number = freefrag->ff_inum;
- tip.i_ffs_uid = freefrag->ff_state & ~ONWORKLIST; /* set above */
+ tip.i_ffs1_uid = freefrag->ff_state & ~ONWORKLIST; /* set above */
ffs_blkfree(&tip, freefrag->ff_blkno, freefrag->ff_fragsize);
pool_put(&freefrag_pool, freefrag);
}
@@ -1733,7 +1733,7 @@ softdep_setup_allocindir_page(ip, lbn, bp, ptrno, newblkno, oldblkno, nbp)
* allocate an associated pagedep to track additions and
* deletions.
*/
- if ((ip->i_ffs_mode & IFMT) == IFDIR &&
+ if ((DIP(ip, mode) & IFMT) == IFDIR &&
pagedep_lookup(ip, lbn, DEPALLOC, &pagedep) == 0)
WORKLIST_INSERT(&nbp->b_dep, &pagedep->pd_list);
if (nbp == NULL) {
@@ -1924,23 +1924,27 @@ softdep_setup_freeblocks(ip, length)
bzero(freeblks, sizeof(struct freeblks));
freeblks->fb_list.wk_type = D_FREEBLKS;
freeblks->fb_state = ATTACHED;
- freeblks->fb_uid = ip->i_ffs_uid;
+ freeblks->fb_uid = DIP(ip, uid);
freeblks->fb_previousinum = ip->i_number;
freeblks->fb_devvp = ip->i_devvp;
freeblks->fb_mnt = ITOV(ip)->v_mount;
- freeblks->fb_oldsize = ip->i_ffs_size;
+ freeblks->fb_oldsize = DIP(ip, size);
freeblks->fb_newsize = length;
- freeblks->fb_chkcnt = ip->i_ffs_blocks;
+ freeblks->fb_chkcnt = DIP(ip, blocks);
+
for (i = 0; i < NDADDR; i++) {
- freeblks->fb_dblks[i] = ip->i_ffs_db[i];
- ip->i_ffs_db[i] = 0;
+ freeblks->fb_dblks[i] = DIP(ip, db[i]);
+ DIP_ASSIGN(ip, db[i], 0);
}
+
for (i = 0; i < NIADDR; i++) {
- freeblks->fb_iblks[i] = ip->i_ffs_ib[i];
- ip->i_ffs_ib[i] = 0;
+ freeblks->fb_iblks[i] = DIP(ip, ib[i]);
+ DIP_ASSIGN(ip, ib[i], 0);
}
- ip->i_ffs_blocks = 0;
- ip->i_ffs_size = 0;
+
+ DIP_ASSIGN(ip, blocks, 0);
+ DIP_ASSIGN(ip, size, 0);
+
/*
* Push the zero'ed inode to to its disk buffer so that we are free
* to delete its dependencies below. Once the dependencies are gone
@@ -2382,8 +2386,8 @@ handle_workitem_freeblocks(freeblks)
tip.i_number = freeblks->fb_previousinum;
tip.i_ump = VFSTOUFS(freeblks->fb_mnt);
tip.i_dev = freeblks->fb_devvp->v_rdev;
- tip.i_ffs_size = freeblks->fb_oldsize;
- tip.i_ffs_uid = freeblks->fb_uid;
+ tip.i_ffs1_size = freeblks->fb_oldsize;
+ tip.i_ffs1_uid = freeblks->fb_uid;
tip.i_vnode = NULL;
tmpval = 1;
baselbns[0] = NDADDR;
@@ -3082,12 +3086,12 @@ softdep_change_linkcnt(ip, nodelay)
ACQUIRE_LOCK(&lk);
(void) inodedep_lookup(ip->i_fs, ip->i_number, flags, &inodedep);
- if (ip->i_ffs_nlink < ip->i_effnlink) {
+ if (DIP(ip, nlink) < ip->i_effnlink) {
FREE_LOCK(&lk);
panic("softdep_change_linkcnt: bad delta");
}
- inodedep->id_nlinkdelta = ip->i_ffs_nlink - ip->i_effnlink;
+ inodedep->id_nlinkdelta = DIP(ip, nlink) - ip->i_effnlink;
FREE_LOCK(&lk);
}
@@ -3122,13 +3126,13 @@ handle_workitem_remove(dirrem)
* Normal file deletion.
*/
if ((dirrem->dm_state & RMDIR) == 0) {
- ip->i_ffs_nlink--;
+ DIP_ADD(ip, nlink, -1);
ip->i_flag |= IN_CHANGE;
- if (ip->i_ffs_nlink < ip->i_effnlink) {
+ if (DIP(ip, nlink) < ip->i_effnlink) {
FREE_LOCK(&lk);
panic("handle_workitem_remove: bad file delta");
}
- inodedep->id_nlinkdelta = ip->i_ffs_nlink - ip->i_effnlink;
+ inodedep->id_nlinkdelta = DIP(ip, nlink) - ip->i_effnlink;
FREE_LOCK(&lk);
vput(vp);
num_dirrem -= 1;
@@ -3142,11 +3146,11 @@ handle_workitem_remove(dirrem)
* truncation completes, arrange to have the reference count on
* the parent decremented to account for the loss of "..".
*/
- ip->i_ffs_nlink -= 2;
+ DIP_ADD(ip, nlink, -2);
ip->i_flag |= IN_CHANGE;
- if (ip->i_ffs_nlink < ip->i_effnlink)
+ if (DIP(ip, nlink) < ip->i_effnlink)
panic("handle_workitem_remove: bad dir delta");
- inodedep->id_nlinkdelta = ip->i_ffs_nlink - ip->i_effnlink;
+ inodedep->id_nlinkdelta = DIP(ip, nlink) - ip->i_effnlink;
FREE_LOCK(&lk);
if ((error = UFS_TRUNCATE(ip, (off_t)0, 0, p->p_ucred)) != 0)
softdep_error("handle_workitem_remove: truncate", error);
@@ -4093,7 +4097,7 @@ softdep_load_inodeblock(ip)
/*
* Check for alternate nlink count.
*/
- ip->i_effnlink = ip->i_ffs_nlink;
+ ip->i_effnlink = DIP(ip, nlink);
ACQUIRE_LOCK(&lk);
if (inodedep_lookup(ip->i_fs, ip->i_number, 0, &inodedep) == 0) {
FREE_LOCK(&lk);
@@ -4133,11 +4137,11 @@ softdep_update_inodeblock(ip, bp, waitfor)
ACQUIRE_LOCK(&lk);
if (inodedep_lookup(ip->i_fs, ip->i_number, 0, &inodedep) == 0) {
FREE_LOCK(&lk);
- if (ip->i_effnlink != ip->i_ffs_nlink)
+ if (ip->i_effnlink != DIP(ip, nlink))
panic("softdep_update_inodeblock: bad link count");
return;
}
- if (inodedep->id_nlinkdelta != ip->i_ffs_nlink - ip->i_effnlink) {
+ if (inodedep->id_nlinkdelta != DIP(ip, nlink) - ip->i_effnlink) {
FREE_LOCK(&lk);
panic("softdep_update_inodeblock: bad delta");
}
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index bf105f0f649..fdf473f27e8 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_vfsops.c,v 1.77 2005/12/17 13:56:01 pedro Exp $ */
+/* $OpenBSD: ffs_vfsops.c,v 1.78 2005/12/28 20:48:17 pedro Exp $ */
/* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */
/*
@@ -491,7 +491,7 @@ ffs_reload_vnode(struct vnode *vp, void *args)
}
*ip->i_din1 = *((struct ufs1_dinode *)bp->b_data +
ino_to_fsbo(fra->fs, ip->i_number));
- ip->i_effnlink = ip->i_ffs_nlink;
+ ip->i_effnlink = DIP(ip, nlink);
brelse(bp);
vput(vp);
return (0);
@@ -1169,7 +1169,7 @@ retry:
if (DOINGSOFTDEP(vp))
softdep_load_inodeblock(ip);
else
- ip->i_effnlink = ip->i_ffs_nlink;
+ ip->i_effnlink = DIP(ip, nlink);
/*
* Initialize the vnode from the inode, check for aliases.
@@ -1181,27 +1181,30 @@ retry:
*vpp = NULL;
return (error);
}
+
/*
* Set up a generation number for this inode if it does not
* already have one. This should only happen on old filesystems.
*/
- if (ip->i_ffs_gen == 0) {
- ip->i_ffs_gen = arc4random() & INT_MAX;
- if (ip->i_ffs_gen == 0 || ip->i_ffs_gen == -1)
- ip->i_ffs_gen = 1; /* shouldn't happen */
+ if (DIP(ip, gen) == 0) {
+ DIP_ASSIGN(ip, gen, arc4random() & INT_MAX);
+ if (DIP(ip, gen) == 0 || DIP(ip, gen) == -1)
+ DIP_ASSIGN(ip, gen, 1); /* Shouldn't happen */
if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
ip->i_flag |= IN_MODIFIED;
}
+
/*
* Ensure that uid and gid are correct. This is a temporary
* fix until fsck has been changed to do the update.
*/
- if (fs->fs_inodefmt < FS_44INODEFMT) {
- ip->i_ffs_uid = ip->i_din1->di_ouid;
- ip->i_ffs_gid = ip->i_din1->di_ogid;
+ if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_inodefmt < FS_44INODEFMT) {
+ ip->i_ffs1_uid = ip->i_din1->di_ouid;
+ ip->i_ffs1_gid = ip->i_din1->di_ogid;
}
*vpp = vp;
+
return (0);
}
@@ -1241,7 +1244,7 @@ ffs_vptofh(struct vnode *vp, struct fid *fhp)
ufhp = (struct ufid *)fhp;
ufhp->ufid_len = sizeof(struct ufid);
ufhp->ufid_ino = ip->i_number;
- ufhp->ufid_gen = ip->i_ffs_gen;
+ ufhp->ufid_gen = DIP(ip, gen);
return (0);
}
diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h
index d62ab2dbf67..8899cefc07e 100644
--- a/sys/ufs/ffs/fs.h
+++ b/sys/ufs/ffs/fs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fs.h,v 1.17 2005/03/01 13:30:50 aaron Exp $ */
+/* $OpenBSD: fs.h,v 1.18 2005/12/28 20:48:18 pedro Exp $ */
/* $NetBSD: fs.h,v 1.6 1995/04/12 21:21:02 mycroft Exp $ */
/*
@@ -507,9 +507,9 @@ struct ocg {
* Determining the size of a file block in the file system.
*/
#define blksize(fs, ip, lbn) \
- (((lbn) >= NDADDR || (ip)->i_ffs_size >= ((lbn) + 1) << (fs)->fs_bshift) \
+ (((lbn) >= NDADDR || DIP((ip), size) >= ((lbn) + 1) << (fs)->fs_bshift) \
? (fs)->fs_bsize \
- : (fragroundup(fs, blkoff(fs, (ip)->i_ffs_size))))
+ : (fragroundup(fs, blkoff(fs, DIP((ip), size)))))
#define dblksize(fs, dip, lbn) \
(((lbn) >= NDADDR || (dip)->di_size >= ((lbn) + 1) << (fs)->fs_bshift) \
? (fs)->fs_bsize \