401 Star 1.4K Fork 1.3K

GVPopenEuler / kernel

 / 详情

ubifs在提交异常后umount触发断言失败UBIFS assert failed: freed == n

已完成
缺陷
创建于  
2023-02-06 11:30

【标题描述】ubifs在提交异常后umount触发断言失败UBIFS assert failed: freed == n
【环境信息】
硬件信息:
NA
软件信息:
OLK-5.10
【问题复现步骤】

  1. Apply diff
  2. ./setup.sh 1
  3. dd if=/dev/urandom of=/root/temp/file bs=4K count=10
  4. sync && umount temp
    出现概率(是否必现,概率性错误)必现
    【预期结果】
    ubifs assert失败
    【实际结果】
    [ 3843.752697] free 3 n 0
    [ 3843.756703] UBIFS error (ubi0:0 pid 1684): ubifs_assert_failed [ubifs]: UBIFS assert failed: freed == n, in fs/ubifs/tnc.c:3072
    【附件信息】
    diff
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index 488f3da7a6c6..f081aaffe9d8 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -3068,6 +3068,7 @@ void ubifs_tnc_close(struct ubifs_info *c)
 
 		n = atomic_long_read(&c->clean_zn_cnt);
 		freed = ubifs_destroy_tnc_subtree(c, c->zroot.znode);
+		pr_err("free %ld n %ld\n", freed, n);
 		ubifs_assert(c, freed == n);
 		atomic_long_sub(n, &ubifs_clean_zn_cnt);
 	}
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
index 01362ad5f804..9d9d379efb0e 100644
--- a/fs/ubifs/tnc_commit.c
+++ b/fs/ubifs/tnc_commit.c
@@ -989,7 +989,7 @@ static int write_index(struct ubifs_info *c)
 		}
 
 		/* The buffer is full or there are no more znodes to do */
-		err = ubifs_leb_write(c, lnum, c->cbuf, buf_offs, blen);
+		err = -EIO;
 		if (err)
 			return err;
 		buf_offs += blen;

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

# 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
}
authentication()
{
	keyctl clear @s
	keyctl add logon ubifs:foo 12345678901234567890123456789012 @s
}

flash_eraseall /dev/mtd0

if [ "$1" == "1" ]
then
	modprobe ubi mtd="0,2048" fm_autoconvert
	ubimkvol -N vol_a -m -n 0 /dev/ubi0
	modprobe ubifs
#	mkfs.ubifs -j 6221824 -R 0 /dev/ubi0_0
	if [ "$2" == "a" ]
	then
		authentication
		mount -t ubifs /dev/ubi0_0 -o auth_key=ubifs:foo,auth_hash_name=sha256 $TMP
	else
		mount -t ubifs /dev/ubi0_0 $TMP
	fi
	if [ "$2" == "e" ]
	then
		encryption
	fi
else
	nandwrite /dev/mtd0 disk > /dev/null
	modprobe ubi mtd="0,2048" fm_autoconvert
	modprobe ubifs
	#echo 1 > /sys/kernel/debug/ubifs/chk_fs
	mount -t ubifs /dev/ubi0_0 $TMP
fi

评论 (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 , @成坚 (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

登录 后才可以发表评论

状态
负责人
项目
里程碑
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

搜索帮助