mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
b25e6a5f78
There is a potential space leak problem when powercut happens in linking
tmpfile, in which case, inode node (with nlink=0) and its' data nodes can
be found from tnc (on flash), but there are no dentries related to the
inode, so the file is invisible but takes free space. Detailed process is
shown as:
ubifs_tmpfile
ubifs_jnl_update // Add bud A into log area
ubifs_add_orphan // Add inode into orphan list
P1 P2
ubifs_link
ubifs_delete_orphan // Delete inode from orphan list, then inode won't
// be written into orphan area, there is no chance
// to delete inode by replaying orphan.
commit // bud A won't be replayed in next mounting
>> powercut <<
ubifs_jnl_update // Link inode to dentry
The root cause is that orphan entry deletion and journal writing(for link)
are interrupted by commit, which makes the two operations are not atomic.
Fix it by doing ubifs_delete_orphan under the protection of c->commit_sem
within ubifs_jnl_update. This is also a preparation to support all creating
new files by orphan inode.
v1 is https://lore.kernel.org/linux-mtd/20200701093227.674945-1-chengzhihao1@huawei.com/
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 |