Commit c755e25
committed
ext4: fix deadlock between inline_data and ext4_expand_extra_isize_ea()
The xattr_sem deadlock problems fixed in commit 2e81a4e: "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 2e81a4e.
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 torvalds#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 torvalds#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: 08168ac 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 2e81a4e as a prereq)
Reported-by: George Spelvin <linux@sciencehorizons.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>1 parent 670e987 commit c755e25
3 files changed
+74
-54
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
384 | | - | |
| 384 | + | |
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
402 | | - | |
| 401 | + | |
403 | 402 | | |
404 | 403 | | |
405 | 404 | | |
| |||
533 | 532 | | |
534 | 533 | | |
535 | 534 | | |
536 | | - | |
| 535 | + | |
537 | 536 | | |
538 | 537 | | |
539 | 538 | | |
| |||
573 | 572 | | |
574 | 573 | | |
575 | 574 | | |
576 | | - | |
| 575 | + | |
577 | 576 | | |
578 | 577 | | |
579 | 578 | | |
| |||
610 | 609 | | |
611 | 610 | | |
612 | 611 | | |
613 | | - | |
| 612 | + | |
614 | 613 | | |
615 | 614 | | |
616 | 615 | | |
| |||
636 | 635 | | |
637 | 636 | | |
638 | 637 | | |
639 | | - | |
| 638 | + | |
640 | 639 | | |
641 | 640 | | |
642 | 641 | | |
| |||
729 | 728 | | |
730 | 729 | | |
731 | 730 | | |
732 | | - | |
| 731 | + | |
733 | 732 | | |
734 | 733 | | |
735 | 734 | | |
| |||
747 | 746 | | |
748 | 747 | | |
749 | 748 | | |
750 | | - | |
| 749 | + | |
751 | 750 | | |
752 | 751 | | |
753 | 752 | | |
| |||
757 | 756 | | |
758 | 757 | | |
759 | 758 | | |
760 | | - | |
| 759 | + | |
761 | 760 | | |
762 | 761 | | |
763 | 762 | | |
| |||
768 | 767 | | |
769 | 768 | | |
770 | 769 | | |
771 | | - | |
| 770 | + | |
772 | 771 | | |
773 | 772 | | |
774 | 773 | | |
| |||
778 | 777 | | |
779 | 778 | | |
780 | 779 | | |
781 | | - | |
| 780 | + | |
782 | 781 | | |
783 | 782 | | |
784 | 783 | | |
785 | | - | |
| 784 | + | |
786 | 785 | | |
787 | 786 | | |
788 | 787 | | |
| |||
1259 | 1258 | | |
1260 | 1259 | | |
1261 | 1260 | | |
1262 | | - | |
| 1261 | + | |
1263 | 1262 | | |
1264 | 1263 | | |
1265 | 1264 | | |
1266 | 1265 | | |
1267 | 1266 | | |
1268 | 1267 | | |
1269 | 1268 | | |
1270 | | - | |
| 1269 | + | |
1271 | 1270 | | |
1272 | 1271 | | |
1273 | 1272 | | |
| |||
1313 | 1312 | | |
1314 | 1313 | | |
1315 | 1314 | | |
1316 | | - | |
| 1315 | + | |
1317 | 1316 | | |
1318 | 1317 | | |
1319 | 1318 | | |
| |||
1673 | 1672 | | |
1674 | 1673 | | |
1675 | 1674 | | |
1676 | | - | |
| 1675 | + | |
1677 | 1676 | | |
1678 | 1677 | | |
1679 | 1678 | | |
1680 | 1679 | | |
1681 | 1680 | | |
1682 | 1681 | | |
1683 | 1682 | | |
1684 | | - | |
| 1683 | + | |
1685 | 1684 | | |
1686 | 1685 | | |
1687 | 1686 | | |
| |||
1715 | 1714 | | |
1716 | 1715 | | |
1717 | 1716 | | |
1718 | | - | |
| 1717 | + | |
1719 | 1718 | | |
1720 | 1719 | | |
1721 | 1720 | | |
| |||
1814 | 1813 | | |
1815 | 1814 | | |
1816 | 1815 | | |
1817 | | - | |
| 1816 | + | |
1818 | 1817 | | |
1819 | | - | |
| 1818 | + | |
1820 | 1819 | | |
1821 | | - | |
| 1820 | + | |
1822 | 1821 | | |
1823 | 1822 | | |
1824 | 1823 | | |
| |||
1903 | 1902 | | |
1904 | 1903 | | |
1905 | 1904 | | |
1906 | | - | |
| 1905 | + | |
1907 | 1906 | | |
1908 | 1907 | | |
1909 | 1908 | | |
| |||
1920 | 1919 | | |
1921 | 1920 | | |
1922 | 1921 | | |
1923 | | - | |
| 1922 | + | |
1924 | 1923 | | |
1925 | 1924 | | |
1926 | 1925 | | |
| |||
1978 | 1977 | | |
1979 | 1978 | | |
1980 | 1979 | | |
1981 | | - | |
| 1980 | + | |
1982 | 1981 | | |
1983 | 1982 | | |
1984 | 1983 | | |
| |||
1994 | 1993 | | |
1995 | 1994 | | |
1996 | 1995 | | |
1997 | | - | |
| 1996 | + | |
1998 | 1997 | | |
1999 | 1998 | | |
2000 | 1999 | | |
| |||
2016 | 2015 | | |
2017 | 2016 | | |
2018 | 2017 | | |
2019 | | - | |
2020 | | - | |
2021 | | - | |
2022 | | - | |
2023 | | - | |
2024 | | - | |
2025 | | - | |
2026 | | - | |
2027 | | - | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
2028 | 2022 | | |
2029 | 2023 | | |
2030 | 2024 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1188 | 1188 | | |
1189 | 1189 | | |
1190 | 1190 | | |
1191 | | - | |
| 1191 | + | |
1192 | 1192 | | |
1193 | 1193 | | |
1194 | 1194 | | |
1195 | 1195 | | |
1196 | 1196 | | |
1197 | 1197 | | |
1198 | | - | |
1199 | | - | |
1200 | | - | |
| 1198 | + | |
1201 | 1199 | | |
1202 | 1200 | | |
1203 | 1201 | | |
| |||
1264 | 1262 | | |
1265 | 1263 | | |
1266 | 1264 | | |
1267 | | - | |
| 1265 | + | |
1268 | 1266 | | |
1269 | 1267 | | |
1270 | 1268 | | |
| |||
1278 | 1276 | | |
1279 | 1277 | | |
1280 | 1278 | | |
1281 | | - | |
1282 | | - | |
1283 | | - | |
| 1279 | + | |
1284 | 1280 | | |
1285 | 1281 | | |
1286 | 1282 | | |
| |||
1497 | 1493 | | |
1498 | 1494 | | |
1499 | 1495 | | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
1500 | 1500 | | |
1501 | | - | |
1502 | | - | |
1503 | | - | |
1504 | | - | |
1505 | | - | |
1506 | 1501 | | |
1507 | 1502 | | |
1508 | 1503 | | |
| |||
1584 | 1579 | | |
1585 | 1580 | | |
1586 | 1581 | | |
1587 | | - | |
1588 | | - | |
| 1582 | + | |
1589 | 1583 | | |
1590 | 1584 | | |
1591 | 1585 | | |
1592 | 1586 | | |
1593 | 1587 | | |
1594 | | - | |
1595 | | - | |
| 1588 | + | |
1596 | 1589 | | |
1597 | | - | |
| 1590 | + | |
| 1591 | + | |
1598 | 1592 | | |
1599 | 1593 | | |
1600 | 1594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
105 | 137 | | |
106 | 138 | | |
107 | 139 | | |
| |||
0 commit comments