Blame SOURCES/bz1440269-2-mkfs_gfs2_Fix_resource_group_alignment_issue.patch

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