2008-07-20 05:20:21 +04:00
|
|
|
/* $NetBSD: lfs_inode.c,v 1.14 2008/07/20 01:20:22 lukem Exp $ */
|
1999-09-29 08:57:48 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1980, 1991, 1993, 1994
|
|
|
|
* 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:11 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1999-09-29 08:57:48 +04: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#ifndef lint
|
2008-07-20 05:20:21 +04:00
|
|
|
__COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\
|
|
|
|
The Regents of the University of California. All rights reserved.");
|
1999-09-29 08:57:48 +04:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#ifndef lint
|
|
|
|
#if 0
|
|
|
|
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95";
|
|
|
|
#else
|
2008-07-20 05:20:21 +04:00
|
|
|
__RCSID("$NetBSD: lfs_inode.c,v 1.14 2008/07/20 01:20:22 lukem Exp $");
|
1999-09-29 08:57:48 +04:00
|
|
|
#endif
|
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <ufs/ufs/dir.h>
|
|
|
|
#include <ufs/ufs/dinode.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <ufs/lfs/lfs.h>
|
|
|
|
|
|
|
|
#include <protocols/dumprestore.h>
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
2006-06-24 09:28:54 +04:00
|
|
|
#include <fcntl.h>
|
1999-09-29 08:57:48 +04:00
|
|
|
#include <fts.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "dump.h"
|
|
|
|
|
|
|
|
#define MAXIFPB (MAXBSIZE / sizeof(IFILE))
|
|
|
|
|
|
|
|
#define HASDUMPEDFILE 0x1
|
|
|
|
#define HASSUBDIRS 0x2
|
|
|
|
|
|
|
|
struct lfs *sblock;
|
|
|
|
|
2003-04-02 14:39:19 +04:00
|
|
|
int is_ufs2 = 0;
|
|
|
|
|
1999-09-29 08:57:48 +04:00
|
|
|
/*
|
|
|
|
* Read the superblock from disk, and check its magic number.
|
|
|
|
* Determine whether byte-swapping needs to be done on this filesystem.
|
|
|
|
*/
|
|
|
|
int
|
2001-11-02 08:44:46 +03:00
|
|
|
fs_read_sblock(char *superblock)
|
1999-09-29 08:57:48 +04:00
|
|
|
{
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
char tbuf[LFS_SBPAD];
|
2001-11-02 08:44:46 +03:00
|
|
|
int ns = 0;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
off_t sboff = LFS_LABELPAD;
|
1999-09-29 08:57:48 +04:00
|
|
|
|
2001-11-02 08:44:46 +03:00
|
|
|
sblock = (struct lfs *)superblock;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
while(1) {
|
|
|
|
rawread(sboff, (char *) sblock, LFS_SBPAD);
|
|
|
|
if (sblock->lfs_magic != LFS_MAGIC) {
|
1999-10-01 08:35:21 +04:00
|
|
|
#ifdef notyet
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if (sblock->lfs_magic == bswap32(LFS_MAGIC)) {
|
|
|
|
lfs_sb_swap(sblock, sblock, 0);
|
2001-11-02 08:44:46 +03:00
|
|
|
ns = 1;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
} else
|
1999-09-29 08:57:48 +04:00
|
|
|
#endif
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
quit("bad sblock magic number\n");
|
|
|
|
}
|
2006-06-24 09:28:54 +04:00
|
|
|
if (fsbtob(sblock, (off_t)sblock->lfs_sboffs[0]) != sboff) {
|
|
|
|
sboff = fsbtob(sblock, (off_t)sblock->lfs_sboffs[0]);
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the secondary and take the older of the two
|
|
|
|
*/
|
2006-06-24 09:28:54 +04:00
|
|
|
rawread(fsbtob(sblock, (off_t)sblock->lfs_sboffs[1]), tbuf, LFS_SBPAD);
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
#ifdef notyet
|
2001-11-02 08:44:46 +03:00
|
|
|
if (ns)
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_sb_swap(tbuf, tbuf, 0);
|
|
|
|
#endif
|
|
|
|
if (((struct lfs *)tbuf)->lfs_magic != LFS_MAGIC) {
|
2006-06-24 09:28:54 +04:00
|
|
|
msg("Warning: secondary superblock at 0x%" PRIx64 " bad magic\n",
|
|
|
|
fsbtodb(sblock, (off_t)sblock->lfs_sboffs[1]));
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
} else {
|
|
|
|
if (sblock->lfs_version > 1) {
|
|
|
|
if (((struct lfs *)tbuf)->lfs_serial < sblock->lfs_serial) {
|
|
|
|
memcpy(sblock, tbuf, LFS_SBPAD);
|
2006-06-24 09:28:54 +04:00
|
|
|
sboff = fsbtob(sblock, (off_t)sblock->lfs_sboffs[1]);
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (((struct lfs *)tbuf)->lfs_otstamp < sblock->lfs_otstamp) {
|
|
|
|
memcpy(sblock, tbuf, LFS_SBPAD);
|
2006-06-24 09:28:54 +04:00
|
|
|
sboff = fsbtob(sblock, (off_t)sblock->lfs_sboffs[1]);
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sboff != LFS_SBPAD) {
|
|
|
|
msg("Using superblock at alternate location 0x%lx\n",
|
|
|
|
(unsigned long)(btodb(sboff)));
|
1999-09-29 08:57:48 +04:00
|
|
|
}
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
|
2001-11-02 08:44:46 +03:00
|
|
|
return ns;
|
1999-09-29 08:57:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in the ufsi struct, as well as the maxino and dev_bsize global
|
|
|
|
* variables.
|
|
|
|
*/
|
|
|
|
struct ufsi *
|
|
|
|
fs_parametrize(void)
|
|
|
|
{
|
|
|
|
static struct ufsi ufsi;
|
|
|
|
|
1999-10-01 08:35:21 +04:00
|
|
|
spcl.c_flags = iswap32(iswap32(spcl.c_flags) | DR_NEWINODEFMT);
|
|
|
|
|
1999-09-29 08:57:48 +04:00
|
|
|
ufsi.ufs_dsize = fsbtodb(sblock,sblock->lfs_size);
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if (sblock->lfs_version == 1)
|
|
|
|
ufsi.ufs_dsize = sblock->lfs_size >> sblock->lfs_blktodb;
|
1999-09-29 08:57:48 +04:00
|
|
|
ufsi.ufs_bsize = sblock->lfs_bsize;
|
|
|
|
ufsi.ufs_bshift = sblock->lfs_bshift;
|
|
|
|
ufsi.ufs_fsize = sblock->lfs_fsize;
|
|
|
|
ufsi.ufs_frag = sblock->lfs_frag;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
ufsi.ufs_fsatoda = sblock->lfs_fsbtodb;
|
|
|
|
if (sblock->lfs_version == 1)
|
|
|
|
ufsi.ufs_fsatoda = 0;
|
1999-09-29 08:57:48 +04:00
|
|
|
ufsi.ufs_nindir = sblock->lfs_nindir;
|
|
|
|
ufsi.ufs_inopb = sblock->lfs_inopb;
|
|
|
|
ufsi.ufs_maxsymlinklen = sblock->lfs_maxsymlinklen;
|
|
|
|
ufsi.ufs_bmask = ~(sblock->lfs_bmask);
|
|
|
|
ufsi.ufs_qbmask = sblock->lfs_bmask;
|
|
|
|
ufsi.ufs_fmask = ~(sblock->lfs_ffmask);
|
|
|
|
ufsi.ufs_qfmask = sblock->lfs_ffmask;
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
dev_bsize = sblock->lfs_bsize >> sblock->lfs_blktodb;
|
1999-09-29 08:57:48 +04:00
|
|
|
|
|
|
|
return &ufsi;
|
|
|
|
}
|
|
|
|
|
|
|
|
ino_t
|
|
|
|
fs_maxino(void)
|
|
|
|
{
|
2003-04-02 14:39:19 +04:00
|
|
|
return ((getino(sblock->lfs_ifile)->dp1.di_size
|
1999-09-29 08:57:48 +04:00
|
|
|
- (sblock->lfs_cleansz + sblock->lfs_segtabsz)
|
|
|
|
* sblock->lfs_bsize)
|
|
|
|
/ sblock->lfs_bsize) * sblock->lfs_ifpb - 1;
|
|
|
|
}
|
|
|
|
|
2003-04-02 14:39:19 +04:00
|
|
|
void
|
|
|
|
fs_mapinodes(ino_t maxino, u_int64_t *tapesz, int *anydirskipped)
|
|
|
|
{
|
|
|
|
ino_t ino;
|
|
|
|
|
|
|
|
for (ino = ROOTINO; ino < maxino; ino++)
|
|
|
|
mapfileino(ino, tapesz, anydirskipped);
|
|
|
|
}
|
|
|
|
|
1999-09-29 08:57:48 +04:00
|
|
|
/*
|
|
|
|
* XXX KS - I know there's a better way to do this.
|
|
|
|
*/
|
|
|
|
#define BASE_SINDIR (NDADDR)
|
|
|
|
#define BASE_DINDIR (NDADDR+NINDIR(fs))
|
|
|
|
#define BASE_TINDIR (NDADDR+NINDIR(fs)+NINDIR(fs)*NINDIR(fs))
|
|
|
|
|
|
|
|
#define D_UNITS (NINDIR(fs))
|
|
|
|
#define T_UNITS (NINDIR(fs)*NINDIR(fs))
|
|
|
|
|
|
|
|
static daddr_t
|
2003-04-02 14:39:19 +04:00
|
|
|
lfs_bmap(struct lfs *fs, struct ufs1_dinode *idinode, daddr_t lbn)
|
1999-09-29 08:57:48 +04:00
|
|
|
{
|
2005-06-18 05:33:16 +04:00
|
|
|
daddr_t residue, up;
|
1999-09-29 08:57:48 +04:00
|
|
|
int off=0;
|
|
|
|
char bp[MAXBSIZE];
|
2005-06-18 05:33:16 +04:00
|
|
|
|
|
|
|
up = UNASSIGNED; /* XXXGCC -Wunitialized [sh3] */
|
1999-09-29 08:57:48 +04:00
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if(lbn > 0 && lbn > lblkno(fs, idinode->di_size)) {
|
1999-09-29 08:57:48 +04:00
|
|
|
return UNASSIGNED;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Indirect blocks: if it is a first-level indirect, pull its
|
|
|
|
* address from the inode; otherwise, call ourselves to find the
|
|
|
|
* address of the parent indirect block, and load that to find
|
|
|
|
* the desired address.
|
|
|
|
*/
|
|
|
|
if(lbn < 0) {
|
|
|
|
lbn *= -1;
|
|
|
|
if(lbn == NDADDR) {
|
|
|
|
/* printf("lbn %d: single indir base\n", -lbn); */
|
|
|
|
return idinode->di_ib[0]; /* single indirect */
|
|
|
|
} else if(lbn == BASE_DINDIR+1) {
|
|
|
|
/* printf("lbn %d: double indir base\n", -lbn); */
|
|
|
|
return idinode->di_ib[1]; /* double indirect */
|
|
|
|
} else if(lbn == BASE_TINDIR+2) {
|
|
|
|
/* printf("lbn %d: triple indir base\n", -lbn); */
|
|
|
|
return idinode->di_ib[2]; /* triple indirect */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the immediate parent. This is essentially finding the
|
|
|
|
* residue of modulus, and then rounding accordingly.
|
|
|
|
*/
|
|
|
|
residue = (lbn-NDADDR) % NINDIR(fs);
|
|
|
|
if(residue == 1) {
|
|
|
|
/* Double indirect. Parent is the triple. */
|
|
|
|
up = idinode->di_ib[2];
|
|
|
|
off = (lbn-2-BASE_TINDIR)/(NINDIR(fs)*NINDIR(fs));
|
|
|
|
if(up == UNASSIGNED || up == LFS_UNUSED_DADDR)
|
|
|
|
return UNASSIGNED;
|
|
|
|
/* printf("lbn %d: parent is the triple\n", -lbn); */
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
bread(fsbtodb(sblock, up), bp, sblock->lfs_bsize);
|
2003-01-25 00:55:02 +03:00
|
|
|
/* XXX ondisk32 */
|
|
|
|
return (daddr_t)((int32_t *)bp)[off];
|
1999-09-29 08:57:48 +04:00
|
|
|
} else /* residue == 0 */ {
|
|
|
|
/* Single indirect. Two cases. */
|
|
|
|
if(lbn < BASE_TINDIR) {
|
|
|
|
/* Parent is the double, simple */
|
|
|
|
up = -(BASE_DINDIR) - 1;
|
|
|
|
off = (lbn-BASE_DINDIR) / D_UNITS;
|
|
|
|
/* printf("lbn %d: parent is %d/%d\n", -lbn, up,off); */
|
|
|
|
} else {
|
|
|
|
/* Ancestor is the triple, more complex */
|
|
|
|
up = ((lbn-BASE_TINDIR) / T_UNITS)
|
|
|
|
* T_UNITS + BASE_TINDIR + 1;
|
|
|
|
off = (lbn/D_UNITS) - (up/D_UNITS);
|
|
|
|
up = -up;
|
|
|
|
/* printf("lbn %d: parent is %d/%d\n", -lbn, up,off); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Direct block. Its parent must be a single indirect. */
|
|
|
|
if(lbn < NDADDR)
|
|
|
|
return idinode->di_db[lbn];
|
|
|
|
else {
|
|
|
|
/* Parent is an indirect block. */
|
|
|
|
up = -(((lbn-NDADDR) / D_UNITS) * D_UNITS + NDADDR);
|
|
|
|
off = (lbn-NDADDR) % D_UNITS;
|
|
|
|
/* printf("lbn %d: parent is %d/%d\n", lbn,up,off); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
up = lfs_bmap(fs,idinode,up);
|
|
|
|
if(up == UNASSIGNED || up == LFS_UNUSED_DADDR)
|
|
|
|
return UNASSIGNED;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
bread(fsbtodb(sblock, up), bp, sblock->lfs_bsize);
|
2003-01-25 00:55:02 +03:00
|
|
|
/* XXX ondisk32 */
|
|
|
|
return (daddr_t)((int32_t *)bp)[off];
|
1999-09-29 08:57:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct ifile *
|
|
|
|
lfs_ientry(ino_t ino)
|
|
|
|
{
|
2003-04-02 14:39:19 +04:00
|
|
|
static struct ifile ifileblock[MAXIFPB];
|
|
|
|
static daddr_t ifblkno;
|
|
|
|
daddr_t lbn;
|
|
|
|
daddr_t blkno;
|
|
|
|
union dinode *dp;
|
1999-09-29 08:57:48 +04:00
|
|
|
|
2003-04-02 14:39:19 +04:00
|
|
|
lbn = ino/sblock->lfs_ifpb + sblock->lfs_cleansz + sblock->lfs_segtabsz;
|
|
|
|
dp = getino(sblock->lfs_ifile);
|
|
|
|
blkno = lfs_bmap(sblock, &dp->dp1 ,lbn);
|
|
|
|
if (blkno != ifblkno)
|
|
|
|
bread(fsbtodb(sblock, blkno), (char *)ifileblock,
|
|
|
|
sblock->lfs_bsize);
|
|
|
|
return ifileblock + (ino % sblock->lfs_ifpb);
|
1999-09-29 08:57:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Search a block for a specific dinode. */
|
2003-04-02 14:39:19 +04:00
|
|
|
static struct ufs1_dinode *
|
|
|
|
lfs_ifind(struct lfs *fs, ino_t ino, struct ufs1_dinode *dip)
|
1999-09-29 08:57:48 +04:00
|
|
|
{
|
2005-02-06 09:07:12 +03:00
|
|
|
int cnt;
|
1999-09-29 08:57:48 +04:00
|
|
|
|
|
|
|
for(cnt=0;cnt<INOPB(fs);cnt++)
|
|
|
|
if(dip[cnt].di_inumber == ino)
|
|
|
|
return &(dip[cnt]);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-04-02 14:39:19 +04:00
|
|
|
union dinode *
|
2005-02-06 09:07:12 +03:00
|
|
|
getino(ino_t inum)
|
1999-09-29 08:57:48 +04:00
|
|
|
{
|
|
|
|
static daddr_t inoblkno;
|
|
|
|
daddr_t blkno;
|
2003-04-02 14:39:19 +04:00
|
|
|
static struct ufs1_dinode inoblock[MAXBSIZE / sizeof (struct ufs1_dinode)];
|
|
|
|
static struct ufs1_dinode ifile_dinode; /* XXX fill this in */
|
|
|
|
static struct ufs1_dinode empty_dinode; /* Always stays zeroed */
|
|
|
|
struct ufs1_dinode *dp;
|
1999-09-29 08:57:48 +04:00
|
|
|
|
|
|
|
if(inum == sblock->lfs_ifile) {
|
|
|
|
/* Load the ifile inode if not already */
|
|
|
|
if(ifile_dinode.di_u.inumber == 0) {
|
|
|
|
blkno = sblock->lfs_idaddr;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
bread(fsbtodb(sblock, blkno), (char *)inoblock,
|
|
|
|
(int)sblock->lfs_bsize);
|
1999-09-29 08:57:48 +04:00
|
|
|
dp = lfs_ifind(sblock, inum, inoblock);
|
|
|
|
ifile_dinode = *dp; /* Structure copy */
|
|
|
|
}
|
2003-04-02 14:39:19 +04:00
|
|
|
return (union dinode *)&ifile_dinode;
|
1999-09-29 08:57:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
curino = inum;
|
|
|
|
blkno = lfs_ientry(inum)->if_daddr;
|
|
|
|
if(blkno == LFS_UNUSED_DADDR)
|
2003-04-02 14:39:19 +04:00
|
|
|
return (union dinode *)&empty_dinode;
|
1999-09-29 08:57:48 +04:00
|
|
|
|
|
|
|
if(blkno != inoblkno) {
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
bread(fsbtodb(sblock, blkno), (char *)inoblock,
|
|
|
|
(int)sblock->lfs_bsize);
|
1999-10-01 08:35:21 +04:00
|
|
|
#ifdef notyet
|
1999-09-29 08:57:48 +04:00
|
|
|
if (needswap)
|
|
|
|
for (i = 0; i < MAXINOPB; i++)
|
|
|
|
ffs_dinode_swap(&inoblock[i], &inoblock[i]);
|
1999-10-01 08:35:21 +04:00
|
|
|
#endif
|
1999-09-29 08:57:48 +04:00
|
|
|
}
|
2003-04-02 14:39:19 +04:00
|
|
|
return (union dinode *)lfs_ifind(sblock, inum, inoblock);
|
1999-09-29 08:57:48 +04:00
|
|
|
}
|
2006-06-24 09:28:54 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Tell the filesystem not to overwrite any currently dirty segments
|
|
|
|
* until we are finished. (It may still write into clean segments, of course,
|
|
|
|
* since we're not using those.) This is only called when dump_lfs is called
|
|
|
|
* with -X, i.e. we are working on a mounted filesystem.
|
|
|
|
*/
|
|
|
|
static int root_fd = -1;
|
|
|
|
char *wrap_mpname;
|
|
|
|
|
|
|
|
int
|
|
|
|
lfs_wrap_stop(char *mpname)
|
|
|
|
{
|
|
|
|
int waitfor = 0;
|
|
|
|
|
|
|
|
root_fd = open(mpname, O_RDONLY, 0);
|
|
|
|
if (root_fd < 0)
|
|
|
|
return -1;
|
|
|
|
wrap_mpname = mpname;
|
|
|
|
fcntl(root_fd, LFCNREWIND, -1); /* Ignore return value */
|
|
|
|
if (fcntl(root_fd, LFCNWRAPSTOP, &waitfor) < 0) {
|
|
|
|
perror("LFCNWRAPSTOP");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
msg("Disabled log wrap on %s\n", mpname);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allow the filesystem to continue normal operation.
|
|
|
|
* This would happen anyway when we exit; we do it explicitly here
|
|
|
|
* to show the message, for the user's benefit.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
lfs_wrap_go(void)
|
|
|
|
{
|
|
|
|
int waitfor = 0;
|
|
|
|
|
|
|
|
if (root_fd < 0)
|
|
|
|
return;
|
|
|
|
|
2006-09-29 03:23:01 +04:00
|
|
|
fcntl(root_fd, LFCNWRAPGO, &waitfor);
|
2006-06-24 09:28:54 +04:00
|
|
|
close(root_fd);
|
|
|
|
root_fd = -1;
|
|
|
|
msg("Re-enabled log wrap on %s\n", wrap_mpname);
|
|
|
|
}
|