Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/newfs_lfs Tweak how lfs_avail is initialized, correspon...
details: https://anonhg.NetBSD.org/src/rev/e4f8a2a8833e
branches: trunk
changeset: 494275:e4f8a2a8833e
user: perseant <perseant%NetBSD.org@localhost>
date: Tue Jul 04 22:35:04 2000 +0000
description:
Tweak how lfs_avail is initialized, corresponding to changes in the
kernel.
Don't make more superblock segments than we have a record of in
the superblock; and print these out as we go, like newfs.
Add am "-M" flag to specify the number of reserved segments, with a note
in the man page not to use it.
diffstat:
sbin/newfs_lfs/config.h | 4 +-
sbin/newfs_lfs/extern.h | 4 +-
sbin/newfs_lfs/lfs.c | 54 +++++++++++++++++++--------------------------
sbin/newfs_lfs/newfs.c | 13 +++++++---
sbin/newfs_lfs/newfs_lfs.8 | 10 +++++---
5 files changed, 42 insertions(+), 43 deletions(-)
diffs (240 lines):
diff -r 0873ff2a9303 -r e4f8a2a8833e sbin/newfs_lfs/config.h
--- a/sbin/newfs_lfs/config.h Tue Jul 04 22:30:37 2000 +0000
+++ b/sbin/newfs_lfs/config.h Tue Jul 04 22:35:04 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: config.h,v 1.3 2000/07/03 01:49:11 perseant Exp $ */
+/* $NetBSD: config.h,v 1.4 2000/07/04 22:35:04 perseant Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -57,7 +57,7 @@
* the cleaner. Experimental data show this number should be around
* 5-10.
*/
-#define DFL_MIN_FREE_SEGS 8
+#define DFL_MIN_FREE_SEGS 10
/*
* MINFREE gives the minimum acceptable percentage of file system
diff -r 0873ff2a9303 -r e4f8a2a8833e sbin/newfs_lfs/extern.h
--- a/sbin/newfs_lfs/extern.h Tue Jul 04 22:30:37 2000 +0000
+++ b/sbin/newfs_lfs/extern.h Tue Jul 04 22:35:04 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.1 1999/03/18 17:18:05 perseant Exp $ */
+/* $NetBSD: extern.h,v 1.2 2000/07/04 22:35:04 perseant Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -44,7 +44,7 @@
u_int log2 __P((u_int));
int make_lfs
__P((int, struct disklabel *, struct partition *, int,
- int, int, int));
+ int, int, int, int));
int mkfs __P((struct partition *, char *, int, int));
extern char *progname;
diff -r 0873ff2a9303 -r e4f8a2a8833e sbin/newfs_lfs/lfs.c
--- a/sbin/newfs_lfs/lfs.c Tue Jul 04 22:30:37 2000 +0000
+++ b/sbin/newfs_lfs/lfs.c Tue Jul 04 22:35:04 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.15 2000/07/03 21:51:05 thorpej Exp $ */
+/* $NetBSD: lfs.c,v 1.16 2000/07/04 22:35:05 perseant Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95";
#else
-__RCSID("$NetBSD: lfs.c,v 1.15 2000/07/03 21:51:05 thorpej Exp $");
+__RCSID("$NetBSD: lfs.c,v 1.16 2000/07/04 22:35:05 perseant Exp $");
#endif
#endif /* not lint */
@@ -188,7 +188,7 @@
static void put __P((int, off_t, void *, size_t));
int
-make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
+make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size, minfreeseg)
int fd;
struct disklabel *lp;
struct partition *partp;
@@ -196,6 +196,7 @@
int block_size;
int frag_size;
int seg_size;
+ int minfreeseg;
{
struct dinode *dip; /* Pointer to a disk inode */
struct dinode *dpagep; /* Pointer to page of disk inodes */
@@ -209,7 +210,6 @@
SEGSUM summary; /* Segment summary structure */
SEGSUM *sp; /* Segment summary pointer */
daddr_t last_sb_addr; /* Address of superblocks */
- daddr_t last_addr; /* Previous segment address */
daddr_t sb_addr; /* Address of superblocks */
daddr_t seg_addr; /* Address of current segment */
char *ipagep; /* Pointer to the page we use to write stuff */
@@ -315,7 +315,10 @@
lfsp->lfs_nseg = lfsp->lfs_dsize / lfsp->lfs_ssize;
lfsp->lfs_nclean = lfsp->lfs_nseg - 1;
lfsp->lfs_maxfilesize = maxtable[lfsp->lfs_bshift] << lfsp->lfs_bshift;
- lfsp->lfs_minfreeseg = lfsp->lfs_nseg / DFL_MIN_FREE_SEGS;
+ if (minfreeseg == 0)
+ lfsp->lfs_minfreeseg = lfsp->lfs_nseg / DFL_MIN_FREE_SEGS;
+ else
+ lfsp->lfs_minfreeseg = minfreeseg;
if (lfsp->lfs_minfreeseg < MIN_FREE_SEGS)
lfsp->lfs_minfreeseg = MIN_FREE_SEGS;
@@ -425,8 +428,9 @@
lfsp->lfs_idaddr = (LFS_LABELPAD + LFS_SBPAD + LFS_SUMMARY_SIZE) /
lp->d_secsize;
+ j = 1;
for (segp = segtable + 1, i = 1; i < lfsp->lfs_nseg; i++, segp++) {
- if ((i % sb_interval) == 0) {
+ if ((i % sb_interval) == 0 && j < LFS_MAXNUMSB) {
segp->su_flags = SEGUSE_SUPERBLOCK;
lfsp->lfs_bfree -= (LFS_SBPAD / lp->d_secsize);
} else
@@ -438,12 +442,9 @@
}
/*
- * Initialize dynamic accounting. The blocks available for
- * writing are the bfree blocks minus 1 segment summary for
- * each segment since you can't write any new data without
- * creating a segment summary.
+ * Initialize dynamic accounting.
*/
- lfsp->lfs_avail = lfsp->lfs_bfree - lfsp->lfs_nseg;
+ lfsp->lfs_avail = lfsp->lfs_bfree;
lfsp->lfs_uinodes = 0;
/*
@@ -685,32 +686,23 @@
cksum(&sp->ss_datasum, LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum));
put(fd, off, sp, LFS_SUMMARY_SIZE);
- /* Now, write rest of segments containing superblocks */
+ /* Now, write the rest of the superblocks */
lfsp->lfs_cksum = lfs_sb_cksum(&(lfsp->lfs_dlfs));
- for (seg_addr = last_addr = lfsp->lfs_sboffs[0], j = 1, i = 1;
- i < lfsp->lfs_nseg; i++) {
+ printf("super-block backups (for fsck -b #) at:\n");
+ for (i = 0; i < LFS_MAXNUMSB; i++) {
+ seg_addr = lfsp->lfs_sboffs[i];
+
+ printf("%d%s ", seg_addr, (i == LFS_MAXNUMSB - 1 ? "" : ","));
/* Leave the time stamp on the alt sb, zero the rest */
- if(j > 1)
+ if(i == 2) {
lfsp->lfs_tstamp = 0;
-
- seg_addr += lfsp->lfs_ssize << lfsp->lfs_fsbtodb;
- sp->ss_next = last_addr;
- last_addr = seg_addr;
+ lfsp->lfs_cksum = lfs_sb_cksum(&(lfsp->lfs_dlfs));
+ }
seg_seek = (off_t)seg_addr * lp->d_secsize;
-
- if (i % sb_interval == 0) {
- if (j < (LFS_MAXNUMSB - 2))
- j++;
- put(fd, seg_seek, &(lfsp->lfs_dlfs), sizeof(struct dlfs));
- seg_seek += LFS_SBPAD;
- }
-
- /* Summary */
- sp->ss_sumsum = cksum(&sp->ss_datasum,
- LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum));
- put(fd, seg_seek, sp, LFS_SUMMARY_SIZE);
+ put(fd, seg_seek, &(lfsp->lfs_dlfs), sizeof(struct dlfs));
}
+ printf("\n");
free(ipagep);
close(fd);
return (0);
diff -r 0873ff2a9303 -r e4f8a2a8833e sbin/newfs_lfs/newfs.c
--- a/sbin/newfs_lfs/newfs.c Tue Jul 04 22:30:37 2000 +0000
+++ b/sbin/newfs_lfs/newfs.c Tue Jul 04 22:35:04 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs.c,v 1.3 2000/02/12 23:58:09 perseant Exp $ */
+/* $NetBSD: newfs.c,v 1.4 2000/07/04 22:35:05 perseant Exp $ */
/*-
* Copyright (c) 1989, 1992, 1993
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)newfs.c 8.5 (Berkeley) 5/24/95";
#else
-__RCSID("$NetBSD: newfs.c,v 1.3 2000/02/12 23:58:09 perseant Exp $");
+__RCSID("$NetBSD: newfs.c,v 1.4 2000/07/04 22:35:05 perseant Exp $");
#endif
#endif /* not lint */
@@ -82,6 +82,7 @@
int fsize = 0; /* fragment size */
int bsize = 0; /* block size */
int minfree = MINFREE; /* free space threshold */
+int minfreeseg = 0; /* free segments reserved for the cleaner */
int bbsize = BBSIZE; /* boot block size */
int sbsize = SBSIZE; /* superblock size */
u_long memleft; /* virtual memory available */
@@ -123,7 +124,7 @@
if (maxpartitions > 26)
fatal("insane maxpartitions value %d", maxpartitions);
- opstring = "B:DFLNb:f:m:s:";
+ opstring = "B:DFLNb:f:M:m:s:";
debug = force = lfs = segsize = 0;
while ((ch = getopt(argc, argv, opstring)) != -1)
@@ -141,6 +142,9 @@
case 'L': /* Create lfs */
lfs = 1;
break;
+ case 'M':
+ minfreeseg = atoi(optarg);
+ break;
case 'N':
Nflag++;
break;
@@ -238,7 +242,8 @@
}
/* If we're making a LFS, we break out here */
- exit(make_lfs(fso, lp, pp, minfree, bsize, fsize, segsize));
+ exit(make_lfs(fso, lp, pp, minfree, bsize, fsize, segsize,
+ minfreeseg));
}
#ifdef COMPAT
diff -r 0873ff2a9303 -r e4f8a2a8833e sbin/newfs_lfs/newfs_lfs.8
--- a/sbin/newfs_lfs/newfs_lfs.8 Tue Jul 04 22:30:37 2000 +0000
+++ b/sbin/newfs_lfs/newfs_lfs.8 Tue Jul 04 22:35:04 2000 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: newfs_lfs.8,v 1.7 2000/02/12 23:58:09 perseant Exp $
+.\" $NetBSD: newfs_lfs.8,v 1.8 2000/07/04 22:35:05 perseant Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -87,9 +87,11 @@
.It Fl m Ar free space \&%
The percentage of space reserved from normal users; the minimum
free space threshold. The default value used is 10%.
-See
-.Xr tunefs 8
-for more details on how to set this option.
+.It Fl M Ar nsegs
+Reserve this many segments for use exclusively by the cleaner, instead
+of letting
+.Nm
+do the computation. Do not use this option.
.It Fl N
Do not actually create the filesystem.
.It Fl s Ar size
Home |
Main Index |
Thread Index |
Old Index