Linux EXT4 FS development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ding Feng" <dingf3ng@gmail.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH] generic: test that insert range respects RLIMIT_FSIZE
Date: Thu, 03 Dec 2026 11:08:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-247645@kernel.org> (raw)
In-Reply-To: <20261203105330.65937-1-dingf3ng@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] generic/810: insert_under_limit() truncates ulimit -f for
  non-KiB unit sizes
- [Low] fstests: missing _cleanup() in generic/810 leaves TEST_DIR file
--

commit cf8171da3dc9f8ba5bc63d270ae5caa9e2305ada
Author: Ding Feng <dingf3ng@gmail.com>

generic: test that insert range respects RLIMIT_FSIZE

This commit adds fstest generic/810 to verify that FALLOC_FL_INSERT_RANGE
fails with EFBIG when the resulting file size would exceed RLIMIT_FSIZE and
succeeds when within the limit.

> diff --git a/tests/generic/810 b/tests/generic/810
> new file mode 100755
> index 0000000000000..25f5ece4210b1
> --- /dev/null
> +++ b/tests/generic/810
> @@ -0,0 +1,46 @@
[ ... ]
> +. ./common/preamble
> +_begin_fstest auto quick insert prealloc
> +
> +_fixed_by_fs_commit ext4 xxxxxxxxxxxx \
> +	"ext4: check RLIMIT_FSIZE in insert range"
> +
> +_require_test
> +_require_xfs_io_command "finsert"
> +
> +file=$TEST_DIR/$seq.file

[Severity: Low]
Does this leave $TEST_DIR/$seq.file behind after the test finishes?
common/preamble's default _cleanup() only removes $tmp.*, and this test only
removes $file during setup, so it remains on TEST_DIR after exit or failure.

Overriding _cleanup() to also remove $file would keep TEST_DIR clean.

> +
> +# Insert range works in whole file blocks, and ulimit -f in 1 KiB units.
> +unit=$(_get_file_block_size $TEST_DIR)
> +[ $unit -lt 4096 ] && unit=4096
> +
> +# Run "finsert 0 $unit" on $file under an FSIZE limit of $1 units.  SIGXFSZ is
> +# ignored so that the call fails with EFBIG instead of killing xfs_io.
> +insert_under_limit()
> +{
> +	bash -c "ulimit -f $(($1 * unit / 1024)); trap '' SIGXFSZ; \
> +		$XFS_IO_PROG -c 'finsert 0 $unit' $file"
> +	echo "size: $(($(stat -c %s $file) / unit)) units"
> +}

[Severity: Low]
Can ulimit -f $(($1 * unit / 1024)) truncate below $1 * unit and cause the
3-unit insert to fail with EFBIG?

On an XFS v4 filesystem with 512-byte blocks and an odd realtime extent size
(such as 9 blocks, or 4608 bytes), _get_file_block_size returns a value over
4096 that is not a multiple of 1024.  insert_under_limit 3 then sets
RLIMIT_FSIZE to 13 KiB (13312 bytes) for a 13824-byte target size.

Doubling unit when unit % 1024 is non-zero preserves allocation-unit
alignment while making $1 * unit an exact multiple of 1024.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203105330.65937-1-dingf3ng@gmail.com?part=1

      reply	other threads:[~2026-12-03 11:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 10:53 [PATCH] generic: test that insert range respects RLIMIT_FSIZE Ding Feng
2026-12-03 11:08 ` sashiko-bot [this message]

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=sashiko-outbox-247645@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dingf3ng@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tytso@mit.edu \
    /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