Skip to contentSkip to conversation

common/rc: Further improve gfs2 support

PATCH New Andreas Gruenbacher 1 participant 1 message Oct 4, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/rc: Further improve gfs2 support

---
 common/rc | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
common/rc +14 -2
index 53bbb118..95d4306e 100644
@@ -1056,7 +1056,19 @@ _scratch_mkfs_sized()
 	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
 	;;
     gfs2)
-	yes | ${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+	# mkfs.gfs2 doesn't automatically shrink journal files on small
+	# filesystems, so the journal files may end up being bigger than the
+	# filesystem, which will cause mkfs.gfs2 to fail.  Until that's fixed,
+	# shrink the journal size to at most one eigth of the filesystem and at
+	# least 8 MiB, the minimum size allowed.
+	MIN_JOURNAL_SIZE=8
+	DEFAULT_JOURNAL_SIZE=128
+	if (( fssize/8 / (1024*1024) < DEFAULT_JOURNAL_SIZE )); then
+	    (( JOURNAL_SIZE = fssize/8 / (1024*1024) ))
+	    (( JOURNAL_SIZE >= MIN_JOURNAL_SIZE )) || JOURNAL_SIZE=$MIN_JOURNAL_SIZE
+	    MKFS_OPTIONS="-J $JOURNAL_SIZE $MKFS_OPTIONS"
+	fi
+	${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -O -b $blocksize $SCRATCH_DEV $blocks
 	;;
     ocfs2)
 	yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
@@ -1143,7 +1155,7 @@ _scratch_mkfs_blocksized()
 	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
 	;;
     gfs2)
-	yes | ${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
+	${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -O -b $blocksize $SCRATCH_DEV
 	;;
     ocfs2)
 	yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize -C $blocksize $SCRATCH_DEV
Signature · 1 line
2.13.5