【标题描述】UBI disable fastmap后fm_anchor没有参与磨损均衡
【环境信息】
硬件信息:
NA
软件信息:
OLK-5.10
【问题复现步骤】
Generate an ubi image with fastmap
./setup.sh 1
umount temp
ubidetach -m0
dd if=/dev/mtd0 of=disk
Disable fastmap, apply diff.patch and re-compile kernel
./setup.sh
~/xfstests-dev/ltp/fsstress -d temp -l 0 -n 100000 -p 4
Several minutes(10min~) later
出现概率(是否必现,概率性错误)必现
【预期结果】
The erase counter of fm_anchor PEB is smaller than any other PEBs
【实际结果】
$ 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
【附件信息】
setup.sh
#!/bin/bash
set -e
TMP=/root/temp
umount $TMP 2>/dev/null || true
mkdir -p $TMP
modprobe -r ubifs 2>/dev/null || true
for i in $(seq 0 1)
do
ubidetach -p /dev/mtd$i 2>/dev/null || true
done
modprobe -r ubi 2>/dev/null || true
modprobe -r nandsim 2>/dev/null || true
mtd=/dev/mtd0
ubi=/dev/ubi0
ID="0xec,0xa1,0x00,0x15" # 128M 128KB 2KB
#ID="0x20,0xa5,0x00,0x15" # 2GB 128KB PEB, 2KB page
#ID="0x20,0xa5,0x00,0x26" # 4G 256KB 4KB 1KB-sub-page
#ID="0x20,0xa7,0x00,0x26" # 4G 256KB 4KB 2KB-sub-page
#ID="0x20,0x33,0x00,0x00" # 16M 16KB PEB, 512 page
modprobe nandsim id_bytes=$ID parts=400
# https://github.com/google/fscryptctl
encryption()
{
head -c 64 /dev/urandom > /tmp/key
key=$(/root/fscryptctl/fscryptctl add_key $TMP < /tmp/key)
/root/fscryptctl/fscryptctl set_policy $key $TMP
/root/fscryptctl/fscryptctl get_policy $TMP
}
flash_eraseall /dev/mtd0
if [ "$1" == "1" ]
then
modprobe ubi mtd="0,2048,1" fm_autoconvert
ubimkvol -N vol_a -m -n 0 /dev/ubi0
rmmod ubi
modprobe ubi mtd="0,2048,1" fm_autoconvert
modprobe ubifs
# mkfs.ubifs -j 6221824 -R 0 /dev/ubi0_0
mount -osync -t ubifs /dev/ubi0_0 $TMP
if [ "$2" == "e" ]
then
encryption
fi
else
nandwrite /dev/mtd0 disk > /dev/null
modprobe ubi mtd="0,2048,1" fm_autoconvert
modprobe ubifs
# echo 1 > /sys/kernel/debug/ubifs/chk_fs
mount -t ubifs /dev/ubi0_0 $TMP
fi
diff
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 4153e0d15c5f..e572ff1c6a7b 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -963,7 +963,8 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
if (!ubi->fm_buf)
goto out_free;
#endif
- err = ubi_attach(ubi, 0);
+ ubi->fm_disabled = 1;
+ err = ubi_attach(ubi, 1);
if (err) {
ubi_err(ubi, "failed to attach mtd%d, error %d",
mtd->index, err);
diff --git a/drivers/mtd/ubi/fastmap-wl.c b/drivers/mtd/ubi/fastmap-wl.c
index 053ab52668e8..1784449ef9b0 100644
--- a/drivers/mtd/ubi/fastmap-wl.c
+++ b/drivers/mtd/ubi/fastmap-wl.c
@@ -153,6 +153,7 @@ void ubi_refill_pools(struct ubi_device *ubi)
* the best anchor PEBs.
*/
ubi->fm_anchor = ubi_wl_get_fm_peb(ubi, 1);
+ printk_ratelimited("anchor %d\n", ubi->fm_anchor->pnum);
for (;;) {
enough = 0;
Hi czh549642238, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: Kernel, and any of the maintainers: @YangYingliang , @成坚 (CHENG Jian) , @jiaoff , @zhengzengkai , @刘勇强 , @wangxiongfeng , @朱科潜 , @WangShaoBo , @lujialin , @wuxu_buque , @Xu Kuohai , @冷嘲啊 , @Lingmingqiang , @yuzenghui , @juntian , @OSSIM , @陈结松 , @whoisxxx , @koulihong , @刘恺 , @hanjun-guo , @woqidaideshi , @Chiqijun , @Kefeng , @ThunderTown , @AlexGuo , @kylin-mayukun , @Zheng Zucheng , @柳歆 , @Jackie Liu , @zhujianwei001 , @郑振鹏 , @SuperSix173 , @colyli , @Zhang Yi , @htforge , @Qiuuuuu , @Yuehaibing , @xiehaocheng , @guzitao , @CTC-Xibo.Wang , @zhanghongchen , @chen wei , @Jason Zeng , @苟浩 , @DuanqiangWen , @georgeguo , @毛泓博 , @AllenShi , @zhangjialin , @Xie XiuQi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
登录 后才可以发表评论