Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add IFILE32 and IFILE64 structures for the on-disk ifile ent...
details: https://anonhg.NetBSD.org/src/rev/f0afc2eb9d5f
branches: trunk
changeset: 809969:f0afc2eb9d5f
user: dholland <dholland%NetBSD.org@localhost>
date: Wed Aug 12 18:25:51 2015 +0000
description:
Add IFILE32 and IFILE64 structures for the on-disk ifile entries.
Add and use accessors. There are also a bunch of places that cast and
I hope I've found them all...
diffstat:
libexec/lfs_cleanerd/coalesce.c | 4 +-
libexec/lfs_cleanerd/lfs_cleanerd.c | 33 +++++++--
sbin/dump_lfs/lfs_inode.c | 24 ++++--
sbin/fsck_lfs/inode.c | 16 +++-
sbin/fsck_lfs/lfs.c | 39 +++++++----
sbin/fsck_lfs/pass0.c | 14 ++--
sbin/fsck_lfs/pass1.c | 8 +-
sbin/fsck_lfs/pass6.c | 30 +++++----
sbin/fsck_lfs/segwrite.c | 10 +-
sbin/newfs_lfs/make_lfs.c | 70 ++++++++++++++-------
sys/lib/libsa/lfsv1.c | 3 +-
sys/lib/libsa/lfsv2.c | 3 +-
sys/lib/libsa/ufs.c | 11 ++-
sys/ufs/lfs/lfs.h | 36 +++++++++-
sys/ufs/lfs/lfs_accessors.h | 43 ++++++++++++-
sys/ufs/lfs/lfs_alloc.c | 115 +++++++++++++++++++++--------------
sys/ufs/lfs/lfs_itimes.c | 10 +-
sys/ufs/lfs/lfs_rfw.c | 8 +-
sys/ufs/lfs/lfs_segment.c | 8 +-
sys/ufs/lfs/lfs_syscalls.c | 8 +-
sys/ufs/lfs/lfs_vfsops.c | 12 +-
usr.sbin/dumplfs/dumplfs.c | 36 +++++++----
22 files changed, 346 insertions(+), 195 deletions(-)
diffs (truncated from 1348 to 300 lines):
diff -r 58a2e6507ac4 -r f0afc2eb9d5f libexec/lfs_cleanerd/coalesce.c
--- a/libexec/lfs_cleanerd/coalesce.c Wed Aug 12 18:25:03 2015 +0000
+++ b/libexec/lfs_cleanerd/coalesce.c Wed Aug 12 18:25:51 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: coalesce.c,v 1.30 2015/08/12 18:25:03 dholland Exp $ */
+/* $NetBSD: coalesce.c,v 1.31 2015/08/12 18:25:51 dholland Exp $ */
/*-
* Copyright (c) 2002, 2005 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
struct ulfs1_dinode *dip, *r;
lfs_ientry(&ifp, fs, ino, &bp);
- daddr = ifp->if_daddr;
+ daddr = lfs_if_getdaddr(fs, ifp);
brelse(bp, 0);
if (daddr == 0x0)
diff -r 58a2e6507ac4 -r f0afc2eb9d5f libexec/lfs_cleanerd/lfs_cleanerd.c
--- a/libexec/lfs_cleanerd/lfs_cleanerd.c Wed Aug 12 18:25:03 2015 +0000
+++ b/libexec/lfs_cleanerd/lfs_cleanerd.c Wed Aug 12 18:25:51 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_cleanerd.c,v 1.46 2015/08/12 18:25:03 dholland Exp $ */
+/* $NetBSD: lfs_cleanerd.c,v 1.47 2015/08/12 18:25:51 dholland Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -342,10 +342,15 @@
* Get IFILE entry for the given inode, store in ifpp. The buffer
* which contains that data is returned in bpp, and must be brelse()d
* by the caller.
+ *
+ * XXX this is cutpaste of LFS_IENTRY from lfs.h; unify the two.
*/
void
lfs_ientry(IFILE **ifpp, struct clfs *fs, ino_t ino, struct ubuf **bpp)
{
+ IFILE64 *ifp64;
+ IFILE32 *ifp32;
+ IFILE_V1 *ifp_v1;
int error;
error = bread(fs->lfs_ivnode,
@@ -354,7 +359,19 @@
if (error)
syslog(LOG_ERR, "%s: ientry failed for ino %d",
lfs_sb_getfsmnt(fs), (int)ino);
- *ifpp = (IFILE *)(*bpp)->b_data + ino % lfs_sb_getifpb(fs);
+ if (fs->lfs_is64) {
+ ifp64 = (IFILE64 *)(*bpp)->b_data;
+ ifp64 += ino % lfs_sb_getifpb(fs);
+ *ifpp = (IFILE *)ifp64;
+ } else if (lfs_sb_getversion(fs) > 1) {
+ ifp32 = (IFILE32 *)(*bpp)->b_data;
+ ifp32 += ino % lfs_sb_getifpb(fs);
+ *ifpp = (IFILE *)ifp32;
+ } else {
+ ifp_v1 = (IFILE_V1 *)(*bpp)->b_data;
+ ifp_v1 += ino % lfs_sb_getifpb(fs);
+ *ifpp = (IFILE *)ifp_v1;
+ }
return;
}
@@ -480,7 +497,7 @@
*/
#ifndef REPAIR_ZERO_FINFO
lfs_ientry(&ifp, fs, dip[i].di_inumber, &ifbp);
- idaddr = ifp->if_daddr;
+ idaddr = lfs_if_getdaddr(fs, ifp);
brelse(ifbp, 0);
if (idaddr != daddr)
#endif
@@ -554,7 +571,7 @@
vers = -1;
#else
lfs_ientry(&ifp, fs, fip->fi_ino, &ifbp);
- vers = ifp->if_version;
+ vers = lfs_if_getversion(fs, ifp);
brelse(ifbp, 0);
#endif
if (vers != fip->fi_version) {
@@ -1416,15 +1433,13 @@
char *cp, *pidname;
#endif
-#ifdef RESCUEDIR
+#if defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ == 8 && \
+ defined(__OPTIMIZE_SIZE__)
/*
* XXX: Work around apparent bug with gcc 4.8 and -Os: it
* claims that ci.clean is uninitialized in clean_fs (at one
* of the several uses of it, which is neither the first nor
- * last use) -- this is conditionalized on RESCUEDIR because
- * it comes up for building the cleaner for /rescue. It
- * doesn't happen with plain -O2, and the value is clearly
- * always initialized.
+ * last use) -- this doesn't happen with plain -O2.
*
* Hopefully in the future further rearrangements will allow
* removing this hack.
diff -r 58a2e6507ac4 -r f0afc2eb9d5f sbin/dump_lfs/lfs_inode.c
--- a/sbin/dump_lfs/lfs_inode.c Wed Aug 12 18:25:03 2015 +0000
+++ b/sbin/dump_lfs/lfs_inode.c Wed Aug 12 18:25:51 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_inode.c,v 1.23 2015/08/02 18:18:09 dholland Exp $ */
+/* $NetBSD: lfs_inode.c,v 1.24 2015/08/12 18:25:52 dholland Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95";
#else
-__RCSID("$NetBSD: lfs_inode.c,v 1.23 2015/08/02 18:18:09 dholland Exp $");
+__RCSID("$NetBSD: lfs_inode.c,v 1.24 2015/08/12 18:25:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -59,8 +59,6 @@
#include "dump.h"
#undef di_inumber
-#define MAXIFPB (MAXBSIZE / sizeof(IFILE))
-
#define HASDUMPEDFILE 0x1
#define HASSUBDIRS 0x2
@@ -278,15 +276,16 @@
return (daddr_t)((int32_t *)bp)[off];
}
-static struct ifile *
+static IFILE *
lfs_ientry(ino_t ino)
{
- static struct ifile ifileblock[MAXIFPB];
+ static char ifileblock[MAXBSIZE];
static daddr_t ifblkno;
daddr_t lbn;
daddr_t blkno;
union dinode *dp;
struct ulfs1_dinode *ldp;
+ unsigned index;
lbn = ino/lfs_sb_getifpb(sblock) + lfs_sb_getcleansz(sblock) + lfs_sb_getsegtabsz(sblock);
dp = getino(lfs_sb_getifile(sblock));
@@ -294,9 +293,16 @@
ldp = (struct ulfs1_dinode *)dp;
blkno = lfs_bmap(sblock, ldp ,lbn);
if (blkno != ifblkno)
- bread(LFS_FSBTODB(sblock, blkno), (char *)ifileblock,
+ bread(LFS_FSBTODB(sblock, blkno), ifileblock,
lfs_sb_getbsize(sblock));
- return ifileblock + (ino % lfs_sb_getifpb(sblock));
+ index = ino % lfs_sb_getifpb(sblock);
+ if (sblock->lfs_is64) {
+ return (IFILE *) &((IFILE64 *)ifileblock)[index];
+ } else if (lfs_sb_getversion(sblock) > 1) {
+ return (IFILE *) &((IFILE32 *)ifileblock)[index];
+ } else {
+ return (IFILE *) &((IFILE_V1 *)ifileblock)[index];
+ }
}
/* Search a block for a specific dinode. */
@@ -334,7 +340,7 @@
}
curino = inum;
- blkno = lfs_ientry(inum)->if_daddr;
+ blkno = lfs_if_getdaddr(sblock, lfs_ientry(inum));
if(blkno == LFS_UNUSED_DADDR)
return &empty_dinode;
diff -r 58a2e6507ac4 -r f0afc2eb9d5f sbin/fsck_lfs/inode.c
--- a/sbin/fsck_lfs/inode.c Wed Aug 12 18:25:03 2015 +0000
+++ b/sbin/fsck_lfs/inode.c Wed Aug 12 18:25:51 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inode.c,v 1.57 2015/07/28 05:09:34 dholland Exp $ */
+/* $NetBSD: inode.c,v 1.58 2015/08/12 18:25:52 dholland Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -104,6 +104,8 @@
struct uvnode *vp;
struct ubuf *bp;
IFILE *ifp;
+ daddr_t daddr;
+ unsigned segno;
vp = vget(fs, ino);
if (vp == NULL)
@@ -111,8 +113,10 @@
if (din_table[ino] == 0x0) {
LFS_IENTRY(ifp, fs, ino, bp);
- din_table[ino] = ifp->if_daddr;
- seg_table[lfs_dtosn(fs, ifp->if_daddr)].su_nbytes += LFS_DINODE1_SIZE;
+ daddr = lfs_if_getdaddr(fs, ifp);
+ segno = lfs_dtosn(fs, daddr);
+ din_table[ino] = daddr;
+ seg_table[segno].su_nbytes += LFS_DINODE1_SIZE;
brelse(bp, 0);
}
return (VTOI(vp)->i_din.ffs1_din);
@@ -458,13 +462,13 @@
/* Send cleared inode to the free list */
LFS_IENTRY(ifp, fs, inumber, bp);
- daddr = ifp->if_daddr;
+ daddr = lfs_if_getdaddr(fs, ifp);
if (daddr == LFS_UNUSED_DADDR) {
brelse(bp, 0);
return;
}
- ifp->if_daddr = LFS_UNUSED_DADDR;
- ifp->if_nextfree = lfs_sb_getfreehd(fs);
+ lfs_if_setdaddr(fs, ifp, LFS_UNUSED_DADDR);
+ lfs_if_setnextfree(fs, ifp, lfs_sb_getfreehd(fs));
lfs_sb_setfreehd(fs, inumber);
sbdirty();
VOP_BWRITE(bp);
diff -r 58a2e6507ac4 -r f0afc2eb9d5f sbin/fsck_lfs/lfs.c
--- a/sbin/fsck_lfs/lfs.c Wed Aug 12 18:25:03 2015 +0000
+++ b/sbin/fsck_lfs/lfs.c Wed Aug 12 18:25:51 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.52 2015/08/02 18:18:09 dholland Exp $ */
+/* $NetBSD: lfs.c,v 1.53 2015/08/12 18:25:52 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -415,7 +415,7 @@
IFILE *ifp;
LFS_IENTRY(ifp, fs, ino, bp);
- daddr = ifp->if_daddr;
+ daddr = lfs_if_getdaddr(fs, ifp);
brelse(bp, 0);
if (daddr <= 0 || lfs_dtosn(fs, daddr) >= lfs_sb_getnseg(fs))
return NULL;
@@ -864,7 +864,7 @@
lfs_valloc(struct lfs *fs, ino_t ino)
{
struct ubuf *bp, *cbp;
- struct ifile *ifp;
+ IFILE *ifp;
ino_t new_ino;
int error;
CLEANERINFO *cip;
@@ -877,9 +877,9 @@
* of the free list into the superblock.
*/
LFS_IENTRY(ifp, fs, new_ino, bp);
- if (ifp->if_daddr != LFS_UNUSED_DADDR)
+ if (lfs_if_getdaddr(fs, ifp) != LFS_UNUSED_DADDR)
panic("lfs_valloc: inuse inode %d on the free list", new_ino);
- LFS_PUT_HEADFREE(fs, cip, cbp, ifp->if_nextfree);
+ LFS_PUT_HEADFREE(fs, cip, cbp, lfs_if_getnextfree(fs, ifp));
brelse(bp, 0);
@@ -910,7 +910,8 @@
{
struct uvnode *vp;
struct inode *ip;
- IFILE *ifp;
+ IFILE64 *ifp64;
+ IFILE32 *ifp32;
IFILE_V1 *ifp_v1;
struct ubuf *bp, *cbp;
daddr_t i, blkno, max;
@@ -932,7 +933,23 @@
max = i + lfs_sb_getifpb(fs);
lfs_sb_subbfree(fs, lfs_btofsb(fs, lfs_sb_getbsize(fs)));
- if (lfs_sb_getversion(fs) == 1) {
+ if (fs->lfs_is64) {
+ for (ifp64 = (IFILE64 *)bp->b_data; i < max; ++ifp64) {
+ ifp64->if_version = 1;
+ ifp64->if_daddr = LFS_UNUSED_DADDR;
+ ifp64->if_nextfree = ++i;
+ }
+ ifp64--;
+ ifp64->if_nextfree = oldlast;
+ } else if (lfs_sb_getversion(fs) > 1) {
+ for (ifp32 = (IFILE32 *)bp->b_data; i < max; ++ifp32) {
+ ifp32->if_version = 1;
+ ifp32->if_daddr = LFS_UNUSED_DADDR;
+ ifp32->if_nextfree = ++i;
+ }
+ ifp32--;
+ ifp32->if_nextfree = oldlast;
+ } else {
for (ifp_v1 = (IFILE_V1 *)bp->b_data; i < max; ++ifp_v1) {
ifp_v1->if_version = 1;
ifp_v1->if_daddr = LFS_UNUSED_DADDR;
@@ -940,14 +957,6 @@
}
ifp_v1--;
Home |
Main Index |
Thread Index |
Old Index