Blame SOURCES/bz1440269-2-mkfs_gfs2_Fix_resource_group_alignment_issue.patch

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