Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Make 32-bit and 64-bit versions of SEGSUM.
details: https://anonhg.NetBSD.org/src/rev/26d55a6c399c
branches: trunk
changeset: 339828:26d55a6c399c
user: dholland <dholland%NetBSD.org@localhost>
date: Wed Aug 12 18:26:26 2015 +0000
description:
Make 32-bit and 64-bit versions of SEGSUM.
Also fix some of the FINFO handling as it's closely entangled.
diffstat:
libexec/lfs_cleanerd/lfs_cleanerd.c | 34 +++++----
sbin/fsck_lfs/lfs.c | 61 +++++++++--------
sbin/fsck_lfs/lfs_user.h | 7 +-
sbin/fsck_lfs/pass6.c | 30 ++++----
sbin/fsck_lfs/segwrite.c | 60 +++++++++++-------
sbin/fsck_lfs/setup.c | 20 +++--
sys/ufs/lfs/lfs.h | 53 ++++++++++++---
sys/ufs/lfs/lfs_accessors.h | 117 +++++++++++++++++++++++++++++++++++-
sys/ufs/lfs/lfs_pages.c | 12 ++-
sys/ufs/lfs/lfs_rfw.c | 59 +++++++++--------
sys/ufs/lfs/lfs_segment.c | 89 ++++++++++++++++----------
sys/ufs/lfs/lfs_vfsops.c | 10 +-
sys/ufs/lfs/lfs_vnops.c | 10 +-
usr.sbin/dumplfs/dumplfs.c | 72 ++++++++++++----------
14 files changed, 416 insertions(+), 218 deletions(-)
diffs (truncated from 1549 to 300 lines):
diff -r 904bd65688a9 -r 26d55a6c399c libexec/lfs_cleanerd/lfs_cleanerd.c
--- a/libexec/lfs_cleanerd/lfs_cleanerd.c Wed Aug 12 18:25:51 2015 +0000
+++ b/libexec/lfs_cleanerd/lfs_cleanerd.c Wed Aug 12 18:26:26 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_cleanerd.c,v 1.47 2015/08/12 18:25:51 dholland Exp $ */
+/* $NetBSD: lfs_cleanerd.c,v 1.48 2015/08/12 18:26:26 dholland Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -423,6 +423,7 @@
struct ulfs1_dinode *dip;
u_int32_t ck, vers;
int fic, inoc, obic;
+ size_t sumstart;
int i;
char *cp;
@@ -438,22 +439,23 @@
ssp = (SEGSUM *)cp;
/* XXX ondisk32 */
iaddrp = ((int32_t *)(cp + lfs_sb_getibsize(fs))) - 1;
- fip = (FINFO *)(cp + sizeof(SEGSUM));
+ fip = SEGSUM_FINFOBASE(fs, cp);
/*
* Check segment header magic and checksum
*/
- if (ssp->ss_magic != SS_MAGIC) {
+ if (lfs_ss_getmagic(fs, ssp) != SS_MAGIC) {
syslog(LOG_WARNING, "%s: sumsum magic number bad at 0x%jx:"
" read 0x%x, expected 0x%x", lfs_sb_getfsmnt(fs),
- (intmax_t)daddr, ssp->ss_magic, SS_MAGIC);
+ (intmax_t)daddr, lfs_ss_getmagic(fs, ssp), SS_MAGIC);
return 0x0;
}
- ck = cksum(&ssp->ss_datasum, lfs_sb_getsumsize(fs) - sizeof(ssp->ss_sumsum));
- if (ck != ssp->ss_sumsum) {
+ sumstart = lfs_ss_getsumstart(fs);
+ ck = cksum((char *)ssp + sumstart, lfs_sb_getsumsize(fs) - sumstart);
+ if (ck != lfs_ss_getsumsum(fs, ssp)) {
syslog(LOG_WARNING, "%s: sumsum checksum mismatch at 0x%jx:"
" read 0x%x, computed 0x%x", lfs_sb_getfsmnt(fs),
- (intmax_t)daddr, ssp->ss_sumsum, ck);
+ (intmax_t)daddr, lfs_ss_getsumsum(fs, ssp), ck);
return 0x0;
}
@@ -469,12 +471,12 @@
* as we go.
*/
fic = inoc = 0;
- while (fic < ssp->ss_nfinfo || inoc < ssp->ss_ninos) {
+ while (fic < lfs_ss_getnfinfo(fs, ssp) || inoc < lfs_ss_getninos(fs, ssp)) {
/*
* We must have either a file block or an inode block.
* If we don't have either one, it's an error.
*/
- if (fic >= ssp->ss_nfinfo && *iaddrp != daddr) {
+ if (fic >= lfs_ss_getnfinfo(fs, ssp) && *iaddrp != daddr) {
syslog(LOG_WARNING, "%s: bad pseg at %jx (seg %d)",
lfs_sb_getfsmnt(fs), (intmax_t)odaddr, lfs_dtosn(fs, odaddr));
*bipp = bip;
@@ -484,7 +486,7 @@
/*
* Note each inode from the inode blocks
*/
- if (inoc < ssp->ss_ninos && *iaddrp == daddr) {
+ 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;
@@ -519,7 +521,7 @@
bip[*bic - 1].bi_inode = dip[i].di_inumber;
bip[*bic - 1].bi_lbn = LFS_UNUSED_LBN;
bip[*bic - 1].bi_daddr = daddr;
- bip[*bic - 1].bi_segcreate = ssp->ss_create;
+ 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;
@@ -533,7 +535,7 @@
/*
* Note each file block from the finfo blocks
*/
- if (fic >= ssp->ss_nfinfo)
+ if (fic >= lfs_ss_getnfinfo(fs, ssp))
continue;
/* Count this finfo, whether or not we use it */
@@ -603,7 +605,7 @@
bip[*bic + i].bi_inode = fip->fi_ino;
bip[*bic + i].bi_lbn = fip->fi_blocks[i];
bip[*bic + i].bi_daddr = daddr;
- bip[*bic + i].bi_segcreate = ssp->ss_create;
+ bip[*bic + i].bi_segcreate = lfs_ss_getcreate(fs, ssp);
bip[*bic + i].bi_version = fip->fi_version;
bip[*bic + i].bi_size = (i == fip->fi_nblocks - 1) ?
fip->fi_lastlength : lfs_sb_getbsize(fs);
@@ -617,15 +619,15 @@
#endif
}
*bic += fip->fi_nblocks;
- fip = (FINFO *)(fip->fi_blocks + fip->fi_nblocks);
+ fip = NEXT_FINFO(fs, fip);
}
#ifndef REPAIR_ZERO_FINFO
- if (ssp->ss_datasum != ck) {
+ if (lfs_ss_getdatasum(fs, ssp) != ck) {
syslog(LOG_WARNING, "%s: data checksum bad at 0x%jx:"
" read 0x%x, computed 0x%x", lfs_sb_getfsmnt(fs),
(intmax_t)odaddr,
- ssp->ss_datasum, ck);
+ lfs_ss_getdatasum(fs, ssp), ck);
*bic = obic;
return 0x0;
}
diff -r 904bd65688a9 -r 26d55a6c399c sbin/fsck_lfs/lfs.c
--- a/sbin/fsck_lfs/lfs.c Wed Aug 12 18:25:51 2015 +0000
+++ b/sbin/fsck_lfs/lfs.c Wed Aug 12 18:26:26 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.53 2015/08/12 18:25:52 dholland Exp $ */
+/* $NetBSD: lfs.c,v 1.54 2015/08/12 18:26:26 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -611,28 +611,29 @@
/*
* Check for a valid segment summary belonging to our fs.
*/
- if (sp->ss_magic != SS_MAGIC ||
- sp->ss_ident != lfs_sb_getident(osb) ||
- sp->ss_serial < serial || /* XXX strengthen this */
- sp->ss_sumsum != cksum(&sp->ss_datasum, lfs_sb_getsumsize(osb) -
- sizeof(sp->ss_sumsum))) {
+ if (lfs_ss_getmagic(osb, sp) != SS_MAGIC ||
+ lfs_ss_getident(osb, sp) != lfs_sb_getident(osb) ||
+ lfs_ss_getserial(osb, sp) < serial || /* XXX strengthen this */
+ lfs_ss_getsumsum(osb, sp) !=
+ cksum((char *)sp + lfs_ss_getsumstart(osb),
+ lfs_sb_getsumsize(osb) - lfs_ss_getsumstart(osb))) {
brelse(bp, 0);
if (debug) {
- if (sp->ss_magic != SS_MAGIC)
+ if (lfs_ss_getmagic(osb, sp) != SS_MAGIC)
pwarn("pseg at 0x%jx: "
"wrong magic number\n",
(uintmax_t)daddr);
- else if (sp->ss_ident != lfs_sb_getident(osb))
+ else if (lfs_ss_getident(osb, sp) != lfs_sb_getident(osb))
pwarn("pseg at 0x%jx: "
"expected ident %jx, got %jx\n",
(uintmax_t)daddr,
- (uintmax_t)sp->ss_ident,
+ (uintmax_t)lfs_ss_getident(osb, sp),
(uintmax_t)lfs_sb_getident(osb));
- else if (sp->ss_serial >= serial)
+ else if (lfs_ss_getserial(osb, sp) >= serial)
pwarn("pseg at 0x%jx: "
"serial %d < %d\n",
(uintmax_t)daddr,
- (int)sp->ss_serial, (int)serial);
+ (int)lfs_ss_getserial(osb, sp), (int)serial);
else
pwarn("pseg at 0x%jx: "
"summary checksum wrong\n",
@@ -640,9 +641,9 @@
}
break;
}
- if (debug && sp->ss_serial != serial)
+ if (debug && lfs_ss_getserial(osb, sp) != serial)
pwarn("warning, serial=%d ss_serial=%d\n",
- (int)serial, (int)sp->ss_serial);
+ (int)serial, (int)lfs_ss_getserial(osb, sp));
++serial;
bc = check_summary(osb, sp, daddr, debug, devvp, NULL);
if (bc == 0) {
@@ -651,14 +652,14 @@
}
if (debug)
pwarn("summary good: 0x%x/%d\n", (uintmax_t)daddr,
- (int)sp->ss_serial);
+ (int)lfs_ss_getserial(osb, sp));
assert (bc > 0);
odaddr = daddr;
daddr += lfs_btofsb(osb, lfs_sb_getsumsize(osb) + bc);
if (lfs_dtosn(osb, odaddr) != lfs_dtosn(osb, daddr) ||
lfs_dtosn(osb, daddr) != lfs_dtosn(osb, daddr +
lfs_btofsb(osb, lfs_sb_getsumsize(osb) + lfs_sb_getbsize(osb)) - 1)) {
- daddr = sp->ss_next;
+ daddr = lfs_ss_getnext(osb, sp);
}
/*
@@ -668,9 +669,9 @@
* to roll forward through them. Likewise, psegs written
* by a previous roll-forward attempt are not interesting.
*/
- if (sp->ss_flags & (SS_CLEAN | SS_RFW))
+ if (lfs_ss_getflags(osb, sp) & (SS_CLEAN | SS_RFW))
hitclean = 1;
- if (hitclean == 0 && (sp->ss_flags & SS_CONT) == 0)
+ if (hitclean == 0 && (lfs_ss_getflags(osb, sp) & SS_CONT) == 0)
nodirop_daddr = daddr;
brelse(bp, 0);
@@ -761,17 +762,17 @@
/* We've already checked the sumsum, just do the data bounds and sum */
/* Count the blocks. */
- nblocks = howmany(sp->ss_ninos, LFS_INOPB(fs));
+ nblocks = howmany(lfs_ss_getninos(fs, sp), LFS_INOPB(fs));
bc = nblocks << (lfs_sb_getversion(fs) > 1 ? lfs_sb_getffshift(fs) : lfs_sb_getbshift(fs));
assert(bc >= 0);
- fp = (FINFO *) (sp + 1);
- for (i = 0; i < sp->ss_nfinfo; i++) {
+ fp = SEGSUM_FINFOBASE(fs, sp);
+ for (i = 0; i < lfs_ss_getnfinfo(fs, sp); i++) {
nblocks += fp->fi_nblocks;
bc += fp->fi_lastlength + ((fp->fi_nblocks - 1)
<< lfs_sb_getbshift(fs));
assert(bc >= 0);
- fp = (FINFO *) (fp->fi_blocks + fp->fi_nblocks);
+ fp = NEXT_FINFO(fs, fp);
if (((char *)fp) - (char *)sp > lfs_sb_getsumsize(fs))
return 0;
}
@@ -786,17 +787,18 @@
daddr = pseg_addr + lfs_btofsb(fs, lfs_sb_getsumsize(fs));
fp = (FINFO *) (sp + 1);
for (i = 0, j = 0;
- i < sp->ss_nfinfo || j < howmany(sp->ss_ninos, LFS_INOPB(fs)); i++) {
- if (i >= sp->ss_nfinfo && *idp != daddr) {
+ i < lfs_ss_getnfinfo(fs, sp) || j < howmany(lfs_ss_getninos(fs, sp), LFS_INOPB(fs)); i++) {
+ if (i >= lfs_ss_getnfinfo(fs, sp) && *idp != daddr) {
pwarn("Not enough inode blocks in pseg at 0x%" PRIx32
": found %d, wanted %d\n",
- pseg_addr, j, howmany(sp->ss_ninos, LFS_INOPB(fs)));
+ pseg_addr, j, howmany(lfs_ss_getninos(fs, sp),
+ LFS_INOPB(fs)));
if (debug)
pwarn("*idp=%x, daddr=%" PRIx32 "\n", *idp,
daddr);
break;
}
- while (j < howmany(sp->ss_ninos, LFS_INOPB(fs)) && *idp == daddr) {
+ while (j < howmany(lfs_ss_getninos(fs, sp), LFS_INOPB(fs)) && *idp == daddr) {
bread(devvp, LFS_FSBTODB(fs, daddr), lfs_sb_getibsize(fs),
0, &bp);
datap[datac++] = ((u_int32_t *) (bp->b_data))[0];
@@ -806,7 +808,7 @@
daddr += lfs_btofsb(fs, lfs_sb_getibsize(fs));
--idp;
}
- if (i < sp->ss_nfinfo) {
+ if (i < lfs_ss_getnfinfo(fs, sp)) {
if (func)
func(daddr, fp);
for (k = 0; k < fp->fi_nblocks; k++) {
@@ -819,7 +821,7 @@
brelse(bp, 0);
daddr += lfs_btofsb(fs, len);
}
- fp = (FINFO *) (fp->fi_blocks + fp->fi_nblocks);
+ fp = NEXT_FINFO(fs, fp);
}
}
@@ -827,12 +829,13 @@
pwarn("Partial segment at 0x%jx expected %d blocks counted %d\n",
(intmax_t)pseg_addr, nblocks, datac);
}
+ /* XXX ondisk32 */
ccksum = cksum(datap, nblocks * sizeof(u_int32_t));
/* Check the data checksum */
- if (ccksum != sp->ss_datasum) {
+ if (ccksum != lfs_ss_getdatasum(fs, sp)) {
pwarn("Partial segment at 0x%jx data checksum"
" mismatch: given 0x%x, computed 0x%x\n",
- (uintmax_t)pseg_addr, sp->ss_datasum, ccksum);
+ (uintmax_t)pseg_addr, lfs_ss_getdatasum(fs, sp), ccksum);
free(datap);
return 0;
}
diff -r 904bd65688a9 -r 26d55a6c399c sbin/fsck_lfs/lfs_user.h
--- a/sbin/fsck_lfs/lfs_user.h Wed Aug 12 18:25:51 2015 +0000
+++ b/sbin/fsck_lfs/lfs_user.h Wed Aug 12 18:26:26 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_user.h,v 1.7 2014/07/13 02:44:21 dholland Exp $ */
+/* $NetBSD: lfs_user.h,v 1.8 2015/08/12 18:26:26 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -31,7 +31,8 @@
#include <stdarg.h>
struct lfs;
-struct segsum;
Home |
Main Index |
Thread Index |
Old Index