Age | Commit message (Collapse) | Author |
|
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 <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
'struct ubi_mkvol_request req' is one parameter of the function 'ubi_mkvol'
, this parameter will be passed to kernel and then be checked. It acts as a
local variable in many ubi tests, such as io_basic, io_read, mkvol_bad,
mkvol_basic, etc.
After commit c355aa465fce ("ubi: expose the volume CRC check skip flag") in
linux-stable, 'struct ubi_mkvol_request' supports a new configuration named
'flags', and req.flags will be checked in kernel function
'verify_mkvol_req'. Currently, there is no initialization for req.flags
before 'ubi_mkvol' invoked. So, req.flags can be an arbitrary number passed
to kernel. When we run ubi tests in qemu (x86_64, kernel image: 5.2.0-rc4),
the following errors may occur:
======================================================================
======================================================================
======================================================================
Test on mtdram, fastmap enabled, VID header offset factor 1
======================================================================
======================================================================
======================================================================
mtdram: 16MiB, PEB size 16KiB, fastmap enabled
Running mkvol_basic /dev/ubi0
Running mkvol_bad /dev/ubi0
[mkvol_bad] test_mkvol():105: ubi_mkvol failed with error 22
(Invalid argument), expected 28 (No space left on device)
[mkvol_bad] test_mkvol():105: bytes = 16060929
Error: mkvol_bad failed
FAILURE
This patch fully initializes every 'struct ubi_mkvol_request req' passed to
'ubi_mkvol', which can fix the bug that the ubi test failed caused by that
req.flags was not initialized. And it is still compatible with old kernel
before kernel commit c355aa465fce ("ubi: expose the volume CRC check skip
flag").
----------------------------------------
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Sorry, the commit is huge, I just did not have time to split it.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
... to avoid confusion when the local common.h shadows the top-level common.h.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
For consistency with ubi-utils.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
libubi_open interface was changed, but the tests were not
amended. Fix this.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Clean-up ubi-utils a little by moving tests to a proper place.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|