btrfs: scrub: move scrub_setup_ctx allocation out of device_list_mutex
authorDavid Sterba <dsterba@suse.com>
Tue, 4 Dec 2018 15:11:56 +0000 (16:11 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Dec 2018 13:51:48 +0000 (14:51 +0100)
commit0e94c4f45d14cf89d1f40c91b0a8517e791672a7
tree8066c321195c5c78093005ab56f566fda6bd069a
parent92f7ba434f51e8e9317f1d166105889aa230abd2
btrfs: scrub: move scrub_setup_ctx allocation out of device_list_mutex

The scrub context is allocated with GFP_KERNEL and called from
btrfs_scrub_dev under the fs_info::device_list_mutex. This is not safe
regarding reclaim that could try to flush filesystem data in order to
get the memory. And the device_list_mutex is held during superblock
commit, so this would cause a lockup.

Move the alocation and initialization before any changes that require
the mutex.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/scrub.c