summaryrefslogtreecommitdiffstats
path: root/sbin/tunefs/tunefs.c
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2013-03-22 21:45:28 +0000
committermckusick <mckusick@FreeBSD.org>2013-03-22 21:45:28 +0000
commitbe2f56b8d7746e3a931d3f607c34cf88e72f901b (patch)
tree4dd79ec73ca7a215a3694baba70bbfe162604d09 /sbin/tunefs/tunefs.c
parent82edd7c36328fd70dad3a7c7b7e7f8de433ce40b (diff)
downloadFreeBSD-src-be2f56b8d7746e3a931d3f607c34cf88e72f901b.zip
FreeBSD-src-be2f56b8d7746e3a931d3f607c34cf88e72f901b.tar.gz
The purpose of this change to the FFS layout policy is to reduce the
running time for a full fsck. It also reduces the random access time for large files and speeds the traversal time for directory tree walks. The key idea is to reserve a small area in each cylinder group immediately following the inode blocks for the use of metadata, specifically indirect blocks and directory contents. The new policy is to preferentially place metadata in the metadata area and everything else in the blocks that follow the metadata area. The size of this area can be set when creating a filesystem using newfs(8) or changed in an existing filesystem using tunefs(8). Both utilities use the `-k held-for-metadata-blocks' option to specify the amount of space to be held for metadata blocks in each cylinder group. By default, newfs(8) sets this area to half of minfree (typically 4% of the data area). This work was inspired by a paper presented at Usenix's FAST '13: www.usenix.org/conference/fast13/ffsck-fast-file-system-checker Details of this implementation appears in the April 2013 of ;login: www.usenix.org/publications/login/april-2013-volume-38-number-2. A copy of the April 2013 ;login: paper can also be downloaded from: www.mckusick.com/publications/faster_fsck.pdf. Reviewed by: kib Tested by: Peter Holm MFC after: 4 weeks
Diffstat (limited to 'sbin/tunefs/tunefs.c')
-rw-r--r--sbin/tunefs/tunefs.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c
index 39e08f7..0671d1d 100644
--- a/sbin/tunefs/tunefs.c
+++ b/sbin/tunefs/tunefs.c
@@ -89,10 +89,9 @@ main(int argc, char *argv[])
const char *special, *on;
const char *name;
int active;
- int Aflag, aflag, eflag, evalue, fflag, fvalue, jflag, Jflag, Lflag;
- int lflag, mflag, mvalue, Nflag, nflag, oflag, ovalue, pflag, sflag;
- int tflag;
- int svalue, Svalue;
+ int Aflag, aflag, eflag, evalue, fflag, fvalue, jflag, Jflag, kflag;
+ int kvalue, Lflag, lflag, mflag, mvalue, Nflag, nflag, oflag, ovalue;
+ int pflag, sflag, svalue, Svalue, tflag;
int ch, found_arg, i;
const char *chg[2];
struct ufs_args args;
@@ -100,13 +99,13 @@ main(int argc, char *argv[])
if (argc < 3)
usage();
- Aflag = aflag = eflag = fflag = jflag = Jflag = Lflag = lflag = 0;
- mflag = Nflag = nflag = oflag = pflag = sflag = tflag = 0;
+ Aflag = aflag = eflag = fflag = jflag = Jflag = kflag = Lflag = 0;
+ lflag = mflag = Nflag = nflag = oflag = pflag = sflag = tflag = 0;
avalue = jvalue = Jvalue = Lvalue = lvalue = Nvalue = nvalue = NULL;
evalue = fvalue = mvalue = ovalue = svalue = Svalue = 0;
active = 0;
found_arg = 0; /* At least one arg is required. */
- while ((ch = getopt(argc, argv, "Aa:e:f:j:J:L:l:m:N:n:o:ps:S:t:"))
+ while ((ch = getopt(argc, argv, "Aa:e:f:j:J:k:L:l:m:N:n:o:ps:S:t:"))
!= -1)
switch (ch) {
@@ -171,6 +170,14 @@ main(int argc, char *argv[])
Jflag = 1;
break;
+ case 'k':
+ found_arg = 1;
+ name = "space to hold for metadata blocks";
+ kvalue = atoi(optarg);
+ if (mvalue < 0)
+ errx(10, "bad %s (%s)", name, optarg);
+ kflag = 1;
+ break;
case 'L':
found_arg = 1;
@@ -404,6 +411,22 @@ main(int argc, char *argv[])
}
}
}
+ if (kflag) {
+ name = "space to hold for metadata blocks";
+ if (sblock.fs_metaspace == kvalue)
+ warnx("%s remains unchanged as %d", name, kvalue);
+ else {
+ kvalue = blknum(&sblock, kvalue);
+ if (kvalue > sblock.fs_fpg / 2) {
+ kvalue = blknum(&sblock, sblock.fs_fpg / 2);
+ warnx("%s cannot exceed half the file system "
+ "space", name);
+ }
+ warnx("%s changes from %jd to %d",
+ name, sblock.fs_metaspace, kvalue);
+ sblock.fs_metaspace = kvalue;
+ }
+ }
if (lflag) {
name = "multilabel";
if (strcmp(lvalue, "enable") == 0) {
@@ -1064,7 +1087,7 @@ usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n",
"usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]",
-" [-J enable | disable] [-j enable | disable]",
+" [-J enable | disable] [-j enable | disable] [-k metaspace]",
" [-L volname] [-l enable | disable] [-m minfree]",
" [-N enable | disable] [-n enable | disable]",
" [-o space | time] [-p] [-s avgfpdir] [-t enable | disable]",
@@ -1097,6 +1120,8 @@ printfs(void)
sblock.fs_avgfpdir);
warnx("minimum percentage of free space: (-m) %d%%",
sblock.fs_minfree);
+ warnx("space to hold for metadata blocks: (-k) %jd",
+ sblock.fs_metaspace);
warnx("optimization preference: (-o) %s",
sblock.fs_optim == FS_OPTSPACE ? "space" : "time");
if (sblock.fs_minfree >= MINFREE &&
OpenPOWER on IntegriCloud