Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Use the lfs dinode accessors in place of the ufs-derived ones.
details: https://anonhg.NetBSD.org/src/rev/005bb57c0ee2
branches: trunk
changeset: 340333:005bb57c0ee2
user: dholland <dholland%NetBSD.org@localhost>
date: Tue Sep 01 06:08:37 2015 +0000
description:
Use the lfs dinode accessors in place of the ufs-derived ones.
(Mostly.)
The ufs-derived ones are fake structure member macros, which are gross
and not very safe. Also, it seems that a lot of places in the lfs code
were using the ffsv1 branch of them unconditionally, and this way it's
guaranteed all those places have been updated.
Found while doing this: for non-devices, have getattr produce NODEV
in the rdev field instead of leaking the address of the first direct
block.
diffstat:
sbin/fsck_lfs/dir.c | 10 +++--
sbin/fsck_lfs/inode.c | 9 +++-
sbin/fsck_lfs/lfs.c | 54 ++++++++++++++++++----------------
sbin/fsck_lfs/pass6.c | 56 ++++++++++++++++++------------------
sbin/fsck_lfs/segwrite.c | 30 ++++++++++--------
sbin/fsck_lfs/setup.c | 6 +-
sys/ufs/lfs/lfs_accessors.h | 52 +++++++++++++++++++++++++++++++-
sys/ufs/lfs/lfs_alloc.c | 6 +-
sys/ufs/lfs/lfs_balloc.c | 20 ++++++------
sys/ufs/lfs/lfs_inode.c | 70 +++++++++++++++++++++++++++-----------------
sys/ufs/lfs/lfs_inode.h | 47 +-----------------------------
sys/ufs/lfs/lfs_itimes.c | 22 +++++++-------
sys/ufs/lfs/lfs_rfw.c | 26 +++++++++-------
sys/ufs/lfs/lfs_segment.c | 50 ++++++++++++++++---------------
sys/ufs/lfs/lfs_syscalls.c | 6 +-
sys/ufs/lfs/lfs_vfsops.c | 43 ++++++++++++++-------------
sys/ufs/lfs/lfs_vnops.c | 26 ++++++++++-----
sys/ufs/lfs/ulfs_bmap.c | 21 +++++++------
sys/ufs/lfs/ulfs_inode.h | 15 +++++----
sys/ufs/lfs/ulfs_vnops.c | 19 +++++++-----
20 files changed, 319 insertions(+), 269 deletions(-)
diffs (truncated from 1576 to 300 lines):
diff -r 33b8a144509c -r 005bb57c0ee2 sbin/fsck_lfs/dir.c
--- a/sbin/fsck_lfs/dir.c Tue Sep 01 03:26:09 2015 +0000
+++ b/sbin/fsck_lfs/dir.c Tue Sep 01 06:08:37 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.36 2015/08/12 18:28:00 dholland Exp $ */
+/* $NetBSD: dir.c,v 1.37 2015/09/01 06:08:37 dholland Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -316,7 +316,7 @@
else {
if (ftypeok(VTOD(vp)))
pfatal("%s=%s\n",
- (VTOI(vp)->i_ffs1_mode & LFS_IFMT) == LFS_IFDIR ?
+ (lfs_dino_getmode(fs, VTOI(vp)->i_din) & LFS_IFMT) == LFS_IFDIR ?
"DIR" : "FILE", pathbuf);
else
pfatal("NAME=%s\n", pathbuf);
@@ -492,7 +492,8 @@
parentdir != (ino_t) - 1)
(void) makeentry(orphan, lfdir, "..");
vp = vget(fs, lfdir);
- VTOI(vp)->i_ffs1_nlink++;
+ lfs_dino_setnlink(fs, VTOI(vp)->i_din,
+ lfs_dino_getnlink(fs, VTOI(vp)->i_din) + 1);
inodirty(VTOI(vp));
lncntp[lfdir]++;
pwarn("DIR I=%llu CONNECTED. ", (unsigned long long)orphan);
@@ -688,7 +689,8 @@
if (ino != parent) {
vp = vget(fs, parent);
- VTOI(vp)->i_ffs1_nlink--;
+ lfs_dino_setnlink(fs, VTOI(vp)->i_din,
+ lfs_dino_getnlink(fs, VTOI(vp)->i_din) - 1);
inodirty(VTOI(vp));
}
freeino(ino);
diff -r 33b8a144509c -r 005bb57c0ee2 sbin/fsck_lfs/inode.c
--- a/sbin/fsck_lfs/inode.c Tue Sep 01 03:26:09 2015 +0000
+++ b/sbin/fsck_lfs/inode.c Tue Sep 01 06:08:37 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inode.c,v 1.60 2015/08/19 20:33:29 dholland Exp $ */
+/* $NetBSD: inode.c,v 1.61 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -305,7 +305,10 @@
pathbuf, (long long)idesc->id_number);
if (reply("ADJUST LENGTH") == 1) {
vp = vget(fs, idesc->id_number);
- VTOI(vp)->i_ffs1_size -= isize;
+ lfs_dino_setsize(fs, VTOI(vp)->i_din,
+ lfs_dino_getsize(fs,
+ VTOI(vp)->i_din)
+ - isize);
isize = 0;
printf(
"YOU MUST RERUN FSCK AFTERWARDS\n");
@@ -444,7 +447,7 @@
vp = vget(fs, idesc->id_number);
if (flag & 0x1) {
pwarn("%s %s", type,
- (VTOI(vp)->i_ffs1_mode & LFS_IFMT) == LFS_IFDIR ? "DIR" : "FILE");
+ (lfs_dino_getmode(fs, VTOI(vp)->i_din) & LFS_IFMT) == LFS_IFDIR ? "DIR" : "FILE");
pinode(idesc->id_number);
}
if ((flag & 0x2) || preen || reply("CLEAR") == 1) {
diff -r 33b8a144509c -r 005bb57c0ee2 sbin/fsck_lfs/lfs.c
--- a/sbin/fsck_lfs/lfs.c Tue Sep 01 03:26:09 2015 +0000
+++ b/sbin/fsck_lfs/lfs.c Tue Sep 01 06:08:37 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.57 2015/08/19 20:33:29 dholland Exp $ */
+/* $NetBSD: lfs.c,v 1.58 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -173,7 +173,7 @@
if (bn >= 0 && bn < ULFS_NDADDR) {
if (nump != NULL)
*nump = 0;
- *bnp = LFS_FSBTODB(fs, ip->i_ffs1_db[bn]);
+ *bnp = LFS_FSBTODB(fs, lfs_dino_getdb(fs, ip->i_din, bn));
if (*bnp == 0)
*bnp = -1;
return (0);
@@ -187,7 +187,7 @@
num = *nump;
/* Get disk address out of indirect block array */
- daddr = ip->i_ffs1_ib[xap->in_off];
+ daddr = lfs_dino_getib(fs, ip->i_din, xap->in_off);
for (bp = NULL, ++xap; --num; ++xap) {
/* Exit the loop if there is no disk address assigned yet and
@@ -228,7 +228,7 @@
* contains the logical block number of the appropriate single, double or
* triple indirect block and the offset into the inode indirect block array.
* Note, the logical block number of the inode single/double/triple indirect
- * block appears twice in the array, once with the offset into the i_ffs1_ib and
+ * block appears twice in the array, once with the offset into di_ib and
* once with the offset into the page itself.
*/
int
@@ -386,18 +386,18 @@
/* ip->i_devvp = fs->lfs_devvp; */
ip->i_lfs = fs;
- ip->i_lfs_effnblks = ip->i_ffs1_blocks;
- ip->i_lfs_osize = ip->i_ffs1_size;
+ ip->i_lfs_effnblks = lfs_dino_getblocks(fs, ip->i_din);
+ ip->i_lfs_osize = lfs_dino_getsize(fs, ip->i_din);
#if 0
- if (fs->lfs_version > 1) {
- ip->i_ffs1_atime = ts.tv_sec;
- ip->i_ffs1_atimensec = ts.tv_nsec;
+ if (lfs_sb_getversion(fs) > 1) {
+ lfs_dino_setatime(fs, ip->i_din, ts.tv_sec);
+ lfs_dino_setatimensec(fs, ip->i_din, ts.tv_nsec);
}
#endif
memset(ip->i_lfs_fragsize, 0, ULFS_NDADDR * sizeof(*ip->i_lfs_fragsize));
for (i = 0; i < ULFS_NDADDR; i++)
- if (ip->i_ffs1_db[i] != 0)
+ if (lfs_dino_getdb(fs, ip->i_din, i) != 0)
ip->i_lfs_fragsize[i] = lfs_blksize(fs, ip, i);
++nvnodes;
@@ -925,10 +925,11 @@
vp = fs->lfs_ivnode;
ip = VTOI(vp);
- blkno = lfs_lblkno(fs, ip->i_ffs1_size);
+ blkno = lfs_lblkno(fs, lfs_dino_getsize(fs, ip->i_din));
- lfs_balloc(vp, ip->i_ffs1_size, lfs_sb_getbsize(fs), &bp);
- ip->i_ffs1_size += lfs_sb_getbsize(fs);
+ lfs_balloc(vp, lfs_dino_getsize(fs, ip->i_din), lfs_sb_getbsize(fs), &bp);
+ lfs_dino_setsize(fs, ip->i_din,
+ lfs_dino_getsize(fs, ip->i_din) + lfs_sb_getbsize(fs));
ip->i_flag |= IN_MODIFIED;
i = (blkno - lfs_sb_getsegtabsz(fs) - lfs_sb_getcleansz(fs)) *
@@ -968,7 +969,7 @@
LFS_BWRITE_LOG(bp);
#ifdef IN_FSCK_LFS
- reset_maxino(((ip->i_ffs1_size >> lfs_sb_getbshift(fs))
+ reset_maxino(((lfs_dino_getsize(fs, ip->i_din) >> lfs_sb_getbshift(fs))
- lfs_sb_getsegtabsz(fs)
- lfs_sb_getcleansz(fs)) * lfs_sb_getifpb(fs));
#endif
@@ -1026,7 +1027,7 @@
*bpp = NULL;
/* Check for block beyond end of file and fragment extension needed. */
- lastblock = lfs_lblkno(fs, ip->i_ffs1_size);
+ lastblock = lfs_lblkno(fs, lfs_dino_getsize(fs, ip->i_din));
if (lastblock < ULFS_NDADDR && lastblock < lbn) {
osize = lfs_blksize(fs, ip, lastblock);
if (osize < lfs_sb_getbsize(fs) && osize > 0) {
@@ -1034,7 +1035,7 @@
lastblock,
(bpp ? &bp : NULL))))
return (error);
- ip->i_ffs1_size = (lastblock + 1) * lfs_sb_getbsize(fs);
+ lfs_dino_setsize(fs, ip->i_din, (lastblock + 1) * lfs_sb_getbsize(fs));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp)
(void) VOP_BWRITE(bp);
@@ -1049,10 +1050,10 @@
* size or it already exists and contains some fragments and
* may need to extend it.
*/
- if (lbn < ULFS_NDADDR && lfs_lblkno(fs, ip->i_ffs1_size) <= lbn) {
+ if (lbn < ULFS_NDADDR && lfs_lblkno(fs, lfs_dino_getsize(fs, ip->i_din)) <= lbn) {
osize = lfs_blksize(fs, ip, lbn);
nsize = lfs_fragroundup(fs, offset + iosize);
- if (lfs_lblktosize(fs, lbn) >= ip->i_ffs1_size) {
+ if (lfs_lblktosize(fs, lbn) >= lfs_dino_getsize(fs, ip->i_din)) {
/* Brand new block or fragment */
frags = lfs_numfrags(fs, nsize);
if (bpp) {
@@ -1061,7 +1062,7 @@
}
ip->i_lfs_effnblks += frags;
lfs_sb_subbfree(fs, frags);
- ip->i_ffs1_db[lbn] = UNWRITTEN;
+ lfs_dino_setdb(fs, ip->i_din, lbn, UNWRITTEN);
} else {
if (nsize <= osize) {
/* No need to extend */
@@ -1105,15 +1106,16 @@
ip->i_lfs_effnblks += bcount;
if (daddr == UNASSIGNED) {
- if (num > 0 && ip->i_ffs1_ib[indirs[0].in_off] == 0) {
- ip->i_ffs1_ib[indirs[0].in_off] = UNWRITTEN;
+ if (num > 0 && lfs_dino_getib(fs, ip->i_din, indirs[0].in_off) == 0) {
+ lfs_dino_setib(fs, ip->i_din, indirs[0].in_off,
+ UNWRITTEN);
}
/*
* Create new indirect blocks if necessary
*/
if (num > 1) {
- idaddr = ip->i_ffs1_ib[indirs[0].in_off];
+ idaddr = lfs_dino_getib(fs, ip->i_din, indirs[0].in_off);
for (i = 1; i < num; ++i) {
ibp = getblk(vp, indirs[i].in_lbn,
lfs_sb_getbsize(fs));
@@ -1165,10 +1167,11 @@
switch (num) {
case 0:
- ip->i_ffs1_db[lbn] = UNWRITTEN;
+ lfs_dino_setdb(fs, ip->i_din, lbn, UNWRITTEN);
break;
case 1:
- ip->i_ffs1_ib[indirs[0].in_off] = UNWRITTEN;
+ lfs_dino_setib(fs, ip->i_din, indirs[0].in_off,
+ UNWRITTEN);
break;
default:
idp = &indirs[num - 1];
@@ -1176,7 +1179,8 @@
panic("lfs_balloc: bread bno %lld",
(long long)idp->in_lbn);
/* XXX ondisk32 */
- ((int32_t *)ibp->b_data)[idp->in_off] = UNWRITTEN;
+ lfs_iblock_set(fs, ibp->b_data, idp->in_off,
+ UNWRITTEN);
VOP_BWRITE(ibp);
}
} else if (bpp && !(bp->b_flags & (B_DONE|B_DELWRI))) {
diff -r 33b8a144509c -r 005bb57c0ee2 sbin/fsck_lfs/pass6.c
--- a/sbin/fsck_lfs/pass6.c Tue Sep 01 03:26:09 2015 +0000
+++ b/sbin/fsck_lfs/pass6.c Tue Sep 01 06:08:37 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass6.c,v 1.43 2015/08/19 20:33:29 dholland Exp $ */
+/* $NetBSD: pass6.c,v 1.44 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -103,21 +103,24 @@
frags = lfs_numfrags(fs, size);
switch (num) {
case 0:
- ooff = ip->i_ffs1_db[lbn];
+ ooff = lfs_dino_getdb(fs, ip->i_din, lbn);
if (ooff <= 0)
- ip->i_ffs1_blocks += frags;
+ lfs_dino_setblocks(fs, ip->i_din,
+ lfs_dino_getblocks(fs, ip->i_din) + frags);
else {
/* possible fragment truncation or extension */
ofrags = lfs_numfrags(fs, ip->i_lfs_fragsize[lbn]);
- ip->i_ffs1_blocks += (frags - ofrags);
+ lfs_dino_setblocks(fs, ip->i_din,
+ lfs_dino_getblocks(fs, ip->i_din) + (frags - ofrags));
}
- ip->i_ffs1_db[lbn] = ndaddr;
+ lfs_dino_setdb(fs, ip->i_din, lbn, ndaddr);
break;
case 1:
- ooff = ip->i_ffs1_ib[a[0].in_off];
+ ooff = lfs_dino_getib(fs, ip->i_din, a[0].in_off);
if (ooff <= 0)
- ip->i_ffs1_blocks += frags;
- ip->i_ffs1_ib[a[0].in_off] = ndaddr;
+ lfs_dino_setblocks(fs, ip->i_din,
+ lfs_dino_getblocks(fs, ip->i_din) + frags);
+ lfs_dino_setib(fs, ip->i_din, a[0].in_off, ndaddr);
break;
default:
ap = &a[num - 1];
@@ -125,10 +128,11 @@
errx(1, "lfs_updatemeta: bread bno %" PRId64,
ap->in_lbn);
- ooff = ((ulfs_daddr_t *) bp->b_data)[ap->in_off];
+ ooff = lfs_iblock_get(fs, bp->b_data, ap->in_off);
if (ooff <= 0)
- ip->i_ffs1_blocks += frags;
- ((ulfs_daddr_t *) bp->b_data)[ap->in_off] = ndaddr;
+ lfs_dino_setblocks(fs, ip->i_din,
+ lfs_dino_getblocks(fs, ip->i_din) + frags);
+ lfs_iblock_set(fs, bp->b_data, ap->in_off, ndaddr);
(void) VOP_BWRITE(bp);
}
@@ -153,8 +157,8 @@
}
/* If block is beyond EOF, update size */
- if (lbn >= 0 && ip->i_ffs1_size <= (lbn << lfs_sb_getbshift(fs))) {
- ip->i_ffs1_size = (lbn << lfs_sb_getbshift(fs)) + 1;
+ if (lbn >= 0 && lfs_dino_getsize(fs, ip->i_din) <= (lbn << lfs_sb_getbshift(fs))) {
Home |
Main Index |
Thread Index |
Old Index