From: Matthew Dillon Date: Sun, 28 Jun 2009 18:53:45 +0000 (-0700) Subject: HAMMER - newfs_hammer - format with highest production version available X-Git-Tag: v2.3.2~75 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/47921633e56ed7030611d658b8b38e2737e5c0b3 HAMMER - newfs_hammer - format with highest production version available * newfs_hammer now probes the HAMMER VFS and uses the highest production version supported to format the HAMMER filesystem. --- diff --git a/sbin/newfs_hammer/newfs_hammer.8 b/sbin/newfs_hammer/newfs_hammer.8 index 44e241c4da..a928d9a97b 100644 --- a/sbin/newfs_hammer/newfs_hammer.8 +++ b/sbin/newfs_hammer/newfs_hammer.8 @@ -44,6 +44,7 @@ .Op Fl f .Op Fl m Ar savesize .Op Fl u Ar undosize +.Op Fl V Ar version .Ar special ... .Sh DESCRIPTION The @@ -129,6 +130,14 @@ By default 0.1% of the root volume's size is used, with a reasonable minimum and a reasonable cap. The UNDO FIFO is used to sequence meta-data out to the media for instant crash recovery. +.It Fl V Ar version +Specify the HAMMER filesystem version to format. By default +.Nm +formats the filesystem using the highest production version number +supported by the HAMMER VFS by checking the vfs.hammer.supported_version +sysctl. +If you need to maintain compatibility with an older version of HAMMER +you may specify the version with this option. .El .Pp The diff --git a/sbin/newfs_hammer/newfs_hammer.c b/sbin/newfs_hammer/newfs_hammer.c index b6f4eb5902..9758dd9cdf 100644 --- a/sbin/newfs_hammer/newfs_hammer.c +++ b/sbin/newfs_hammer/newfs_hammer.c @@ -46,6 +46,7 @@ static u_int64_t nowtime(void); static void usage(void); static int ForceOpt = 0; +static int HammerVersion = -1; #define GIG (1024LL*1024*1024) @@ -81,7 +82,7 @@ main(int ac, char **av) /* * Parse arguments */ - while ((ch = getopt(ac, av, "fL:b:m:u:")) != -1) { + while ((ch = getopt(ac, av, "fL:b:m:u:V:")) != -1) { switch(ch) { case 'f': ForceOpt = 1; @@ -113,6 +114,16 @@ main(int ac, char **av) "lead to VFS panics.\n"); } break; + case 'V': + HammerVersion = strtol(optarg, NULL, 0); + if (HammerVersion < HAMMER_VOL_VERSION_MIN || + HammerVersion >= HAMMER_VOL_VERSION_WIP) { + errx(1, + "I don't understand how to format " + "HAMMER version %d\n", + HammerVersion); + } + break; default: usage(); break; @@ -125,6 +136,29 @@ main(int ac, char **av) exit(1); } + if (HammerVersion < 0) { + size_t olen = sizeof(HammerVersion); + HammerVersion = HAMMER_VOL_VERSION_DEFAULT; + if (sysctlbyname("vfs.hammer.supported_version", + &HammerVersion, &olen, NULL, 0) == 0) { + if (HammerVersion >= HAMMER_VOL_VERSION_WIP) { + HammerVersion = HAMMER_VOL_VERSION_WIP - 1; + fprintf(stderr, + "newfs_hammer: WARNING: HAMMER VFS " + "supports higher version then I " + "understand,\n" + "using version %d\n", + HammerVersion); + } + } else { + fprintf(stderr, + "newfs_hammer: WARNING: HAMMER VFS not " + "loaded, cannot get version info.\n" + "Using version %d\n", + HAMMER_VOL_VERSION_DEFAULT); + } + } + /* * Collect volume information */ @@ -195,8 +229,9 @@ main(int ac, char **av) uuid_to_string(&Hammer_FSId, &fsidstr, &status); printf("---------------------------------------------\n"); - printf("%d volume%s total size %s\n", - NumVolumes, (NumVolumes == 1 ? "" : "s"), sizetostr(total)); + printf("%d volume%s total size %s version %d\n", + NumVolumes, (NumVolumes == 1 ? "" : "s"), + sizetostr(total), HammerVersion); printf("boot-area-size: %s\n", sizetostr(BootAreaSize)); printf("memory-log-size: %s\n", sizetostr(MemAreaSize)); printf("undo-buffer-size: %s\n", sizetostr(UndoBufferSize)); @@ -423,7 +458,7 @@ format_volume(struct volume_info *vol, int nvols, const char *label, snprintf(ondisk->vol_name, sizeof(ondisk->vol_name), "%s", label); ondisk->vol_no = vol->vol_no; ondisk->vol_count = nvols; - ondisk->vol_version = HAMMER_VOL_VERSION_DEFAULT; + ondisk->vol_version = HammerVersion; ondisk->vol_bot_beg = vol->vol_alloc; vol->vol_alloc += BootAreaSize; @@ -528,6 +563,8 @@ format_root(const char *label) idata->obj_type = HAMMER_OBJTYPE_DIRECTORY; idata->size = 0; idata->nlinks = 1; + if (HammerVersion >= HAMMER_VOL_VERSION_TWO) + idata->cap_flags |= HAMMER_INODE_CAP_DIR_LOCAL_INO; pfsd->sync_low_tid = 1; pfsd->sync_beg_tid = 0; diff --git a/sbin/newfs_hammer/newfs_hammer.h b/sbin/newfs_hammer/newfs_hammer.h index 5bc3802cdc..4ace7fd1a3 100644 --- a/sbin/newfs_hammer/newfs_hammer.h +++ b/sbin/newfs_hammer/newfs_hammer.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include