[PATCH 2/4] ubi: Expose mean erase counter for fastmap in sysfs

Zhihao Cheng chengzhihao1 at huawei.com
Wed Oct 9 19:58:49 PDT 2024


在 2024/10/9 21:44, Rickard x Andersson 写道:
> On 10/8/24 11:27, Zhihao Cheng wrote:
>> 在 2024/10/4 16:22, Rickard Andersson 写道:
>>> Since the fastmap area has its own wear levelling it is valuable to
>>> provide a mean value for that area. This value can be used in order
>>> to estimate life expectancy of the flash.
>>>
>>
>> There are 2 cases shown as following:
>> 1) fastmap is disabled: We can determine whether the wear-leveling 
>> algorithm works fine by comparing 'max_ec' with 'mean_ec'.
>> 2) fastmap is enabled: The max_ec may come from first 64 PEBs(fastmap 
>> area), or it may come from data area(pnum > 64), how can we determine 
>> whether the wear-leveling algorithm works fine for data area?
> 
> Thanks for the feedback.
> 
> My main goal is to provide mean values to determine how worn down the 
> flash is. I am sort of assuming that the wear leveling algorithm works 
> but that it previously had bugs, which made it difficult to use max_ec 
> to get a complete picture of the wear.
> I could add max_ec_fastmap for symmetry if you want? Then I will make 
> max_ec_fastmap cover blocks 0 - 63, and max_ec will cover 0 - LAST_BLOCK.
> 

How about providing four variables:
1. mean_ec_data: mean ec for data area
2. max_ec_data:max ec for data area
3. mean_ec_fastmap:mean ec for fastmap area
4. max_ec_fastmap:max ec for fastmap area

If CONFIG_MTD_UBI_FASTMAP is enabled, all variables are displayed under 
sysfs, mean_ec_data and max_ec_data are calculated by 64~LAST_PEB, 
mean_ec_fastmap and max_ec_fastmap are calculated by 0~64 PEBs, despite 
whatever 'ubi->fm_disabled' is.
If CONFIG_MTD_UBI_FASTMAP is disabled, only mean_ec_data and max_ec_data 
are displayed under sysfs, the mean_ec_data and max_ec_data are 
calculated by all PEBs.

>>
>> 'if (!ubi->fm_disabled))' is enough.
>>> +            peb_count = UBI_FM_MAX_START;
>>> +        else
>>> +            return 0; /* No fastmap on this UBI device */
>>
>> If we format /dev/mtdX by command 'ubiformat -e 0', the return value 
>> '0' may confuse us, it means that the fastmap is disabled or the 
>> mean_ec_fastmap is 0.
> 
> Do you prefer the function "dev_attribute_show" to return -ENODEV in 
> case we have no fastmap? I.e this behavior:
> 
> /sys/class/ubi/ubi0 # cat mean_ec_fastmap
> cat: read error: No such device
> 
> Best regards,
> Rickard Andersson
> 
> 
> .




More information about the linux-mtd mailing list