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.
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
(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
Created attachment 303081 [details] A patch to verify test cases
Created attachment 303082 [details] Shell script of test cases
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