Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Provide 32-bit and 64-bit versions of FINFO.
details: https://anonhg.NetBSD.org/src/rev/f67a078cbc4c
branches: trunk
changeset: 339829:f67a078cbc4c
user: dholland <dholland%NetBSD.org@localhost>
date: Wed Aug 12 18:27:01 2015 +0000
description:
Provide 32-bit and 64-bit versions of FINFO.
This also entailed sorting out part of struct segment, as that
contains a pointer into the current FINFO data.
diffstat:
libexec/lfs_cleanerd/lfs_cleanerd.c | 32 +++---
sbin/fsck_lfs/lfs.c | 12 +-
sbin/fsck_lfs/lfs_user.h | 6 +-
sbin/fsck_lfs/pass6.c | 22 ++--
sbin/fsck_lfs/segwrite.c | 82 ++++++++++++------
sbin/fsck_lfs/segwrite.h | 4 +-
sbin/fsck_lfs/setup.c | 4 +-
sys/ufs/lfs/lfs.h | 42 +++++++-
sys/ufs/lfs/lfs_accessors.h | 154 +++++++++++++++++++++++++++++++++++-
sys/ufs/lfs/lfs_debug.c | 16 ++-
sys/ufs/lfs/lfs_rfw.c | 25 +++--
sys/ufs/lfs/lfs_segment.c | 120 +++++++++++++++++++--------
sys/ufs/lfs/lfs_vfsops.c | 6 +-
usr.sbin/dumplfs/dumplfs.c | 36 ++++---
14 files changed, 405 insertions(+), 156 deletions(-)
diffs (truncated from 1220 to 300 lines):
diff -r 26d55a6c399c -r f67a078cbc4c libexec/lfs_cleanerd/lfs_cleanerd.c
--- a/libexec/lfs_cleanerd/lfs_cleanerd.c Wed Aug 12 18:26:26 2015 +0000
+++ b/libexec/lfs_cleanerd/lfs_cleanerd.c Wed Aug 12 18:27:01 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_cleanerd.c,v 1.48 2015/08/12 18:26:26 dholland Exp $ */
+/* $NetBSD: lfs_cleanerd.c,v 1.49 2015/08/12 18:27:01 dholland Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -546,7 +546,7 @@
* Kernels with this problem always wrote this zero-sized
* finfo last, so just ignore it.
*/
- if (fip->fi_nblocks == 0) {
+ if (lfs_fi_getnblocks(fs, fip) == 0) {
#ifdef REPAIR_ZERO_FINFO
struct ubuf *nbp;
SEGSUM *nssp;
@@ -572,27 +572,27 @@
#ifdef REPAIR_ZERO_FINFO
vers = -1;
#else
- lfs_ientry(&ifp, fs, fip->fi_ino, &ifbp);
+ lfs_ientry(&ifp, fs, lfs_fi_getino(fs, fip), &ifbp);
vers = lfs_if_getversion(fs, ifp);
brelse(ifbp, 0);
#endif
- if (vers != fip->fi_version) {
+ if (vers != lfs_fi_getversion(fs, fip)) {
size_t size;
/* Read all the blocks from the data summary */
- for (i = 0; i < fip->fi_nblocks; i++) {
- size = (i == fip->fi_nblocks - 1) ?
- fip->fi_lastlength : lfs_sb_getbsize(fs);
+ for (i = 0; i < lfs_fi_getnblocks(fs, fip); i++) {
+ size = (i == lfs_fi_getnblocks(fs, fip) - 1) ?
+ lfs_fi_getlastlength(fs, fip) : lfs_sb_getbsize(fs);
cp = fd_ptrget(fs->clfs_devvp, daddr);
ck = lfs_cksum_part(cp, sizeof(u_int32_t), ck);
daddr += lfs_btofsb(fs, size);
}
- fip = (FINFO *)(fip->fi_blocks + fip->fi_nblocks);
+ fip = NEXT_FINFO(fs, fip);
continue;
}
/* Add all the blocks from the finfos (current or not) */
- nbip = (BLOCK_INFO *)realloc(bip, (*bic + fip->fi_nblocks) *
+ nbip = (BLOCK_INFO *)realloc(bip, (*bic + lfs_fi_getnblocks(fs, fip)) *
sizeof(*bip));
if (nbip)
bip = nbip;
@@ -601,14 +601,14 @@
return 0x0;
}
- for (i = 0; i < fip->fi_nblocks; i++) {
- bip[*bic + i].bi_inode = fip->fi_ino;
- bip[*bic + i].bi_lbn = fip->fi_blocks[i];
+ for (i = 0; i < lfs_fi_getnblocks(fs, fip); i++) {
+ bip[*bic + i].bi_inode = lfs_fi_getino(fs, fip);
+ bip[*bic + i].bi_lbn = lfs_fi_getblock(fs, fip, i);
bip[*bic + i].bi_daddr = daddr;
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);
+ bip[*bic + i].bi_version = lfs_fi_getversion(fs, fip);
+ bip[*bic + i].bi_size = (i == lfs_fi_getnblocks(fs, fip) - 1) ?
+ lfs_fi_getlastlength(fs, fip) : lfs_sb_getbsize(fs);
cp = fd_ptrget(fs->clfs_devvp, daddr);
ck = lfs_cksum_part(cp, sizeof(u_int32_t), ck);
bip[*bic + i].bi_bp = cp;
@@ -618,7 +618,7 @@
check_test_pattern(bip + *bic + i); /* XXXDEBUG */
#endif
}
- *bic += fip->fi_nblocks;
+ *bic += lfs_fi_getnblocks(fs, fip);
fip = NEXT_FINFO(fs, fip);
}
diff -r 26d55a6c399c -r f67a078cbc4c sbin/fsck_lfs/lfs.c
--- a/sbin/fsck_lfs/lfs.c Wed Aug 12 18:26:26 2015 +0000
+++ b/sbin/fsck_lfs/lfs.c Wed Aug 12 18:27:01 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.54 2015/08/12 18:26:26 dholland Exp $ */
+/* $NetBSD: lfs.c,v 1.55 2015/08/12 18:27:01 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -768,8 +768,8 @@
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)
+ nblocks += lfs_fi_getnblocks(fs, fp);
+ bc += lfs_fi_getlastlength(fs, fp) + ((lfs_fi_getnblocks(fs, fp) - 1)
<< lfs_sb_getbshift(fs));
assert(bc >= 0);
fp = NEXT_FINFO(fs, fp);
@@ -811,9 +811,9 @@
if (i < lfs_ss_getnfinfo(fs, sp)) {
if (func)
func(daddr, fp);
- for (k = 0; k < fp->fi_nblocks; k++) {
- len = (k == fp->fi_nblocks - 1 ?
- fp->fi_lastlength
+ for (k = 0; k < lfs_fi_getnblocks(fs, fp); k++) {
+ len = (k == lfs_fi_getnblocks(fs, fp) - 1 ?
+ lfs_fi_getlastlength(fs, fp)
: lfs_sb_getbsize(fs));
bread(devvp, LFS_FSBTODB(fs, daddr), len,
0, &bp);
diff -r 26d55a6c399c -r f67a078cbc4c sbin/fsck_lfs/lfs_user.h
--- a/sbin/fsck_lfs/lfs_user.h Wed Aug 12 18:26:26 2015 +0000
+++ b/sbin/fsck_lfs/lfs_user.h Wed Aug 12 18:27:01 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_user.h,v 1.8 2015/08/12 18:26:26 dholland Exp $ */
+/* $NetBSD: lfs_user.h,v 1.9 2015/08/12 18:27:01 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -33,7 +33,7 @@
struct lfs;
/* XXX do these really need to be here? */
union segsum;
-struct finfo;
+union finfo;
/*
* In the fsck code we don't need lfs_unlockvp, but we don't have a mount
@@ -86,7 +86,7 @@
struct uvnode *lfs_raw_vget(struct lfs *, ino_t, int, ulfs_daddr_t);
struct lfs *lfs_init(int, daddr_t, daddr_t, int, int);
struct lfs *lfs_verify(struct lfs *, struct lfs *, struct uvnode *, int);
-int check_summary(struct lfs *, union segsum *, ulfs_daddr_t, int, struct uvnode *, void (*)(ulfs_daddr_t, struct finfo *));
+int check_summary(struct lfs *, union segsum *, ulfs_daddr_t, int, struct uvnode *, void (*)(ulfs_daddr_t, union finfo *));
ulfs_daddr_t try_verify(struct lfs *, struct uvnode *, ulfs_daddr_t, int);
struct ulfs1_dinode *lfs_ifind(struct lfs *, ino_t, struct ubuf *);
void call_panic(const char *, ...);
diff -r 26d55a6c399c -r f67a078cbc4c sbin/fsck_lfs/pass6.c
--- a/sbin/fsck_lfs/pass6.c Wed Aug 12 18:26:26 2015 +0000
+++ b/sbin/fsck_lfs/pass6.c Wed Aug 12 18:27:01 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass6.c,v 1.40 2015/08/12 18:26:26 dholland Exp $ */
+/* $NetBSD: pass6.c,v 1.41 2015/08/12 18:27:01 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -262,18 +262,18 @@
int i;
size_t size;
- vp = vget(fs, fip->fi_ino);
+ vp = vget(fs, lfs_fi_getino(fs, fip));
if (vp && vp != fs->lfs_ivnode &&
- VTOI(vp)->i_ffs1_gen == fip->fi_version) {
- for (i = 0; i < fip->fi_nblocks; i++) {
- size = (i == fip->fi_nblocks - 1 ?
- fip->fi_lastlength : lfs_sb_getbsize(fs));
+ VTOI(vp)->i_ffs1_gen == lfs_fi_getversion(fs, fip)) {
+ for (i = 0; i < lfs_fi_getnblocks(fs, fip); i++) {
+ size = (i == lfs_fi_getnblocks(fs, fip) - 1 ?
+ lfs_fi_getlastlength(fs, fip) : lfs_sb_getbsize(fs));
if (debug)
- pwarn("ino %lld lbn %lld -> 0x%lx\n",
- (long long)fip->fi_ino,
- (long long)fip->fi_blocks[i],
- (long)daddr);
- rfw_update_single(vp, fip->fi_blocks[i], daddr, size);
+ pwarn("ino %ju lbn %jd -> 0x%jx\n",
+ (uintmax_t)lfs_fi_getino(fs, fip),
+ (intmax_t)lfs_fi_getblock(fs, fip, i),
+ (intmax_t)daddr);
+ rfw_update_single(vp, lfs_fi_getblock(fs, fip, i), daddr, size);
daddr += lfs_btofsb(fs, size);
}
}
diff -r 26d55a6c399c -r f67a078cbc4c sbin/fsck_lfs/segwrite.c
--- a/sbin/fsck_lfs/segwrite.c Wed Aug 12 18:26:26 2015 +0000
+++ b/sbin/fsck_lfs/segwrite.c Wed Aug 12 18:27:01 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: segwrite.c,v 1.39 2015/08/12 18:26:27 dholland Exp $ */
+/* $NetBSD: segwrite.c,v 1.40 2015/08/12 18:27:01 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -106,6 +106,9 @@
extern u_int32_t lfs_sb_cksum(struct lfs *);
extern int preen;
+static void lfs_shellsort(struct lfs *,
+ struct ubuf **, union lfs_blocks *, int, int);
+
/*
* Logical block number match routines used when traversing the dirty block
* chain.
@@ -198,7 +201,7 @@
lfs_writefile(struct lfs * fs, struct segment * sp, struct uvnode * vp)
{
struct ubuf *bp;
- struct finfo *fip;
+ FINFO *fip;
struct inode *ip;
IFILE *ifp;
SEGSUM *ssp;
@@ -206,10 +209,10 @@
ip = VTOI(vp);
if (sp->seg_bytes_left < lfs_sb_getbsize(fs) ||
- sp->sum_bytes_left < sizeof(struct finfo))
+ sp->sum_bytes_left < FINFOSIZE(fs) + LFS_BLKPTRSIZE(fs))
(void) lfs_writeseg(fs, sp);
- sp->sum_bytes_left -= FINFOSIZE;
+ sp->sum_bytes_left -= FINFOSIZE(fs);
ssp = (SEGSUM *)sp->segsum;
lfs_ss_setnfinfo(fs, ssp, lfs_ss_getnfinfo(fs, ssp) + 1);
@@ -219,10 +222,10 @@
}
fip = sp->fip;
- fip->fi_nblocks = 0;
- fip->fi_ino = ip->i_number;
- LFS_IENTRY(ifp, fs, fip->fi_ino, bp);
- fip->fi_version = lfs_if_getversion(fs, ifp);
+ lfs_fi_setnblocks(fs, fip, 0);
+ lfs_fi_setino(fs, fip, ip->i_number);
+ LFS_IENTRY(ifp, fs, lfs_fi_getino(fs, fip), bp);
+ lfs_fi_setversion(fs, fip, lfs_if_getversion(fs, ifp));
brelse(bp, 0);
lfs_gather(fs, sp, vp, lfs_match_data);
@@ -231,11 +234,12 @@
lfs_gather(fs, sp, vp, lfs_match_tindir);
fip = sp->fip;
- if (fip->fi_nblocks != 0) {
+ if (lfs_fi_getnblocks(fs, fip) != 0) {
sp->fip = NEXT_FINFO(fs, fip);
- sp->start_lbp = &sp->fip->fi_blocks[0];
+ lfs_blocks_fromfinfo(fs, &sp->start_lbp, sp->fip);
} else {
- sp->sum_bytes_left += FINFOSIZE;
+ /* XXX shouldn't this update sp->fip? */
+ sp->sum_bytes_left += FINFOSIZE(fs);
lfs_ss_setnfinfo(fs, ssp, lfs_ss_getnfinfo(fs, ssp) - 1);
}
}
@@ -380,15 +384,15 @@
sp->seg_bytes_left < bp->b_bcount) {
lfs_updatemeta(sp);
- version = sp->fip->fi_version;
+ version = lfs_fi_getversion(fs, sp->fip);
(void) lfs_writeseg(fs, sp);
- sp->fip->fi_version = version;
- sp->fip->fi_ino = VTOI(sp->vp)->i_number;
+ lfs_fi_setversion(fs, sp->fip, version);
+ lfs_fi_setino(fs, sp->fip, VTOI(sp->vp)->i_number);
/* Add the current file to the segment summary. */
ssp = (SEGSUM *)sp->segsum;
lfs_ss_setnfinfo(fs, ssp, lfs_ss_getnfinfo(fs, ssp) + 1);
- sp->sum_bytes_left -= FINFOSIZE;
+ sp->sum_bytes_left -= FINFOSIZE(fs);
return 1;
}
@@ -397,8 +401,13 @@
/* bp->b_flags &= ~B_DONE; */
*sp->cbpp++ = bp;
- for (j = 0; j < blksinblk; j++)
- sp->fip->fi_blocks[sp->fip->fi_nblocks++] = bp->b_lblkno + j;
+ for (j = 0; j < blksinblk; j++) {
+ unsigned bn;
+
+ bn = lfs_fi_getnblocks(fs, sp->fip);
+ lfs_fi_setnblocks(fs, sp->fip, bn + 1);
+ lfs_fi_setblock(fs, sp->fip, bn, bp->b_lblkno + j);;
+ }
sp->sum_bytes_left -= sizeof(ulfs_daddr_t) * blksinblk;
sp->seg_bytes_left -= bp->b_bcount;
@@ -533,9 +542,22 @@
int i, nblocks, num;
int frags;
int bytesleft, size;
+ union lfs_blocks tmpptr;
+ fs = sp->fs;
vp = sp->vp;
+
+ /*
+ * This code was cutpasted from the kernel. See the
Home |
Main Index |
Thread Index |
Old Index