2006-11-09 22:36:36 +03:00
|
|
|
/* $NetBSD: pass6.c,v 1.18 2006/11/09 19:36:36 christos Exp $ */
|
2003-03-28 11:09:52 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Konrad E. Schroder <perseant@hhhh.org>.
|
|
|
|
*
|
|
|
|
* 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 NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
|
|
|
|
#include <ufs/ufs/ufsmount.h>
|
|
|
|
#include <ufs/ufs/inode.h>
|
|
|
|
#include <ufs/ufs/dir.h>
|
|
|
|
#define vnode uvnode
|
|
|
|
#include <ufs/lfs/lfs.h>
|
|
|
|
#undef vnode
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <err.h>
|
2006-09-01 23:52:48 +04:00
|
|
|
#include <signal.h>
|
2003-03-28 11:09:52 +03:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2006-11-09 22:36:36 +03:00
|
|
|
#include <util.h>
|
2003-03-28 11:09:52 +03:00
|
|
|
|
|
|
|
#include "bufcache.h"
|
|
|
|
#include "vnode.h"
|
2005-09-13 08:14:17 +04:00
|
|
|
#include "lfs_user.h"
|
2003-03-28 11:09:52 +03:00
|
|
|
#include "segwrite.h"
|
|
|
|
|
|
|
|
#include "fsck.h"
|
|
|
|
#include "extern.h"
|
|
|
|
#include "fsutil.h"
|
|
|
|
|
|
|
|
extern u_int32_t cksum(void *, size_t);
|
|
|
|
extern u_int32_t lfs_sb_cksum(struct dlfs *);
|
|
|
|
|
|
|
|
extern ufs_daddr_t badblk;
|
|
|
|
extern SEGUSE *seg_table;
|
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
static int nnewblocks;
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
/*
|
|
|
|
* Our own copy of lfs_update_single so we can account in seg_table
|
|
|
|
* as well as the Ifile; and so we can add the blocks to their new
|
|
|
|
* segment.
|
|
|
|
*
|
|
|
|
* Change the given block's address to ndaddr, finding its previous
|
|
|
|
* location using ufs_bmaparray().
|
|
|
|
*
|
|
|
|
* Account for this change in the segment table.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
rfw_update_single(struct uvnode *vp, daddr_t lbn, ufs_daddr_t ndaddr, int size)
|
|
|
|
{
|
|
|
|
SEGUSE *sup;
|
|
|
|
struct ubuf *bp;
|
|
|
|
struct indir a[NIADDR + 2], *ap;
|
|
|
|
struct inode *ip;
|
|
|
|
daddr_t daddr, ooff;
|
|
|
|
int num, error;
|
2005-06-08 23:09:55 +04:00
|
|
|
int i, bb, osize = 0, obb = 0;
|
2003-03-28 11:09:52 +03:00
|
|
|
u_int32_t oldsn, sn;
|
|
|
|
|
|
|
|
ip = VTOI(vp);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
ip->i_flag |= IN_MODIFIED;
|
2003-03-28 11:09:52 +03:00
|
|
|
|
|
|
|
error = ufs_bmaparray(fs, vp, lbn, &daddr, a, &num);
|
|
|
|
if (error)
|
|
|
|
errx(1, "lfs_updatemeta: ufs_bmaparray returned %d"
|
|
|
|
" looking up lbn %" PRId64 "\n", error, lbn);
|
|
|
|
if (daddr > 0)
|
|
|
|
daddr = dbtofsb(fs, daddr);
|
|
|
|
|
|
|
|
bb = fragstofsb(fs, numfrags(fs, size));
|
|
|
|
switch (num) {
|
|
|
|
case 0:
|
2003-04-02 14:39:19 +04:00
|
|
|
ooff = ip->i_ffs1_db[lbn];
|
2003-03-28 11:09:52 +03:00
|
|
|
if (ooff <= 0)
|
2003-04-02 14:39:19 +04:00
|
|
|
ip->i_ffs1_blocks += bb;
|
2003-03-28 11:09:52 +03:00
|
|
|
else {
|
|
|
|
/* possible fragment truncation or extension */
|
|
|
|
obb = btofsb(fs, ip->i_lfs_fragsize[lbn]);
|
2003-04-02 14:39:19 +04:00
|
|
|
ip->i_ffs1_blocks += (bb - obb);
|
2003-03-28 11:09:52 +03:00
|
|
|
}
|
2003-04-02 14:39:19 +04:00
|
|
|
ip->i_ffs1_db[lbn] = ndaddr;
|
2003-03-28 11:09:52 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
2003-04-02 14:39:19 +04:00
|
|
|
ooff = ip->i_ffs1_ib[a[0].in_off];
|
2003-03-28 11:09:52 +03:00
|
|
|
if (ooff <= 0)
|
2003-04-02 14:39:19 +04:00
|
|
|
ip->i_ffs1_blocks += bb;
|
|
|
|
ip->i_ffs1_ib[a[0].in_off] = ndaddr;
|
2003-03-28 11:09:52 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ap = &a[num - 1];
|
|
|
|
if (bread(vp, ap->in_lbn, fs->lfs_bsize, NULL, &bp))
|
|
|
|
errx(1, "lfs_updatemeta: bread bno %" PRId64,
|
|
|
|
ap->in_lbn);
|
|
|
|
|
|
|
|
ooff = ((ufs_daddr_t *) bp->b_data)[ap->in_off];
|
|
|
|
if (ooff <= 0)
|
2003-04-02 14:39:19 +04:00
|
|
|
ip->i_ffs1_blocks += bb;
|
2003-03-28 11:09:52 +03:00
|
|
|
((ufs_daddr_t *) bp->b_data)[ap->in_off] = ndaddr;
|
|
|
|
(void) VOP_BWRITE(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update segment usage information, based on old size
|
|
|
|
* and location.
|
|
|
|
*/
|
|
|
|
if (daddr > 0) {
|
|
|
|
oldsn = dtosn(fs, daddr);
|
|
|
|
if (lbn >= 0 && lbn < NDADDR)
|
|
|
|
osize = ip->i_lfs_fragsize[lbn];
|
|
|
|
else
|
|
|
|
osize = fs->lfs_bsize;
|
|
|
|
LFS_SEGENTRY(sup, fs, oldsn, bp);
|
|
|
|
seg_table[oldsn].su_nbytes -= osize;
|
|
|
|
sup->su_nbytes -= osize;
|
|
|
|
if (!(bp->b_flags & B_GATHERED))
|
|
|
|
fs->lfs_flags |= LFS_IFDIRTY;
|
|
|
|
LFS_WRITESEGENTRY(sup, fs, oldsn, bp);
|
|
|
|
for (i = 0; i < btofsb(fs, osize); i++)
|
|
|
|
clrbmap(daddr + i);
|
|
|
|
}
|
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
/* If block is beyond EOF, update size */
|
|
|
|
if (lbn >= 0 && ip->i_ffs1_size <= (lbn << fs->lfs_bshift)) {
|
|
|
|
ip->i_ffs1_size = (lbn << fs->lfs_bshift) + 1;
|
|
|
|
}
|
|
|
|
|
2006-09-01 23:52:48 +04:00
|
|
|
/* If block frag size is too large for old EOF, update size */
|
|
|
|
if (lbn < NDADDR) {
|
|
|
|
off_t minsize;
|
|
|
|
|
|
|
|
minsize = (lbn << fs->lfs_bshift);
|
|
|
|
minsize += (size - fs->lfs_fsize) + 1;
|
|
|
|
if (ip->i_ffs1_size < minsize)
|
|
|
|
ip->i_ffs1_size = minsize;
|
|
|
|
}
|
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
/* Count for the user */
|
|
|
|
++nnewblocks;
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
/* Add block to its new segment */
|
|
|
|
sn = dtosn(fs, ndaddr);
|
|
|
|
LFS_SEGENTRY(sup, fs, sn, bp);
|
|
|
|
seg_table[sn].su_nbytes += size;
|
|
|
|
sup->su_nbytes += size;
|
|
|
|
if (!(bp->b_flags & B_GATHERED))
|
|
|
|
fs->lfs_flags |= LFS_IFDIRTY;
|
|
|
|
LFS_WRITESEGENTRY(sup, fs, sn, bp);
|
|
|
|
for (i = 0; i < btofsb(fs, size); i++)
|
2006-09-01 23:52:48 +04:00
|
|
|
#ifndef VERBOSE_BLOCKMAP
|
2003-03-28 11:09:52 +03:00
|
|
|
setbmap(daddr + i);
|
2006-09-01 23:52:48 +04:00
|
|
|
#else
|
|
|
|
setbmap(daddr + i, ip->i_number);
|
|
|
|
#endif
|
2003-03-28 11:09:52 +03:00
|
|
|
|
|
|
|
/* Check bfree accounting as well */
|
2005-06-08 23:09:55 +04:00
|
|
|
if (daddr <= 0) {
|
2003-03-28 11:09:52 +03:00
|
|
|
fs->lfs_bfree -= btofsb(fs, size);
|
|
|
|
} else if (size != osize) {
|
|
|
|
fs->lfs_bfree -= (bb - obb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now that this block has a new address, and its old
|
|
|
|
* segment no longer owns it, we can forget about its
|
|
|
|
* old size.
|
|
|
|
*/
|
|
|
|
if (lbn >= 0 && lbn < NDADDR)
|
|
|
|
ip->i_lfs_fragsize[lbn] = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove the vnode from the cache, including any blocks it
|
|
|
|
* may hold. Account the blocks. Finally account the removal
|
|
|
|
* of the inode from its segment.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
remove_ino(struct uvnode *vp, ino_t ino)
|
|
|
|
{
|
|
|
|
IFILE *ifp;
|
|
|
|
SEGUSE *sup;
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
CLEANERINFO *cip;
|
|
|
|
struct ubuf *bp, *sbp, *cbp;
|
2003-03-28 11:09:52 +03:00
|
|
|
struct inodesc idesc;
|
|
|
|
ufs_daddr_t daddr;
|
|
|
|
int obfree;
|
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (debug)
|
|
|
|
pwarn("remove ino %d\n", (int)ino);
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
obfree = fs->lfs_bfree;
|
|
|
|
LFS_IENTRY(ifp, fs, ino, bp);
|
|
|
|
daddr = ifp->if_daddr;
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (daddr > 0) {
|
|
|
|
ifp->if_daddr = 0x0;
|
2006-07-19 06:45:10 +04:00
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
LFS_GET_HEADFREE(fs, cip, cbp, &(ifp->if_nextfree));
|
2006-07-19 06:45:10 +04:00
|
|
|
VOP_BWRITE(bp);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
LFS_PUT_HEADFREE(fs, cip, cbp, ino);
|
|
|
|
sbdirty();
|
2003-03-28 11:09:52 +03:00
|
|
|
|
2006-07-19 06:45:10 +04:00
|
|
|
if (vp == NULL)
|
|
|
|
vp = lfs_raw_vget(fs, ino, fs->lfs_ivnode->v_fd, daddr);
|
2003-03-28 11:09:52 +03:00
|
|
|
|
2006-07-20 02:48:11 +04:00
|
|
|
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), sbp);
|
2003-04-02 14:39:19 +04:00
|
|
|
sup->su_nbytes -= DINODE1_SIZE;
|
2003-03-28 11:09:52 +03:00
|
|
|
VOP_BWRITE(sbp);
|
2006-07-20 02:48:11 +04:00
|
|
|
seg_table[dtosn(fs, daddr)].su_nbytes -= DINODE1_SIZE;
|
2006-07-19 06:45:10 +04:00
|
|
|
} else
|
|
|
|
brelse(bp);
|
2003-03-28 11:09:52 +03:00
|
|
|
|
|
|
|
/* Do on-disk accounting */
|
|
|
|
if (vp) {
|
|
|
|
idesc.id_number = ino;
|
|
|
|
idesc.id_func = pass4check; /* Delete dinode and blocks */
|
|
|
|
idesc.id_type = ADDR;
|
|
|
|
idesc.id_lblkno = 0;
|
|
|
|
clri(&idesc, "unknown", 2); /* XXX magic number 2 */
|
2005-04-13 03:14:18 +04:00
|
|
|
/* vp has been destroyed */
|
2003-03-28 11:09:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use FIP records to update blocks, if the generation number matches.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
pass6harvest(ufs_daddr_t daddr, FINFO *fip)
|
|
|
|
{
|
|
|
|
struct uvnode *vp;
|
|
|
|
int i;
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
vp = vget(fs, fip->fi_ino);
|
|
|
|
if (vp && vp != fs->lfs_ivnode &&
|
2003-04-02 14:39:19 +04:00
|
|
|
VTOI(vp)->i_ffs1_gen == fip->fi_version) {
|
2003-03-28 11:09:52 +03:00
|
|
|
for (i = 0; i < fip->fi_nblocks; i++) {
|
|
|
|
size = (i == fip->fi_nblocks - 1 ?
|
|
|
|
fip->fi_lastlength : fs->lfs_bsize);
|
2006-09-01 23:52:48 +04:00
|
|
|
if (debug)
|
|
|
|
pwarn("ino %lld lbn %lld -> 0x%lx\n",
|
|
|
|
(long long)fip->fi_ino,
|
|
|
|
(long long)fip->fi_blocks[i],
|
|
|
|
(long)daddr);
|
2003-03-28 11:09:52 +03:00
|
|
|
rfw_update_single(vp, fip->fi_blocks[i], daddr, size);
|
|
|
|
daddr += btofsb(fs, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check validity of blocks on roll-forward inodes.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
pass6check(struct inodesc * idesc)
|
|
|
|
{
|
|
|
|
int i, sn, anyout, anynew;
|
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
/* Brand new blocks are always OK */
|
|
|
|
if (idesc->id_blkno == UNWRITTEN)
|
|
|
|
return KEEPON;
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
/* Check that the blocks do not lie within clean segments. */
|
|
|
|
anyout = anynew = 0;
|
|
|
|
for (i = 0; i < fragstofsb(fs, idesc->id_numfrags); i++) {
|
|
|
|
sn = dtosn(fs, idesc->id_blkno + i);
|
|
|
|
if (sn < 0 || sn >= fs->lfs_nseg ||
|
|
|
|
(seg_table[sn].su_flags & SEGUSE_DIRTY) == 0) {
|
|
|
|
anyout = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (seg_table[sn].su_flags & SEGUSE_ACTIVE) {
|
|
|
|
if (sn != dtosn(fs, fs->lfs_offset) ||
|
|
|
|
idesc->id_blkno > fs->lfs_offset) {
|
|
|
|
++anynew;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!anynew) {
|
|
|
|
/* Clear so pass1check won't be surprised */
|
|
|
|
clrbmap(idesc->id_blkno + i);
|
|
|
|
seg_table[sn].su_nbytes -= fsbtob(fs, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (anyout) {
|
|
|
|
blkerror(idesc->id_number, "BAD", idesc->id_blkno);
|
|
|
|
if (badblk++ >= MAXBAD) {
|
2005-08-19 06:07:18 +04:00
|
|
|
pwarn("EXCESSIVE BAD BLKS I=%llu",
|
|
|
|
(unsigned long long)idesc->id_number);
|
2003-03-28 11:09:52 +03:00
|
|
|
if (preen)
|
|
|
|
pwarn(" (SKIPPING)\n");
|
|
|
|
else if (reply("CONTINUE") == 0)
|
2006-11-09 22:36:36 +03:00
|
|
|
err(EEXIT, "%s", "");
|
2003-03-28 11:09:52 +03:00
|
|
|
return (STOP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pass1check(idesc);
|
|
|
|
}
|
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
static void
|
|
|
|
account_indir(struct uvnode *vp, struct ufs1_dinode *dp, daddr_t ilbn, daddr_t daddr, int lvl)
|
|
|
|
{
|
|
|
|
struct ubuf *bp;
|
|
|
|
int32_t *dap, *odap, *buf, *obuf;
|
|
|
|
daddr_t lbn;
|
|
|
|
|
|
|
|
if (lvl == 0)
|
|
|
|
lbn = -ilbn;
|
|
|
|
else
|
|
|
|
lbn = ilbn + 1;
|
|
|
|
bread(fs->lfs_devvp, fsbtodb(fs, daddr), fs->lfs_bsize, NULL, &bp);
|
2006-11-09 22:36:36 +03:00
|
|
|
buf = emalloc(fs->lfs_bsize);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
memcpy(buf, bp->b_data, fs->lfs_bsize);
|
|
|
|
brelse(bp);
|
|
|
|
|
2006-11-09 22:36:36 +03:00
|
|
|
obuf = emalloc(fs->lfs_bsize);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (vp) {
|
|
|
|
bread(vp, ilbn, fs->lfs_bsize, NULL, &bp);
|
|
|
|
memcpy(obuf, bp->b_data, fs->lfs_bsize);
|
|
|
|
brelse(bp);
|
|
|
|
} else
|
|
|
|
memset(obuf, 0, fs->lfs_bsize);
|
|
|
|
|
|
|
|
for (dap = buf, odap = obuf;
|
|
|
|
dap < (int32_t *)((char *)buf + fs->lfs_bsize);
|
|
|
|
++dap, ++odap) {
|
|
|
|
if (*dap > 0 && *dap != *odap) {
|
|
|
|
rfw_update_single(vp, lbn, *dap, dblksize(fs, dp, lbn));
|
|
|
|
if (lvl > 0)
|
|
|
|
account_indir(vp, dp, lbn, *dap, lvl - 1);
|
|
|
|
}
|
|
|
|
if (lvl == 0)
|
|
|
|
++lbn;
|
|
|
|
else if (lvl == 1)
|
|
|
|
lbn -= NINDIR(fs);
|
|
|
|
else if (lvl == 2)
|
|
|
|
lbn -= NINDIR(fs) * NINDIR(fs);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(obuf);
|
|
|
|
free(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Account block changes between new found inode and existing inode.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
account_block_changes(struct ufs1_dinode *dp)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
daddr_t lbn, off, odaddr;
|
|
|
|
struct uvnode *vp;
|
|
|
|
struct inode *ip;
|
|
|
|
|
|
|
|
vp = vget(fs, dp->di_inumber);
|
|
|
|
ip = (vp ? VTOI(vp) : NULL);
|
|
|
|
|
|
|
|
/* Check direct block holdings between existing and new */
|
|
|
|
for (i = 0; i < NDADDR; i++) {
|
|
|
|
odaddr = (ip ? ip->i_ffs1_db[i] : 0x0);
|
|
|
|
if (dp->di_db[i] > 0 && dp->di_db[i] != odaddr)
|
|
|
|
rfw_update_single(vp, i, dp->di_db[i],
|
|
|
|
dblksize(fs, dp, i));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check indirect block holdings between existing and new */
|
|
|
|
off = 0;
|
|
|
|
for (i = 0; i < NIADDR; i++) {
|
|
|
|
odaddr = (ip ? ip->i_ffs1_ib[i] : 0x0);
|
|
|
|
if (dp->di_ib[i] > 0 && dp->di_ib[i] != odaddr) {
|
|
|
|
lbn = -(NDADDR + off + i);
|
|
|
|
rfw_update_single(vp, i, dp->di_ib[i], fs->lfs_bsize);
|
|
|
|
account_indir(vp, dp, lbn, dp->di_ib[i], i);
|
|
|
|
}
|
|
|
|
if (off == 0)
|
|
|
|
off = NINDIR(fs);
|
|
|
|
else
|
|
|
|
off *= NINDIR(fs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
/*
|
|
|
|
* Give a previously allocated inode a new address; do segment
|
|
|
|
* accounting if necessary.
|
|
|
|
*
|
|
|
|
* Caller has ensured that this inode is not on the free list, so no
|
|
|
|
* free list accounting is done.
|
|
|
|
*/
|
|
|
|
static void
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
readdress_inode(struct ufs1_dinode *dp, ufs_daddr_t daddr)
|
2003-03-28 11:09:52 +03:00
|
|
|
{
|
|
|
|
IFILE *ifp;
|
|
|
|
SEGUSE *sup;
|
|
|
|
struct ubuf *bp;
|
|
|
|
int sn;
|
|
|
|
ufs_daddr_t odaddr;
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
ino_t thisino = dp->di_inumber;
|
|
|
|
struct uvnode *vp;
|
|
|
|
|
|
|
|
/* Recursively check all block holdings, account changes */
|
|
|
|
account_block_changes(dp);
|
2003-03-28 11:09:52 +03:00
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
/* Move ifile pointer to this location */
|
2003-03-28 11:09:52 +03:00
|
|
|
LFS_IENTRY(ifp, fs, thisino, bp);
|
|
|
|
odaddr = ifp->if_daddr;
|
2006-07-19 06:45:10 +04:00
|
|
|
assert(odaddr != 0);
|
2003-03-28 11:09:52 +03:00
|
|
|
ifp->if_daddr = daddr;
|
|
|
|
VOP_BWRITE(bp);
|
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (debug)
|
2006-09-01 23:52:48 +04:00
|
|
|
pwarn("readdress ino %d from 0x%x to 0x%x mode %o nlink %d\n",
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
(int)dp->di_inumber,
|
|
|
|
(unsigned)odaddr,
|
2006-09-01 23:52:48 +04:00
|
|
|
(unsigned)daddr,
|
|
|
|
(int)dp->di_mode, (int)dp->di_nlink);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
|
|
|
|
/* Copy over preexisting in-core inode, if any */
|
|
|
|
vp = vget(fs, thisino);
|
|
|
|
memcpy(VTOI(vp)->i_din.ffs1_din, dp, sizeof(*dp));
|
|
|
|
|
|
|
|
/* Finally account the inode itself */
|
2003-03-28 11:09:52 +03:00
|
|
|
sn = dtosn(fs, odaddr);
|
|
|
|
LFS_SEGENTRY(sup, fs, sn, bp);
|
2003-04-02 14:39:19 +04:00
|
|
|
sup->su_nbytes -= DINODE1_SIZE;
|
2003-03-28 11:09:52 +03:00
|
|
|
VOP_BWRITE(bp);
|
2003-04-02 14:39:19 +04:00
|
|
|
seg_table[sn].su_nbytes -= DINODE1_SIZE;
|
2003-03-28 11:09:52 +03:00
|
|
|
|
|
|
|
sn = dtosn(fs, daddr);
|
|
|
|
LFS_SEGENTRY(sup, fs, sn, bp);
|
2003-04-02 14:39:19 +04:00
|
|
|
sup->su_nbytes += DINODE1_SIZE;
|
2003-03-28 11:09:52 +03:00
|
|
|
VOP_BWRITE(bp);
|
2003-04-02 14:39:19 +04:00
|
|
|
seg_table[sn].su_nbytes += DINODE1_SIZE;
|
2003-03-28 11:09:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate the given inode from the free list.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
alloc_inode(ino_t thisino, ufs_daddr_t daddr)
|
|
|
|
{
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
ino_t ino, nextfree, oldhead;
|
2003-03-28 11:09:52 +03:00
|
|
|
IFILE *ifp;
|
|
|
|
SEGUSE *sup;
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
struct ubuf *bp, *cbp;
|
|
|
|
CLEANERINFO *cip;
|
2003-03-28 11:09:52 +03:00
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (debug)
|
|
|
|
pwarn("allocating ino %d at 0x%x\n", (int)thisino,
|
|
|
|
(unsigned)daddr);
|
2005-06-08 23:09:55 +04:00
|
|
|
while (thisino >= maxino) {
|
|
|
|
extend_ifile(fs);
|
|
|
|
}
|
2005-04-13 03:14:18 +04:00
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
LFS_IENTRY(ifp, fs, thisino, bp);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (ifp->if_daddr != 0) {
|
|
|
|
pwarn("allocated inode %lld already allocated\n",
|
|
|
|
(long long)thisino);
|
|
|
|
}
|
2003-03-28 11:09:52 +03:00
|
|
|
nextfree = ifp->if_nextfree;
|
|
|
|
ifp->if_nextfree = 0;
|
|
|
|
ifp->if_daddr = daddr;
|
|
|
|
VOP_BWRITE(bp);
|
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
LFS_GET_HEADFREE(fs, cip, cbp, &oldhead);
|
|
|
|
if (oldhead == thisino) {
|
|
|
|
LFS_PUT_HEADFREE(fs, cip, cbp, nextfree);
|
2003-03-28 11:09:52 +03:00
|
|
|
sbdirty();
|
|
|
|
if (nextfree == 0) {
|
2005-06-08 23:09:55 +04:00
|
|
|
extend_ifile(fs);
|
2003-03-28 11:09:52 +03:00
|
|
|
}
|
|
|
|
} else {
|
2005-04-13 03:14:18 +04:00
|
|
|
/* Search the free list for this inode */
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
ino = oldhead;
|
2003-03-28 11:09:52 +03:00
|
|
|
while (ino) {
|
|
|
|
LFS_IENTRY(ifp, fs, ino, bp);
|
|
|
|
assert(ifp->if_nextfree != ino);
|
|
|
|
if (ifp->if_nextfree == thisino) {
|
|
|
|
ifp->if_nextfree = nextfree;
|
|
|
|
VOP_BWRITE(bp);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (nextfree == 0)
|
|
|
|
LFS_PUT_TAILFREE(fs, cip, cbp, ino);
|
2003-03-28 11:09:52 +03:00
|
|
|
break;
|
|
|
|
} else
|
|
|
|
ino = ifp->if_nextfree;
|
|
|
|
brelse(bp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Account for new location */
|
|
|
|
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), bp);
|
2003-04-02 14:39:19 +04:00
|
|
|
sup->su_nbytes += DINODE1_SIZE;
|
2003-03-28 11:09:52 +03:00
|
|
|
VOP_BWRITE(bp);
|
2003-04-02 14:39:19 +04:00
|
|
|
seg_table[dtosn(fs, daddr)].su_nbytes += DINODE1_SIZE;
|
2003-03-28 11:09:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Roll forward from the last verified checkpoint.
|
|
|
|
*
|
|
|
|
* Basic strategy:
|
|
|
|
*
|
|
|
|
* Run through the summaries finding the last valid partial segment.
|
|
|
|
* Note segment numbers as we go. For each inode that we find, compare
|
|
|
|
* its generation number; if newer than old inode's (or if old inode is
|
|
|
|
* USTATE), change to that inode. Recursively look at inode blocks that
|
|
|
|
* do not have their old disk addresses. These addresses must lie in
|
|
|
|
* segments we have seen already in our roll forward.
|
|
|
|
*
|
|
|
|
* A second pass through the past-checkpoint area verifies the validity
|
|
|
|
* of these new blocks, as well as updating other blocks that do not
|
|
|
|
* have corresponding new inodes (but their generation number must match
|
|
|
|
* the old generation number).
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
pass6(void)
|
|
|
|
{
|
|
|
|
ufs_daddr_t daddr, ibdaddr, odaddr, lastgood, nextseg, *idaddrp;
|
|
|
|
struct uvnode *vp, *devvp;
|
|
|
|
CLEANERINFO *cip;
|
|
|
|
SEGUSE *sup;
|
|
|
|
SEGSUM *sp;
|
|
|
|
struct ubuf *bp, *ibp, *sbp, *cbp;
|
2003-04-02 14:39:19 +04:00
|
|
|
struct ufs1_dinode *dp;
|
2003-03-28 11:09:52 +03:00
|
|
|
struct inodesc idesc;
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
int i, j, bc, hassuper;
|
|
|
|
int nnewfiles, ndelfiles, nmvfiles;
|
2006-09-01 23:52:48 +04:00
|
|
|
int sn, curseg;
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
char *ibbuf;
|
2006-09-01 23:52:48 +04:00
|
|
|
long lastserial;
|
2003-03-28 11:09:52 +03:00
|
|
|
|
2005-03-25 23:16:37 +03:00
|
|
|
devvp = fs->lfs_devvp;
|
2003-03-28 11:09:52 +03:00
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
/* If we can't roll forward because of created files, don't try */
|
|
|
|
if (no_roll_forward) {
|
|
|
|
if (debug)
|
|
|
|
pwarn("not rolling forward due to possible allocation conflict\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
/* Find last valid partial segment */
|
|
|
|
lastgood = try_verify(fs, devvp, 0, debug);
|
|
|
|
if (lastgood == fs->lfs_offset) {
|
|
|
|
if (debug)
|
|
|
|
pwarn("not rolling forward, nothing to recover\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (debug)
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
pwarn("could roll forward from 0x%" PRIx32 " to 0x%" PRIx32 "\n",
|
2003-03-28 11:09:52 +03:00
|
|
|
fs->lfs_offset, lastgood);
|
2005-04-24 00:21:03 +04:00
|
|
|
|
2006-04-17 23:05:16 +04:00
|
|
|
if (!preen && reply("ROLL FORWARD") == 0)
|
2005-04-24 00:21:03 +04:00
|
|
|
return;
|
2003-03-28 11:09:52 +03:00
|
|
|
/*
|
|
|
|
* Pass 1: find inode blocks. We ignore the Ifile inode but accept
|
|
|
|
* changes to any other inode.
|
|
|
|
*/
|
|
|
|
|
2006-11-09 22:36:36 +03:00
|
|
|
ibbuf = emalloc(fs->lfs_ibsize);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
nnewfiles = ndelfiles = nmvfiles = nnewblocks = 0;
|
2003-03-28 11:09:52 +03:00
|
|
|
daddr = fs->lfs_offset;
|
|
|
|
nextseg = fs->lfs_nextseg;
|
2006-07-19 03:47:44 +04:00
|
|
|
hassuper = 0;
|
2006-09-01 23:52:48 +04:00
|
|
|
lastserial = 0;
|
2003-03-28 11:09:52 +03:00
|
|
|
while (daddr != lastgood) {
|
|
|
|
seg_table[dtosn(fs, daddr)].su_flags |= SEGUSE_DIRTY | SEGUSE_ACTIVE;
|
|
|
|
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), sbp);
|
|
|
|
sup->su_flags |= SEGUSE_DIRTY;
|
|
|
|
VOP_BWRITE(sbp);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
|
|
|
|
/* Could be a superblock */
|
|
|
|
if (sntod(fs, dtosn(fs, daddr)) == daddr) {
|
2006-09-01 23:52:48 +04:00
|
|
|
if (daddr == fs->lfs_start) {
|
|
|
|
++hassuper;
|
|
|
|
daddr += btofsb(fs, LFS_LABELPAD);
|
|
|
|
}
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
for (i = 0; i < LFS_MAXNUMSB; i++) {
|
|
|
|
if (daddr == fs->lfs_sboffs[i]) {
|
2006-09-01 23:52:48 +04:00
|
|
|
++hassuper;
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
daddr += btofsb(fs, LFS_SBPAD);
|
|
|
|
}
|
|
|
|
if (daddr < fs->lfs_sboffs[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
/* Read in summary block */
|
|
|
|
bread(devvp, fsbtodb(fs, daddr), fs->lfs_sumsize, NULL, &bp);
|
|
|
|
sp = (SEGSUM *)bp->b_data;
|
2006-09-01 23:52:48 +04:00
|
|
|
if (debug)
|
|
|
|
pwarn("sum at 0x%x: ninos=%d nfinfo=%d\n",
|
|
|
|
(unsigned)daddr, (int)sp->ss_ninos,
|
|
|
|
(int)sp->ss_nfinfo);
|
2003-03-28 11:09:52 +03:00
|
|
|
|
|
|
|
/* We have verified that this is a good summary. */
|
|
|
|
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), sbp);
|
|
|
|
++sup->su_nsums;
|
|
|
|
VOP_BWRITE(sbp);
|
|
|
|
fs->lfs_bfree -= btofsb(fs, fs->lfs_sumsize);
|
|
|
|
fs->lfs_dmeta += btofsb(fs, fs->lfs_sumsize);
|
|
|
|
sbdirty();
|
|
|
|
nextseg = sp->ss_next;
|
|
|
|
if (sntod(fs, dtosn(fs, daddr)) == daddr +
|
|
|
|
hassuper * btofsb(fs, LFS_SBPAD) &&
|
|
|
|
dtosn(fs, daddr) != dtosn(fs, fs->lfs_offset)) {
|
|
|
|
--fs->lfs_nclean;
|
|
|
|
sbdirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find inodes, look at generation number. */
|
|
|
|
if (sp->ss_ninos) {
|
|
|
|
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), sbp);
|
|
|
|
sup->su_ninos += howmany(sp->ss_ninos, INOPB(fs));
|
|
|
|
VOP_BWRITE(sbp);
|
|
|
|
fs->lfs_dmeta += btofsb(fs, howmany(sp->ss_ninos,
|
|
|
|
INOPB(fs)) *
|
|
|
|
fs->lfs_ibsize);
|
|
|
|
}
|
|
|
|
idaddrp = ((ufs_daddr_t *)((char *)bp->b_data + fs->lfs_sumsize));
|
|
|
|
for (i = 0; i < howmany(sp->ss_ninos, INOPB(fs)); i++) {
|
2006-11-09 22:36:36 +03:00
|
|
|
ino_t *inums;
|
2003-03-28 11:09:52 +03:00
|
|
|
|
2006-11-09 22:36:36 +03:00
|
|
|
inums = ecalloc(INOPB(fs) + 1, sizeof(*inums));
|
2003-03-28 11:09:52 +03:00
|
|
|
ibdaddr = *--idaddrp;
|
|
|
|
fs->lfs_bfree -= btofsb(fs, fs->lfs_ibsize);
|
|
|
|
sbdirty();
|
|
|
|
bread(devvp, fsbtodb(fs, ibdaddr), fs->lfs_ibsize,
|
|
|
|
NOCRED, &ibp);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
memcpy(ibbuf, ibp->b_data, fs->lfs_ibsize);
|
|
|
|
brelse(ibp);
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
j = 0;
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
for (dp = (struct ufs1_dinode *)ibbuf;
|
|
|
|
dp < (struct ufs1_dinode *)ibbuf + INOPB(fs);
|
2003-03-28 11:09:52 +03:00
|
|
|
++dp) {
|
|
|
|
if (dp->di_u.inumber == 0 ||
|
|
|
|
dp->di_u.inumber == fs->lfs_ifile)
|
|
|
|
continue;
|
|
|
|
/* Basic sanity checks */
|
2006-10-16 07:21:34 +04:00
|
|
|
if (dp->di_nlink < 0
|
|
|
|
#if 0
|
|
|
|
|| dp->di_u.inumber < 0
|
|
|
|
|| dp->di_size < 0
|
|
|
|
#endif
|
|
|
|
) {
|
2006-04-17 23:05:16 +04:00
|
|
|
pwarn("BAD INODE AT 0x%" PRIx32 "\n",
|
2003-03-28 11:09:52 +03:00
|
|
|
ibdaddr);
|
|
|
|
brelse(bp);
|
2006-11-09 22:36:36 +03:00
|
|
|
free(inums);
|
2003-03-28 11:09:52 +03:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
vp = vget(fs, dp->di_u.inumber);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Four cases:
|
|
|
|
* (1) Invalid inode (nlink == 0).
|
|
|
|
* If currently allocated, remove.
|
|
|
|
*/
|
|
|
|
if (dp->di_nlink == 0) {
|
|
|
|
remove_ino(vp, dp->di_u.inumber);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
++ndelfiles;
|
2003-03-28 11:09:52 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* (2) New valid inode, previously free.
|
|
|
|
* Nothing to do except account
|
|
|
|
* the inode itself, done after the
|
|
|
|
* loop.
|
|
|
|
*/
|
|
|
|
if (vp == NULL) {
|
2006-09-01 23:52:48 +04:00
|
|
|
if (!(sp->ss_flags & SS_DIROP))
|
|
|
|
pfatal("NEW FILE IN NON-DIROP PARTIAL SEGMENT");
|
|
|
|
else {
|
|
|
|
inums[j++] = dp->di_u.inumber;
|
|
|
|
nnewfiles++;
|
|
|
|
}
|
2003-03-28 11:09:52 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* (3) Valid new version of previously
|
|
|
|
* allocated inode. Delete old file
|
|
|
|
* and proceed as in (2).
|
|
|
|
*/
|
2003-04-02 14:39:19 +04:00
|
|
|
if (vp && VTOI(vp)->i_ffs1_gen < dp->di_gen) {
|
2003-03-28 11:09:52 +03:00
|
|
|
remove_ino(vp, dp->di_u.inumber);
|
2006-09-01 23:52:48 +04:00
|
|
|
if (!(sp->ss_flags & SS_DIROP))
|
|
|
|
pfatal("NEW FILE VERSION IN NON-DIROP PARTIAL SEGMENT");
|
|
|
|
else {
|
|
|
|
inums[j++] = dp->di_u.inumber;
|
|
|
|
ndelfiles++;
|
|
|
|
nnewfiles++;
|
|
|
|
}
|
2003-03-28 11:09:52 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* (4) Same version of previously
|
|
|
|
* allocated inode. Move inode to
|
|
|
|
* this location, account inode change
|
|
|
|
* only. We'll pick up any new
|
|
|
|
* blocks when we do the block pass.
|
|
|
|
*/
|
2003-04-02 14:39:19 +04:00
|
|
|
if (vp && VTOI(vp)->i_ffs1_gen == dp->di_gen) {
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
nmvfiles++;
|
|
|
|
readdress_inode(dp, ibdaddr);
|
2003-03-28 11:09:52 +03:00
|
|
|
|
|
|
|
/* Update with new info */
|
|
|
|
VTOD(vp)->di_mode = dp->di_mode;
|
|
|
|
VTOD(vp)->di_nlink = dp->di_nlink;
|
|
|
|
/* XXX size is important */
|
|
|
|
VTOD(vp)->di_size = dp->di_size;
|
|
|
|
VTOD(vp)->di_atime = dp->di_atime;
|
|
|
|
VTOD(vp)->di_atimensec = dp->di_atimensec;
|
|
|
|
VTOD(vp)->di_mtime = dp->di_mtime;
|
|
|
|
VTOD(vp)->di_mtimensec = dp->di_mtimensec;
|
|
|
|
VTOD(vp)->di_ctime = dp->di_ctime;
|
|
|
|
VTOD(vp)->di_ctimensec = dp->di_ctimensec;
|
|
|
|
VTOD(vp)->di_flags = dp->di_flags;
|
|
|
|
VTOD(vp)->di_uid = dp->di_uid;
|
|
|
|
VTOD(vp)->di_gid = dp->di_gid;
|
|
|
|
inodirty(VTOI(vp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (j = 0; inums[j]; j++) {
|
|
|
|
alloc_inode(inums[j], ibdaddr);
|
|
|
|
vp = lfs_raw_vget(fs, inums[j],
|
|
|
|
devvp->v_fd, ibdaddr);
|
|
|
|
/* We'll get the blocks later */
|
2006-09-01 23:52:48 +04:00
|
|
|
if (debug)
|
|
|
|
pwarn("alloc ino %d nlink %d\n",
|
|
|
|
(int)inums[j], VTOD(vp)->di_nlink);
|
2003-03-28 11:09:52 +03:00
|
|
|
memset(VTOD(vp)->di_db, 0, (NDADDR + NIADDR) *
|
|
|
|
sizeof(ufs_daddr_t));
|
|
|
|
VTOD(vp)->di_blocks = 0;
|
|
|
|
|
|
|
|
vp->v_flag |= VDIROP;
|
|
|
|
inodirty(VTOI(vp));
|
|
|
|
}
|
2006-11-09 22:36:36 +03:00
|
|
|
free(inums);
|
2003-03-28 11:09:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bc = check_summary(fs, sp, daddr, debug, devvp, NULL);
|
|
|
|
if (bc == 0) {
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
pwarn("unexpected bad seg ptr at 0x%x with serial=%d\n",
|
|
|
|
(int)daddr, (int)sp->ss_serial);
|
2003-03-28 11:09:52 +03:00
|
|
|
brelse(bp);
|
|
|
|
break;
|
2006-09-01 23:52:48 +04:00
|
|
|
} else {
|
|
|
|
if (debug)
|
|
|
|
pwarn("good seg ptr at 0x%x with serial=%d\n",
|
|
|
|
(int)daddr, (int)sp->ss_serial);
|
|
|
|
lastserial = sp->ss_serial;
|
|
|
|
}
|
2003-03-28 11:09:52 +03:00
|
|
|
odaddr = daddr;
|
|
|
|
daddr += btofsb(fs, fs->lfs_sumsize + bc);
|
|
|
|
if (dtosn(fs, odaddr) != dtosn(fs, daddr) ||
|
|
|
|
dtosn(fs, daddr) != dtosn(fs, daddr +
|
2006-09-01 23:52:48 +04:00
|
|
|
btofsb(fs, fs->lfs_sumsize + fs->lfs_bsize) - 1)) {
|
2003-03-28 11:09:52 +03:00
|
|
|
daddr = ((SEGSUM *)bp->b_data)->ss_next;
|
|
|
|
}
|
|
|
|
brelse(bp);
|
|
|
|
}
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
out:
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
free(ibbuf);
|
2003-03-28 11:09:52 +03:00
|
|
|
|
2006-09-01 23:52:48 +04:00
|
|
|
/* Set serial here, just to be sure (XXX should be right already) */
|
|
|
|
fs->lfs_serial = lastserial + 1;
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
/*
|
|
|
|
* Check our new vnodes. Any blocks must lie in segments that
|
|
|
|
* we've seen before (SEGUSE_DIRTY or SEGUSE_RFW); and the rest
|
|
|
|
* of the pass 1 checks as well.
|
|
|
|
*/
|
|
|
|
memset(&idesc, 0, sizeof(struct inodesc));
|
|
|
|
idesc.id_type = ADDR;
|
|
|
|
idesc.id_func = pass6check;
|
|
|
|
idesc.id_lblkno = 0;
|
|
|
|
LIST_FOREACH(vp, &vnodelist, v_mntvnodes) {
|
2003-03-29 03:09:43 +03:00
|
|
|
if ((vp->v_flag & VDIROP) == 0)
|
|
|
|
--n_files; /* Don't double count */
|
2003-03-28 11:09:52 +03:00
|
|
|
checkinode(VTOI(vp)->i_number, &idesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Second pass. Run through FINFO entries looking for blocks
|
|
|
|
* with the same generation number as files we've seen before.
|
|
|
|
* If they have it, pretend like we just wrote them. We don't
|
|
|
|
* do the pretend-write, though, if we've already seen them
|
|
|
|
* (the accounting would have been done for us already).
|
|
|
|
*/
|
|
|
|
daddr = fs->lfs_offset;
|
|
|
|
while (daddr != lastgood) {
|
|
|
|
if (!(seg_table[dtosn(fs, daddr)].su_flags & SEGUSE_DIRTY)) {
|
|
|
|
seg_table[dtosn(fs, daddr)].su_flags |= SEGUSE_DIRTY;
|
|
|
|
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), sbp);
|
|
|
|
sup->su_flags |= SEGUSE_DIRTY;
|
|
|
|
VOP_BWRITE(sbp);
|
|
|
|
}
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
|
|
|
|
/* Could be a superblock */
|
|
|
|
if (sntod(fs, dtosn(fs, daddr)) == daddr) {
|
2006-09-01 23:52:48 +04:00
|
|
|
if (daddr == fs->lfs_start)
|
|
|
|
daddr += btofsb(fs, LFS_LABELPAD);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
for (i = 0; i < LFS_MAXNUMSB; i++) {
|
|
|
|
if (daddr == fs->lfs_sboffs[i]) {
|
|
|
|
daddr += btofsb(fs, LFS_SBPAD);
|
|
|
|
}
|
|
|
|
if (daddr < fs->lfs_sboffs[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
/* Read in summary block */
|
|
|
|
bread(devvp, fsbtodb(fs, daddr), fs->lfs_sumsize, NULL, &bp);
|
|
|
|
sp = (SEGSUM *)bp->b_data;
|
|
|
|
bc = check_summary(fs, sp, daddr, debug, devvp, pass6harvest);
|
|
|
|
if (bc == 0) {
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
pwarn("unexpected bad seg ptr [2] at 0x%x with serial=%d\n",
|
|
|
|
(int)daddr, (int)sp->ss_serial);
|
2003-03-28 11:09:52 +03:00
|
|
|
brelse(bp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
odaddr = daddr;
|
|
|
|
daddr += btofsb(fs, fs->lfs_sumsize + bc);
|
|
|
|
fs->lfs_avail -= btofsb(fs, fs->lfs_sumsize + bc);
|
|
|
|
if (dtosn(fs, odaddr) != dtosn(fs, daddr) ||
|
|
|
|
dtosn(fs, daddr) != dtosn(fs, daddr +
|
2006-09-01 23:52:48 +04:00
|
|
|
btofsb(fs, fs->lfs_sumsize + fs->lfs_bsize) - 1)) {
|
2003-03-28 11:09:52 +03:00
|
|
|
fs->lfs_avail -= sntod(fs, dtosn(fs, daddr) + 1) - daddr;
|
|
|
|
daddr = ((SEGSUM *)bp->b_data)->ss_next;
|
|
|
|
}
|
|
|
|
LFS_CLEANERINFO(cip, fs, cbp);
|
|
|
|
LFS_SYNC_CLEANERINFO(cip, fs, cbp, 0);
|
|
|
|
bp->b_flags |= B_AGE;
|
|
|
|
brelse(bp);
|
|
|
|
}
|
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
/* Final address could also be a superblock */
|
|
|
|
if (sntod(fs, dtosn(fs, lastgood)) == lastgood) {
|
2006-09-01 23:52:48 +04:00
|
|
|
if (lastgood == fs->lfs_start)
|
|
|
|
lastgood += btofsb(fs, LFS_LABELPAD);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
for (i = 0; i < LFS_MAXNUMSB; i++) {
|
|
|
|
if (lastgood == fs->lfs_sboffs[i])
|
|
|
|
lastgood += btofsb(fs, LFS_SBPAD);
|
|
|
|
if (lastgood < fs->lfs_sboffs[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
/* Update offset to point at correct location */
|
|
|
|
fs->lfs_offset = lastgood;
|
|
|
|
fs->lfs_curseg = sntod(fs, dtosn(fs, lastgood));
|
2006-09-01 23:52:48 +04:00
|
|
|
for (sn = curseg = dtosn(fs, fs->lfs_curseg);;) {
|
|
|
|
sn = (sn + 1) % fs->lfs_nseg;
|
|
|
|
if (sn == curseg)
|
|
|
|
errx(1, "no clean segments");
|
|
|
|
LFS_SEGENTRY(sup, fs, sn, bp);
|
|
|
|
if ((sup->su_flags & SEGUSE_DIRTY) == 0) {
|
|
|
|
sup->su_flags |= SEGUSE_DIRTY | SEGUSE_ACTIVE;
|
|
|
|
VOP_BWRITE(bp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
brelse(bp);
|
|
|
|
}
|
|
|
|
fs->lfs_nextseg = sntod(fs, sn);
|
2003-03-28 11:09:52 +03:00
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (preen) {
|
|
|
|
if (ndelfiles)
|
|
|
|
pwarn("roll forward deleted %d file%s\n", ndelfiles,
|
|
|
|
(ndelfiles > 1 ? "s" : ""));
|
|
|
|
if (nnewfiles)
|
|
|
|
pwarn("roll forward added %d file%s\n", nnewfiles,
|
|
|
|
(nnewfiles > 1 ? "s" : ""));
|
|
|
|
if (nmvfiles)
|
|
|
|
pwarn("roll forward relocated %d inode%s\n", nmvfiles,
|
|
|
|
(nmvfiles > 1 ? "s" : ""));
|
|
|
|
if (nnewblocks)
|
|
|
|
pwarn("roll forward verified %d data block%s\n", nnewblocks,
|
|
|
|
(nnewblocks > 1 ? "s" : ""));
|
|
|
|
if (ndelfiles == 0 && nnewfiles == 0 && nmvfiles == 0 &&
|
|
|
|
nnewblocks == 0)
|
|
|
|
pwarn("roll forward produced nothing new\n");
|
|
|
|
}
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
if (!preen) {
|
|
|
|
/* Run pass 5 again (it's quick anyway). */
|
|
|
|
pwarn("** Phase 6b - Recheck Segment Block Accounting\n");
|
|
|
|
pass5();
|
|
|
|
}
|
2005-04-12 03:19:24 +04:00
|
|
|
|
|
|
|
/* Likewise for pass 0 */
|
|
|
|
if (!preen)
|
|
|
|
pwarn("** Phase 6c - Recheck Inode Free List\n");
|
|
|
|
pass0();
|
2003-03-28 11:09:52 +03:00
|
|
|
}
|