This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 8c8c724a53e6a832232335d72f634e12d57f3ea9
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Aug 11 13:17:50 2020 +0100
mkfs.gfs2: Don't exceed IOV_MAX when zeroing first alignment gap
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 <anprice(a)redhat.com>
---
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 36fd08e..3fb2eb9 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 4c8b224..96c4f6a 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])
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.