commit 896a2f709141728355c2a1e8cdf377c51573de05 Author: Andrew Price Date: Thu Apr 13 07:42:18 2017 -0400 mkfs.gfs2: Fix resource group alignment issue Make sure the resource groups created when allocating the journals have an aligned length to avoid subsequent resource groups start addresses getting misaligned. This can cause read-modify-write issues during mkfs and likely in other situations, harming performance. Test case included. Resolves: rhbz#1440269 Signed-off-by: Andrew Price diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c index 83065fb..2e08bc6 100644 --- a/gfs2/mkfs/main_mkfs.c +++ b/gfs2/mkfs/main_mkfs.c @@ -721,6 +721,7 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o if (mkfs_journals == NULL) return 1; *rgaddr = lgfs2_rgrp_align_addr(rgs, sdp->sb_addr + 1); + rgsize = lgfs2_rgrp_align_len(rgs, rgsize); for (j = 0; j < opts->journals; j++) { int result; diff --git a/tests/mkfs.at b/tests/mkfs.at index c026a76..274a81d 100644 --- a/tests/mkfs.at +++ b/tests/mkfs.at @@ -102,6 +102,13 @@ AT_CHECK([$GFS_MKFS -p lock_dlm -t "financial_cluster:this_time_we_test_fs_namin GFS_FSCK_CHECK([$GFS_MKFS -p lock_dlm -t "a_really_long_named_cluster_here:concurrently_lets_check_fs_len" $GFS_TGT]) AT_CLEANUP +# -o test_topology order: +# alignment_offset, +# logical_sector_size, +# minimum_io_size, +# optimal_io_size, +# physical_sector_size + AT_SETUP([Device i/o limits handling]) AT_KEYWORDS(mkfs.gfs2 mkfs) AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:0:0:0:0 $GFS_TGT], 0, [ignore], [ignore]) @@ -109,3 +116,10 @@ AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=7168:512:0:33553920:512 $GFS AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=7168:512:8192:33553920:512 $GFS_TGT], 0, [ignore], [Warning: device is not properly aligned. This may harm performance. ]) AT_CLEANUP + +AT_SETUP([Resource group alignment]) +AT_KEYWORDS(mkfs.gfs2 mkfs) +AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:512:65536:393216:512 $GFS_TGT], 0, [ignore], [ignore]) +# Check rgrp alignment to minimum_io_size: 65536 / 4096 == 16 +AT_CHECK([gfs2_edit -p rindex $GFS_TGT | grep ri_addr | awk '{print $2, $2 % 16; if ($2 % 16 != 0) { exit 1 }}'], 0, [ignore], [ignore]) +AT_CLEANUP