kernel_optimize_test/fs/ext4
Jan Kara a8f8e6ae97 ext4: fix deadlock with fs freezing and EA inodes
commit 46e294efc355c48d1dd4d58501aa56dac461792a upstream.

Xattr code using inodes with large xattr data can end up dropping last
inode reference (and thus deleting the inode) from places like
ext4_xattr_set_entry(). That function is called with transaction started
and so ext4_evict_inode() can deadlock against fs freezing like:

CPU1					CPU2

removexattr()				freeze_super()
  vfs_removexattr()
    ext4_xattr_set()
      handle = ext4_journal_start()
      ...
      ext4_xattr_set_entry()
        iput(old_ea_inode)
          ext4_evict_inode(old_ea_inode)
					  sb->s_writers.frozen = SB_FREEZE_FS;
					  sb_wait_write(sb, SB_FREEZE_FS);
					  ext4_freeze()
					    jbd2_journal_lock_updates()
					      -> blocks waiting for all
					         handles to stop
            sb_start_intwrite()
	      -> blocks as sb is already in SB_FREEZE_FS state

Generally it is advisable to delete inodes from a separate transaction
as it can consume quite some credits however in this case it would be
quite clumsy and furthermore the credits for inode deletion are quite
limited and already accounted for. So just tweak ext4_evict_inode() to
avoid freeze protection if we have transaction already started and thus
it is not really needed anyway.

Cc: stable@vger.kernel.org
Fixes: dec214d00e ("ext4: xattr inode deduplication")
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Link: https://lore.kernel.org/r/20201127110649.24730-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-30 11:54:13 +01:00
..
acl.c
acl.h
balloc.c
bitmap.c
block_validity.c
dir.c ext4: use generic casefolding support 2020-10-28 13:43:13 -04:00
ext4_extents.h
ext4_jbd2.c
ext4_jbd2.h
ext4.h ext4: fix bogus warning in ext4_update_dx_flag() 2020-11-19 22:41:10 -05:00
extents_status.c
extents_status.h
extents.c ext4: fix an IS_ERR() vs NULL check 2020-12-30 11:54:13 +01:00
fast_commit.c ext4: fix sparse warnings in fast_commit code 2020-11-07 00:08:23 -05:00
fast_commit.h ext4: disable fast commit with data journalling 2020-11-06 23:01:05 -05:00
file.c ext4: make s_mount_flags modifications atomic 2020-11-06 23:01:05 -05:00
fsmap.c jbd2: rename j_maxlen to j_total_len and add jbd2_journal_max_txn_bufs 2020-11-06 23:01:02 -05:00
fsmap.h
fsync.c ext4: make s_mount_flags modifications atomic 2020-11-06 23:01:05 -05:00
hash.c ext4: use generic casefolding support 2020-10-28 13:43:13 -04:00
ialloc.c
indirect.c
inline.c ext4: unlock xattr_sem properly in ext4_inline_data_truncate() 2020-11-06 22:52:36 -05:00
inode-test.c
inode.c ext4: fix deadlock with fs freezing and EA inodes 2020-12-30 11:54:13 +01:00
ioctl.c
Kconfig
Makefile
mballoc.c ext4: fix a memory leak of ext4_free_data 2020-12-30 11:54:13 +01:00
mballoc.h
migrate.c
mmp.c
move_extent.c
namei.c ext4: prevent creating duplicate encrypted filenames 2020-12-26 16:02:44 +01:00
page-io.c
readpage.c
resize.c
super.c ext4: drop fast_commit from /proc/mounts 2020-11-19 15:41:57 -05:00
symlink.c
sysfs.c ext4: indicate that fast_commit is available via /sys/fs/ext4/feature/... 2020-10-28 13:43:22 -04:00
truncate.h
verity.c
xattr_hurd.c
xattr_security.c
xattr_trusted.c
xattr_user.c
xattr.c
xattr.h