Blame SOURCES/bz1839219-mkfs_gfs2_Don_t_use_i_o_limits_hints_4K_for_block_size.patch

9757e7
commit b33f8871a821b7f0461dec89f0066a9cb6aa1c71
9757e7
Author: Andrew Price <anprice@redhat.com>
9757e7
Date:   Wed May 27 12:31:58 2020 +0100
9757e7
9757e7
    mkfs.gfs2: Don't use i/o limits hints <4K for block size
9757e7
    
9757e7
    Some devices report an optimal_io_size less than 4K. Currently mkfs.gfs2
9757e7
    uses the non-zero value to choose the block size, which is almost
9757e7
    certainly a bad choice when it's less than 4K. Update choose_blocksize()
9757e7
    to avoid using device topology hints for the block size choice when
9757e7
    they're less than the default block size (4K). Test case included.
9757e7
    
9757e7
    Resolves: rhbz#1839219
9757e7
    Signed-off-by: Andrew Price <anprice@redhat.com>
9757e7
9757e7
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
9757e7
index 846b341f..412d4701 100644
9757e7
--- a/gfs2/mkfs/main_mkfs.c
9757e7
+++ b/gfs2/mkfs/main_mkfs.c
9757e7
@@ -505,7 +505,7 @@ static unsigned choose_blocksize(struct mkfs_opts *opts)
9757e7
 	}
9757e7
 	if (!opts->got_bsize && got_topol) {
9757e7
 		if (dev->optimal_io_size <= getpagesize() &&
9757e7
-		    dev->optimal_io_size >= dev->minimum_io_size)
9757e7
+		    dev->optimal_io_size >= GFS2_DEFAULT_BSIZE)
9757e7
 			bsize = dev->optimal_io_size;
9757e7
 		else if (dev->physical_sector_size <= getpagesize() &&
9757e7
 		         dev->physical_sector_size >= GFS2_DEFAULT_BSIZE)
9757e7
diff --git a/tests/mkfs.at b/tests/mkfs.at
9757e7
index 57785a0d..4c8b2249 100644
9757e7
--- a/tests/mkfs.at
9757e7
+++ b/tests/mkfs.at
9757e7
@@ -112,6 +112,8 @@ AT_CLEANUP
9757e7
 AT_SETUP([Device i/o limits handling])
9757e7
 AT_KEYWORDS(mkfs.gfs2 mkfs)
9757e7
 AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:0:0:0:0 $GFS_TGT], 0, [ignore], [ignore])
9757e7
+AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:512:512:512:512 $GFS_TGT], 0, [ignore], [ignore])
9757e7
+AT_CHECK([gfs2_edit -p sb field sb_bsize $GFS_TGT | tr -d '\n' ], 0, [4096], [ignore])
9757e7
 AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=7168:512:0:33553920:512 $GFS_TGT], 0, [ignore], [ignore])
9757e7
 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.
9757e7
 ])