From 68ddd0cf2afcf24aec1458fb3a2abdcf81917daa Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Fri, 14 Jun 2019 20:18:48 +0800 Subject: ubi-tests: mkvol test: Checks return value 'ENOSPC' for 'ubi_mkvol' UBI tests try to create too many volumes in mkvol_bad and mkvol_basic. Currently mtd-utils allows return value 'ENFILE' from 'ubi_mkvol', that works fine in most situations. But what if the number of PEBs equals to the maximum count of volumes? For example, mkvol_basic test will fail in a 64MiB flash with 512KiB PEB size. Following is the output of mkvol_basic test: ====================================================================== ====================================================================== ====================================================================== Test on mtdram, fastmap enabled, VID header offset factor 1 ====================================================================== ====================================================================== ====================================================================== mtdram: 64MiB, PEB size 512KiB, fastmap enabled Running mkvol_basic /dev/ubi0 [mkvol_basic] mkvol_multiple():182: function ubi_mkvol() failed with error 28 (No space left on device) [mkvol_basic] mkvol_multiple():183: vol_id 122 Error: mkvol_basic failed FAILURE The reason is that there is no available PEB to support a new volume. We can see following verbose in dmesg: ubi0: attached mtd0 (name "mtdram test device", size 64 MiB) ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128 ubi0: available PEBs: 122, total reserved PEBs: 6, PEBs reserved for bad PEB handling: 0 The maximum count of volumes is 128, so we can create 128 volumes theoretically. But there are 122 available PEBs becauese of existence of reserved PEBs. In addition, a volume occupies at least one PEB. Actually, we can only create 122 volumes, Therefore, 'ubi_mkvol' returns 'ENOSPC' when mkvol_basic tries to create 123rd volume. And we can see corresponding error message in dmesg: ubi0 error: ubi_create_volume [ubi]: not enough PEBs, only 0 available ubi0 error: ubi_create_volume [ubi]: cannot create volume 122, error -28 So, 'ENOSPC' can happen before 'ENFILE' in flash with a small amount of PEBs. This patch checks return value 'ENOSPC' for 'ubi_mkvol' when mkvol test is trying to create too many volumes. ---------------------------------------- Signed-off-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- tests/ubi-tests/mkvol_bad.c | 2 +- tests/ubi-tests/mkvol_basic.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/ubi-tests') diff --git a/tests/ubi-tests/mkvol_bad.c b/tests/ubi-tests/mkvol_bad.c index 7e46726..a5143e3 100644 --- a/tests/ubi-tests/mkvol_bad.c +++ b/tests/ubi-tests/mkvol_bad.c @@ -200,7 +200,7 @@ static int test_mkvol(void) * Note, because of gluebi we may be unable to create * dev_info.max_vol_count devices (MTD restrictions). */ - if (errno == ENFILE) + if (errno == ENFILE || errno == ENOSPC) break; failed("ubi_mkvol"); errorm("vol_id %d", i); diff --git a/tests/ubi-tests/mkvol_basic.c b/tests/ubi-tests/mkvol_basic.c index c7c6984..cc3f7ba 100644 --- a/tests/ubi-tests/mkvol_basic.c +++ b/tests/ubi-tests/mkvol_basic.c @@ -178,7 +178,7 @@ static int mkvol_multiple(void) req.name = nm; if (ubi_mkvol(libubi, node, &req)) { - if (errno == ENFILE) { + if (errno == ENFILE || errno == ENOSPC) { max = i; break; } -- cgit v1.2.3