mkfs.gfs2: Scale down journal size for smaller devices
PATCH v3 1/1 mkfs.gfs2: Scale down journal size for smaller devices
Currently the default behaviour when the journal size is not specified is to use a default size of 128M, which means that mkfs.gfs2 can run out of space while writing to a small device. The hard default also means that some xfstests fail with gfs2 as they try to create small file systems.
This patch addresses these problems by setting sensible default journal sizes depending on the size of the file system. Journal sizes specified by the user are limited to half of the fs. As the minimum journal size is 8MB that means we effectively get a hard minimum file system size of 16MB (per journal).
---
v3: Use 128M journals up to 1TB filesystems (assuming 4K blocks) and rework the
journal size ranges to be more sensible, based on Bob's feedback.
gfs2/libgfs2/libgfs2.h | 2 ++ gfs2/man/mkfs.gfs2.8 | 5 +++-- gfs2/mkfs/main_mkfs.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-- tests/edit.at | 2 +- tests/mkfs.at | 10 ++++++++++ tests/testsuite.at | 6 ++++++ 6 files changed, 74 insertions(+), 5 deletions(-)
gfs2/libgfs2/libgfs2.h +2 -0
@@ -319,6 +319,8 @@ struct metapath {#define GFS2_DEFAULT_BSIZE (4096)#define GFS2_DEFAULT_JSIZE (128) +#define GFS2_MAX_JSIZE (1024) +#define GFS2_MIN_JSIZE (8)#define GFS2_DEFAULT_RGSIZE (256)#define GFS2_DEFAULT_UTSIZE (1)#define GFS2_DEFAULT_QCSIZE (1)
gfs2/man/mkfs.gfs2.8 +3 -2
@@ -32,8 +32,9 @@ Enable debugging output. Print out a help message describing the available options, then exit. .TP \fB-J\fP \fImegabytes\fR -The size of each journal. The default journal size is 128 megabytes and the -minimum size is 8 megabytes. +The size of each journal. The minimum size is 8 megabytes and the maximum is +1024. If this is not specified, a value based on a sensible proportion of the +file system will be chosen. .TP \fB-j\fP \fIjournals\fR The number of journals for mkfs.gfs2 to create. At least one journal is
gfs2/mkfs/main_mkfs.c +52 -2
80 lines not on this page · raw message
tests/edit.at +1 -1
@@ -6,7 +6,7 @@ AT_KEYWORDS(gfs2_edit edit) GFS_TGT_REGEN AT_CHECK([$GFS_MKFS -p lock_nolock $GFS_TGT $(($(gfs_max_blocks 4096)/2))], 0, [ignore], [ignore]) AT_CHECK([gfs2_edit savemeta $GFS_TGT test.meta > savemeta.log], 0, [ignore], [ignore]) -AT_CHECK([head -2 savemeta.log], 0, [There are 1310718 blocks of 4096 bytes in the filesystem. +AT_CHECK([head -2 savemeta.log], 0, [There are 1310716 blocks of 4096 bytes in the filesystem. Filesystem size: 4.1023GB ], [ignore]) GFS_TGT_REGEN
tests/mkfs.at +10 -0
@@ -155,3 +155,13 @@ AT_CHECK([rgrifieldscheck.sh $GFS_TGT], 0, [ignore], [ignore]) AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:512:65536:393216:512 $GFS_TGT], 0, [ignore], [ignore]) AT_CHECK([rgrifieldscheck.sh $GFS_TGT], 0, [ignore], [ignore]) AT_CLEANUP + +AT_SETUP([Small filesystems]) +AT_KEYWORDS(mkfs.gfs2 mkfs) +GFS_TGT_SIZE(32M) +AT_CHECK([$GFS_MKFS -p lock_nolock $GFS_TGT], 0, [ignore], [ignore]) +AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore]) +GFS_TGT_SIZE(64M) +AT_CHECK([$GFS_MKFS -p lock_nolock -j2 $GFS_TGT], 0, [ignore], [ignore]) +AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore]) +AT_CLEANUP
tests/testsuite.at +6 -0
@@ -4,6 +4,12 @@ m4_define([GFS_TGT_REGEN], [AT_CHECK([rm -f $GFS_TGT && truncate -s ${GFS_TGT_SZ}G ${GFS_TGT}], [ignore], [ignore], [ignore]) AT_SKIP_IF([test ! -f ${GFS_TGT}])]) +# Regenerate the sparse file used for testing, with a given size, and skip the test if it fails +# Usage: GFS_TGT_REGEN(<size>) +m4_define([GFS_TGT_SIZE], +[AT_CHECK([rm -f $GFS_TGT && truncate -s $1 ${GFS_TGT}], [ignore], [ignore], [ignore]) +AT_SKIP_IF([test ! -f ${GFS_TGT}])]) + # Regenerate, check, fsck is used a lot so combine it into one macro # Usage: GFS_FSCK_CHECK ([mkfs.gfs2 ... $GFS_TGT]) m4_define([GFS_FSCK_CHECK],
Signature · 1 line
2.14.3