From: Andrew Price Date: Tue, 11 Aug 2020 13:27:15 +0100 Subject: [Cluster-devel] [PATCH] mkfs.gfs2: Don't exceed IOV_MAX when zeroing first alignment gap Message-ID: <20200811122715.373661-1-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit The first resource group can be aligned far away from the superblock when the device has large stripes, and zeroing that gap with a small block size can mean that the iovec used exceeds IOV_MAX and causes pwritev to fail with EINVAL. Split the writes to guard against that. Signed-off-by: Andrew Price --- gfs2/mkfs/main_mkfs.c | 13 ++++++++++--- tests/mkfs.at | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c index 36fd08e7..3fb2eb92 100644 --- a/gfs2/mkfs/main_mkfs.c +++ b/gfs2/mkfs/main_mkfs.c @@ -711,9 +711,16 @@ static int place_rgrp(struct gfs2_sbd *sdp, lgfs2_rgrp_t rg, int debug) prev_end = lgfs2_rgrp_index(prev)->ri_data0 + lgfs2_rgrp_index(prev)->ri_data; } - err = zero_gap(sdp, prev_end, ri->ri_addr - prev_end); - if (err != 0) - return -1; + while (prev_end < ri->ri_addr) { + size_t gap_len = ri->ri_addr - prev_end; + + if (gap_len > IOV_MAX) + gap_len = IOV_MAX; + err = zero_gap(sdp, prev_end, gap_len); + if (err != 0) + return -1; + prev_end += gap_len; + } err = lgfs2_rgrp_write(sdp->device_fd, rg); if (err != 0) { perror(_("Failed to write resource group")); diff --git a/tests/mkfs.at b/tests/mkfs.at index 4c8b2249..96c4f6ab 100644 --- a/tests/mkfs.at +++ b/tests/mkfs.at @@ -117,6 +117,7 @@ AT_CHECK([gfs2_edit -p sb field sb_bsize $GFS_TGT | tr -d '\n' ], 0, [4096], [ig AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=7168:512:0:33553920:512 $GFS_TGT], 0, [ignore], [ignore]) 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_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:512:4194304:8388608:512 -b 1024 $GFS_TGT], 0, [ignore], [ignore]) AT_CLEANUP AT_SETUP([Resource group alignment]) -- 2.26.2