Theodore Ts'o
9b06cce3ca
ext4: fix deadlock between inline_data and ext4_expand_extra_isize_ea()
...
commit c755e251357a0cee0679081f08c3f4ba797a8009 upstream.
The xattr_sem deadlock problems fixed in commit 2e81a4eeedca: "ext4:
avoid deadlock when expanding inode size" didn't include the use of
xattr_sem in fs/ext4/inline.c. With the addition of project quota
which added a new extra inode field, this exposed deadlocks in the
inline_data code similar to the ones fixed by 2e81a4eeedca.
The deadlock can be reproduced via:
dmesg -n 7
mke2fs -t ext4 -O inline_data -Fq -I 256 /dev/vdc 32768
mount -t ext4 -o debug_want_extra_isize=24 /dev/vdc /vdc
mkdir /vdc/a
umount /vdc
mount -t ext4 /dev/vdc /vdc
echo foo > /vdc/a/foo
and looks like this:
[ 11.158815]
[ 11.160276] =============================================
[ 11.161960] [ INFO: possible recursive locking detected ]
[ 11.161960] 4.10.0-rc3-00015-g011b30a8a3cf #160 Tainted: G W
[ 11.161960] ---------------------------------------------
[ 11.161960] bash/2519 is trying to acquire lock:
[ 11.161960] (&ei->xattr_sem){++++..}, at: [<c1225a4b>] ext4_expand_extra_isize_ea+0x3d/0x4cd
[ 11.161960]
[ 11.161960] but task is already holding lock:
[ 11.161960] (&ei->xattr_sem){++++..}, at: [<c1227941>] ext4_try_add_inline_entry+0x3a/0x152
[ 11.161960]
[ 11.161960] other info that might help us debug this:
[ 11.161960] Possible unsafe locking scenario:
[ 11.161960]
[ 11.161960] CPU0
[ 11.161960] ----
[ 11.161960] lock(&ei->xattr_sem);
[ 11.161960] lock(&ei->xattr_sem);
[ 11.161960]
[ 11.161960] *** DEADLOCK ***
[ 11.161960]
[ 11.161960] May be due to missing lock nesting notation
[ 11.161960]
[ 11.161960] 4 locks held by bash/2519:
[ 11.161960] #0 : (sb_writers#3){.+.+.+}, at: [<c11a2414>] mnt_want_write+0x1e/0x3e
[ 11.161960] #1 : (&type->i_mutex_dir_key){++++++}, at: [<c119508b>] path_openat+0x338/0x67a
[ 11.161960] #2 : (jbd2_handle){++++..}, at: [<c123314a>] start_this_handle+0x582/0x622
[ 11.161960] #3 : (&ei->xattr_sem){++++..}, at: [<c1227941>] ext4_try_add_inline_entry+0x3a/0x152
[ 11.161960]
[ 11.161960] stack backtrace:
[ 11.161960] CPU: 0 PID: 2519 Comm: bash Tainted: G W 4.10.0-rc3-00015-g011b30a8a3cf #160
[ 11.161960] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1 04/01/2014
[ 11.161960] Call Trace:
[ 11.161960] dump_stack+0x72/0xa3
[ 11.161960] __lock_acquire+0xb7c/0xcb9
[ 11.161960] ? kvm_clock_read+0x1f/0x29
[ 11.161960] ? __lock_is_held+0x36/0x66
[ 11.161960] ? __lock_is_held+0x36/0x66
[ 11.161960] lock_acquire+0x106/0x18a
[ 11.161960] ? ext4_expand_extra_isize_ea+0x3d/0x4cd
[ 11.161960] down_write+0x39/0x72
[ 11.161960] ? ext4_expand_extra_isize_ea+0x3d/0x4cd
[ 11.161960] ext4_expand_extra_isize_ea+0x3d/0x4cd
[ 11.161960] ? _raw_read_unlock+0x22/0x2c
[ 11.161960] ? jbd2_journal_extend+0x1e2/0x262
[ 11.161960] ? __ext4_journal_get_write_access+0x3d/0x60
[ 11.161960] ext4_mark_inode_dirty+0x17d/0x26d
[ 11.161960] ? ext4_add_dirent_to_inline.isra.12+0xa5/0xb2
[ 11.161960] ext4_add_dirent_to_inline.isra.12+0xa5/0xb2
[ 11.161960] ext4_try_add_inline_entry+0x69/0x152
[ 11.161960] ext4_add_entry+0xa3/0x848
[ 11.161960] ? __brelse+0x14/0x2f
[ 11.161960] ? _raw_spin_unlock_irqrestore+0x44/0x4f
[ 11.161960] ext4_add_nondir+0x17/0x5b
[ 11.161960] ext4_create+0xcf/0x133
[ 11.161960] ? ext4_mknod+0x12f/0x12f
[ 11.161960] lookup_open+0x39e/0x3fb
[ 11.161960] ? __wake_up+0x1a/0x40
[ 11.161960] ? lock_acquire+0x11e/0x18a
[ 11.161960] path_openat+0x35c/0x67a
[ 11.161960] ? sched_clock_cpu+0xd7/0xf2
[ 11.161960] do_filp_open+0x36/0x7c
[ 11.161960] ? _raw_spin_unlock+0x22/0x2c
[ 11.161960] ? __alloc_fd+0x169/0x173
[ 11.161960] do_sys_open+0x59/0xcc
[ 11.161960] SyS_open+0x1d/0x1f
[ 11.161960] do_int80_syscall_32+0x4f/0x61
[ 11.161960] entry_INT80_32+0x2f/0x2f
[ 11.161960] EIP: 0xb76ad469
[ 11.161960] EFLAGS: 00000286 CPU: 0
[ 11.161960] EAX: ffffffda EBX: 08168ac8 ECX: 00008241 EDX: 000001b6
[ 11.161960] ESI: b75e46bc EDI: b7755000 EBP: bfbdb108 ESP: bfbdafc0
[ 11.161960] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b
Cc: stable@vger.kernel.org # 3.10 (requires 2e81a4eeedca as a prereq)
Reported-by: George Spelvin <linux@sciencehorizons.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-24 09:32:10 +02:00
..
2017-11-30 08:37:22 +00:00
2015-06-30 19:44:57 -07:00
2016-06-07 18:14:32 -07:00
2017-12-20 10:04:56 +01:00
2017-12-20 10:04:51 +01:00
2015-07-04 19:36:06 -07:00
2018-04-13 19:50:06 +02:00
2015-11-16 20:38:43 -05:00
2017-12-20 10:04:52 +01:00
2018-04-13 19:50:04 +02:00
2017-11-24 08:32:25 +01:00
2017-06-26 07:13:08 +02:00
2017-08-06 19:19:42 -07:00
2016-08-16 09:30:49 +02:00
2017-09-13 14:09:45 -07:00
2017-11-30 08:37:20 +00:00
2016-03-03 15:07:09 -08:00
2015-12-12 10:15:34 -08:00
2018-01-31 12:06:11 +01:00
2018-04-24 09:32:10 +02:00
2018-03-22 09:23:22 +01:00
2017-03-15 09:57:15 +08:00
2015-08-07 13:59:24 +02:00
2017-10-27 10:23:18 +02:00
2017-11-02 09:40:49 +01:00
2017-12-20 10:04:59 +01:00
2015-09-10 13:29:01 -07:00
2016-10-31 04:13:58 -06:00
2016-09-30 10:18:39 +02:00
2016-06-01 12:15:54 -07:00
2017-06-26 07:13:11 +02:00
2017-11-30 08:37:20 +00:00
2018-04-24 09:32:07 +02:00
2016-10-31 04:13:58 -06:00
2017-06-14 13:16:24 +02:00
2018-02-16 20:09:42 +01:00
2018-04-13 19:50:02 +02:00
2015-11-06 17:50:42 -08:00
2015-07-04 19:36:06 -07:00
2018-03-28 18:40:15 +02:00
2018-04-13 19:50:10 +02:00
2018-02-03 17:04:28 +01:00
2018-03-24 10:58:48 +01:00
2017-11-30 08:37:20 +00:00
2017-08-06 19:19:42 -07:00
2015-11-06 17:50:42 -08:00
2017-12-09 18:42:43 +01:00
2018-04-13 19:50:14 +02:00
2018-04-08 11:52:00 +02:00
2017-08-06 19:19:43 -07:00
2018-02-03 17:04:28 +01:00
2015-10-16 11:42:28 -07:00
2018-04-24 09:32:05 +02:00
2017-06-17 06:39:38 +02:00
2015-11-13 20:34:33 -05:00
2017-04-12 12:38:33 +02:00
2015-11-23 21:11:08 -05:00
2015-11-04 22:13:45 -05:00
2018-04-24 09:32:05 +02:00
2017-12-20 10:05:01 +01:00
2017-06-14 13:16:24 +02:00
2018-03-03 10:19:44 +01:00
2018-03-22 09:23:31 +01:00
2016-10-22 12:26:56 +02:00
2015-11-10 12:07:22 -08:00
2017-07-21 07:44:57 +02:00
2017-05-20 14:27:01 +02:00
2017-06-14 13:16:24 +02:00
2015-08-05 13:49:35 -07:00
2018-02-25 11:03:51 +01:00
2018-04-08 11:51:57 +02:00
2017-07-05 14:37:20 +02:00
2015-11-16 23:54:45 -08:00
2018-03-22 09:23:31 +01:00
2017-10-18 09:20:42 +02:00
2015-08-17 18:39:46 -04:00
2017-09-07 08:34:10 +02:00
2017-07-21 07:44:57 +02:00
2018-01-31 12:06:11 +01:00
2016-04-12 09:08:58 -07:00
2015-08-07 04:39:40 +03:00
2015-11-05 23:05:32 -08:00
2017-12-20 10:04:54 +01:00
2018-02-16 20:09:38 +01:00
2015-08-17 23:38:10 -04:00
2015-11-16 23:54:45 -08:00
2015-08-12 15:28:45 -05:00
2018-01-17 09:35:27 +01:00
2015-10-15 10:33:21 -04:00
2017-07-21 07:44:57 +02:00
2017-06-14 13:16:24 +02:00
2018-04-24 09:32:04 +02:00
2017-07-21 07:44:57 +02:00
2018-02-16 20:09:43 +01:00
2017-07-15 11:57:44 +02:00
2018-01-23 19:50:15 +01:00
2017-07-21 07:44:58 +02:00
2017-04-30 05:49:28 +02:00
2017-01-26 08:23:47 +01:00
2016-04-12 09:08:55 -07:00
2017-10-05 09:41:45 +02:00
2018-01-31 12:06:09 +01:00
2017-08-06 19:19:42 -07:00
2015-08-07 04:39:40 +03:00
2017-02-23 17:43:09 +01:00
2017-06-14 13:16:24 +02:00
2018-03-03 10:19:41 +01:00
2015-11-06 17:50:42 -08:00
2017-05-08 07:46:01 +02:00
2017-12-20 10:04:53 +01:00
2016-10-22 12:26:56 +02:00
2017-10-12 11:27:32 +02:00