Blame SOURCES/bz1440269-2-mkfs_gfs2_Fix_resource_group_alignment_issue.patch

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