All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: fstests@vger.kernel.org
Cc: Filipe Manana <fdmanana@kernel.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH v2] generic/273: Limit number of files by available inodes
Date: Wed, 30 Nov 2022 18:01:53 +0100	[thread overview]
Message-ID: <20221130170153.31924-1-jack@suse.cz> (raw)

Test generic/273 is failing for ext4 with 1k blocksize because it is
creating more files than we have available inodes. Just limit the number
of files created to the number of inodes.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 tests/generic/273 | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Changes since v1:
* Handle btrfs which reports 0 free inodes

diff --git a/tests/generic/273 b/tests/generic/273
index f86dae9b8095..54c199962421 100755
--- a/tests/generic/273
+++ b/tests/generic/273
@@ -50,9 +50,21 @@ _file_create()
 
 	cd $SCRATCH_MNT/origin
 
-	_disksize=`$DF_PROG -B 1 $SCRATCH_MNT | tail -1 | $AWK_PROG '{ print $5 }'`
+	_disksize=$(_get_available_space $SCRATCH_MNT)
+	_free_inodes=$(_get_free_inode $SCRATCH_MNT)
+	# Some filesystems do not limit number of inodes and return 0
+	if [ $_free_inodes -eq 0 ]; then
+		# Guess one block per inode
+		_free_inodes=$(($_disksize / $block_size))
+	fi
+	# Leave some slack for directories etc.
+	_free_inodes=$(($_free_inodes - $_free_inodes/8))
 	_disksize=$(($_disksize / 3))
-	_num=$(($_disksize / $count / $threads / $block_size))
+	_num=$(($_disksize / $count / $block_size))
+	if [ $_num -gt $_free_inodes ]; then
+		_num=$_free_inodes
+	fi
+	_num=$(($_num/$threads))
 	_count=$count
 	while [ $_i -lt $_num ]
 	do
-- 
2.35.3


             reply	other threads:[~2022-11-30 17:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 17:01 Jan Kara [this message]
2022-12-03  6:33 ` [PATCH v2] generic/273: Limit number of files by available inodes 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=20221130170153.31924-1-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=fdmanana@kernel.org \
    --cc=fstests@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.