]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: iterate all devices during trim, instead of fs_devices::alloc_list
authorJeff Mahoney <jeffm@suse.com>
Thu, 6 Sep 2018 21:18:14 +0000 (17:18 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 15 Oct 2018 15:23:32 +0000 (17:23 +0200)
commit096b7fddc87aeb79f28b6efb99cc2dde8f35c214
treecabf9d3212054f7b2b86128a055be05675e56af6
parent356b75e41590e976e28217cf9ad1b3a9c29a6854
btrfs: iterate all devices during trim, instead of fs_devices::alloc_list

btrfs_trim_fs iterates over the fs_devices->alloc_list while holding the
device_list_mutex.  The problem is that ->alloc_list is protected by the
chunk mutex.  We don't want to hold the chunk mutex over the trim of the
entire file system.  Fortunately, the ->dev_list list is protected by
the dev_list mutex and while it will give us all devices, including
read-only devices, we already just skip the read-only devices.  Then we
can continue to take and release the chunk mutex while scanning each
device.

Fixes: 5119c091e6a ("btrfs: iterate over unused chunk space in FITRIM")
CC: stable@vger.kernel.org # 4.4+
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c