From: "Darrick J. Wong" <djwong@kernel.org>
To: Pavel Reichl <preichl@redhat.com>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH v4 1/2] common: new helper to alloacate fixed size files
Date: Wed, 21 Sep 2022 17:27:49 -0700 [thread overview]
Message-ID: <YyusBYYvkBA0qEF4@magnolia> (raw)
In-Reply-To: <20220921141025.920599-2-preichl@redhat.com>
On Wed, Sep 21, 2022 at 04:10:24PM +0200, Pavel Reichl wrote:
> Helper that creates files of specified size using falloc if supported,
> otherwise pwrite is used.
>
> Signed-off-by: Pavel Reichl <preichl@redhat.com>
> ---
> common/rc | 22 ++++++++++++++++++++++
> tests/generic/694 | 8 +++++++-
> 2 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/common/rc b/common/rc
> index a25cbcd0..3d4587b7 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -4925,6 +4925,28 @@ hexdump()
> _fail "Use _hexdump(), please!"
> }
>
> +# Try to create a file with inode->i_blocks = $length. There may be some small
Nit: It's really trying to create a file with i_blocks >= (length/blocksize).
> +# overhead, e.g. ext2 filesystem allocates a substantial number of blocks
> +# to store block mappings. Those are accounted to i_blocks.
> +_create_file_sized()
> +{
> + local length=$1
> + local file=$2
> + local tmp=`mktemp -u`
> + local ret=0
> +
> + $XFS_IO_PROG -ft -c "falloc 0 $length" $file >$tmp.out 2>&1
> + ret=$?
> + if (grep -Eq "Operation not supported|command .* not found" $tmp.out);then
> + # fallocate isn't supported, fallback to general buffer write
> + $XFS_IO_PROG -ft -c "pwrite 0 $length" $file >$tmp.out 2>&1
> + ret=$?
> + fi
> + [ $ret -ne 0 ] && cat $tmp.out
> + rm -f $tmp.out
> + return $ret
> +}
> +
> init_rc
>
> ################################################################################
> diff --git a/tests/generic/694 b/tests/generic/694
> index dfd988df..09fb9e71 100755
> --- a/tests/generic/694
> +++ b/tests/generic/694
> @@ -21,6 +21,9 @@ _cleanup()
> }
>
> _supported_fs generic
> +_fixed_by_kernel_commit 0c336d6e33f4 \
> + "exfat: fix incorrect loading of i_blocks for large file"
> +
> _require_test
> _require_fs_space $TEST_DIR $((4 * 1024 * 1024)) #kB
>
> @@ -30,7 +33,10 @@ junk_dir=$TEST_DIR/$seq
> junk_file=$junk_dir/junk
> mkdir -p $junk_dir
>
> -$XFS_IO_PROG -f -c "pwrite -W 0 4G" $junk_file > /dev/null
> +_create_file_sized 4G $junk_file
> +if [ $? -ne 0 ]; then
> + echo "_create_file_sized failed"
echo "could not create 4G test file" ?
--D
> +fi
>
> iblocks=`stat -c '%b' $junk_file`
>
> --
> 2.37.3
>
next prev parent reply other threads:[~2022-09-22 0:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-21 14:10 [PATCH v4 0/2] test i_blocks for truncated largefiles Pavel Reichl
2022-09-21 14:10 ` [PATCH v4 1/2] common: new helper to alloacate fixed size files Pavel Reichl
2022-09-22 0:27 ` Darrick J. Wong [this message]
2022-09-21 14:10 ` [PATCH v4 2/2] generic: test i_blocks for truncated large files Pavel Reichl
2022-09-22 0:29 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YyusBYYvkBA0qEF4@magnolia \
--to=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=preichl@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox