]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/btrfs-start-readahead-also-in-seed-devices.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.14 / btrfs-start-readahead-also-in-seed-devices.patch
1 From c4e0540d0ad49c8ceab06cceed1de27c4fe29f6e Mon Sep 17 00:00:00 2001
2 From: Naohiro Aota <naohiro.aota@wdc.com>
3 Date: Thu, 6 Jun 2019 16:54:44 +0900
4 Subject: btrfs: start readahead also in seed devices
5
6 From: Naohiro Aota <naohiro.aota@wdc.com>
7
8 commit c4e0540d0ad49c8ceab06cceed1de27c4fe29f6e upstream.
9
10 Currently, btrfs does not consult seed devices to start readahead. As a
11 result, if readahead zone is added to the seed devices, btrfs_reada_wait()
12 indefinitely wait for the reada_ctl to finish.
13
14 You can reproduce the hung by modifying btrfs/163 to have larger initial
15 file size (e.g. xfs_io pwrite 4M instead of current 256K).
16
17 Fixes: 7414a03fbf9e ("btrfs: initial readahead code and prototypes")
18 Cc: stable@vger.kernel.org # 3.2+: ce7791ffee1e: Btrfs: fix race between readahead and device replace/removal
19 Cc: stable@vger.kernel.org # 3.2+
20 Reviewed-by: Filipe Manana <fdmanana@suse.com>
21 Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
22 Signed-off-by: David Sterba <dsterba@suse.com>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25 ---
26 fs/btrfs/reada.c | 5 +++++
27 1 file changed, 5 insertions(+)
28
29 --- a/fs/btrfs/reada.c
30 +++ b/fs/btrfs/reada.c
31 @@ -759,6 +759,7 @@ static void __reada_start_machine(struct
32 u64 total = 0;
33 int i;
34
35 +again:
36 do {
37 enqueued = 0;
38 mutex_lock(&fs_devices->device_list_mutex);
39 @@ -770,6 +771,10 @@ static void __reada_start_machine(struct
40 mutex_unlock(&fs_devices->device_list_mutex);
41 total += enqueued;
42 } while (enqueued && total < 10000);
43 + if (fs_devices->seed) {
44 + fs_devices = fs_devices->seed;
45 + goto again;
46 + }
47
48 if (enqueued == 0)
49 return;