[PATCH] generic/020: Compute correct max_attrs for UBIFS

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



When testing on a MTD with a rather small erase block
size, the default max_attr limit can be too much and the
test will fail.
Instead compute the actual limit.

Signed-off-by: Richard Weinberger <richard@xxxxxx>
---
 common/config     | 1 +
 common/ubifs      | 9 +++++++++
 tests/generic/020 | 6 ++++++
 3 files changed, 16 insertions(+)
 create mode 100644 common/ubifs

diff --git a/common/config b/common/config
index c9771ff9..05f2bb35 100644
--- a/common/config
+++ b/common/config
@@ -545,6 +545,7 @@ _source_specific_fs()
 		;;
 	ubifs)
 		[ "$UBIUPDATEVOL_PROG" = "" ] && _fatal "ubiupdatevol not found"
+		. ./common/ubifs
 		;;
 	esac
 }
diff --git a/common/ubifs b/common/ubifs
new file mode 100644
index 00000000..08323260
--- /dev/null
+++ b/common/ubifs
@@ -0,0 +1,9 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-only
+
+_get_leb_size()
+{
+	local ubivol=$1
+
+	cat /sys/class/ubi/`basename $ubivol`/usable_eb_size
+}
diff --git a/tests/generic/020 b/tests/generic/020
index da258aa5..4951b9e3 100755
--- a/tests/generic/020
+++ b/tests/generic/020
@@ -101,6 +101,12 @@ _attr_get_max()
 			let max_attrs=$((($BLOCK_SIZE - 32) / (16 + 12 + 16 )))
 		fi
 		;;
+	ubifs)
+		LEB_SIZE=`_get_leb_size $TEST_DEV`
+		# On UBIFS, the number of xattrs has to be less than 50% LEB size
+		# divided by 160 (inode size)
+		let max_attrs=$((($LEB_SIZE / 2 / 160) - 1))
+		;;
 	*)
 		# Assume max ~1 block of attrs
 		BLOCK_SIZE=`_get_block_size $TEST_DIR`
-- 
2.35.3





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux