From 64c21cf3c812a213d74ec5ad306f1ef908a14a9e Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 27 Apr 2008 00:43:57 +0000 Subject: [PATCH] HAMMER utilities: Misc documentation and new options. * Add the -u option. This option allows the size of the undo FIFO buffer to be specified. * Document missing newfs_hammer's options. --- sbin/hammer/hammer_util.h | 3 ++- sbin/hammer/ondisk.c | 21 +++++++++++++++++++-- sbin/newfs_hammer/newfs_hammer.8 | 20 +++++++++++++++----- sbin/newfs_hammer/newfs_hammer.c | 28 ++++++++++++++++++---------- 4 files changed, 54 insertions(+), 18 deletions(-) diff --git a/sbin/hammer/hammer_util.h b/sbin/hammer/hammer_util.h index c83e16923e..e16e07d23b 100644 --- a/sbin/hammer/hammer_util.h +++ b/sbin/hammer/hammer_util.h @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sbin/hammer/hammer_util.h,v 1.12 2008/03/18 05:21:53 dillon Exp $ + * $DragonFly: src/sbin/hammer/hammer_util.h,v 1.13 2008/04/27 00:43:55 dillon Exp $ */ #include @@ -97,6 +97,7 @@ extern uuid_t Hammer_FSType; extern uuid_t Hammer_FSId; extern int64_t BootAreaSize; extern int64_t MemAreaSize; +extern int64_t UndoBufferSize; extern int NumVolumes; extern int RootVolNo; extern struct volume_list VolList; diff --git a/sbin/hammer/ondisk.c b/sbin/hammer/ondisk.c index 3374577e71..54fba33f44 100644 --- a/sbin/hammer/ondisk.c +++ b/sbin/hammer/ondisk.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sbin/hammer/ondisk.c,v 1.14 2008/03/18 05:21:53 dillon Exp $ + * $DragonFly: src/sbin/hammer/ondisk.c,v 1.15 2008/04/27 00:43:55 dillon Exp $ */ #include @@ -64,6 +64,7 @@ uuid_t Hammer_FSType; uuid_t Hammer_FSId; int64_t BootAreaSize; int64_t MemAreaSize; +int64_t UndoBufferSize; int UsingSuperClusters; int NumVolumes; int RootVolNo = -1; @@ -520,13 +521,29 @@ void format_undomap(hammer_volume_ondisk_t ondisk) { const int undo_zone = HAMMER_ZONE_UNDO_INDEX; - const hammer_off_t undo_limit = HAMMER_LARGEBLOCK_SIZE; /* XXX */ + hammer_off_t undo_limit; hammer_blockmap_t blockmap; hammer_off_t scan; struct hammer_blockmap_layer2 *layer2; int n; int limit_index; + /* + * Size the undo buffer in multiples of HAMMER_LARGEBLOCK_SIZE, + * up to HAMMER_UNDO_LAYER2 large blocks. Size to approximately + * 0.1% of the disk. + */ + undo_limit = UndoBufferSize; + if (undo_limit == 0) + undo_limit = (ondisk->vol_buf_end - ondisk->vol_buf_beg) / 1000; + undo_limit = (undo_limit + HAMMER_LARGEBLOCK_MASK64) & + ~HAMMER_LARGEBLOCK_MASK64; + if (undo_limit < HAMMER_LARGEBLOCK_SIZE) + undo_limit = HAMMER_LARGEBLOCK_SIZE; + if (undo_limit > HAMMER_LARGEBLOCK_SIZE * HAMMER_UNDO_LAYER2) + undo_limit = HAMMER_LARGEBLOCK_SIZE * HAMMER_UNDO_LAYER2; + UndoBufferSize = undo_limit; + blockmap = &ondisk->vol0_blockmap[undo_zone]; bzero(blockmap, sizeof(*blockmap)); blockmap->phys_offset = HAMMER_BLOCKMAP_UNAVAIL; diff --git a/sbin/newfs_hammer/newfs_hammer.8 b/sbin/newfs_hammer/newfs_hammer.8 index 59bf95edf6..544850503d 100644 --- a/sbin/newfs_hammer/newfs_hammer.8 +++ b/sbin/newfs_hammer/newfs_hammer.8 @@ -30,7 +30,7 @@ .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $DragonFly: src/sbin/newfs_hammer/newfs_hammer.8,v 1.5 2008/02/19 21:02:08 thomas Exp $ +.\" $DragonFly: src/sbin/newfs_hammer/newfs_hammer.8,v 1.6 2008/04/27 00:43:57 dillon Exp $ .Dd September 10, 2007 .Dt NEWFS_HAMMER 8 .Os @@ -40,7 +40,9 @@ .Sh SYNOPSIS .Nm .Fl L Ar label -.Op Fl U Ar uuid +.Op Fl b Ar bootsize +.Op Fl m Ar savesize +.Op Fl u Ar undosize .Ar special ... .Sh DESCRIPTION The @@ -61,9 +63,17 @@ The options are as follows: .It Fl L Ar label All HAMMER filesystems must be named and names should be unique on a per-machine basis. -.It Fl U Ar uuid -All HAMMER filesystems are assigned a globally unique UUID. -If no UUID is specified one will be synthesized. +.It Fl b Ar bootsize +Specify a fixed area in which a boot related kernel and data can be stored. +By default a boot area of approximately 4MB will be created. +.It Fl m Ar savesize +Specify a fixed area which HAMMER may use as a memory log. This area is +currently unused. +.It Fl u Ar undosize +Specify the size of the fixed UNDO FIFO. 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. .El .\".Sh NOTES .Sh EXAMPLES diff --git a/sbin/newfs_hammer/newfs_hammer.c b/sbin/newfs_hammer/newfs_hammer.c index bf672ecfad..654761bd9d 100644 --- a/sbin/newfs_hammer/newfs_hammer.c +++ b/sbin/newfs_hammer/newfs_hammer.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sbin/newfs_hammer/newfs_hammer.c,v 1.21 2008/03/19 20:18:16 dillon Exp $ + * $DragonFly: src/sbin/newfs_hammer/newfs_hammer.c,v 1.22 2008/04/27 00:43:57 dillon Exp $ */ #include "newfs_hammer.h" @@ -74,7 +74,7 @@ main(int ac, char **av) /* * Parse arguments */ - while ((ch = getopt(ac, av, "L:b:m:")) != -1) { + while ((ch = getopt(ac, av, "L:b:m:u:")) != -1) { switch(ch) { case 'L': label = optarg; @@ -89,6 +89,12 @@ main(int ac, char **av) HAMMER_BUFSIZE, HAMMER_MEM_MAXBYTES, 2); break; + case 'u': + UndoBufferSize = getsize(optarg, + HAMMER_LARGEBLOCK_SIZE, + HAMMER_LARGEBLOCK_SIZE * + HAMMER_UNDO_LAYER2, 2); + break; default: usage(); break; @@ -145,13 +151,6 @@ main(int ac, char **av) MemAreaSize = HAMMER_MEM_MINBYTES; } - printf("---------------------------------------------\n"); - printf("%d volume%s total size %s\n", - NumVolumes, (NumVolumes == 1 ? "" : "s"), sizetostr(total)); - printf("boot-area-size: %s\n", sizetostr(BootAreaSize)); - printf("memory-log-size: %s\n", sizetostr(MemAreaSize)); - printf("\n"); - /* * Format the volumes. Format the root volume first so we can * bootstrap the freemap. @@ -161,6 +160,14 @@ main(int ac, char **av) if (i != RootVolNo) format_volume(get_volume(i), NumVolumes, label); } + printf("---------------------------------------------\n"); + printf("%d volume%s total size %s\n", + NumVolumes, (NumVolumes == 1 ? "" : "s"), sizetostr(total)); + printf("boot-area-size: %s\n", sizetostr(BootAreaSize)); + printf("memory-log-size: %s\n", sizetostr(MemAreaSize)); + printf("undo-buffer-size: %s\n", sizetostr(UndoBufferSize)); + printf("\n"); + flush_all_volumes(); return(0); } @@ -176,7 +183,8 @@ usage(void) /* * Convert the size in bytes to a human readable string. */ -static const char * +static +const char * sizetostr(off_t size) { static char buf[32]; -- 2.41.0