Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Hack up dinode usage to be 64 vs. 32 as needed. Part 1.
details: https://anonhg.NetBSD.org/src/rev/11bcd1d2eed9
branches: trunk
changeset: 339831:11bcd1d2eed9
user: dholland <dholland%NetBSD.org@localhost>
date: Wed Aug 12 18:28:00 2015 +0000
description:
Hack up dinode usage to be 64 vs. 32 as needed. Part 1.
(This part changes the native lfs code; the ufs-derived code already
has 64 vs. 32 logic, but as aspects of it are unsafe, and don't
entirely interoperate cleanly with the lfs 64/32 stuff, pass 2 will be
rehashing that.)
diffstat:
libexec/lfs_cleanerd/coalesce.c | 42 +++++++----
libexec/lfs_cleanerd/lfs_cleanerd.c | 18 ++--
sbin/dump/dump.h | 6 +-
sbin/dump_lfs/lfs_inode.c | 80 +++++++++++++--------
sbin/fsck_lfs/dir.c | 81 +++++++++++++---------
sbin/fsck_lfs/extern.h | 8 +-
sbin/fsck_lfs/fsck.h | 9 +-
sbin/fsck_lfs/fsck_vars.h | 4 +-
sbin/fsck_lfs/inode.c | 99 +++++++++++++++------------
sbin/fsck_lfs/lfs.c | 31 +++++---
sbin/fsck_lfs/lfs_user.h | 7 +-
sbin/fsck_lfs/pass1.c | 103 ++++++++++++++++++---------
sbin/fsck_lfs/pass2.c | 40 +++++++---
sbin/fsck_lfs/pass4.c | 6 +-
sbin/fsck_lfs/pass6.c | 131 ++++++++++++++++++++---------------
sbin/fsck_lfs/segwrite.c | 35 ++++++---
sbin/fsck_lfs/setup.c | 4 +-
sbin/fsck_lfs/utilities.c | 8 +-
sbin/fsck_lfs/vars.c | 4 +-
sbin/newfs_lfs/make_lfs.c | 85 ++++++++++++++---------
sys/lib/libsa/lfsv1.c | 4 +-
sys/lib/libsa/lfsv2.c | 4 +-
sys/lib/libsa/ufs.c | 5 +-
sys/ufs/lfs/lfs.h | 17 +++-
sys/ufs/lfs/lfs_accessors.h | 98 ++++++++++++++++++++++++++-
sys/ufs/lfs/lfs_alloc.c | 12 +-
sys/ufs/lfs/lfs_bio.c | 6 +-
sys/ufs/lfs/lfs_debug.c | 26 +++---
sys/ufs/lfs/lfs_extern.h | 13 ++-
sys/ufs/lfs/lfs_inode.c | 21 +++--
sys/ufs/lfs/lfs_inode.h | 9 +-
sys/ufs/lfs/lfs_rfw.c | 66 ++++++++++++-----
sys/ufs/lfs/lfs_segment.c | 98 +++++++++++++++-----------
sys/ufs/lfs/lfs_syscalls.c | 6 +-
sys/ufs/lfs/lfs_vfsops.c | 67 ++++++++++++-----
sys/ufs/lfs/lfs_vnops.c | 10 +-
sys/ufs/lfs/ulfs_inode.h | 4 +-
usr.sbin/dumplfs/dumplfs.c | 80 ++++++++++++---------
38 files changed, 841 insertions(+), 506 deletions(-)
diffs (truncated from 3337 to 300 lines):
diff -r 6d32fb64281d -r 11bcd1d2eed9 libexec/lfs_cleanerd/coalesce.c
--- a/libexec/lfs_cleanerd/coalesce.c Wed Aug 12 18:27:18 2015 +0000
+++ b/libexec/lfs_cleanerd/coalesce.c Wed Aug 12 18:28:00 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: coalesce.c,v 1.31 2015/08/12 18:25:51 dholland Exp $ */
+/* $NetBSD: coalesce.c,v 1.32 2015/08/12 18:28:00 dholland Exp $ */
/*-
* Copyright (c) 2002, 2005 The NetBSD Foundation, Inc.
@@ -109,13 +109,14 @@
"No such error"
};
-static struct ulfs1_dinode *
+static union lfs_dinode *
get_dinode(struct clfs *fs, ino_t ino)
{
IFILE *ifp;
daddr_t daddr;
struct ubuf *bp;
- struct ulfs1_dinode *dip, *r;
+ union lfs_dinode *dip, *r;
+ unsigned i;
lfs_ientry(&ifp, fs, ino, &bp);
daddr = lfs_if_getdaddr(fs, ifp);
@@ -125,16 +126,26 @@
return NULL;
bread(fs->clfs_devvp, daddr, lfs_sb_getibsize(fs), 0, &bp);
- for (dip = (struct ulfs1_dinode *)bp->b_data;
- dip < (struct ulfs1_dinode *)(bp->b_data + lfs_sb_getibsize(fs)); dip++)
- if (dip->di_inumber == ino) {
- r = (struct ulfs1_dinode *)malloc(sizeof(*r));
+ for (i = 0; i < LFS_INOPB(fs); i++) {
+ dip = DINO_IN_BLOCK(fs, bp->b_data, i);
+ if (lfs_dino_getinumber(fs, dip) == ino) {
+ r = malloc(sizeof(*r));
if (r == NULL)
break;
- memcpy(r, dip, sizeof(*r));
+ /*
+ * Don't just assign the union, as if we're
+ * 32-bit and it's the last inode in the block
+ * that will run off the end of the buffer.
+ */
+ if (fs->lfs_is64) {
+ r->u_64 = dip->u_64;
+ } else {
+ r->u_32 = dip->u_32;
+ }
brelse(bp, 0);
return r;
}
+ }
brelse(bp, 0);
return NULL;
}
@@ -149,7 +160,7 @@
BLOCK_INFO *bip = NULL, *tbip;
CLEANERINFO cip;
struct ubuf *bp;
- struct ulfs1_dinode *dip;
+ union lfs_dinode *dip;
struct clfs_seguse *sup;
struct lfs_fcntl_markv /* {
BLOCK_INFO *blkiov;
@@ -166,7 +177,7 @@
return COALESCE_NOINODE;
/* Compute file block size, set up for bmapv */
- onb = nb = lfs_lblkno(fs, dip->di_size);
+ onb = nb = lfs_lblkno(fs, lfs_dino_getsize(fs, dip));
/* XXX for now, don't do any file small enough to have fragments */
if (nb < ULFS_NDADDR) {
@@ -176,16 +187,17 @@
/* Sanity checks */
#if 0 /* di_size is uint64_t -- this is a noop */
- if (dip->di_size < 0) {
- dlog("ino %d, negative size (%" PRId64 ")", ino, dip->di_size);
+ if (lfs_dino_getsize(fs, dip) < 0) {
+ dlog("ino %d, negative size (%" PRId64 ")", ino,
+ lfs_dino_getsize(fs, dip));
free(dip);
return COALESCE_BADSIZE;
}
#endif
- if (nb > dip->di_blocks) {
+ if (nb > lfs_dino_getblocks(fs, dip)) {
dlog("ino %ju, computed blocks %jd > held blocks %ju",
(uintmax_t)ino, (intmax_t)nb,
- (uintmax_t)dip->di_blocks);
+ (uintmax_t)lfs_dino_getblocks(fs, dip));
free(dip);
return COALESCE_BADBLOCKSIZE;
}
@@ -220,7 +232,7 @@
memset(bip + i, 0, sizeof(BLOCK_INFO));
bip[i].bi_inode = ino;
bip[i].bi_lbn = i;
- bip[i].bi_version = dip->di_gen;
+ bip[i].bi_version = lfs_dino_getgen(fs, dip);
/* Don't set the size, but let lfs_bmap fill it in */
}
/*
diff -r 6d32fb64281d -r 11bcd1d2eed9 libexec/lfs_cleanerd/lfs_cleanerd.c
--- a/libexec/lfs_cleanerd/lfs_cleanerd.c Wed Aug 12 18:27:18 2015 +0000
+++ b/libexec/lfs_cleanerd/lfs_cleanerd.c Wed Aug 12 18:28:00 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_cleanerd.c,v 1.49 2015/08/12 18:27:01 dholland Exp $ */
+/* $NetBSD: lfs_cleanerd.c,v 1.50 2015/08/12 18:28:00 dholland Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -420,7 +420,7 @@
daddr_t idaddr, odaddr;
FINFO *fip;
struct ubuf *ifbp;
- struct ulfs1_dinode *dip;
+ union lfs_dinode *dip;
u_int32_t ck, vers;
int fic, inoc, obic;
size_t sumstart;
@@ -489,16 +489,16 @@
if (inoc < lfs_ss_getninos(fs, ssp) && *iaddrp == daddr) {
cp = fd_ptrget(fs->clfs_devvp, daddr);
ck = lfs_cksum_part(cp, sizeof(u_int32_t), ck);
- dip = (struct ulfs1_dinode *)cp;
for (i = 0; i < lfs_sb_getinopb(fs); i++) {
- if (dip[i].di_inumber == 0)
+ dip = DINO_IN_BLOCK(fs, cp, i);
+ if (lfs_dino_getinumber(fs, dip) == 0)
break;
/*
* Check currency before adding it
*/
#ifndef REPAIR_ZERO_FINFO
- lfs_ientry(&ifp, fs, dip[i].di_inumber, &ifbp);
+ lfs_ientry(&ifp, fs, lfs_dino_getinumber(fs, dip), &ifbp);
idaddr = lfs_if_getdaddr(fs, ifp);
brelse(ifbp, 0);
if (idaddr != daddr)
@@ -518,13 +518,13 @@
*bipp = bip;
return 0x0;
}
- bip[*bic - 1].bi_inode = dip[i].di_inumber;
+ bip[*bic - 1].bi_inode = lfs_dino_getinumber(fs, dip);
bip[*bic - 1].bi_lbn = LFS_UNUSED_LBN;
bip[*bic - 1].bi_daddr = daddr;
bip[*bic - 1].bi_segcreate = lfs_ss_getcreate(fs, ssp);
- bip[*bic - 1].bi_version = dip[i].di_gen;
- bip[*bic - 1].bi_bp = &(dip[i]);
- bip[*bic - 1].bi_size = LFS_DINODE1_SIZE;
+ bip[*bic - 1].bi_version = lfs_dino_getgen(fs, dip);
+ bip[*bic - 1].bi_bp = dip;
+ bip[*bic - 1].bi_size = DINOSIZE(fs);
}
inoc += i;
daddr += lfs_btofsb(fs, lfs_sb_getibsize(fs));
diff -r 6d32fb64281d -r 11bcd1d2eed9 sbin/dump/dump.h
--- a/sbin/dump/dump.h Wed Aug 12 18:27:18 2015 +0000
+++ b/sbin/dump/dump.h Wed Aug 12 18:28:00 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dump.h,v 1.52 2015/07/28 05:09:34 dholland Exp $ */
+/* $NetBSD: dump.h,v 1.53 2015/08/12 18:28:00 dholland Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -43,8 +43,8 @@
struct ufs1_dinode dp1;
struct ufs2_dinode dp2;
#ifdef DUMP_LFS
- struct ulfs1_dinode dlp1;
- struct ulfs2_dinode dlp2;
+ struct lfs32_dinode dlp32;
+ struct lfs64_dinode dlp64;
#endif
};
#define DIP(dp, field) \
diff -r 6d32fb64281d -r 11bcd1d2eed9 sbin/dump_lfs/lfs_inode.c
--- a/sbin/dump_lfs/lfs_inode.c Wed Aug 12 18:27:18 2015 +0000
+++ b/sbin/dump_lfs/lfs_inode.c Wed Aug 12 18:28:00 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_inode.c,v 1.24 2015/08/12 18:25:52 dholland Exp $ */
+/* $NetBSD: lfs_inode.c,v 1.25 2015/08/12 18:28:00 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.24 2015/08/12 18:25:52 dholland Exp $");
+__RCSID("$NetBSD: lfs_inode.c,v 1.25 2015/08/12 18:28:00 dholland Exp $");
#endif
#endif /* not lint */
@@ -196,7 +196,7 @@
#define T_UNITS (LFS_NINDIR(fs)*LFS_NINDIR(fs))
static daddr_t
-lfs_bmap(struct lfs *fs, struct ulfs1_dinode *idinode, daddr_t lbn)
+lfs_bmap(struct lfs *fs, union lfs_dinode *idinode, daddr_t lbn)
{
daddr_t residue, up;
int off=0;
@@ -204,7 +204,7 @@
up = UNASSIGNED; /* XXXGCC -Wunitialized [sh3] */
- if(lbn > 0 && lbn > lfs_lblkno(fs, idinode->di_size)) {
+ if(lbn > 0 && lbn > lfs_lblkno(fs, lfs_dino_getsize(fs, idinode))) {
return UNASSIGNED;
}
/*
@@ -217,13 +217,13 @@
lbn *= -1;
if (lbn == ULFS_NDADDR) {
/* printf("lbn %d: single indir base\n", -lbn); */
- return idinode->di_ib[0]; /* single indirect */
+ return lfs_dino_getib(fs, idinode, 0); /* single indirect */
} else if(lbn == BASE_DINDIR+1) {
/* printf("lbn %d: double indir base\n", -lbn); */
- return idinode->di_ib[1]; /* double indirect */
+ return lfs_dino_getib(fs, idinode, 1); /* double indirect */
} else if(lbn == BASE_TINDIR+2) {
/* printf("lbn %d: triple indir base\n", -lbn); */
- return idinode->di_ib[2]; /* triple indirect */
+ return lfs_dino_getib(fs, idinode, 2); /* triple indirect */
}
/*
@@ -233,7 +233,7 @@
residue = (lbn-ULFS_NDADDR) % LFS_NINDIR(fs);
if(residue == 1) {
/* Double indirect. Parent is the triple. */
- up = idinode->di_ib[2];
+ up = lfs_dino_getib(fs, idinode, 2);
off = (lbn-2-BASE_TINDIR)/(LFS_NINDIR(fs)*LFS_NINDIR(fs));
if(up == UNASSIGNED || up == LFS_UNUSED_DADDR)
return UNASSIGNED;
@@ -260,7 +260,7 @@
} else {
/* Direct block. Its parent must be a single indirect. */
if (lbn < ULFS_NDADDR)
- return idinode->di_db[lbn];
+ return lfs_dino_getdb(fs, idinode, lbn);
else {
/* Parent is an indirect block. */
up = -(((lbn-ULFS_NDADDR) / D_UNITS) * D_UNITS + ULFS_NDADDR);
@@ -284,14 +284,18 @@
daddr_t lbn;
daddr_t blkno;
union dinode *dp;
- struct ulfs1_dinode *ldp;
+ union lfs_dinode *ldp;
unsigned index;
lbn = ino/lfs_sb_getifpb(sblock) + lfs_sb_getcleansz(sblock) + lfs_sb_getsegtabsz(sblock);
dp = getino(lfs_sb_getifile(sblock));
- /* XXX XXX this is horribly unsafe */
- ldp = (struct ulfs1_dinode *)dp;
- blkno = lfs_bmap(sblock, ldp ,lbn);
+ /* XXX this is foolish */
+ if (sblock->lfs_is64) {
+ ldp = (union lfs_dinode *)&dp->dlp64;
+ } else {
+ ldp = (union lfs_dinode *)&dp->dlp32;
+ }
+ blkno = lfs_bmap(sblock, ldp, lbn);
if (blkno != ifblkno)
bread(LFS_FSBTODB(sblock, blkno), ifileblock,
lfs_sb_getbsize(sblock));
@@ -306,14 +310,18 @@
}
/* Search a block for a specific dinode. */
-static struct ulfs1_dinode *
-lfs_ifind(struct lfs *fs, ino_t ino, struct ulfs1_dinode *dip)
+static union lfs_dinode *
+lfs_ifind(struct lfs *fs, ino_t ino, void *block)
{
- int cnt;
+ union lfs_dinode *dip;
+ unsigned i, num;
- for (cnt = 0; cnt < LFS_INOPB(fs); cnt++)
- if(dip[cnt].di_inumber == ino)
- return &(dip[cnt]);
+ num = LFS_INOPB(fs);
+ for (i = num; i-- > 0; ) {
+ dip = DINO_IN_BLOCK(fs, block, i);
+ if (lfs_dino_getinumber(fs, dip) == ino)
+ return dip;
+ }
return NULL;
Home |
Main Index |
Thread Index |
Old Index