Re: [PATCH] generic/645: Confirm availability of free inodes

"Darrick J. Wong" <[email protected]> Thu, 25 Jun 2026 11:42:59 -0700
Newsgroups org.kernel.vger.fstests
Message-ID <20260625184259.GP6070@frogsfrogsfrogs>
On Wed, Jun 17, 2026 at 11:12:16AM +0530, Ojaswin Mujoo wrote:
> When running generic/645 with ext4 using 64k block size + bigalloc, the
> test fails with ENOSPC because the filesystem runs out of inodes before
> the test completes.
> 
> The test creates approximately 10,001 files, however, in this particular
> configuration a standard 5G FS only has around ~5100 inodes resulting in
> the ENOSPC failure.
> 
> Add a check using _get_free_inode() to verify sufficient inodes are
> available before running the test, else skip it.
> 
> Reported-by: Disha Goel <[email protected]>
> Signed-off-by: Ojaswin Mujoo <[email protected]>
> ---
>  tests/generic/645 | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tests/generic/645 b/tests/generic/645
> index d6eb75e6..944b33db 100755
> --- a/tests/generic/645
> +++ b/tests/generic/645
> @@ -19,6 +19,12 @@ _require_chown
>  _wants_kernel_commit dacfd001eaf2 \
>  	"fs/mnt_idmapping.c: Return -EINVAL when no map is written"
>  
> +_free_inodes=$(_get_free_inode $TEST_DIR)
> +if [ $_free_inodes -ne 0 ] && [ $_free_inodes -lt 10001 ]; then

I'm assuming the > 0 check here is to cover weird filesystems like fat
that don't advertise any inodes?  /me wonders if that ought to be a
common helper where we can record that justification:

_require_free_inodes() {
	local path="$1"
	local nr="$2"

	local _free_inodes=$(_get_free_inode "$path")

	# Weird filesystems like vfat don't report any inodes, so we
	# can't check for sufficient free inodes; IOWs, FAFO.
	test "$_free_inodes" -eq 0 && return

	test "$_free_inodes" -lt "$nr" && \
		_notrun "Insufficient free inodes ($_free_inodes), need at least $nr"
}


_require_free_inodes $TEST_DIR 10001

(maybe clean up the comment a bit)

--D

> +	_notrun "Insufficient free inodes ($_free_inodes), need at least 10001"
> +fi
> +
>  echo "Silence is golden"
>  
>  $here/src/vfs/vfstest --test-nested-userns \
> -- 
> 2.53.0
> 
>