Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Merge the short-lived perseant-lfsv2 branch into the trunk.
details: https://anonhg.NetBSD.org/src/rev/69affec6072f
branches: trunk
changeset: 512678:69affec6072f
user: perseant <perseant%NetBSD.org@localhost>
date: Fri Jul 13 20:30:18 2001 +0000
description:
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.
diffstat:
libexec/lfs_cleanerd/clean.h | 61 ++-
libexec/lfs_cleanerd/cleanerd.c | 131 +++-----
libexec/lfs_cleanerd/lfs_cleanerd.8 | 11 +-
libexec/lfs_cleanerd/library.c | 220 ++++++--------
libexec/lfs_cleanerd/misc.c | 10 +-
libexec/lfs_cleanerd/print.c | 49 +-
sbin/dump_lfs/Makefile | 3 +-
sbin/dump_lfs/lfs_inode.c | 80 ++++-
sbin/fsck_lfs/dir.c | 12 +-
sbin/fsck_lfs/inode.c | 66 +++-
sbin/fsck_lfs/pass0.c | 35 +-
sbin/fsck_lfs/pass1.c | 11 +-
sbin/fsck_lfs/pass5.c | 45 +-
sbin/fsck_lfs/setup.c | 174 ++++++----
sbin/fsck_lfs/utilities.c | 33 +-
sbin/newfs_lfs/config.h | 17 +-
sbin/newfs_lfs/extern.h | 17 +-
sbin/newfs_lfs/lfs.c | 531 ++++++++++++++++++++++++-----------
sbin/newfs_lfs/misc.c | 7 +-
sbin/newfs_lfs/newfs.c | 78 +++--
sbin/newfs_lfs/newfs_lfs.8 | 27 +-
sys/ufs/lfs/TODO | 44 +--
sys/ufs/lfs/lfs.h | 304 ++++++++++++++------
sys/ufs/lfs/lfs_alloc.c | 173 +++++++----
sys/ufs/lfs/lfs_balloc.c | 36 +-
sys/ufs/lfs/lfs_bio.c | 81 +---
sys/ufs/lfs/lfs_cksum.c | 9 +-
sys/ufs/lfs/lfs_debug.c | 28 +-
sys/ufs/lfs/lfs_extern.h | 185 ++++++------
sys/ufs/lfs/lfs_inode.c | 82 ++--
sys/ufs/lfs/lfs_segment.c | 414 +++++++++++++++------------
sys/ufs/lfs/lfs_subr.c | 18 +-
sys/ufs/lfs/lfs_syscalls.c | 343 +++++++++++++++-------
sys/ufs/lfs/lfs_vfsops.c | 495 ++++++++++++++++++++-------------
sys/ufs/lfs/lfs_vnops.c | 77 ++---
sys/ufs/ufs/ufs_readwrite.c | 6 +-
usr.sbin/dumplfs/dumplfs.c | 495 ++++++++++++++++++---------------
usr.sbin/dumplfs/extern.h | 4 +-
usr.sbin/dumplfs/misc.c | 10 +-
39 files changed, 2549 insertions(+), 1873 deletions(-)
diffs (truncated from 9160 to 300 lines):
diff -r 210ef058cd20 -r 69affec6072f libexec/lfs_cleanerd/clean.h
--- a/libexec/lfs_cleanerd/clean.h Fri Jul 13 20:00:23 2001 +0000
+++ b/libexec/lfs_cleanerd/clean.h Fri Jul 13 20:30:18 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: clean.h,v 1.10 2001/02/04 22:12:47 christos Exp $ */
+/* $NetBSD: clean.h,v 1.11 2001/07/13 20:30:21 perseant Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -84,7 +84,6 @@
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_daddr_shift; /* shift to get byte offset of daddr */
u_long fi_ifile_count; /* # entries in the ifile table */
off_t fi_ifile_length; /* length of the ifile */
time_t fi_fs_tstamp; /* last fs activity, per ifile */
@@ -94,34 +93,26 @@
* XXX: size (in bytes) of a segment
* should lfs_bsize be fsbtodb(fs,1), blksize(fs), or lfs_dsize?
*/
-#define seg_size(fs) ((fs)->lfs_ssize << (fs)->lfs_bshift)
-
-/* daddr -> byte offset */
-#define datobyte(fs, da) (((off_t)(da)) << (fs)->fi_daddr_shift)
-#define bytetoda(fs, byte) ((byte) >> (fs)->fi_daddr_shift)
+#define seg_size(fs) fsbtob((fs), segtod((fs), 1))
#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)
-#define IFILE_ENTRY(fs, if, i) \
- ((IFILE *)((caddr_t)(if) + ((i) / (fs)->lfs_ifpb << (fs)->lfs_bshift)) \
- + (i) % (fs)->lfs_ifpb)
-
-#define SEGUSE_ENTRY(fs, su, i) \
- ((SEGUSE *)((caddr_t)(su) + (fs)->lfs_bsize * ((i) / (fs)->lfs_sepb)) +\
- (i) % (fs)->lfs_sepb)
+#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))
-__BEGIN_DECLS
-int dump_summary __P((struct lfs *, SEGSUM *, u_long, daddr_t **, daddr_t));
-int fs_getmntinfo __P((struct statfs **, char *, const char *));
-void get __P((int, off_t, void *, size_t));
-FS_INFO *get_fs_info __P((struct statfs *, int));
-int lfs_segmapv __P((FS_INFO *, int, caddr_t, BLOCK_INFO **, int *));
-int mmap_segment __P((FS_INFO *, int, caddr_t *, int));
-void munmap_segment __P((FS_INFO *, caddr_t, int));
-void reread_fs_info __P((FS_INFO *, int));
-void toss __P((void *, int *, size_t,
- int (*)(const void *, const void *, const void *), void *));
+#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))
/*
* USEFUL DEBUGGING FUNCTIONS:
@@ -155,8 +146,20 @@
ctime((time_t *)&(sup)->su_lastmod)); \
}
-void dump_super __P((struct lfs *));
-void dump_cleaner_info __P((void *));
-void print_SEGSUM __P(( struct lfs *, SEGSUM *, daddr_t));
-void print_CLEANERINFO __P((CLEANERINFO *));
+__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 *);
__END_DECLS
diff -r 210ef058cd20 -r 69affec6072f libexec/lfs_cleanerd/cleanerd.c
--- a/libexec/lfs_cleanerd/cleanerd.c Fri Jul 13 20:00:23 2001 +0000
+++ b/libexec/lfs_cleanerd/cleanerd.c Fri Jul 13 20:30:18 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cleanerd.c,v 1.30 2001/02/04 22:12:47 christos Exp $ */
+/* $NetBSD: cleanerd.c,v 1.31 2001/07/13 20:30:21 perseant Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "@(#)cleanerd.c 8.5 (Berkeley) 6/10/95";
#else
-__RCSID("$NetBSD: cleanerd.c,v 1.30 2001/02/04 22:12:47 christos Exp $");
+__RCSID("$NetBSD: cleanerd.c,v 1.31 2001/07/13 20:30:21 perseant Exp $");
#endif
#endif /* not lint */
@@ -109,24 +109,24 @@
#define CLEAN_BYTES 0x1
/* function prototypes for system calls; not sure where they should go */
-int lfs_segwait __P((fsid_t *, struct timeval *));
-int lfs_segclean __P((fsid_t *, u_long));
-int lfs_bmapv __P((fsid_t *, BLOCK_INFO *, int));
-int lfs_markv __P((fsid_t *, BLOCK_INFO *, int));
+int lfs_segwait(fsid_t *, struct timeval *);
+int lfs_segclean(fsid_t *, u_long);
+int lfs_bmapv(fsid_t *, BLOCK_INFO *, int);
+int lfs_markv(fsid_t *, BLOCK_INFO *, int);
/* function prototypes */
-int bi_tossold __P((const void *, const void *, const void *));
-int choose_segments __P((FS_INFO *, struct seglist *,
- unsigned long (*)(FS_INFO *, SEGUSE *)));
-void clean_fs __P((FS_INFO *, unsigned long (*)(FS_INFO *, SEGUSE *), int, long));
-int clean_loop __P((FS_INFO *, int, long));
-int add_segment __P((FS_INFO *, struct seglist *, SEGS_AND_BLOCKS *));
-int clean_segments __P((FS_INFO *, SEGS_AND_BLOCKS *));
-unsigned long cost_benefit __P((FS_INFO *, SEGUSE *));
-int cost_compare __P((const void *, const void *));
-void sig_report __P((int));
-void just_exit __P((int));
-int main __P((int, char *[]));
+int bi_tossold(const void *, const void *, const void *);
+int choose_segments(FS_INFO *, struct seglist *,
+ unsigned long (*)(FS_INFO *, SEGUSE *));
+void clean_fs(FS_INFO *, unsigned long (*)(FS_INFO *, SEGUSE *), int, long);
+int clean_loop(FS_INFO *, int, long);
+int add_segment(FS_INFO *, struct seglist *, SEGS_AND_BLOCKS *);
+int clean_segments(FS_INFO *, SEGS_AND_BLOCKS *);
+unsigned long cost_benefit(FS_INFO *, SEGUSE *);
+int cost_compare(const void *, const void *);
+void sig_report(int);
+void just_exit(int);
+int main(int, char *[]);
/*
* Cleaning Cost Functions:
@@ -141,9 +141,7 @@
*/
unsigned long
-cost_benefit(fsp, su)
- FS_INFO *fsp; /* file system information */
- SEGUSE *su;
+cost_benefit(FS_INFO *fsp, SEGUSE *su)
{
struct lfs *lfsp;
struct timeval t;
@@ -180,9 +178,7 @@
}
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char **argv)
{
FS_INFO *fsp;
struct statfs *lstatfsp; /* file system stats */
@@ -340,24 +336,21 @@
/* return the number of segments cleaned */
int
-clean_loop(fsp, nsegs, options)
- FS_INFO *fsp; /* file system information */
- int nsegs;
- long options;
+clean_loop(FS_INFO *fsp, int nsegs, long options)
{
struct lfs *lfsp;
double loadavg[MAXLOADS];
time_t now;
u_long max_free_segs;
- u_long db_per_seg;
+ u_long fsb_per_seg;
lfsp = &fsp->fi_lfs;
/*
* Compute the maximum possible number of free segments, given the
* number of free blocks.
*/
- db_per_seg = fsbtodb(lfsp, lfsp->lfs_ssize);
- max_free_segs = fsp->fi_cip->bfree / db_per_seg + lfsp->lfs_minfreeseg;
+ fsb_per_seg = segtod(lfsp, 1);
+ max_free_segs = fsp->fi_cip->bfree / fsb_per_seg + lfsp->lfs_minfreeseg;
/*
* We will clean if there are not enough free blocks or total clean
@@ -366,16 +359,16 @@
now = time((time_t *)NULL);
if(debug > 1) {
- syslog(LOG_DEBUG, "db_per_seg = %lu bfree = %u avail = %d,"
- " bfree = %u, ", db_per_seg, fsp->fi_cip->bfree,
+ syslog(LOG_DEBUG, "fsb_per_seg = %lu bfree = %u avail = %d,"
+ " bfree = %u, ", fsb_per_seg, fsp->fi_cip->bfree,
fsp->fi_cip->avail, fsp->fi_cip->bfree);
syslog(LOG_DEBUG, "clean segs = %d, max_free_segs = %ld",
fsp->fi_cip->clean, max_free_segs);
}
- if ((fsp->fi_cip->bfree - fsp->fi_cip->avail > db_per_seg &&
- fsp->fi_cip->avail < (long)db_per_seg &&
- fsp->fi_cip->bfree > (long)db_per_seg) ||
+ if ((fsp->fi_cip->bfree - fsp->fi_cip->avail > fsb_per_seg &&
+ fsp->fi_cip->avail < (long)fsb_per_seg &&
+ fsp->fi_cip->bfree > (long)fsb_per_seg) ||
(fsp->fi_cip->clean < max_free_segs &&
(fsp->fi_cip->clean <= lfsp->lfs_minfreeseg ||
fsp->fi_cip->clean < max_free_segs * BUSY_LIM)))
@@ -444,9 +437,9 @@
}
}
if (debug > 1) {
- if (fsp->fi_cip->bfree - fsp->fi_cip->avail <= db_per_seg)
+ if (fsp->fi_cip->bfree - fsp->fi_cip->avail <= fsb_per_seg)
syslog(LOG_DEBUG, "condition 1 false");
- if (fsp->fi_cip->avail >= (long)db_per_seg)
+ if (fsp->fi_cip->avail >= (long)fsb_per_seg)
syslog(LOG_DEBUG, "condition 2 false");
if (fsp->fi_cip->clean >= max_free_segs)
syslog(LOG_DEBUG, "condition 3 false");
@@ -462,14 +455,11 @@
void
-clean_fs(fsp, cost_func, nsegs, options)
- FS_INFO *fsp; /* file system information */
- unsigned long (*cost_func) __P((FS_INFO *, SEGUSE *));
- int nsegs;
- long options;
+clean_fs(FS_INFO *fsp, unsigned long (*cost_func)(FS_INFO *, SEGUSE *),
+ int nsegs, long options)
{
struct seglist *segs, *sp;
- long int to_clean, cleaned_bytes, seg_size;
+ long int to_clean, cleaned_bytes;
unsigned long i, j, total;
struct rusage ru;
fsid_t *fsidp;
@@ -477,7 +467,6 @@
SEGS_AND_BLOCKS *sbp;
fsidp = &fsp->fi_statfsp->f_fsid;
- seg_size = (1 << fsp->fi_lfs.lfs_segshift);
if ((segs =
malloc(fsp->fi_lfs.lfs_nseg * sizeof(struct seglist))) == NULL) {
@@ -589,9 +578,7 @@
* cost/benefit than any utilized segment.
*/
int
-cost_compare(a, b)
- const void *a;
- const void *b;
+cost_compare(const void *a, const void *b)
{
return ((struct seglist *)b)->sl_cost < ((struct seglist *)a)->sl_cost ? -1 : 1;
}
@@ -602,10 +589,7 @@
* filled in.
*/
int
-choose_segments(fsp, seglist, cost_func)
- FS_INFO *fsp;
- struct seglist *seglist;
- unsigned long (*cost_func) __P((FS_INFO *, SEGUSE *));
+choose_segments(FS_INFO *fsp, struct seglist *seglist, unsigned long (*cost_func)(FS_INFO *, SEGUSE *))
{
struct lfs *lfsp;
struct seglist *sp;
@@ -663,10 +647,7 @@
* in preparation for sending through lfs_markv.
*/
int
-add_segment(fsp, slp, sbp)
- FS_INFO *fsp;
- struct seglist *slp;
- SEGS_AND_BLOCKS *sbp;
+add_segment(FS_INFO *fsp, struct seglist *slp, SEGS_AND_BLOCKS *sbp)
{
int id = slp->sl_id;
BLOCK_INFO *tba, *_bip;
@@ -684,7 +665,7 @@
lfsp = &fsp->fi_lfs;
Home |
Main Index |
Thread Index |
Old Index