Skip to contentSkip to conversation

xfstests-bld: add support for UBIFS using block2mtd

PATCH In review Eric Biggers 2 participants 2 messages Dec 14, 2017 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xfstests-bld: add support for UBIFS using block2mtd

Hi Ted, are you interested in taking this UBIFS support patch into xfstests-bld now? The 'block2mtd' approach hasn't gotten any better from when I sent this patch out originally, but it's better than nothing (it's useful to me, at least). Also, xfstests itself supports UBIFS now, so only xfstests-bld support is missing.

---8<---

This patch adds UBIFS support to the xfstests-bld test runners (kvm-xfstests, gce-xfstests, etc.).

Unlike most filesystems, UBIFS is not block-device based. Instead it uses an UBI volume, which is layered above an MTD (raw flash) device. Still, it's possible to use the block2mtd kernel module to emulate an MTD device given a block device. Therefore, the xfstests-bld config for UBIFS uses block2mtd to create MTD devices, then UBI devices and UBI volumes, that are backed by the xfstests partitions.

This approach has some limitations. First, it takes a long time to 'ubiformat' the emulated MTD devices the first time UBIFS tests are run. Second, block2mtd doesn't support removing MTD devices, which prevents the underlying partitions from being reused to test other filesystems after UBIFS until the VM is rebooted. Still, it's better than having no way to test UBIFS.

I also tried using QEMU to emulate a MTD device directly, but I couldn't get it to work; and that definitely won't work for gce-xfstests. Also, David Oberhollenzer had tried using nandsim instead of block2mtd, but said the following:

"Modifying the xfstests-bld patch to use nandsim (which simulates a
NAND flash MTD device) instead of block2mtd has been considered, however the default size of 128MiB is slightly too small for generic/129.

Nandsim does not have an option to directly specify the size of the backing buffer but instead requires a set of NAND ID bytes that imply (among other things) the size of the chip (example, see 1). The ID bytes would have to be added to the kernel arguments for the UBIFS case. It might be desirable to document this somehow, for the next person who has to adjust the size, once a new test exhausts it. Also, it would be ultimately limted by available RAM and what can be encoded using the NAND ID bytes."

---
 .../files/root/fs/ubifs/cfg/all.list               |   1 +
 .../test-appliance/files/root/fs/ubifs/cfg/default |  11 ++
 .../test-appliance/files/root/fs/ubifs/config      | 180 +++++++++++++++++++++
 kvm-xfstests/test-appliance/files/root/runtests.sh |   4 +-
 kvm-xfstests/test-appliance/gce-xfstests-bld.sh    |   1 +
 kvm-xfstests/test-appliance/xfstests-packages      |   1 +
 6 files changed, 196 insertions(+), 2 deletions(-)
 create mode 100644 kvm-xfstests/test-appliance/files/root/fs/ubifs/cfg/all.list
 create mode 100644 kvm-xfstests/test-appliance/files/root/fs/ubifs/cfg/default
 create mode 100644 kvm-xfstests/test-appliance/files/root/fs/ubifs/config
kvm-xfstests/test-appliance/files/root/fs/ubifs/cfg/all.list new file +1 -0
new file mode 100644
index 0000000..4ad96d5
@@ -0,0 +1 @@
+default
kvm-xfstests/test-appliance/files/root/fs/ubifs/cfg/default new file +11 -0
new file mode 100644
index 0000000..be3ba67
@@ -0,0 +1,11 @@
+SIZE=small
+
+# set up UBI volumes for our block devices
+export TEST_DEV=$(__blkdev_to_ubi_volume $SM_TST_DEV)
+export TEST_DIR=$SM_TST_MNT
+export SCRATCH_DEV=$(__blkdev_to_ubi_volume $SM_SCR_DEV)
+export SCRATCH_MNT=$SM_SCR_MNT
+
+export MKFS_OPTIONS=""
+export UBIFS_MOUNT_OPTIONS=""
+TESTNAME="ubifs"
kvm-xfstests/test-appliance/files/root/fs/ubifs/config new file +180 -0

180 lines not on this page · raw message

kvm-xfstests/test-appliance/files/root/runtests.sh +2 -2
index bf237e8..a44f389 100755
@@ -285,11 +285,11 @@ do
 	    */ovl) ;;
 	    *:/*) ;;
 	    *)
-		if ! test -b $TEST_DEV ; then
+		if ! [ -b $TEST_DEV -o -c $TEST_DEV ]; then
 		    echo "Test device $TEST_DEV does not exist, skipping $i config"
 		    continue
 		fi
-		if ! test -b $SCRATCH_DEV ; then
+		if ! [ -b $SCRATCH_DEV -o -c $SCRATCH_DEV ]; then
 		    echo "Scratch device $SCRATCH_DEV does not exist, skipping $i config"
 		    continue
 		fi
kvm-xfstests/test-appliance/gce-xfstests-bld.sh +1 -0
index 6127e4a..a7ad6e9 100644
@@ -43,6 +43,7 @@ PACKAGES="bash-completion \
 	liblzo2-2 \
 	lighttpd \
 	lvm2 \
+	mtd-utils \
 	nano \
 	openssl \
 	perl \
kvm-xfstests/test-appliance/xfstests-packages +1 -0
index b0fc878..aa1d2e8 100644
@@ -22,6 +22,7 @@ liblzo2-2
 libbsd0
 lvm2
 makedev
+mtd-utils
 perl
 procps
 psmisc
Signature · 1 line
2.15.1.504.g5279b80103-goog
#1 lore raw
Quoted 5 lines · Eric Biggers

Hi Ted, are you interested in taking this UBIFS support patch into xfstests-bld now? The 'block2mtd' approach hasn't gotten any better from when I sent this patch out originally, but it's better than nothing (it's useful to me, at least). Also, xfstests itself supports UBIFS now, so only xfstests-bld support is missing.

Agreed, thanks for doing this work! I've applied this patch to xfstests-bld.

- Ted