public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Nirjhar Roy (IBM)" <nirjhar.roy.lists@gmail.com>
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, ritesh.list@gmail.com,
	ojaswin@linux.ibm.com, djwong@kernel.org, zlang@kernel.org,
	fdmanana@kernel.org, nirjhar.roy.lists@gmail.com
Subject: [PATCH 7/7] generic/274: Make the test compatible with all blocksizes.
Date: Tue, 29 Jul 2025 06:21:50 +0000	[thread overview]
Message-ID: <0a9f6e6d2018c6d505be192031aeb9e656b23bd3.1753769382.git.nirjhar.roy.lists@gmail.com> (raw)
In-Reply-To: <cover.1753769382.git.nirjhar.roy.lists@gmail.com>

On btrfs with 64k blocksize on powerpc with 64k pagesize
it failed with the following error:

     ------------------------------
     preallocation test
     ------------------------------
    -done
    +failed to write to test file
    +(see /home/xfstests-dev/results//btrfs_64k/generic/274.full for details)
    ...
So, this test is written with 4K block size in mind. As we can see,
it first creates a file of size 4K and then fallocates 4MB beyond the
EOF.
Then there are 2 loops - one that fragments at alternate blocks and
the other punches holes in the remaining alternate blocks. Hence,
the test fails in 64k block size due to incorrect calculations.

Fix this test by making the test scale with the block size, that is
the offset, filesize and the assumed blocksize matches/scales with
the actual blocksize of the underlying filesystem.

Reported-by: Disha Goel <disgoel@linux.ibm.com>
Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>
---
 tests/generic/274 | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/tests/generic/274 b/tests/generic/274
index 916c7173..4ea42f30 100755
--- a/tests/generic/274
+++ b/tests/generic/274
@@ -40,30 +40,31 @@ _scratch_unmount 2>/dev/null
 _scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
 _scratch_mount
 
-# Create a 4k file and Allocate 4M past EOF on that file
-$XFS_IO_PROG -f -c "pwrite 0 4k" -c "falloc -k 4k 4m" $SCRATCH_MNT/test \
-	>>$seqres.full 2>&1 || _fail "failed to create test file"
+blksz=`_get_block_size $SCRATCH_MNT`
+scale=$(( blksz / 1024 ))
+# Create a blocksize worth file and Allocate a large file past EOF on that file
+$XFS_IO_PROG -f -c "pwrite -b $blksz 0 $blksz" -c "falloc -k $blksz $(( 1 * 1024 * 1024 * scale ))" \
+	$SCRATCH_MNT/test >>$seqres.full 2>&1 || _fail "failed to create test file"
 
 # Fill the rest of the fs completely
 # Note, this will show ENOSPC errors in $seqres.full, that's ok.
 echo "Fill fs with 1M IOs; ENOSPC expected" >> $seqres.full
 dd if=/dev/zero of=$SCRATCH_MNT/tmp1 bs=1M >>$seqres.full 2>&1
-echo "Fill fs with 4K IOs; ENOSPC expected" >> $seqres.full
-dd if=/dev/zero of=$SCRATCH_MNT/tmp2 bs=4K >>$seqres.full 2>&1
+echo "Fill fs with $blksz K IOs; ENOSPC expected" >> $seqres.full
+dd if=/dev/zero of=$SCRATCH_MNT/tmp2 bs=$blksz >>$seqres.full 2>&1
 _scratch_sync
 # Last effort, use O_SYNC
-echo "Fill fs with 4K DIOs; ENOSPC expected" >> $seqres.full
-dd if=/dev/zero of=$SCRATCH_MNT/tmp3 bs=4K oflag=sync >>$seqres.full 2>&1
+echo "Fill fs with $blksz DIOs; ENOSPC expected" >> $seqres.full
+dd if=/dev/zero of=$SCRATCH_MNT/tmp3 bs=$blksz oflag=sync >>$seqres.full 2>&1
 # Save space usage info
 echo "Post-fill space:" >> $seqres.full
 df $SCRATCH_MNT >>$seqres.full 2>&1
-
 # Now attempt a write into all of the preallocated space -
 # in a very nasty way, badly fragmenting it and then filling it in.
 echo "Fill in prealloc space; fragment at offsets:" >> $seqres.full
 for i in `seq 1 2 1023`; do
 	echo -n "$i " >> $seqres.full
-	dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=4K count=1 conv=notrunc \
+	dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=$blksz count=1 conv=notrunc \
 		>>$seqres.full 2>/dev/null || _fail "failed to write to test file"
 done
 _scratch_sync
@@ -71,7 +72,7 @@ echo >> $seqres.full
 echo "Fill in prealloc space; fill holes at offsets:" >> $seqres.full
 for i in `seq 2 2 1023`; do
 	echo -n "$i " >> $seqres.full
-	dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=4K count=1 conv=notrunc \
+	dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=$blksz count=1 conv=notrunc \
 		>>$seqres.full 2>/dev/null || _fail "failed to fill test file"
 done
 _scratch_sync
-- 
2.34.1


  parent reply	other threads:[~2025-07-29  6:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-29  6:21 [PATCH 0/7] btrfs: Misc test fixes for large block/node sizes Nirjhar Roy (IBM)
2025-07-29  6:21 ` [PATCH 1/7] common/filter: Add a helper function to filter offsets and sizes Nirjhar Roy (IBM)
2025-07-29  6:21 ` [PATCH 2/7] common/btrfs: Add a helper function to get the nodesize Nirjhar Roy (IBM)
2025-07-29  6:21 ` [PATCH 3/7] btrfs/137: Make this compatible with all block sizes Nirjhar Roy (IBM)
2025-08-04  3:58   ` Qu Wenruo
2025-08-05  9:41     ` Ojaswin Mujoo
2025-08-05  9:44       ` Qu Wenruo
2025-08-05 12:39         ` Ojaswin Mujoo
2025-08-05 10:47       ` Filipe Manana
2025-08-12  6:23         ` Nirjhar Roy (IBM)
2025-08-12  6:22     ` Nirjhar Roy (IBM)
2025-07-29  6:21 ` [PATCH 4/7] btrfs/200: Make this test scale with the block size Nirjhar Roy (IBM)
2025-07-29  6:53   ` Filipe Manana
2025-08-12  6:26     ` Nirjhar Roy (IBM)
2025-08-04  4:19   ` Qu Wenruo
2025-07-29  6:21 ` [PATCH 5/7] generic/563: Increase the write tolerance to 6% for larger nodesize Nirjhar Roy (IBM)
2025-07-29  7:45   ` Christoph Hellwig
2025-08-04  7:18     ` Nirjhar Roy (IBM)
2025-07-30 15:06   ` Filipe Manana
2025-08-04  7:18     ` Nirjhar Roy (IBM)
2025-08-04  4:28   ` Qu Wenruo
2025-08-12  6:27     ` Nirjhar Roy (IBM)
2025-07-29  6:21 ` [PATCH 6/7] btrfs/301: Make this test compatible with all block sizes Nirjhar Roy (IBM)
2025-08-04  4:32   ` Qu Wenruo
2025-08-12  6:30     ` Nirjhar Roy (IBM)
2025-07-29  6:21 ` Nirjhar Roy (IBM) [this message]
2025-08-04  4:35   ` [PATCH 7/7] generic/274: Make the test compatible with all blocksizes Qu Wenruo
2025-08-12  6:30     ` Nirjhar Roy (IBM)

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=0a9f6e6d2018c6d505be192031aeb9e656b23bd3.1753769382.git.nirjhar.roy.lists@gmail.com \
    --to=nirjhar.roy.lists@gmail.com \
    --cc=djwong@kernel.org \
    --cc=fdmanana@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=zlang@kernel.org \
    /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