Bug 216623 - ubi: support disabling fastmap by module parameter
Summary: ubi: support disabling fastmap by module parameter
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-25 02:03 UTC by wangzhaolong1
Modified: 2022-10-25 07:57 UTC (History)
0 users

See Also:
Kernel Version: 6.1.0 -rc2
Subsystem:
Regression: No
Bisected commit-id:


Attachments
A patch to verify test cases (410 bytes, patch)
2022-10-25 07:49 UTC, wangzhaolong1
Details | Diff
Shell script of test cases (1.90 KB, application/x-shellscript)
2022-10-25 07:50 UTC, wangzhaolong1
Details

Description wangzhaolong1 2022-10-25 02:03:39 UTC
The UBI can use the IOCTL to disable the fastmap after the mainline 669d204469c4 ("ubi: fastmap: Add fastmap control support for 'UBI_IOCATT' ioctl"). To destroy the fastmap on the image, we need to reattach the device in user space.

However, if the UBI driver build in kernel and the UBI volume is the root partition, the UBI device cannot be reattached in user space.

To disable fastmap in this case, the UBI must provide the kernel cmdline parameters to disable fastmap during attach.
Comment 1 wangzhaolong1 2022-10-25 07:36:55 UTC
I try to add 'enable_fm' as 5th module init parameter of mtd=xx to control fastmap enable or not. If the value is non-zero, fastmap is enabled.. Default value is 0.

For historical reasons, to enable or disable fastmap during module loading, fm_autoconvert must be set to non-zero.

The following table lists the parameter combinations and expected results.

+-----------------+---------------+---------------------------+
|        \        |  enable_fm=0  |  enable_fm=1              |
+-----------------+---------------+---------------------------+
|fm_autoconvert=Y |  disable fm   |  enable fm                |
+---------------------------------+---------------------------+
|fm_autoconvert=N |  disable fm   | Enable fastmap if fastmap |
|                 |               | exists on the old image   |
+-------------------------------------------------------------+

The old image has fastmap.

case 1 : fm_autoconvert=Y, enable_fm=0 -- fastmap disabled
case 2 : fm_autoconvert=Y, enable_fm=1 -- fastmap enabled
case 3 : fm_autoconvert=N, enable_fm=0 -- fastmap disabled
case 4 : fm_autoconvert=N, enable_fm=1 -- fastmap enabled


The old image does not have fastmap.

case 5 : fm_autoconvert=Y, enable_fm=0 -- fastmap disabled
case 6 : fm_autoconvert=Y, enable_fm=1 -- fastmap enabled
case 7 : fm_autoconvert=N, enable_fm=0 -- fastmap disabled
case 8 : fm_autoconvert=N, enable_fm=1 -- fastmap disabled
Comment 2 wangzhaolong1 2022-10-25 07:45:11 UTC
(In reply to wangzhaolong1 from comment #1)
> I try to add 'enable_fm' as 5th module init parameter of mtd=xx to control
> fastmap enable or not. If the value is non-zero, fastmap is enabled..
> Default value is 0.
> 
> For historical reasons, to enable or disable fastmap during module loading,
> fm_autoconvert must be set to non-zero.
> 
> The following table lists the parameter combinations and expected results.
> 
> +-----------------+---------------+---------------------------+
> |        \        |  enable_fm=0  |  enable_fm=1              |
> +-----------------+---------------+---------------------------+
> |fm_autoconvert=Y |  disable fm   |  enable fm                |
> +---------------------------------+---------------------------+
> |fm_autoconvert=N |  disable fm   | Enable fastmap if fastmap |
> |                 |               | exists on the old image   |
> +-------------------------------------------------------------+
> 
> The old image has fastmap.
> 
> case 1 : fm_autoconvert=Y, enable_fm=0 -- fastmap disabled
> case 2 : fm_autoconvert=Y, enable_fm=1 -- fastmap enabled
> case 3 : fm_autoconvert=N, enable_fm=0 -- fastmap disabled
> case 4 : fm_autoconvert=N, enable_fm=1 -- fastmap enabled
> 
> 
> The old image does not have fastmap.
> 
> case 5 : fm_autoconvert=Y, enable_fm=0 -- fastmap disabled
> case 6 : fm_autoconvert=Y, enable_fm=1 -- fastmap enabled
> case 7 : fm_autoconvert=N, enable_fm=0 -- fastmap disabled
> case 8 : fm_autoconvert=N, enable_fm=1 -- fastmap disabled

The prerequisite is that CONFIG_MTD_UBI_FASTMAP=y
Comment 3 wangzhaolong1 2022-10-25 07:49:20 UTC
Created attachment 303081 [details]
A patch to verify test cases
Comment 4 wangzhaolong1 2022-10-25 07:50:33 UTC
Created attachment 303082 [details]
Shell script of test cases
Comment 5 wangzhaolong1 2022-10-25 07:57:11 UTC
Run Test Cases:

1.Apply the patch for verification.
git apply verify.diff

2.kernel config:
CONFIG_MTD_NAND_NANDSIM=m
CONFIG_MTD_UBI=m
CONFIG_MTD_UBI_FASTMAP=y

3.Start a VM environment.

4../test.sh
Get the output:

The old image has fastmap: Test cases 1 to 4 are successful
The old image does not have fastmap: Test cases 5 to 8 are successful
TEST CASES PASSED

done

Note You need to log in before you can comment on or make changes to this bug.