summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-08-29 16:03:49 -0700
committerZorro Lang <zlang@kernel.org>2023-09-02 13:54:38 +0800
commit2848174358e542de0ad18c42cd79f7208ae93711 (patch)
tree97c76ff833d5ee3423c10eec3768de1909e54d0a
parent225170dbbc688b36a57bf4fd3eb67ef6e5705f28 (diff)
xfs/559: adapt to kernels that use large folios for writesv2023.09.03
The write invalidation code in iomap can only be triggered for writes that span multiple folios. If the kernel reports a huge page size, scale up the write size. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
-rwxr-xr-xtests/xfs/55929
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/xfs/559 b/tests/xfs/559
index cffe5045..64fc16eb 100755
--- a/tests/xfs/559
+++ b/tests/xfs/559
@@ -42,11 +42,38 @@ $XFS_IO_PROG -c 'chattr -x' $SCRATCH_MNT &> $seqres.full
_require_pagecache_access $SCRATCH_MNT
blocks=10
-blksz=$(_get_page_size)
+
+# If this kernel advertises huge page support, it's possible that it could be
+# using large folios for the page cache writes. It is necessary to write
+# multiple folios (large or regular) to triggering the write invalidation,
+# so we'll scale the test write size accordingly.
+blksz=$(_get_hugepagesize)
+base_pagesize=$(_get_page_size)
+test -z "$blksz" && blksz=${base_pagesize}
filesz=$((blocks * blksz))
dirty_offset=$(( filesz - 1 ))
write_len=$(( ( (blocks - 1) * blksz) + 1 ))
+# The write invalidation that we're testing below can only occur as part of
+# a single large write. The kernel limits writes to one base page less than
+# 2GiB to prevent lengthy IOs and integer overflows. If the block size is so
+# huge (e.g. 512M huge pages on arm64) that we'd exceed that, reduce the number
+# of blocks to get us under the limit.
+max_writesize=$((2147483647 - base_pagesize))
+if ((write_len > max_writesize)); then
+ blocks=$(( ( (max_writesize - 1) / blksz) + 1))
+ # We need at least three blocks in the file to test invalidation
+ # between writes to multiple folios. If we drop below that,
+ # reconfigure ourselves with base pages and hope for the best.
+ if ((blocks < 3)); then
+ blksz=$base_pagesize
+ blocks=10
+ fi
+ filesz=$((blocks * blksz))
+ dirty_offset=$(( filesz - 1 ))
+ write_len=$(( ( (blocks - 1) * blksz) + 1 ))
+fi
+
# Create a large file with a large unwritten range.
$XFS_IO_PROG -f -c "falloc 0 $filesz" $SCRATCH_MNT/file >> $seqres.full