]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
ext4: Do not iput inode under running transaction
authorJan Kara <jack@suse.cz>
Tue, 5 Nov 2019 16:44:11 +0000 (17:44 +0100)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 5 Nov 2019 17:13:25 +0000 (12:13 -0500)
commit9b88f9fb0d2fc8f7e71e75a42c5a064bc6cfffd2
treeddf3f8ea6c1000bad300072104cf00b5b1fe8558
parenta9e26328adfa82b1f3c941bc6e3daea47631abce
ext4: Do not iput inode under running transaction

When ext4_mkdir(), ext4_symlink(), ext4_create(), or ext4_mknod() fail
to add entry into directory, it ends up dropping freshly created inode
under the running transaction and thus inode truncation happens under
that transaction. That breaks assumptions that evict() does not get
called from a transaction context and at least in ext4_symlink() case it
can result in inode eviction deadlocking in inode_wait_for_writeback()
when flush worker finds symlink inode, starts to write it back and
blocks on starting a transaction. So change the code in ext4_mkdir() and
ext4_add_nondir() to drop inode reference only after the transaction is
stopped. We also have to add inode to the orphan list in that case as
otherwise the inode would get leaked in case we crash before inode
deletion is committed.

CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20191105164437.32602-5-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/namei.c