ubi: fastmap: Add fastmap control support for 'UBI_IOCATT' ioctl
authorZhihao Cheng <chengzhihao1@huawei.com>
Wed, 17 Aug 2022 03:27:35 +0000 (11:27 +0800)
committerRichard Weinberger <richard@nod.at>
Wed, 21 Sep 2022 16:29:18 +0000 (18:29 +0200)
commit669d204469c46e91d99da24914130f78277a71d3
tree89df41eb05bec3b2e152076e2c9069765983fbab
parente7f35da21f6f8c6a8c7d262dd4e4bd32e3083f79
ubi: fastmap: Add fastmap control support for 'UBI_IOCATT' ioctl

[1] suggests that fastmap is suitable for large flash devices. Module
parameter 'fm_autoconvert' is a coarse grained switch to enable all
ubi devices to generate fastmap, which may turn on fastmap even for
small flash devices.

This patch imports a new field 'disable_fm' in struct 'ubi_attach_req'
to support following situations by ioctl 'UBI_IOCATT'.
 [old functions]
 A. Disable 'fm_autoconvert': Disbable fastmap for all ubi devices
 B. Enable 'fm_autoconvert': Enable fastmap for all ubi devices
 [new function]
 C. Enable 'fm_autoconvert', set 'disable_fm' for given device: Don't
    create new fastmap and do full scan (existed fastmap will be
    destroyed) for the given ubi device.

A simple test case in [2].

[1] http://www.linux-mtd.infradead.org/doc/ubi.html#L_fastmap
[2] https://bugzilla.kernel.org/show_bug.cgi?id=216278

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/build.c
drivers/mtd/ubi/cdev.c
drivers/mtd/ubi/ubi.h
include/uapi/mtd/ubi-user.h