mbox series

[v2,00/12] ubi: fastmap: Fix a series of wear leveling problems

Message ID 20230828063845.3142561-1-chengzhihao1@huawei.com (mailing list archive)
Headers show
Series ubi: fastmap: Fix a series of wear leveling problems | expand

Message

Zhihao Cheng Aug. 28, 2023, 6:38 a.m. UTC
This series of patches fix three problems:
1. Inconsistent erase counter from wl entry and disk, for patches 1~4.
2. Same PEB is always resued for fastmap data, for patches 5~9.
3. First 64 PEBs have large erase counter than others, for patches 10~12.

Besides, patches 4/5 bring an improvement of the UBI service life.

Regression tests are in [Link].

Link: https://bugzilla.kernel.org/show_bug.cgi?id=217787.

v1->v2:
  Patch 6: Change wait condition in wait_free_pebs_for_pool(), there are
	   two situations that cause waiting infinately:
	   1. __erase_worker schedules itself if -EBUSY returned when
	      shutting down system.
	   2. The 'min_expect_free' cannot be satisfied when bad block
	      occurs and ubi becomes ro(The erased PEB should be the
              last one of 'min_expect_free', but it becomes bad in
	      __erase_worker).
 PS: After re-testing, the testing results in [Link] is not affected.


Zhihao Cheng (12):
  ubi: fastmap: Fix missed ec updating after erasing old fastmap data
    block
  ubi: fastmap: erase_block: Get erase counter from wl_entry rather than
    flash
  ubi: fastmap: Allocate memory with GFP_NOFS in ubi_update_fastmap
  ubi: Replace erase_block() with sync_erase()
  ubi: fastmap: Use free pebs reserved for bad block handling
  ubi: fastmap: Wait until there are enough free PEBs before filling
    pools
  ubi: fastmap: Remove unneeded break condition while filling pools
  ubi: fastmap: may_reserve_for_fm: Don't reserve PEB if fm_anchor
    exists
  ubi: fastmap: Get wl PEB even ec beyonds the 'max' if free PEBs are
    run out
  ubi: fastmap: Fix lapsed wear leveling for first 64 PEBs
  ubi: fastmap: Add module parameter to control reserving filling pool
    PEBs
  ubi: fastmap: Add control in 'UBI_IOCATT' ioctl to reserve PEBs for
    filling pools

 drivers/mtd/ubi/build.c      |  25 +++++++-
 drivers/mtd/ubi/cdev.c       |   3 +-
 drivers/mtd/ubi/eba.c        |   3 -
 drivers/mtd/ubi/fastmap-wl.c | 112 +++++++++++++++++++++++++++--------
 drivers/mtd/ubi/fastmap.c    |  66 +++------------------
 drivers/mtd/ubi/ubi.h        |  10 +++-
 drivers/mtd/ubi/wl.c         |  48 +++++++++------
 drivers/mtd/ubi/wl.h         |   6 +-
 include/uapi/mtd/ubi-user.h  |   4 +-
 9 files changed, 164 insertions(+), 113 deletions(-)

Comments

Zhihao Cheng Oct. 12, 2023, 2:57 a.m. UTC | #1
在 2023/8/28 14:38, Zhihao Cheng 写道:
> This series of patches fix three problems:
> 1. Inconsistent erase counter from wl entry and disk, for patches 1~4.
> 2. Same PEB is always resued for fastmap data, for patches 5~9.
> 3. First 64 PEBs have large erase counter than others, for patches 10~12.
> 
> Besides, patches 4/5 bring an improvement of the UBI service life.
> 
> Regression tests are in [Link].
> 
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=217787.
> 
> v1->v2:
>    Patch 6: Change wait condition in wait_free_pebs_for_pool(), there are
> 	   two situations that cause waiting infinately:
> 	   1. __erase_worker schedules itself if -EBUSY returned when
> 	      shutting down system.
> 	   2. The 'min_expect_free' cannot be satisfied when bad block
> 	      occurs and ubi becomes ro(The erased PEB should be the
>                last one of 'min_expect_free', but it becomes bad in
> 	      __erase_worker).
>   PS: After re-testing, the testing results in [Link] is not affected.
> 

Hi, Richard. I hope you can take some time(when you have free time) to 
have a glance of this series of patches, I have made some tests on 
virtual machine for 2+ months(and half month for physical nand flash), 
so far ubi works fine with patches applied.

