Bug 218661 - BUG REPORT: ubifs: unattached xattr inode if powercut after deleting
Summary: BUG REPORT: ubifs: unattached xattr inode if powercut after deleting
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: fs_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-30 06:37 UTC by Zhihao Cheng
Modified: 2024-03-30 07:38 UTC (History)
0 users

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments
test.sh (1.40 KB, application/x-shellscript)
2024-03-30 06:41 UTC, Zhihao Cheng
Details
a.c (890 bytes, text/plain)
2024-03-30 06:41 UTC, Zhihao Cheng
Details
test_userxattr.sh (1.44 KB, application/x-shellscript)
2024-03-30 07:38 UTC, Zhihao Cheng
Details

Description Zhihao Cheng 2024-03-30 06:37:20 UTC
The xattr inode will be alone in TNC and its' xattr entry cannot be found in TNC, when powercut in selinux or encryption scenario.

1. touch file (selinux enable)
   xattr entry, xattr inode, inode, dentry are fell on disk
2. open file
3. unlink file
   inode(nlink=0), xattr inode(nlink=1) are added into orphan list
4. commit
   write inode ino and xattr inode ino to orphan area
5. powercut
6. mount
   do_kill_orphans 
    inode(nlink=0) is deleted from TNC by ubifs_tnc_remove_range, xattr entry is deleted too.
    xattr inode(nlink=1) is not deleted from TNC

Finally, xattr inode is alone in TNC, its' xattr entry has been deleted.
Comment 1 Zhihao Cheng 2024-03-30 06:39:07 UTC
Reproduce:
1. ./test.sh 1
2. Dump mtd image and do powercut when you see printing message "Execute powercut".
3. Reboot && ./test.sh

[   41.155062] UBIFS error (ubi0:0 pid 1093): dbg_check_filesystem [ubifs]: inode 66 nlink is 1, but calculated nlink is 0
[   41.156438] UBIFS (ubi0:0): dump of the inode 66 sitting in LEB 12:2128
[   41.156442] 	magic          0x6101831
[   41.156901] 	crc            0xb205a6bc
[   41.157402] 	node_type      0 (inode node)
[   41.157935] 	group_type     1 (in node group)
[   41.158515] 	sqnum          12
[   41.158887] 	len            197
[   41.159322] 	key            (66, inode)
[   41.159793] 	creat_sqnum    9
[   41.160194] 	size           37
[   41.160582] 	nlink          1
[   41.160966] 	atime          1711779452.0
[   41.161470] 	mtime          1711779452.0
[   41.161969] 	ctime          1711779452.0
[   41.162487] 	uid            0
[   41.162877] 	gid            0
[   41.163283] 	mode           33279
[   41.163666] 	flags          0x20
[   41.164112] 	xattr_cnt      0
[   41.164488] 	xattr_size     0
[   41.164861] 	xattr_names    0
[   41.165265] 	compr_type     0x3
[   41.165662] 	data len       37
Comment 2 Zhihao Cheng 2024-03-30 06:40:21 UTC
(In reply to Zhihao Cheng from comment #1)

> [   41.160194]        size           37
> [   41.160582]        nlink          1
> [   41.163666]        flags          0x20  # UBIFS_XATTR_FL
> [   41.164112]        xattr_cnt      0
> [   41.164488]        xattr_size     0
> [   41.164861]        xattr_names    0
> [   41.165265]        compr_type     0x3
> [   41.165662]        data len       37
Comment 3 Zhihao Cheng 2024-03-30 06:41:10 UTC
Created attachment 306060 [details]
test.sh
Comment 4 Zhihao Cheng 2024-03-30 06:41:21 UTC
Created attachment 306061 [details]
a.c
Comment 5 Zhihao Cheng 2024-03-30 07:38:46 UTC
Created attachment 306062 [details]
test_userxattr.sh

Actually, all kinds of xattr could trigger this problem.

Note You need to log in before you can comment on or make changes to this bug.