Bug 216341

Summary: ubi: small erase counter of fm_anchor after disabling fastmap
Product: Drivers Reporter: Zhihao Cheng (chengzhihao1)
Component: OtherAssignee: drivers_other
Status: NEW ---    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 5.19-rc7 Subsystem:
Regression: No Bisected commit-id:
Attachments: setup.sh
diff.patch
delay_v2.patch

Description Zhihao Cheng 2022-08-09 03:00:49 UTC
CONFIG_MTD_UBI_FASTMAP=y
CONFIG_MTD_UBI_WL_THRESHOLD=50

1. Generate an ubi image with fastmap
./setup.sh 1
umount temp
ubidetach -m0
dd if=/dev/mtd0 of=disk

2. Disable fastmap, apply diff.patch and re-compile kernel
3. ./setup.sh
4. ~/xfstests-dev/ltp/fsstress -d temp -l 0 -n 100000 -p 4
5. Several minutes(10min~) later

=========================================================
from              to     count      min      avg      max
---------------------------------------------------------
0        ..        9:        1        4        4        4
10       ..       99:        0        0        0        0
100      ..      999:      399      835      858      886
1000     ..     9999:        0        0        0        0
10000    ..    99999:        0        0        0        0
100000   ..      inf:        0        0        0        0
---------------------------------------------------------
Total               :      400        4      856      886

$ dmesg
[ 1189.836985] anchor 7
[ 1189.847611] anchor 7
[ 1189.859065] anchor 7

$ cat /sys/kernel/debug/ubi/ubi0/detailed_erase_block_info
physical_block_number   erase_count
0                       939        
1                       904        
2                       923        
3                       904        
4                       940        
5                       913        
6                       930        
7                       9          # The erase counter of fm_anchor PEB is smaller than any other PEBs
8                       905        
9                       902        
10                      945        
11                      916        
12                      922        
13                      923        
14                      900        
15                      927
Comment 1 Zhihao Cheng 2022-08-09 03:02:02 UTC
Created attachment 301535 [details]
setup.sh
Comment 2 Zhihao Cheng 2022-08-09 03:02:59 UTC
Created attachment 301536 [details]
diff.patch
Comment 3 Zhihao Cheng 2022-08-09 06:15:19 UTC
(In reply to Zhihao Cheng from comment #2)
> Created attachment 301536 [details]
> diff.patch

Use diff_v2.patch
Comment 4 Zhihao Cheng 2022-08-09 06:15:33 UTC
Created attachment 301537 [details]
delay_v2.patch