fsverity.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Andrey Albershteyn <aalbersh@redhat.com>
To: fstests@vger.kernel.org, fsverity@lists.linux.dev
Cc: Andrey Albershteyn <aalbersh@redhat.com>
Subject: [PATCH] common/rc: make _get_max_file_size find file size on mount point
Date: Mon, 11 Sep 2023 22:06:17 +0200	[thread overview]
Message-ID: <20230911200617.777985-1-aalbersh@redhat.com> (raw)

Currently, _get_max_file_size finds max file size on $TEST_DIR.
The tests/generic/692 uses this function to detect file size and
then tries to create a file on $SCRATCH_MNT.

This works fine when test and scratch filesystems have the same
block size. However, it will fail if they differ, for example, TEST
is 4k and SCRATCH is 1k (file will be too big).

Found this by running generic/692 on ext4 with -b 1024.

Make _get_max_file_size accept mount point on which to detect max
file size.

Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
 common/rc         | 8 +++++++-
 tests/generic/299 | 2 +-
 tests/generic/485 | 2 +-
 tests/generic/692 | 2 +-
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/common/rc b/common/rc
index 68d2ad04..d17ec73a 100644
--- a/common/rc
+++ b/common/rc
@@ -4809,7 +4809,13 @@ _require_scratch_feature()
 # be UINT32_MAX * block_size, but other filesystems may allow up to LLONG_MAX.
 _get_max_file_size()
 {
-	local testfile=$TEST_DIR/maxfilesize.$seq
+	if [ -z $1 ] || [ ! -d $1 ]; then
+		echo "Missing mount point argument for _get_max_file_size"
+		exit 1
+	fi
+
+	local mnt=$1
+	local testfile=$mnt/maxfilesize.$seq
 	local l=0
 	local r=9223372036854775807 # LLONG_MAX
 
diff --git a/tests/generic/299 b/tests/generic/299
index d8ecff53..0cd12202 100755
--- a/tests/generic/299
+++ b/tests/generic/299
@@ -30,7 +30,7 @@ NUM_JOBS=$((4*LOAD_FACTOR))
 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
 FILE_SIZE=$((BLK_DEV_SIZE * 512))
 
-max_file_size=$(_get_max_file_size)
+max_file_size=$(_get_max_file_size $TEST_DIR)
 if [ $max_file_size -lt $FILE_SIZE ]; then
 	FILE_SIZE=$max_file_size
 fi
diff --git a/tests/generic/485 b/tests/generic/485
index 3f7749ff..8bab450b 100755
--- a/tests/generic/485
+++ b/tests/generic/485
@@ -30,7 +30,7 @@ _require_xfs_io_command "finsert"
 _require_xfs_io_command "truncate"
 
 block_size=$(_get_file_block_size $TEST_DIR)
-max_file_size=$(_get_max_file_size)
+max_file_size=$(_get_max_file_size $TEST_DIR)
 max_blocks=$((max_file_size / block_size))
 testfile=$TEST_DIR/testfile.$seq
 
diff --git a/tests/generic/692 b/tests/generic/692
index 95f6ec04..3fb8ac01 100755
--- a/tests/generic/692
+++ b/tests/generic/692
@@ -40,7 +40,7 @@ _scratch_mount
 
 fsv_file=$SCRATCH_MNT/file.fsv
 
-max_sz=$(_get_max_file_size)
+max_sz=$(_get_max_file_size $SCRATCH_MNT)
 _fsv_scratch_begin_subtest "way too big: fail on first merkle block"
 truncate -s $max_sz $fsv_file
 _fsv_enable $fsv_file |& _filter_scratch
-- 
2.40.1


             reply	other threads:[~2023-09-11 20:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 20:06 Andrey Albershteyn [this message]
2023-09-12 12:42 ` [PATCH] common/rc: make _get_max_file_size find file size on mount point Zorro Lang
2023-09-12 14:56   ` Darrick J. Wong
2023-09-13  8:44     ` Andrey Albershteyn
2023-09-13 13:57       ` Zorro Lang

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=20230911200617.777985-1-aalbersh@redhat.com \
    --to=aalbersh@redhat.com \
    --cc=fstests@vger.kernel.org \
    --cc=fsverity@lists.linux.dev \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).