Filipe Manana
3b87d0c583
btrfs: fix sleep while in non-sleep context during qgroup removal
...
commit 0bb788300990d3eb5582d3301a720f846c78925c upstream.
While removing a qgroup's sysfs entry we end up taking the kernfs_mutex,
through kobject_del(), while holding the fs_info->qgroup_lock spinlock,
producing the following trace:
[821.843637] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:281
[821.843641] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 28214, name: podman
[821.843644] CPU: 3 PID: 28214 Comm: podman Tainted: G W 5.11.6 #15
[821.843646] Hardware name: Dell Inc. PowerEdge R330/084XW4, BIOS 2.11.0 12/08/2020
[821.843647] Call Trace:
[821.843650] dump_stack+0xa1/0xfb
[821.843656] ___might_sleep+0x144/0x160
[821.843659] mutex_lock+0x17/0x40
[821.843662] kernfs_remove_by_name_ns+0x1f/0x80
[821.843666] sysfs_remove_group+0x7d/0xe0
[821.843668] sysfs_remove_groups+0x28/0x40
[821.843670] kobject_del+0x2a/0x80
[821.843672] btrfs_sysfs_del_one_qgroup+0x2b/0x40 [btrfs]
[821.843685] __del_qgroup_rb+0x12/0x150 [btrfs]
[821.843696] btrfs_remove_qgroup+0x288/0x2a0 [btrfs]
[821.843707] btrfs_ioctl+0x3129/0x36a0 [btrfs]
[821.843717] ? __mod_lruvec_page_state+0x5e/0xb0
[821.843719] ? page_add_new_anon_rmap+0xbc/0x150
[821.843723] ? kfree+0x1b4/0x300
[821.843725] ? mntput_no_expire+0x55/0x330
[821.843728] __x64_sys_ioctl+0x5a/0xa0
[821.843731] do_syscall_64+0x33/0x70
[821.843733] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[821.843736] RIP: 0033:0x4cd3fb
[821.843741] RSP: 002b:000000c000906b20 EFLAGS: 00000206 ORIG_RAX: 0000000000000010
[821.843744] RAX: ffffffffffffffda RBX: 000000c000050000 RCX: 00000000004cd3fb
[821.843745] RDX: 000000c000906b98 RSI: 000000004010942a RDI: 000000000000000f
[821.843747] RBP: 000000c000907cd0 R08: 000000c000622901 R09: 0000000000000000
[821.843748] R10: 000000c000d992c0 R11: 0000000000000206 R12: 000000000000012d
[821.843749] R13: 000000000000012c R14: 0000000000000200 R15: 0000000000000049
Fix this by removing the qgroup sysfs entry while not holding the spinlock,
since the spinlock is only meant for protection of the qgroup rbtree.
Reported-by: Stuart Shelton <srcshelton@gmail.com>
Link: https://lore.kernel.org/linux-btrfs/7A5485BB-0628-419D-A4D3-27B1AF47E25A@gmail.com/
Fixes: 49e5fb46211de0 ("btrfs: qgroup: export qgroups in sysfs")
CC: stable@vger.kernel.org # 5.10+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-30 14:31:53 +02:00
..
2020-12-01 21:40:47 +01:00
2020-10-24 12:26:05 -07:00
2021-03-04 11:38:37 +01:00
2021-03-25 09:04:07 +01:00
2020-10-16 11:11:22 -07:00
2020-09-18 16:45:50 -04:00
2021-01-06 14:56:52 +01:00
2021-03-30 14:31:53 +02:00
2021-01-27 11:55:22 +01:00
2021-03-04 11:38:08 +01:00
2021-03-30 14:31:50 +02:00
2021-03-17 17:06:34 +01:00
2020-09-18 16:45:50 -04:00
2020-12-26 16:02:43 +01:00
2021-03-04 11:37:17 +01:00
2020-10-15 18:42:13 -07:00
2020-08-07 11:33:22 -07:00
2020-11-25 16:55:02 +01:00
2020-09-18 16:45:50 -04:00
2021-03-07 12:34:05 +01:00
2021-03-04 11:38:41 +01:00
2020-10-24 12:26:05 -07:00
2021-03-25 09:04:17 +01:00
2021-03-07 12:34:12 +01:00
2020-09-18 16:45:50 -04:00
2021-03-20 10:43:43 +01:00
2021-03-30 14:31:49 +02:00
2020-10-29 17:22:59 -05:00
2020-10-29 17:22:59 -05:00
2020-09-18 16:45:50 -04:00
2021-02-10 09:29:20 +01:00
2020-11-04 08:52:46 -08:00
2021-03-04 11:38:00 +01:00
2020-11-19 22:38:29 -05:00
2021-03-04 11:37:51 +01:00
2021-03-07 12:34:04 +01:00
2021-01-27 11:55:29 +01:00
2020-12-30 11:53:30 +01:00
2020-09-18 16:45:50 -04:00
2021-03-30 14:31:52 +02:00
2020-12-30 11:53:45 +01:00
2021-03-25 09:04:08 +01:00
2021-02-13 13:55:16 +01:00
2021-01-17 14:16:59 +01:00
2021-02-26 10:13:00 +01:00
2021-03-04 11:38:18 +01:00
2020-09-22 23:39:45 -04:00
2020-08-04 15:01:58 -04:00
2021-02-17 11:02:30 +01:00
2021-03-04 11:38:42 +01:00
2021-03-25 09:04:08 +01:00
2020-09-18 16:45:50 -04:00
2020-09-18 16:45:50 -04:00
2021-03-04 11:37:53 +01:00
2020-10-16 11:11:22 -07:00
2021-01-06 14:56:52 +01:00
2020-10-24 12:26:05 -07:00
2021-02-13 13:55:19 +01:00
2020-10-02 12:02:30 +02:00
2020-09-18 16:45:50 -04:00
2021-03-04 11:37:51 +01:00
2021-03-17 17:06:23 +01:00
2020-10-24 12:26:05 -07:00
2020-09-10 14:03:31 -07:00
2020-10-15 15:11:56 -07:00
2021-03-07 12:34:05 +01:00
2021-03-25 09:04:05 +01:00
2020-11-10 16:53:07 -08:00
2020-10-16 11:11:21 -07:00
2020-10-29 17:22:59 -05:00
2020-08-24 08:49:13 +10:00
2021-03-17 17:06:35 +01:00
2021-03-17 17:06:27 +01:00
2020-10-18 09:27:09 -07:00
2020-12-06 10:19:07 -08:00
2020-10-14 14:54:45 -07:00
2021-02-26 10:13:01 +01:00
2020-07-29 16:14:27 +02:00
2020-10-15 15:03:10 -07:00
2021-03-04 11:38:41 +01:00
2021-01-09 13:46:24 +01:00
2021-01-06 14:56:53 +01:00
2020-10-17 15:05:30 -06:00
2021-01-30 13:55:18 +01:00
2020-08-23 17:36:59 -05:00
2020-10-13 18:38:27 -07:00
2020-07-29 16:14:27 +02:00
2021-01-27 11:54:53 +01:00
2020-08-23 17:36:59 -05:00
2020-08-04 21:02:38 -04:00
2020-12-30 11:53:49 +01:00
2020-09-22 23:45:57 -04:00
2021-03-25 09:04:13 +01:00
2021-02-13 13:54:56 +01:00
2021-02-13 13:54:56 +01:00
2020-07-31 08:16:01 +02:00
2021-02-17 11:02:21 +01:00
2020-10-05 13:37:04 +02:00
2020-11-22 10:48:22 -08:00
2021-03-20 10:43:44 +01:00
2020-10-23 11:33:41 -07:00
2021-03-07 12:34:11 +01:00
2021-01-19 18:27:32 +01:00
2020-12-30 11:54:24 +01:00
2021-01-27 11:55:29 +01:00
2021-03-17 17:06:13 +01:00
2020-12-30 11:54:02 +01:00
2020-10-23 11:33:41 -07:00
2020-07-31 08:16:00 +02:00
2020-10-15 09:48:49 -07:00
2021-03-25 09:04:16 +01:00
2020-11-15 22:12:53 -05:00
2020-08-23 17:36:59 -05:00
2020-10-24 12:40:18 -07:00
2020-09-26 22:55:05 -04:00
2020-08-27 16:06:47 -04:00
2020-11-10 16:53:11 -08:00
2020-10-16 11:11:22 -07:00
2020-07-31 08:16:01 +02:00
2020-10-13 18:38:27 -07:00