* [PATCH v3] generic: fallocate two bytes at block boundary
@ 2019-09-27 10:38 Max Reitz
2019-09-29 3:18 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Max Reitz @ 2019-09-27 10:38 UTC (permalink / raw)
To: fstests; +Cc: Max Reitz
Allocating two bytes at a block boundary with fallocate should allocate
both blocks involved. Test this by writing data to both bytes
afterwards and see whether the on-disk size increases (it should not).
This is a regression test for the kernel patch "xfs: Fix tail rounding
in xfs_alloc_file_space()".
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
v3:
- Use test directory instead of scratch mount
- Add reference to the corresponding XFS patch to the commit message
- Add test to the "prealloc" group
v2:
- Use _get_file_block_size instead of manual stat -fc '%S'
- Use xfs_io instead of fallocate/dd
(and require falloc support)
- Add the ' B' that was missing as allocated_size_after's unit in the
error message
---
tests/generic/568 | 60 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/568.out | 4 +++
tests/generic/group | 1 +
3 files changed, 65 insertions(+)
create mode 100755 tests/generic/568
create mode 100644 tests/generic/568.out
diff --git a/tests/generic/568 b/tests/generic/568
new file mode 100755
index 00000000..a3c0b4ae
--- /dev/null
+++ b/tests/generic/568
@@ -0,0 +1,60 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Red Hat, Inc. All Rights Reserved.
+#
+# FS QA Test No. generic/568
+#
+# Test that fallocating an unaligned range allocates all blocks
+# touched by that range
+#
+seq=$(basename $0)
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=$PWD
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ cd /
+ rm -f "$tmp".*
+ rm -f "$TEST_DIR/falloctest-$seq"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_xfs_io_command "falloc"
+
+testfile="$TEST_DIR/falloctest-$seq"
+
+# Fallocate 2 bytes across a block boundary
+block_size=$(_get_file_block_size "$TEST_DIR")
+$XFS_IO_PROG -f -c "falloc $((block_size - 1)) 2" "$testfile"
+
+# Both the first blocks should be allocated now. Check that by
+# inquiring whether the file grows when we write to the two bytes we
+# have just fallocated.
+
+allocated_size_before=$(($(stat -c '%b * %B' "$testfile")))
+
+$XFS_IO_PROG -c "pwrite $((block_size - 1)) 2" "$testfile" \
+ | _filter_xfs_io | sed -e "s/$((block_size - 1))/block_size - 1/"
+
+allocated_size_after=$(($(stat -c '%b * %B' "$testfile")))
+
+if [ $allocated_size_after -gt $allocated_size_before ]; then
+ echo "ERROR: File grew from ${allocated_size_before} B to" \
+ "${allocated_size_after} B when writing to the fallocated range."
+else
+ echo "OK: File did not grow."
+fi
+
+status=0
+exit
diff --git a/tests/generic/568.out b/tests/generic/568.out
new file mode 100644
index 00000000..435a9630
--- /dev/null
+++ b/tests/generic/568.out
@@ -0,0 +1,4 @@
+QA output created by 568
+wrote 2/2 bytes at offset block_size - 1
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+OK: File did not grow.
diff --git a/tests/generic/group b/tests/generic/group
index 7cf4f6c4..dd971f0c 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -570,3 +570,4 @@
565 auto quick copy_range
566 auto quick quota metadata
567 auto quick rw punch
+568 auto quick rw prealloc
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] generic: fallocate two bytes at block boundary
2019-09-27 10:38 [PATCH v3] generic: fallocate two bytes at block boundary Max Reitz
@ 2019-09-29 3:18 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2019-09-29 3:18 UTC (permalink / raw)
To: Max Reitz; +Cc: fstests
On Fri, Sep 27, 2019 at 12:38:46PM +0200, Max Reitz wrote:
> Allocating two bytes at a block boundary with fallocate should allocate
> both blocks involved. Test this by writing data to both bytes
> afterwards and see whether the on-disk size increases (it should not).
>
> This is a regression test for the kernel patch "xfs: Fix tail rounding
> in xfs_alloc_file_space()".
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> v3:
> - Use test directory instead of scratch mount
> - Add reference to the corresponding XFS patch to the commit message
> - Add test to the "prealloc" group
>
> v2:
> - Use _get_file_block_size instead of manual stat -fc '%S'
> - Use xfs_io instead of fallocate/dd
> (and require falloc support)
> - Add the ' B' that was missing as allocated_size_after's unit in the
> error message
> ---
> tests/generic/568 | 60 +++++++++++++++++++++++++++++++++++++++++++
> tests/generic/568.out | 4 +++
> tests/generic/group | 1 +
> 3 files changed, 65 insertions(+)
> create mode 100755 tests/generic/568
> create mode 100644 tests/generic/568.out
>
> diff --git a/tests/generic/568 b/tests/generic/568
> new file mode 100755
> index 00000000..a3c0b4ae
> --- /dev/null
> +++ b/tests/generic/568
> @@ -0,0 +1,60 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2019 Red Hat, Inc. All Rights Reserved.
> +#
> +# FS QA Test No. generic/568
> +#
> +# Test that fallocating an unaligned range allocates all blocks
> +# touched by that range
> +#
> +seq=$(basename $0)
> +seqres="$RESULT_DIR/$seq"
> +echo "QA output created by $seq"
> +
> +here=$PWD
> +tmp=/tmp/$$
> +status=1 # failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> + cd /
> + rm -f "$tmp".*
> + rm -f "$TEST_DIR/falloctest-$seq"
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs generic
> +_supported_os Linux
> +_require_xfs_io_command "falloc"
> +
> +testfile="$TEST_DIR/falloctest-$seq"
> +
> +# Fallocate 2 bytes across a block boundary
> +block_size=$(_get_file_block_size "$TEST_DIR")
> +$XFS_IO_PROG -f -c "falloc $((block_size - 1)) 2" "$testfile"
> +
> +# Both the first blocks should be allocated now. Check that by
> +# inquiring whether the file grows when we write to the two bytes we
> +# have just fallocated.
> +
> +allocated_size_before=$(($(stat -c '%b * %B' "$testfile")))
> +
> +$XFS_IO_PROG -c "pwrite $((block_size - 1)) 2" "$testfile" \
> + | _filter_xfs_io | sed -e "s/$((block_size - 1))/block_size - 1/"
> +
> +allocated_size_after=$(($(stat -c '%b * %B' "$testfile")))
> +
> +if [ $allocated_size_after -gt $allocated_size_before ]; then
> + echo "ERROR: File grew from ${allocated_size_before} B to" \
> + "${allocated_size_after} B when writing to the fallocated range."
> +else
> + echo "OK: File did not grow."
> +fi
> +
> +status=0
> +exit
> diff --git a/tests/generic/568.out b/tests/generic/568.out
> new file mode 100644
> index 00000000..435a9630
> --- /dev/null
> +++ b/tests/generic/568.out
> @@ -0,0 +1,4 @@
> +QA output created by 568
> +wrote 2/2 bytes at offset block_size - 1
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +OK: File did not grow.
> diff --git a/tests/generic/group b/tests/generic/group
> index 7cf4f6c4..dd971f0c 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -570,3 +570,4 @@
> 565 auto quick copy_range
> 566 auto quick quota metadata
> 567 auto quick rw punch
> +568 auto quick rw prealloc
> --
> 2.21.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-29 3:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-27 10:38 [PATCH v3] generic: fallocate two bytes at block boundary Max Reitz
2019-09-29 3:18 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).