Skip to contentSkip to conversation

generic/273: Limit number of files by available inodes

PATCH In review Jan Kara 2 participants 2 messages Nov 30, 2022 – Dec 3, 2022

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH v2 1/1 generic/273: Limit number of files by available inodes

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.

---
 tests/generic/273 | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

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

tests/generic/273 +14 -2
index f86dae9b8095..54c199962421 100755
@@ -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
Signature · 1 line
2.35.3
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Jan Kara

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.

---

Looks good to me,

Quoted 37 lines
 tests/generic/273 | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

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

tests/generic/273 +14 -2
index f86dae9b8095..54c199962421 100755
@@ -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
Signature · 1 line
2.35.3