Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
/* $NetBSD: clean.h,v 1.11 2001/07/13 20:30:21 perseant Exp $ */
|
1997-10-07 17:44:03 +04:00
|
|
|
|
1994-06-08 22:42:09 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1998-03-01 05:20:01 +03:00
|
|
|
* @(#)clean.h 8.2 (Berkeley) 5/4/95
|
1994-06-08 22:42:09 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The LFS user-level library will be used when writing cleaners and
|
|
|
|
* checkers for LFS file systems. It will have facilities for finding
|
|
|
|
* and parsing LFS segments.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DUMP_SUM_HEADER 0x0001
|
|
|
|
#define DUMP_INODE_ADDRS 0x0002
|
|
|
|
#define DUMP_FINFOS 0x0004
|
|
|
|
#define DUMP_ALL 0xFFFF
|
|
|
|
|
|
|
|
#define IFILE_NAME "ifile"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cleaner parameters
|
|
|
|
* BUSY_LIM: lower bound of the number of segments currently available
|
|
|
|
* as a percentage of the total number of free segments possibly
|
|
|
|
* available.
|
|
|
|
* IDLE_LIM: Same as BUSY_LIM but used when the system is idle.
|
|
|
|
* MIN_SEGS: Minimum number of segments you should always have.
|
|
|
|
* I have no idea what this should be, but it should probably
|
|
|
|
* be a function of lfsp.
|
|
|
|
* NUM_TO_CLEAN: Number of segments to clean at once. Again, this
|
|
|
|
* should probably be based on the file system size and how
|
|
|
|
* full or empty the segments being cleaned are.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define BUSY_LIM 0.50
|
|
|
|
#define IDLE_LIM 0.90
|
|
|
|
|
|
|
|
#define MIN_SEGS(lfsp) (3)
|
|
|
|
#define NUM_TO_CLEAN(fsp) (1)
|
|
|
|
|
|
|
|
#define MAXLOADS 3
|
|
|
|
#define ONE_MIN 0
|
|
|
|
#define FIVE_MIN 1
|
|
|
|
#define FIFTEEN_MIN 2
|
|
|
|
|
1999-11-09 23:33:37 +03:00
|
|
|
#define TIME_THRESHOLD 5 /* Time to tell looping from running */
|
|
|
|
#define LOOP_THRESHOLD 5 /* Number of looping respawns before exit */
|
|
|
|
|
1999-03-10 03:57:16 +03:00
|
|
|
#include <sys/time.h>
|
|
|
|
|
1994-06-08 22:42:09 +04:00
|
|
|
typedef struct fs_info {
|
|
|
|
struct statfs *fi_statfsp; /* fsstat info from getfsstat */
|
|
|
|
struct lfs fi_lfs; /* superblock */
|
|
|
|
CLEANERINFO *fi_cip; /* Cleaner info from ifile */
|
|
|
|
SEGUSE *fi_segusep; /* segment usage table (from ifile) */
|
|
|
|
IFILE *fi_ifilep; /* ifile table (from ifile) */
|
|
|
|
u_long fi_ifile_count; /* # entries in the ifile table */
|
|
|
|
off_t fi_ifile_length; /* length of the ifile */
|
1999-03-10 03:57:16 +03:00
|
|
|
time_t fi_fs_tstamp; /* last fs activity, per ifile */
|
1994-06-08 22:42:09 +04:00
|
|
|
} FS_INFO;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: size (in bytes) of a segment
|
|
|
|
* should lfs_bsize be fsbtodb(fs,1), blksize(fs), or lfs_dsize?
|
|
|
|
*/
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
#define seg_size(fs) fsbtob((fs), segtod((fs), 1))
|
1994-06-08 22:42:09 +04:00
|
|
|
|
|
|
|
#define CLEANSIZE(fsp) (fsp->fi_lfs.lfs_cleansz << fsp->fi_lfs.lfs_bshift)
|
|
|
|
#define SEGTABSIZE(fsp) (fsp->fi_lfs.lfs_segtabsz << fsp->fi_lfs.lfs_bshift)
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
#define IFILE_ENTRY(fs, ife, i) \
|
|
|
|
((fs)->lfs_version == 1 ? \
|
|
|
|
(IFILE *)((IFILE_V1 *)((caddr_t)(ife) + ((i) / (fs)->lfs_ifpb <<\
|
|
|
|
(fs)->lfs_bshift)) + (i) % (fs)->lfs_ifpb) : \
|
|
|
|
((IFILE *)((caddr_t)(ife) + ((i) / (fs)->lfs_ifpb << \
|
|
|
|
(fs)->lfs_bshift)) + (i) % (fs)->lfs_ifpb))
|
|
|
|
|
|
|
|
#define SEGUSE_ENTRY(fs, su, i) \
|
|
|
|
((fs)->lfs_version == 1 ? \
|
|
|
|
(SEGUSE *)((SEGUSE_V1 *)((caddr_t)(su) + (fs)->lfs_bsize * \
|
|
|
|
((i) / (fs)->lfs_sepb)) + \
|
|
|
|
(i) % (fs)->lfs_sepb) : \
|
|
|
|
((SEGUSE *)((caddr_t)(su) + (fs)->lfs_bsize * \
|
|
|
|
((i) / (fs)->lfs_sepb)) + \
|
|
|
|
(i) % (fs)->lfs_sepb))
|
1994-06-08 22:42:09 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* USEFUL DEBUGGING FUNCTIONS:
|
|
|
|
*/
|
1998-10-07 19:00:34 +04:00
|
|
|
#define PRINT_FINFO(fp, ip) if(debug > 1) { \
|
|
|
|
syslog(LOG_DEBUG," %s %s%d version %d nblocks %d\n", \
|
1994-06-08 22:42:09 +04:00
|
|
|
(ip)->if_version > (fp)->fi_version ? "TOSSING" : "KEEPING", \
|
|
|
|
"FINFO for inode: ", (fp)->fi_ino, \
|
|
|
|
(fp)->fi_version, (fp)->fi_nblocks); \
|
|
|
|
}
|
|
|
|
|
1998-10-07 19:00:34 +04:00
|
|
|
#define PRINT_INODE(b, bip) if(debug > 1) { \
|
|
|
|
syslog(LOG_DEBUG,"\t%s inode: %d daddr: 0x%lx create: %s\n", \
|
1998-09-12 01:21:29 +04:00
|
|
|
b ? "KEEPING" : "TOSSING", (bip)->bi_inode, (long)(bip)->bi_daddr, \
|
1994-06-08 22:42:09 +04:00
|
|
|
ctime((time_t *)&(bip)->bi_segcreate)); \
|
|
|
|
}
|
|
|
|
|
1998-10-07 19:00:34 +04:00
|
|
|
#define PRINT_BINFO(bip) if(debug > 1 ) { \
|
|
|
|
syslog(LOG_DEBUG,"\tinode: %d lbn: %d daddr: 0x%lx create: %s\n", \
|
1998-09-12 01:21:29 +04:00
|
|
|
(bip)->bi_inode, (bip)->bi_lbn, (unsigned long)(bip)->bi_daddr, \
|
1994-06-08 22:42:09 +04:00
|
|
|
ctime((time_t *)&(bip)->bi_segcreate)); \
|
|
|
|
}
|
|
|
|
|
1998-10-07 19:00:34 +04:00
|
|
|
#define PRINT_SEGUSE(sup, n) if(debug > 1) { \
|
1999-03-10 03:57:16 +03:00
|
|
|
syslog(LOG_DEBUG,"Segment %d nbytes=%lu\tflags=%c%c%c ninos=%d nsums=%d lastmod: %s", \
|
1998-09-12 01:21:29 +04:00
|
|
|
n, (unsigned long)(sup)->su_nbytes, \
|
1994-06-08 22:42:09 +04:00
|
|
|
(sup)->su_flags & SEGUSE_DIRTY ? 'D' : 'C', \
|
|
|
|
(sup)->su_flags & SEGUSE_ACTIVE ? 'A' : ' ', \
|
|
|
|
(sup)->su_flags & SEGUSE_SUPERBLOCK ? 'S' : ' ', \
|
|
|
|
(sup)->su_ninos, (sup)->su_nsums, \
|
|
|
|
ctime((time_t *)&(sup)->su_lastmod)); \
|
|
|
|
}
|
|
|
|
|
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
|
|
|
__BEGIN_DECLS
|
|
|
|
int dump_summary(struct lfs *, SEGSUM *, u_long, daddr_t **, daddr_t);
|
|
|
|
int fs_getmntinfo(struct statfs **, char *, const char *);
|
|
|
|
void get(int, off_t, void *, size_t);
|
|
|
|
FS_INFO *get_fs_info(struct statfs *, int);
|
|
|
|
int lfs_segmapv(FS_INFO *, int, caddr_t, BLOCK_INFO **, int *);
|
|
|
|
int mmap_segment(FS_INFO *, int, caddr_t *, int);
|
|
|
|
void munmap_segment(FS_INFO *, caddr_t, int);
|
|
|
|
void reread_fs_info(FS_INFO *, int);
|
|
|
|
void toss __P((void *, int *, size_t,
|
|
|
|
int (*)(const void *, const void *, const void *), void *));
|
|
|
|
|
|
|
|
void dump_super(struct lfs *);
|
|
|
|
void dump_cleaner_info(void *);
|
|
|
|
void print_SEGSUM(struct lfs *, SEGSUM *, daddr_t);
|
|
|
|
void print_CLEANERINFO(CLEANERINFO *);
|
1994-06-08 22:42:09 +04:00
|
|
|
__END_DECLS
|