mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 20:46:48 +02:00
For selinux or encryption scenarios, UBIFS could become inconsistent
while creating new files in powercut case. Encryption/selinux related
xattrs will be created before creating file dentry, which makes creation
process is not atomic, details are shown as:
Encryption case:
ubifs_create
ubifs_new_inode
fscrypt_set_context
ubifs_xattr_set
create_xattr
ubifs_jnl_update // Disk: xentry xinode inode(LAST_OF_NODE_GROUP)
>> power cut <<
ubifs_jnl_update // Disk: dentry inode parent_inode(LAST_OF_NODE_GROUP)
Selinux case:
ubifs_create
ubifs_new_inode
ubifs_init_security
security_inode_init_security
ubifs_xattr_set
create_xattr
ubifs_jnl_update // Disk: xentry xinode inode(LAST_OF_NODE_GROUP)
>> power cut <<
ubifs_jnl_update // Disk: dentry inode parent_inode(LAST_OF_NODE_GROUP)
Above process will make chk_fs failed in next mounting:
UBIFS error (ubi0:0 pid 7995): dbg_check_filesystem [ubifs]: inode 66
nlink is 1, but calculated nlink is 0
Fix it by allocating orphan inode for each non-xattr file creation, then
removing orphan list in journal writing process, which ensures that both
xattr and dentry be effective in atomic when powercut happens.
Fixes:
|
||
|---|---|---|
| .. | ||
| auth.c | ||
| budget.c | ||
| commit.c | ||
| compress.c | ||
| crypto.c | ||
| debug.c | ||
| debug.h | ||
| dir.c | ||
| file.c | ||
| find.c | ||
| gc.c | ||
| io.c | ||
| ioctl.c | ||
| journal.c | ||
| Kconfig | ||
| key.h | ||
| log.c | ||
| lprops.c | ||
| lpt_commit.c | ||
| lpt.c | ||
| Makefile | ||
| master.c | ||
| misc.c | ||
| misc.h | ||
| orphan.c | ||
| recovery.c | ||
| replay.c | ||
| sb.c | ||
| scan.c | ||
| shrinker.c | ||
| super.c | ||
| sysfs.c | ||
| tnc_commit.c | ||
| tnc_misc.c | ||
| tnc.c | ||
| ubifs-media.h | ||
| ubifs.h | ||
| xattr.c | ||