NetBSD/sbin/fsck_lfs/pass0.c

373 lines
11 KiB
C
Raw Normal View History

Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
/* $NetBSD: pass0.c,v 1.9 2001/07/13 20:30:19 perseant Exp $ */
1999-07-03 23:55:03 +04:00
/*
* Copyright (c) 1998 Konrad E. Schroder.
* Copyright (c) 1980, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/time.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>
#include <sys/mount.h>
#include <ufs/lfs/lfs.h>
#include <ufs/lfs/lfs_extern.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fsck.h"
#include "extern.h"
#include "fsutil.h"
/* Flags for check_segment */
#define CKSEG_VERBOSE 1
#define CKSEG_IGNORECLEAN 2
2000-05-23 05:48:52 +04:00
extern int fake_cleanseg;
void
check_segment(int, int, daddr_t, struct lfs *, int,
int (*)(struct lfs *, SEGSUM *, daddr_t));
/*
* Pass 0. Check the LFS partial segments for valid checksums, correcting
* if necessary. Also check for valid offsets for inode and finfo blocks.
*/
2000-05-23 05:48:52 +04:00
/*
* XXX more could be done here---consistency between inode-held blocks and
* finfo blocks, for one thing.
*/
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
#define dbshift (sblock.lfs_bshift - sblock.lfs_blktodb)
void
pass0()
{
2000-05-23 05:48:52 +04:00
daddr_t daddr;
IFILE *ifp;
struct bufarea *bp;
ino_t ino, lastino, nextino, *visited;
2000-05-23 05:48:52 +04:00
/*
* Check the inode free list for inuse inodes, and cycles.
* Make sure that all free inodes are in fact on the list.
2000-05-23 05:48:52 +04:00
*/
visited = (ino_t *)malloc(maxino * sizeof(ino_t));
memset(visited, 0, maxino * sizeof(ino_t));
2000-05-23 05:48:52 +04:00
lastino = 0;
ino = sblock.lfs_free;
while (ino) {
if (ino >= maxino) {
printf("! Ino %d out of range (last was %d)\n", ino,
lastino);
break;
}
if (visited[ino]) {
pwarn("! Ino %d already found on the free list!\n",
ino);
if (preen || reply("FIX") == 1) {
/* lastino can't be zero */
ifp = lfs_ientry(lastino, &bp);
ifp->if_nextfree = 0;
dirty(bp);
bp->b_flags &= ~B_INUSE;
}
break;
}
++visited[ino];
2000-05-23 05:48:52 +04:00
ifp = lfs_ientry(ino, &bp);
nextino = ifp->if_nextfree;
daddr = ifp->if_daddr;
bp->b_flags &= ~B_INUSE;
if (daddr) {
pwarn("! Ino %d with daddr 0x%x is on the free list!\n",
2000-05-23 05:48:52 +04:00
ino, daddr);
if (preen || reply("FIX") == 1) {
if (lastino == 0) {
sblock.lfs_free = nextino;
sbdirty();
} else {
ifp = lfs_ientry(lastino, &bp);
ifp->if_nextfree = nextino;
dirty(bp);
2000-05-23 05:48:52 +04:00
bp->b_flags &= ~B_INUSE;
}
ino = nextino;
continue;
}
}
lastino = ino;
ino = nextino;
}
/*
* Make sure all free inodes were found on the list
*/
for (ino = ROOTINO+1; ino < maxino; ++ino) {
if (visited[ino])
continue;
ifp = lfs_ientry(ino, &bp);
if (ifp->if_daddr) {
bp->b_flags &= ~B_INUSE;
continue;
}
pwarn("! Ino %d free, but not on the free list\n", ino);
if (preen || reply("FIX") == 1) {
ifp->if_nextfree = sblock.lfs_free;
sblock.lfs_free = ino;
sbdirty();
dirty(bp);
}
bp->b_flags &= ~B_INUSE;
}
}
2000-05-23 05:48:52 +04:00
static void
dump_segsum(SEGSUM * sump, daddr_t addr)
{
2000-05-23 05:48:52 +04:00
printf("Dump partial summary block 0x%x\n", addr);
printf("\tsumsum: %x (%d)\n", sump->ss_sumsum, sump->ss_sumsum);
printf("\tdatasum: %x (%d)\n", sump->ss_datasum, sump->ss_datasum);
printf("\tnext: %x (%d)\n", sump->ss_next, sump->ss_next);
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
printf("\tcreate: %llx (%lld)\n", (long long)sump->ss_create,
(long long)sump->ss_create);
2000-05-23 05:48:52 +04:00
printf("\tnfinfo: %x (%d)\n", sump->ss_nfinfo, sump->ss_nfinfo);
printf("\tninos: %x (%d)\n", sump->ss_ninos, sump->ss_ninos);
printf("\tflags: %c%c\n",
sump->ss_flags & SS_DIROP ? 'd' : '-',
sump->ss_flags & SS_CONT ? 'c' : '-');
}
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
/* XXX Don't use... broken. -JO */
2000-05-23 05:48:52 +04:00
void
check_segment(int fd, int segnum, daddr_t addr, struct lfs * fs, int flags, int (*func)(struct lfs *, SEGSUM *, daddr_t))
{
2000-05-23 05:48:52 +04:00
struct lfs *sbp;
SEGSUM *sump = NULL;
SEGUSE *su;
struct bufarea *bp = NULL;
int psegnum = 0, ninos = 0;
off_t sum_offset, db_ssize;
int bc, su_flags, su_nsums, su_ninos;
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
db_ssize = segtod(&sblock, 1);
2000-05-23 05:48:52 +04:00
su = lfs_gseguse(segnum, &bp);
su_flags = su->su_flags;
su_nsums = su->su_nsums;
su_ninos = su->su_ninos;
bp->b_flags &= ~B_INUSE;
2000-05-23 05:48:52 +04:00
/* printf("Seg at 0x%x\n",addr); */
if ((flags & CKSEG_VERBOSE) && segnum * db_ssize + fs->lfs_sboffs[0] != addr)
pwarn("WARNING: segment begins at 0x%llx, should be 0x%llx\n",
2000-05-23 05:48:52 +04:00
(long long unsigned)addr,
(long long unsigned)(segnum * db_ssize + fs->lfs_sboffs[0]));
sum_offset = ((off_t)addr << dbshift);
2000-05-23 05:48:52 +04:00
/* If this segment should have a superblock, look for one */
if (su_flags & SEGUSE_SUPERBLOCK) {
bp = getddblk(sum_offset >> dbshift, LFS_SBPAD);
sum_offset += LFS_SBPAD;
2000-05-23 05:48:52 +04:00
/* check for a superblock -- XXX this is crude */
sbp = (struct lfs *)(bp->b_un.b_buf);
if (sbp->lfs_magic == LFS_MAGIC) {
#if 0
2000-05-23 05:48:52 +04:00
if (sblock.lfs_tstamp == sbp->lfs_tstamp &&
memcmp(sbp, &sblock, sizeof(*sbp)) &&
(flags & CKSEG_VERBOSE))
pwarn("SUPERBLOCK MISMATCH SEGMENT %d\n", segnum);
#endif
2000-05-23 05:48:52 +04:00
} else {
if (flags & CKSEG_VERBOSE)
pwarn("SEGMENT %d SUPERBLOCK INVALID\n", segnum);
/* XXX allow to fix */
}
bp->b_flags &= ~B_INUSE;
}
2000-05-23 05:48:52 +04:00
/* XXX need to also check whether this one *should* be dirty */
if ((flags & CKSEG_IGNORECLEAN) && (su_flags & SEGUSE_DIRTY) == 0)
return;
2000-05-23 05:48:52 +04:00
while (1) {
if (su_nsums <= psegnum)
break;
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
bp = getddblk(sum_offset >> dbshift, sblock.lfs_sumsize);
2000-05-23 05:48:52 +04:00
sump = (SEGSUM *)(bp->b_un.b_buf);
if (sump->ss_magic != SS_MAGIC) {
if (flags & CKSEG_VERBOSE)
printf("PARTIAL SEGMENT %d SEGMENT %d BAD PARTIAL SEGMENT MAGIC (0x%x should be 0x%x)\n",
psegnum, segnum, sump->ss_magic, SS_MAGIC);
bp->b_flags &= ~B_INUSE;
break;
}
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
if (sump->ss_sumsum != cksum(&sump->ss_datasum, sblock.lfs_sumsize - sizeof(sump->ss_sumsum))) {
2000-05-23 05:48:52 +04:00
if (flags & CKSEG_VERBOSE) {
/* Corrupt partial segment */
pwarn("CORRUPT PARTIAL SEGMENT %d/%d OF SEGMENT %d AT BLK 0x%llx",
2000-05-23 05:48:52 +04:00
psegnum, su_nsums, segnum,
(unsigned long long)sum_offset >> dbshift);
if (db_ssize < (sum_offset >> dbshift) - addr)
pwarn(" (+0x%llx/0x%llx)",
2000-05-23 05:48:52 +04:00
(unsigned long long)(((sum_offset >> dbshift) - addr) -
db_ssize),
(unsigned long long)db_ssize);
else
pwarn(" (-0x%llx/0x%llx)",
2000-05-23 05:48:52 +04:00
(unsigned long long)(db_ssize -
((sum_offset >> dbshift) - addr)),
(unsigned long long)db_ssize);
pwarn("\n");
dump_segsum(sump, sum_offset >> dbshift);
}
/* XXX fix it maybe */
bp->b_flags &= ~B_INUSE;
break; /* XXX could be throwing away data, but if
* this segsum is invalid, how to know where
* the next summary begins? */
}
/*
* Good partial segment
*/
bc = (*func)(&sblock, sump, (daddr_t)(sum_offset >> dbshift));
if (bc) {
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
sum_offset += sblock.lfs_sumsize + bc;
ninos += (sump->ss_ninos + INOPB(&sblock) - 1)
/ INOPB(&sblock);
2000-05-23 05:48:52 +04:00
psegnum++;
} else {
bp->b_flags &= ~B_INUSE;
break;
}
bp->b_flags &= ~B_INUSE;
}
if (flags & CKSEG_VERBOSE) {
if (ninos != su_ninos)
pwarn("SEGMENT %d has %d ninos, not %d\n",
segnum, ninos, su_ninos);
if (psegnum != su_nsums)
pwarn("SEGMENT %d has %d summaries, not %d\n",
segnum, psegnum, su_nsums);
}
return;
}
2000-05-23 05:48:52 +04:00
int
check_summary(struct lfs * fs, SEGSUM * sp, daddr_t pseg_addr)
{
2000-05-23 05:48:52 +04:00
FINFO *fp;
int bc; /* Bytes in partial segment */
int nblocks;
daddr_t seg_addr, *dp, *idp, daddr;
struct bufarea *bp;
int i, j, k, datac, len;
long sn;
u_long *datap;
u_int32_t ccksum;
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
sn = dtosn(fs, pseg_addr);
seg_addr = sntod(fs, sn);
2000-05-23 05:48:52 +04:00
/*
* printf("Pseg at 0x%x, %d inos, %d
* finfos\n",addr>>dbshift,sp->ss_ninos,sp->ss_nfinfo);
*/
/* We've already checked the sumsum, just do the data bounds and sum */
2000-05-23 05:48:52 +04:00
/* 1. Count the blocks. */
nblocks = ((sp->ss_ninos + INOPB(fs) - 1) / INOPB(fs));
bc = nblocks << fs->lfs_bshift;
2000-05-23 05:48:52 +04:00
fp = (FINFO *)(sp + 1);
for (i = 0; i < sp->ss_nfinfo; i++) {
nblocks += fp->fi_nblocks;
bc += fp->fi_lastlength + ((fp->fi_nblocks - 1) << fs->lfs_bshift);
fp = (FINFO *)(fp->fi_blocks + fp->fi_nblocks);
}
datap = (u_long *)malloc(nblocks * sizeof(*datap));
datac = 0;
2000-05-23 05:48:52 +04:00
dp = (daddr_t *)sp;
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
dp += sblock.lfs_sumsize / sizeof(daddr_t);
2000-05-23 05:48:52 +04:00
dp--;
2000-05-23 05:48:52 +04:00
idp = dp;
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
daddr = pseg_addr + btofsb(&sblock, sblock.lfs_sumsize);
2000-05-23 05:48:52 +04:00
fp = (FINFO *)(sp + 1);
for (i = 0, j = 0; i < sp->ss_nfinfo || j < howmany(sp->ss_ninos, INOPB(fs)); i++) {
/* printf("*idp=%x, daddr=%x\n", *idp, daddr); */
if (i >= sp->ss_nfinfo && *idp != daddr) {
pwarn("Not enough inode blocks in pseg at 0x%x: found %d, wanted %d\n",
pseg_addr, j, howmany(sp->ss_ninos, INOPB(fs)));
pwarn("*idp=%x, daddr=%x\n", *idp, daddr);
break;
}
while (j < howmany(sp->ss_ninos, INOPB(fs)) && *idp == daddr) {
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
bp = getddblk(daddr, fs->lfs_bsize);
2000-05-23 05:48:52 +04:00
datap[datac++] = ((u_long *)(bp->b_un.b_buf))[0];
bp->b_flags &= ~B_INUSE;
2000-05-23 05:48:52 +04:00
++j;
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
daddr += btofsb(&sblock, fs->lfs_bsize);
2000-05-23 05:48:52 +04:00
--idp;
}
if (i < sp->ss_nfinfo) {
for (k = 0; k < fp->fi_nblocks; k++) {
len = (k == fp->fi_nblocks - 1 ? fp->fi_lastlength
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
: fs->lfs_bsize);
2000-05-23 05:48:52 +04:00
bp = getddblk(daddr, len);
datap[datac++] = ((u_long *)(bp->b_un.b_buf))[0];
bp->b_flags &= ~B_INUSE;
Merge the short-lived perseant-lfsv2 branch into the trunk. Kernels and tools understand both v1 and v2 filesystems; newfs_lfs generates v2 by default. Changes for the v2 layout include: - Segments of non-PO2 size and arbitrary block offset, so these can be matched to convenient physical characteristics of the partition (e.g., stripe or track size and offset). - Address by fragment instead of by disk sector, paving the way for non-512-byte-sector devices. In theory fragments can be as large as you like, though in reality they must be smaller than MAXBSIZE in size. - Use serial number and filesystem identifier to ensure that roll-forward doesn't get old data and think it's new. Roll-forward is enabled for v2 filesystems, though not for v1 filesystems by default. - The inode free list is now a tailq, paving the way for undelete (undelete is not yet implemented, but can be without further non-backwards-compatible changes to disk structures). - Inode atime information is kept in the Ifile, instead of on the inode; that is, the inode is never written *just* because atime was changed. Because of this the inodes remain near the file data on the disk, rather than wandering all over as the disk is read repeatedly. This speeds up repeated reads by a small but noticeable amount. Other changes of note include: - The ifile written by newfs_lfs can now be of arbitrary length, it is no longer restricted to a single indirect block. - Fixed an old bug where ctime was changed every time a vnode was created. I need to look more closely to make sure that the times are only updated during write(2) and friends, not after-the-fact during a segment write, and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
daddr += btofsb(&sblock, len);
2000-05-23 05:48:52 +04:00
}
fp = (FINFO *)(fp->fi_blocks + fp->fi_nblocks);
}
}
2000-05-23 05:48:52 +04:00
if (datac != nblocks) {
pwarn("Partial segment at 0x%x expected %d blocks counted %d\n",
pseg_addr, nblocks, datac);
}
ccksum = cksum(datap, nblocks * sizeof(u_long));
/* Check the data checksum */
if (ccksum != sp->ss_datasum) {
pwarn("Partial segment at 0x%x data checksum mismatch: got 0x%x, expected 0x%x\n",
pseg_addr, sp->ss_datasum, ccksum);
/* return 0; */
}
return bc;
}