402 Star 1.4K Fork 1.3K

GVPopenEuler / kernel

 / 详情

【OLK-5.10】UBI获取空闲PEB失败,设备变只读

已完成
缺陷
创建于  
2022-05-11 10:11

【标题描述】能够简要描述问题:说明什么场景下,做了什么操作,出现什么问题(尽量使用正向表达方式)
执行下面脚本大概率复现UBI创建卷失败,报没有空间

#!/bin/bash

# exit on error
set -e

ubidetach -p /dev/mtd0 2>/dev/null || true
modprobe -r ubi 2>/dev/null || true
modprobe -r nandsim 2>/dev/null || true

mtd=/dev/mtd0
ubi=/dev/ubi0

# 2GB, 8-bits, page size 4KB, OOB 128B, block 128KB
ID="0x20,0xa5,0x00,0x16"
TSIZE=400MiB

modprobe nandsim id_bytes=$ID
flash_erase -q -j $mtd 0 0
modprobe ubi

ubiattach -p $mtd
ubimkvol $ubi -N test -s $TSIZE

exit 0

[   32.228248] ubi0 error: ubi_wl_get_peb [ubi]: Unable to get a free PEB from user WL pool
[   32.229321] ubi0 warning: ubi_eba_atomic_leb_change [ubi]: switch to read-only mode
[   32.230341] CPU: 0 PID: 7439 Comm: ubimkvol Not tainted 5.10.0-14014-g00455bffe746-dirty #345
[   32.231444] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc314
[   32.233152] Call Trace:
[   32.233494]  ? dump_stack+0xa6/0xd5
[   32.233958]  ? ubi_eba_atomic_leb_change+0x45e/0x470 [ubi]
[   32.234678]  ? ubi_update_layout_vol+0x48/0x70 [ubi]
[   32.235327]  ? ubi_change_vtbl_record+0x9e/0x140 [ubi]
[   32.235995]  ? ubi_create_volume+0x63c/0x830 [ubi]
[   32.236627]  ? ubi_cdev_ioctl+0xc14/0x1170 [ubi]
[   32.237228]  ? __se_sys_ioctl+0xda/0x130
[   32.237740]  ? __x64_sys_ioctl+0x1e/0x30
[   32.238255]  ? do_syscall_64+0x45/0x70
[   32.238741]  ? entry_SYSCALL_64_after_hwframe+0x44/0xa9
[   32.239967] ubi0 error: ubi_create_volume [ubi]: cannot create volume 0, error -28

【环境信息】
硬件信息:
NA
软件信息:
OLK5.10
【问题复现步骤】
具体操作步骤
在内核加打印

diff --git a/drivers/mtd/ubi/fastmap-wl.c b/drivers/mtd/ubi/fastmap-wl.c
index 0ee452275578..b4f095e1dc09 100644
--- a/drivers/mtd/ubi/fastmap-wl.c
+++ b/drivers/mtd/ubi/fastmap-wl.c
@@ -187,6 +187,7 @@ void ubi_refill_pools(struct ubi_device *ubi)
 			break;
 	}
 
+	pr_err("pool->size %d\n", pool->size);
 	wl_pool->used = 0;
 	pool->used = 0;
 
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 55bae06cf408..479b1b16f34d 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -185,12 +185,15 @@ static void wl_entry_destroy(struct ubi_device *ubi, struct ubi_wl_entry *e)
  * This function returns zero in case of success and a negative error code in
  * case of failure.
  */
+#include <linux/delay.h>
 static int do_work(struct ubi_device *ubi)
 {
 	int err;
 	struct ubi_work *wrk;
 
 	cond_resched();
+	if (ubi->free.rb_node)
+		msleep(2000);
 
 	/*
 	 * @ubi->work_sem is used to synchronize with the workers. Workers take

执行上述复现脚本
出现概率(是否必现,概率性错误)大
【预期结果】
用户态ubimkvol失败,内核打印"ubi_wl_get_peb [ubi]: Unable to get a free PEB from user WL pool"
【实际结果】

ubimkvol: error!: cannot UBI create volume

          error 28 (No space left on device)

setup ubifs failed

[   32.228248] ubi0 error: ubi_wl_get_peb [ubi]: Unable to get a free PEB from user WL pool
[   32.229321] ubi0 warning: ubi_eba_atomic_leb_change [ubi]: switch to read-only mode
[   32.230341] CPU: 0 PID: 7439 Comm: ubimkvol Not tainted 5.10.0-14014-g00455bffe746-dirty #345
[   32.231444] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc314
[   32.233152] Call Trace:
[   32.233494]  ? dump_stack+0xa6/0xd5
[   32.233958]  ? ubi_eba_atomic_leb_change+0x45e/0x470 [ubi]
[   32.234678]  ? ubi_update_layout_vol+0x48/0x70 [ubi]
[   32.235327]  ? ubi_change_vtbl_record+0x9e/0x140 [ubi]
[   32.235995]  ? ubi_create_volume+0x63c/0x830 [ubi]
[   32.236627]  ? ubi_cdev_ioctl+0xc14/0x1170 [ubi]
[   32.237228]  ? __se_sys_ioctl+0xda/0x130
[   32.237740]  ? __x64_sys_ioctl+0x1e/0x30
[   32.238255]  ? do_syscall_64+0x45/0x70
[   32.238741]  ? entry_SYSCALL_64_after_hwframe+0x44/0xa9
[   32.239967] ubi0 error: ubi_create_volume [ubi]: cannot create volume 0, error -28

【附件信息】

评论 (1)

chengzhihao 创建了缺陷

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 , @pi3orama , @成坚 (CHENG Jian) , @jiaoff , @Xie XiuQi

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
5329419 openeuler ci bot 1632792936
C
1
https://gitee.com/openeuler/kernel.git
git@gitee.com:openeuler/kernel.git
openeuler
kernel
kernel

搜索帮助