2015-07-28 08:09:34 +03:00
|
|
|
/* $NetBSD: pass0.c,v 1.37 2015/07/28 05:09:34 dholland Exp $ */
|
1999-07-03 23:55:03 +04:00
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1999, 2000, 2001, 2002, 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
/*-
|
1999-03-18 05:02:18 +03:00
|
|
|
* Copyright (c) 1980, 1986, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 14:04:22 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1999-03-18 05:02:18 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
#include <sys/types.h>
|
1999-03-18 05:02:18 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/time.h>
|
2003-03-28 11:09:52 +03:00
|
|
|
#include <sys/buf.h>
|
1999-03-18 05:02:18 +03:00
|
|
|
#include <sys/mount.h>
|
2003-03-28 11:09:52 +03:00
|
|
|
|
2013-06-06 04:54:49 +04:00
|
|
|
#define vnode uvnode
|
1999-03-18 05:02:18 +03:00
|
|
|
#include <ufs/lfs/lfs.h>
|
2015-07-28 08:09:34 +03:00
|
|
|
#include <ufs/lfs/lfs_accessors.h>
|
2013-06-08 06:16:03 +04:00
|
|
|
#include <ufs/lfs/lfs_inode.h>
|
2003-03-28 11:09:52 +03:00
|
|
|
#undef vnode
|
1999-03-18 05:02:18 +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
|
|
|
#include <assert.h>
|
2006-03-17 22:24:08 +03:00
|
|
|
#include <err.h>
|
1999-03-18 05:02:18 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2006-11-09 22:36:36 +03:00
|
|
|
#include <util.h>
|
1999-03-18 05:02:18 +03:00
|
|
|
|
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
|
|
|
|
1999-03-18 05:02:18 +03:00
|
|
|
#include "fsck.h"
|
|
|
|
#include "extern.h"
|
|
|
|
#include "fsutil.h"
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
extern int fake_cleanseg;
|
1999-03-18 05:02:18 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Pass 0. Check the LFS partial segments for valid checksums, correcting
|
|
|
|
* if necessary. Also check for valid offsets for inode and finfo blocks.
|
|
|
|
*/
|
2000-05-23 05:48:52 +04:00
|
|
|
/*
|
|
|
|
* XXX more could be done here---consistency between inode-held blocks and
|
|
|
|
* finfo blocks, for one thing.
|
|
|
|
*/
|
1999-03-18 05:02:18 +03:00
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
#define dbshift (fs->lfs_bshift - fs->lfs_blktodb)
|
1999-03-18 05:02:18 +03:00
|
|
|
|
2000-05-30 08:33:14 +04:00
|
|
|
void
|
2005-01-19 22:41:59 +03:00
|
|
|
pass0(void)
|
1999-03-18 05:02:18 +03:00
|
|
|
{
|
2003-03-28 11:09:52 +03:00
|
|
|
daddr_t daddr;
|
2003-03-31 23:56:59 +04:00
|
|
|
CLEANERINFO *cip;
|
2003-03-28 11:09:52 +03:00
|
|
|
IFILE *ifp;
|
2006-04-17 23:05:16 +04:00
|
|
|
struct ubuf *bp, *cbp;
|
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, plastino, nextino, lowfreeino, freehd;
|
|
|
|
char *visited;
|
2003-03-31 23:56:59 +04:00
|
|
|
int writeit = 0;
|
1999-03-18 05:02:18 +03:00
|
|
|
|
2000-05-23 05:48:52 +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
|
|
|
* Check the inode free list for inuse inodes, and cycles.
|
2000-05-30 08:33:14 +04:00
|
|
|
* Make sure that all free inodes are in fact on the list.
|
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
|
|
|
*/
|
2006-11-09 22:36:36 +03:00
|
|
|
visited = ecalloc(maxino, sizeof(*visited));
|
2001-11-02 08:33:21 +03:00
|
|
|
plastino = 0;
|
2005-03-25 23:14:43 +03:00
|
|
|
lowfreeino = maxino;
|
2006-04-17 23:05:16 +04:00
|
|
|
LFS_CLEANERINFO(cip, fs, cbp);
|
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
|
|
|
freehd = ino = cip->free_head;
|
2007-10-09 01:39:49 +04:00
|
|
|
brelse(cbp, 0);
|
2006-04-17 23:05:16 +04:00
|
|
|
|
2000-05-23 05:48:52 +04:00
|
|
|
while (ino) {
|
2005-03-25 23:14:43 +03:00
|
|
|
if (lowfreeino > ino)
|
|
|
|
lowfreeino = ino;
|
2000-06-14 22:43:57 +04:00
|
|
|
if (ino >= maxino) {
|
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("OUT OF RANGE INO %llu ON FREE LIST\n",
|
2006-04-17 23:05:16 +04:00
|
|
|
(unsigned long long)ino);
|
2000-06-14 22:43:57 +04:00
|
|
|
break;
|
|
|
|
}
|
2000-05-30 08:33:14 +04:00
|
|
|
if (visited[ino]) {
|
2006-04-17 23:05:16 +04:00
|
|
|
pwarn("INO %llu ALREADY FOUND ON FREE LIST\n",
|
2005-08-19 06:07:18 +04:00
|
|
|
(unsigned long long)ino);
|
2000-05-30 08:33:14 +04:00
|
|
|
if (preen || reply("FIX") == 1) {
|
2001-11-02 08:33:21 +03:00
|
|
|
/* plastino can't be zero */
|
2003-03-28 11:09:52 +03:00
|
|
|
LFS_IENTRY(ifp, fs, plastino, bp);
|
2000-05-30 08:33:14 +04:00
|
|
|
ifp->if_nextfree = 0;
|
2003-03-28 11:09:52 +03:00
|
|
|
VOP_BWRITE(bp);
|
2000-05-30 08:33:14 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
visited[ino] = 1;
|
2003-03-28 11:09:52 +03:00
|
|
|
LFS_IENTRY(ifp, fs, ino, bp);
|
2000-05-23 05:48:52 +04:00
|
|
|
nextino = ifp->if_nextfree;
|
|
|
|
daddr = ifp->if_daddr;
|
2007-10-09 01:39:49 +04:00
|
|
|
brelse(bp, 0);
|
2000-05-23 05:48:52 +04:00
|
|
|
if (daddr) {
|
2006-04-17 23:05:16 +04:00
|
|
|
pwarn("INO %llu WITH DADDR 0x%llx ON FREE LIST\n",
|
2005-08-19 06:07:18 +04:00
|
|
|
(unsigned long long)ino, (long long) daddr);
|
2000-05-23 05:48:52 +04:00
|
|
|
if (preen || reply("FIX") == 1) {
|
2001-11-02 08:33:21 +03:00
|
|
|
if (plastino == 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
|
|
|
freehd = nextino;
|
2000-05-23 05:48:52 +04:00
|
|
|
sbdirty();
|
|
|
|
} else {
|
2003-03-28 11:09:52 +03:00
|
|
|
LFS_IENTRY(ifp, fs, plastino, bp);
|
2000-05-23 05:48:52 +04:00
|
|
|
ifp->if_nextfree = nextino;
|
2003-03-28 11:09:52 +03:00
|
|
|
VOP_BWRITE(bp);
|
2000-05-23 05:48:52 +04:00
|
|
|
}
|
|
|
|
ino = nextino;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2001-11-02 08:33:21 +03:00
|
|
|
plastino = ino;
|
2000-05-23 05:48:52 +04:00
|
|
|
ino = nextino;
|
|
|
|
}
|
2003-03-31 23:56:59 +04:00
|
|
|
|
|
|
|
|
2000-05-30 08:33:14 +04:00
|
|
|
/*
|
|
|
|
* Make sure all free inodes were found on the list
|
|
|
|
*/
|
2013-06-06 04:52:50 +04:00
|
|
|
for (ino = maxino - 1; ino > ULFS_ROOTINO; --ino) {
|
2000-05-30 08:33:14 +04:00
|
|
|
if (visited[ino])
|
|
|
|
continue;
|
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
LFS_IENTRY(ifp, fs, ino, bp);
|
2000-05-30 08:33:14 +04:00
|
|
|
if (ifp->if_daddr) {
|
2007-10-09 01:39:49 +04:00
|
|
|
brelse(bp, 0);
|
2000-05-30 08:33:14 +04:00
|
|
|
continue;
|
|
|
|
}
|
2006-04-17 23:05:16 +04:00
|
|
|
pwarn("INO %llu FREE BUT NOT ON FREE LIST\n",
|
2005-08-19 06:07:18 +04:00
|
|
|
(unsigned long long)ino);
|
2000-05-30 08:33:14 +04:00
|
|
|
if (preen || reply("FIX") == 1) {
|
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
|
|
|
assert(ino != freehd);
|
|
|
|
ifp->if_nextfree = freehd;
|
2006-04-17 23:05:16 +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
|
|
|
freehd = ino;
|
2000-05-30 08:33:14 +04:00
|
|
|
sbdirty();
|
2006-04-17 23:05:16 +04:00
|
|
|
|
|
|
|
/* If freelist was empty, this is the tail */
|
|
|
|
if (plastino == 0)
|
|
|
|
plastino = ino;
|
2003-03-28 11:09:52 +03:00
|
|
|
} else
|
2007-10-09 01:39:49 +04:00
|
|
|
brelse(bp, 0);
|
2000-05-23 05:48:52 +04:00
|
|
|
}
|
2003-03-31 23:56:59 +04:00
|
|
|
|
2006-04-17 23:05:16 +04:00
|
|
|
LFS_CLEANERINFO(cip, fs, cbp);
|
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 (cip->free_head != freehd) {
|
|
|
|
/* They've already given us permission for this change */
|
|
|
|
cip->free_head = freehd;
|
|
|
|
writeit = 1;
|
|
|
|
}
|
2015-07-24 09:56:41 +03:00
|
|
|
if (freehd != lfs_sb_getfreehd(fs)) {
|
|
|
|
pwarn("FREE LIST HEAD IN SUPERBLOCK SHOULD BE %u (WAS %ju)\n",
|
|
|
|
lfs_sb_getfreehd(fs), (uintmax_t)freehd);
|
2003-03-31 23:56:59 +04:00
|
|
|
if (preen || reply("FIX")) {
|
2015-07-24 09:56:41 +03:00
|
|
|
lfs_sb_setfreehd(fs, freehd);
|
2006-04-17 23:05:16 +04:00
|
|
|
sbdirty();
|
2003-03-31 23:56:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cip->free_tail != plastino) {
|
2006-04-17 23:05:16 +04:00
|
|
|
pwarn("FREE LIST TAIL SHOULD BE %llu (WAS %llu)\n",
|
|
|
|
(unsigned long long)plastino,
|
|
|
|
(unsigned long long)cip->free_tail);
|
2003-03-31 23:56:59 +04:00
|
|
|
if (preen || reply("FIX")) {
|
|
|
|
cip->free_tail = plastino;
|
|
|
|
writeit = 1;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
2005-02-26 08:45:54 +03:00
|
|
|
if (writeit)
|
2006-04-17 23:05:16 +04:00
|
|
|
LFS_SYNC_CLEANERINFO(cip, fs, cbp, writeit);
|
2005-02-26 08:45:54 +03:00
|
|
|
else
|
2007-10-09 01:39:49 +04:00
|
|
|
brelse(cbp, 0);
|
2005-03-25 23:14:43 +03:00
|
|
|
|
2015-07-24 09:56:41 +03:00
|
|
|
if (lfs_sb_getfreehd(fs) == 0) {
|
2005-04-12 03:19:24 +04:00
|
|
|
pwarn("%sree list head is 0x0\n", preen ? "f" : "F");
|
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 || reply("FIX"))
|
2005-06-08 23:09:55 +04:00
|
|
|
extend_ifile(fs);
|
2005-04-12 03:19:24 +04:00
|
|
|
}
|
1999-03-18 05:02:18 +03:00
|
|
|
}
|