> 
> Zhihao Cheng (12):
>    ubi: fastmap: Fix missed ec updating after erasing old fastmap data
>      block
>    ubi: fastmap: erase_block: Get erase counter from wl_entry rather than
>      flash
>    ubi: fastmap: Allocate memory with GFP_NOFS in ubi_update_fastmap
>    ubi: Replace erase_block() with sync_erase()
>    ubi: fastmap: Use free pebs reserved for bad block handling
>    ubi: fastmap: Wait until there are enough free PEBs before filling
>      pools
>    ubi: fastmap: Remove unneeded break condition while filling pools
>    ubi: fastmap: may_reserve_for_fm: Don't reserve PEB if fm_anchor
>      exists
>    ubi: fastmap: Get wl PEB even ec beyonds the 'max' if free PEBs are
>      run out
>    ubi: fastmap: Fix lapsed wear leveling for first 64 PEBs
>    ubi: fastmap: Add module parameter to control reserving filling pool
>      PEBs
>    ubi: fastmap: Add control in 'UBI_IOCATT' ioctl to reserve PEBs for
>      filling pools
> 
>   drivers/mtd/ubi/build.c      |  25 +++++++-
>   drivers/mtd/ubi/cdev.c       |   3 +-
>   drivers/mtd/ubi/eba.c        |   3 -
>   drivers/mtd/ubi/fastmap-wl.c | 112 +++++++++++++++++++++++++++--------
>   drivers/mtd/ubi/fastmap.c    |  66 +++------------------
>   drivers/mtd/ubi/ubi.h        |  10 +++-
>   drivers/mtd/ubi/wl.c         |  48 +++++++++------
>   drivers/mtd/ubi/wl.h         |   6 +-
>   include/uapi/mtd/ubi-user.h  |   4 +-
>   9 files changed, 164 insertions(+), 113 deletions(-)
>
Richard Weinberger Oct. 15, 2023, 7:34 p.m. UTC | #2
----- Ursprüngliche Mail -----
> Von: "chengzhihao1" <chengzhihao1@huawei.com>
> An: "richard" <richard@nod.at>, "Miquel Raynal" <miquel.raynal@bootlin.com>, "Vignesh Raghavendra" <vigneshr@ti.com>,
> "mcoquelin stm32" <mcoquelin.stm32@gmail.com>, "alexandre torgue" <alexandre.torgue@foss.st.com>
> CC: "linux-mtd" <linux-mtd@lists.infradead.org>, "linux-stm32" <linux-stm32@st-md-mailman.stormreply.com>,
> "linux-arm-kernel" <linux-arm-kernel@lists.infradead.org>, "Bagas Sanjaya" <bagasdotme@gmail.com>
> Gesendet: Donnerstag, 12. Oktober 2023 04:57:52
> Betreff: Re: [PATCH v2 00/12] ubi: fastmap: Fix a series of wear leveling problems

> 在 2023/8/28 14:38, Zhihao Cheng 写道:
>> This series of patches fix three problems:
>> 1. Inconsistent erase counter from wl entry and disk, for patches 1~4.
>> 2. Same PEB is always resued for fastmap data, for patches 5~9.
>> 3. First 64 PEBs have large erase counter than others, for patches 10~12.
>> 
>> Besides, patches 4/5 bring an improvement of the UBI service life.
>> 
>> Regression tests are in [Link].
>> 
>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=217787.
>> 
>> v1->v2:
>>    Patch 6: Change wait condition in wait_free_pebs_for_pool(), there are
>> 	   two situations that cause waiting infinately:
>> 	   1. __erase_worker schedules itself if -EBUSY returned when
>> 	      shutting down system.
>> 	   2. The 'min_expect_free' cannot be satisfied when bad block
>> 	      occurs and ubi becomes ro(The erased PEB should be the
>>                last one of 'min_expect_free', but it becomes bad in
>> 	      __erase_worker).
>>   PS: After re-testing, the testing results in [Link] is not affected.
>> 
> 
> Hi, Richard. I hope you can take some time(when you have free time) to
> have a glance of this series of patches, I have made some tests on
> virtual machine for 2+ months(and half month for physical nand flash),
> so far ubi works fine with patches applied.

I didn't forget. :-)

Thanks,
//richard