summaryrefslogtreecommitdiffstats
path: root/sbin/tunefs
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2002-06-21 06:18:05 +0000
committermckusick <mckusick@FreeBSD.org>2002-06-21 06:18:05 +0000
commit88d85c15ef183c06524d6ca695f62c0c0672b00c (patch)
treef1364dbfb9835934a3879b5904f7ff9a1495744c /sbin/tunefs
parenteacb69b0197a8553d5004aa99532cabad8778e36 (diff)
downloadFreeBSD-src-88d85c15ef183c06524d6ca695f62c0c0672b00c.zip
FreeBSD-src-88d85c15ef183c06524d6ca695f62c0c0672b00c.tar.gz
This commit adds basic support for the UFS2 filesystem. The UFS2
filesystem expands the inode to 256 bytes to make space for 64-bit block pointers. It also adds a file-creation time field, an ability to use jumbo blocks per inode to allow extent like pointer density, and space for extended attributes (up to twice the filesystem block size worth of attributes, e.g., on a 16K filesystem, there is space for 32K of attributes). UFS2 fully supports and runs existing UFS1 filesystems. New filesystems built using newfs can be built in either UFS1 or UFS2 format using the -O option. In this commit UFS1 is the default format, so if you want to build UFS2 format filesystems, you must specify -O 2. This default will be changed to UFS2 when UFS2 proves itself to be stable. In this commit the boot code for reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c) as there is insufficient space in the boot block. Once the size of the boot block is increased, this code can be defined. Things to note: the definition of SBSIZE has changed to SBLOCKSIZE. The header file <ufs/ufs/dinode.h> must be included before <ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and ufs_lbn_t. Still TODO: Verify that the first level bootstraps work for all the architectures. Convert the utility ffsinfo to understand UFS2 and test growfs. Add support for the extended attribute storage. Update soft updates to ensure integrity of extended attribute storage. Switch the current extended attribute interfaces to use the extended attribute storage. Add the extent like functionality (framework is there, but is currently never used). Sponsored by: DARPA & NAI Labs. Reviewed by: Poul-Henning Kamp <phk@freebsd.org>
Diffstat (limited to 'sbin/tunefs')
-rw-r--r--sbin/tunefs/tunefs.841
-rw-r--r--sbin/tunefs/tunefs.c64
2 files changed, 48 insertions, 57 deletions
diff --git a/sbin/tunefs/tunefs.8 b/sbin/tunefs/tunefs.8
index 3480397..424e209 100644
--- a/sbin/tunefs/tunefs.8
+++ b/sbin/tunefs/tunefs.8
@@ -32,7 +32,7 @@
.\" @(#)tunefs.8 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
-.Dd December 11, 1993
+.Dd May 18, 2002
.Dt TUNEFS 8
.Os
.Sh NAME
@@ -42,7 +42,6 @@
.Nm
.Op Fl A
.Op Fl a Ar maxcontig
-.Op Fl d Ar rotdelay
.Op Fl e Ar maxbpg
.Op Fl f Ar avgfilesize
.Op Fl m Ar minfree
@@ -57,6 +56,13 @@
.Nm Tunefs
is designed to change the dynamic parameters of a filesystem
which affect the layout policies.
+The
+.Nm
+program cannot be run on an active filesystem.
+To change an active filesystem,
+you must either downgrade the filesystem to read-only
+or unmount it.
+.Pp
The parameters which are to be changed are indicated by the flags
given below:
.Bl -tag -width indent
@@ -66,19 +72,8 @@ this option will cause all backups to be modified as well as the
primary super-block. This is potentially dangerous - use with caution.
.It Fl a Ar maxcontig
Specify the maximum number of contiguous blocks that will
-be laid out before forcing a rotational delay (see
-.Fl d
-below).
-The default value is one, since most device drivers require
-an interrupt per disk transfer.
-Device drivers that can chain several buffers together in a single
-transfer should set this to the maximum chain length.
-.It Fl d Ar rotdelay
-Specify the expected time (in milliseconds)
-to service a transfer completion
-interrupt and initiate a new transfer on the same disk.
-It is used to decide how much rotational spacing to place between
-successive blocks in a file.
+be laid out before allowing a rotational delay.
+The default value is 16.
.It Fl e Ar maxbpg
Indicate the maximum number of blocks any single file can
allocate out of a cylinder group before it is forced to begin
@@ -131,9 +126,11 @@ the percent fragmentation changes on the filesystem.
.It Fl p
Show a summary of what the current tunable settings
are on the selected filesystem. More detailed information can be
-obtained in the
+obtained from the
.Xr dumpfs 8
-manual page.
+or
+.Xr ffsinfo 8
+programs.
.It Fl s Ar avgfpdir
Specify the expected number of files per directory.
.El
@@ -148,6 +145,7 @@ specified mount point.
.Sh SEE ALSO
.Xr fs 5 ,
.Xr dumpfs 8 ,
+.Xr ffsinfo 8 ,
.Xr newfs 8
.Rs
.%A M. McKusick
@@ -162,13 +160,8 @@ specified mount point.
.%O "(reprinted in the BSD System Manager's Manual, SMM:5)"
.Re
.Sh BUGS
-This program should work on mounted and active filesystems.
-Because the super-block is not kept in the buffer cache,
-the changes will only take effect if the program
-is run on dismounted filesystems.
-To change the root filesystem, the system must be rebooted
-after the filesystem is tuned.
-.\" Take this out and a Unix Demon will dog your steps from now until
+This program should work on active filesystems.
+.\" Take this out and a Unix Daemon will dog your steps from now until
.\" the time_t's wrap around.
.Pp
You can tune a filesystem, but you can't tune a fish.
diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c
index b40c8cb..e272446 100644
--- a/sbin/tunefs/tunefs.c
+++ b/sbin/tunefs/tunefs.c
@@ -53,8 +53,9 @@ static const char rcsid[] =
#include <sys/disklabel.h>
#include <sys/stat.h>
-#include <ufs/ffs/fs.h>
#include <ufs/ufs/ufsmount.h>
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
#include <err.h>
#include <fcntl.h>
@@ -77,8 +78,8 @@ union {
int fi;
long dev_bsize = 1;
-void bwrite(daddr_t, const char *, int);
-int bread(daddr_t, char *, int);
+void bwrite(ufs2_daddr_t, const char *, int);
+int bread(ufs2_daddr_t, char *, int);
void getsb(struct fs *, const char *);
void putsb(struct fs *, const char *, int);
void usage(void);
@@ -93,9 +94,9 @@ main(argc, argv)
const char *name;
struct stat st;
int Aflag = 0, active = 0;
- int aflag = 0, dflag = 0, eflag = 0, fflag = 0, mflag = 0;
+ int aflag = 0, eflag = 0, fflag = 0, mflag = 0;
int nflag = 0, oflag = 0, pflag = 0, sflag = 0;
- int avalue = 0, dvalue = 0, evalue = 0, fvalue = 0;
+ int avalue = 0, evalue = 0, fvalue = 0;
int mvalue = 0, ovalue = 0, svalue = 0;
char *nvalue = NULL;
struct fstab *fs;
@@ -108,7 +109,7 @@ main(argc, argv)
if (argc < 3)
usage();
found_arg = 0; /* at least one arg is required */
- while ((ch = getopt(argc, argv, "Aa:d:e:f:m:n:o:ps:")) != -1)
+ while ((ch = getopt(argc, argv, "Aa:e:f:m:n:o:ps:")) != -1)
switch (ch) {
case 'A':
found_arg = 1;
@@ -122,12 +123,6 @@ main(argc, argv)
errx(10, "%s must be >= 1 (was %s)", name, optarg);
aflag = 1;
break;
- case 'd':
- found_arg = 1;
- name = "rotational delay between contiguous blocks";
- dvalue = atoi(optarg);
- dflag = 1;
- break;
case 'e':
found_arg = 1;
name = "maximum blocks per file in a cylinder group";
@@ -237,17 +232,6 @@ again:
sblock.fs_maxcontig = avalue;
}
}
- if (dflag) {
- name = "rotational delay between contiguous blocks";
- if (sblock.fs_rotdelay == dvalue) {
- warnx("%s remains unchanged as %dms", name, dvalue);
- }
- else {
- warnx("%s changes from %dms to %dms",
- name, sblock.fs_rotdelay, dvalue);
- sblock.fs_rotdelay = dvalue;
- }
- }
if (eflag) {
name = "maximum blocks per file in a cylinder group";
if (sblock.fs_maxbpg == evalue) {
@@ -358,20 +342,36 @@ usage()
exit(2);
}
+/*
+ * Possible superblock locations ordered from most to least likely.
+ */
+static int sblock_try[] = SBLOCKSEARCH;
+static ufs2_daddr_t sblockloc;
+
void
getsb(fs, file)
struct fs *fs;
const char *file;
{
+ int i;
fi = open(file, O_RDONLY);
if (fi < 0)
err(3, "cannot open %s", file);
- if (bread((daddr_t)SBOFF, (char *)fs, SBSIZE))
- err(4, "%s: bad super block", file);
- if (fs->fs_magic != FS_MAGIC)
- errx(5, "%s: bad magic number", file);
+ for (i = 0; sblock_try[i] != -1; i++) {
+ if (bread(sblock_try[i], (char *)fs, SBLOCKSIZE))
+ err(4, "%s: bad super block", file);
+ if ((fs->fs_magic == FS_UFS1_MAGIC ||
+ (fs->fs_magic == FS_UFS2_MAGIC &&
+ fs->fs_sblockloc == numfrags(fs, sblock_try[i]))) &&
+ fs->fs_bsize <= MAXBSIZE &&
+ fs->fs_bsize >= sizeof(struct fs))
+ break;
+ }
+ if (sblock_try[i] == -1)
+ err(5, "Cannot find filesystem superblock");
dev_bsize = fs->fs_fsize / fsbtodb(fs, 1);
+ sblockloc = sblock_try[i] / dev_bsize;
}
void
@@ -392,11 +392,11 @@ putsb(fs, file, all)
close(i);
if (fi < 0)
err(3, "cannot open %s", file);
- bwrite((daddr_t)SBOFF / dev_bsize, (const char *)fs, SBSIZE);
+ bwrite(sblockloc, (const char *)fs, SBLOCKSIZE);
if (all)
for (i = 0; i < fs->fs_ncg; i++)
bwrite(fsbtodb(fs, cgsblock(fs, i)),
- (const char *)fs, SBSIZE);
+ (const char *)fs, SBLOCKSIZE);
close(fi);
}
@@ -407,8 +407,6 @@ printfs()
(sblock.fs_flags & FS_DOSOFTDEP)? "enabled" : "disabled");
warnx("maximum contiguous block count: (-a) %d",
sblock.fs_maxcontig);
- warnx("rotational delay between contiguous blocks: (-d) %d ms",
- sblock.fs_rotdelay);
warnx("maximum blocks per file in a cylinder group: (-e) %d",
sblock.fs_maxbpg);
warnx("average file size: (-f) %d",
@@ -429,7 +427,7 @@ printfs()
void
bwrite(blk, buf, size)
- daddr_t blk;
+ ufs2_daddr_t blk;
const char *buf;
int size;
{
@@ -442,7 +440,7 @@ bwrite(blk, buf, size)
int
bread(bno, buf, cnt)
- daddr_t bno;
+ ufs2_daddr_t bno;
char *buf;
int cnt;
{
OpenPOWER on IntegriCloud