From: Oleg Drokin Date: Mon, 11 Jan 2021 23:57:40 +0000 (-0500) Subject: LU-14324 tests: Fix fsx fallocate detection X-Git-Tag: 2.14.0-RC1~26 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=e5f8487ec3e0cbd01cfdeca183f244b1a5dedbc5;hp=98015004516cad1173e2bac2a4695bdc56e4d9a4 LU-14324 tests: Fix fsx fallocate detection Avoid kernel playing fake tricks on us by optimizing away small increases in file size by fallocate, so to ensure the truth make large fallocate call instead. Additionally always truncate to zero after all call, as even a failed call can result in increased file size. Test-Parameters: trivial testlist=sanity env=ONLY=150 Test-Parameters: testlist=sanityn env=ONLY=16,COUNT=10000 Test-Parameters: testlist=sanity-dom env=ONLY=fsx,sanityn,SANITYN_ONLY=16 Test-Parameters: fstype=zfs testlist=sanity env=ONLY=150 Test-Parameters: fstype=zfs testlist=sanityn env=ONLY=16,COUNT=10000 Test-Parameters: fstype=zfs testlist=sanity-dom env=ONLY=fsx,sanityn,SANITYN_ONLY=16 Change-Id: I8cddb7d0d30bdf89bf13d18ae36a5f950adc392d Fixes: 03247bda765c ("LU-14286 osd-ldiskfs: fallocate() should zero new blocks") Signed-off-by: Oleg Drokin Reviewed-on: https://review.whamcloud.com/41202 Reviewed-by: Andreas Dilger Tested-by: jenkins Reviewed-by: Arshad Hussain Tested-by: Maloo --- diff --git a/lustre/tests/fsx.c b/lustre/tests/fsx.c index 2f765c0..66e1de5 100644 --- a/lustre/tests/fsx.c +++ b/lustre/tests/fsx.c @@ -1526,7 +1526,8 @@ test_fallocate(int mode) int fd = get_fd(); if (!lite) { - if (fallocate(fd, mode, 0, 1) && errno == EOPNOTSUPP) { + /* Must go more than a page away so let's go 4M to be sure */ + if (fallocate(fd, mode, 0, 4096*1024) && errno == EOPNOTSUPP) { if (!quiet) warn("%s: filesystem does not support fallocate mode 0x%x, disabling!", __func__, mode); @@ -1534,8 +1535,10 @@ test_fallocate(int mode) ret = 1; } - /* Call truncate only when fallocate succeeds */ - if (ret == 1 && ftruncate(fd, 0) == -1) + /* Always call ftruncate since file size might be adjusted + * by fallocate even on error + */ + if (ftruncate(fd, 0) == -1) warn("ftruncate to 0 size failed"); } return ret;