linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: start readahead also in seed devices
@ 2019-06-06  7:54 Naohiro Aota
  2019-06-06 11:14 ` Filipe Manana
  2019-06-07 13:39 ` David Sterba
  0 siblings, 2 replies; 4+ messages in thread
From: Naohiro Aota @ 2019-06-06  7:54 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba, Naohiro Aota, stable

Currently, btrfs does not consult seed devices to start readahead. As a
result, if readahead zone is added to the seed devices, btrfs_reada_wait()
indefinitely wait for the reada_ctl to finish.

You can reproduce the hung by modifying btrfs/163 to have larger initial
file size (e.g. xfs_io pwrite 4M instead of current 256K).

Fixes: 7414a03fbf9e ("btrfs: initial readahead code and prototypes")
Cc: stable@vger.kernel.org # 3.2+: ce7791ffee1e: Btrfs: fix race between readahead and device replace/removal
Cc: stable@vger.kernel.org # 3.2+
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/reada.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index 10d9589001a9..bb5bd49573b4 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -747,6 +747,7 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info)
 	u64 total = 0;
 	int i;
 
+again:
 	do {
 		enqueued = 0;
 		mutex_lock(&fs_devices->device_list_mutex);
@@ -758,6 +759,10 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info)
 		mutex_unlock(&fs_devices->device_list_mutex);
 		total += enqueued;
 	} while (enqueued && total < 10000);
+	if (fs_devices->seed) {
+		fs_devices = fs_devices->seed;
+		goto again;
+	}
 
 	if (enqueued == 0)
 		return;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: start readahead also in seed devices
  2019-06-06  7:54 [PATCH] btrfs: start readahead also in seed devices Naohiro Aota
@ 2019-06-06 11:14 ` Filipe Manana
  2019-06-07  2:29   ` Naohiro Aota
  2019-06-07 13:39 ` David Sterba
  1 sibling, 1 reply; 4+ messages in thread
From: Filipe Manana @ 2019-06-06 11:14 UTC (permalink / raw)
  To: Naohiro Aota; +Cc: linux-btrfs, David Sterba, stable

On Thu, Jun 6, 2019 at 8:56 AM Naohiro Aota <naohiro.aota@wdc.com> wrote:
>
> Currently, btrfs does not consult seed devices to start readahead. As a
> result, if readahead zone is added to the seed devices, btrfs_reada_wait()
> indefinitely wait for the reada_ctl to finish.
>
> You can reproduce the hung by modifying btrfs/163 to have larger initial
> file size (e.g. xfs_io pwrite 4M instead of current 256K).

Are you planning on submitting a patch for the test case as well, so
that it writes at least 4Mb?
Would be useful to have.

>
> Fixes: 7414a03fbf9e ("btrfs: initial readahead code and prototypes")
> Cc: stable@vger.kernel.org # 3.2+: ce7791ffee1e: Btrfs: fix race between readahead and device replace/removal
> Cc: stable@vger.kernel.org # 3.2+
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good, thanks.

> ---
>  fs/btrfs/reada.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
> index 10d9589001a9..bb5bd49573b4 100644
> --- a/fs/btrfs/reada.c
> +++ b/fs/btrfs/reada.c
> @@ -747,6 +747,7 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info)
>         u64 total = 0;
>         int i;
>
> +again:
>         do {
>                 enqueued = 0;
>                 mutex_lock(&fs_devices->device_list_mutex);
> @@ -758,6 +759,10 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info)
>                 mutex_unlock(&fs_devices->device_list_mutex);
>                 total += enqueued;
>         } while (enqueued && total < 10000);
> +       if (fs_devices->seed) {
> +               fs_devices = fs_devices->seed;
> +               goto again;
> +       }
>
>         if (enqueued == 0)
>                 return;
> --
> 2.21.0
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: start readahead also in seed devices
  2019-06-06 11:14 ` Filipe Manana
@ 2019-06-07  2:29   ` Naohiro Aota
  0 siblings, 0 replies; 4+ messages in thread
From: Naohiro Aota @ 2019-06-07  2:29 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs, David Sterba

On 2019/06/06 20:14, Filipe Manana wrote:
> On Thu, Jun 6, 2019 at 8:56 AM Naohiro Aota <naohiro.aota@wdc.com> wrote:
>>
>> Currently, btrfs does not consult seed devices to start readahead. As a
>> result, if readahead zone is added to the seed devices, btrfs_reada_wait()
>> indefinitely wait for the reada_ctl to finish.
>>
>> You can reproduce the hung by modifying btrfs/163 to have larger initial
>> file size (e.g. xfs_io pwrite 4M instead of current 256K).
> 
> Are you planning on submitting a patch for the test case as well, so
> that it writes at least 4Mb?
> Would be useful to have.

I will send that patch soon.

Thanks,

> 
>>
>> Fixes: 7414a03fbf9e ("btrfs: initial readahead code and prototypes")
>> Cc: stable@vger.kernel.org # 3.2+: ce7791ffee1e: Btrfs: fix race between readahead and device replace/removal
>> Cc: stable@vger.kernel.org # 3.2+
>> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> 
> Reviewed-by: Filipe Manana <fdmanana@suse.com>
> 
> Looks good, thanks.
> 
>> ---
>>   fs/btrfs/reada.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
>> index 10d9589001a9..bb5bd49573b4 100644
>> --- a/fs/btrfs/reada.c
>> +++ b/fs/btrfs/reada.c
>> @@ -747,6 +747,7 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info)
>>          u64 total = 0;
>>          int i;
>>
>> +again:
>>          do {
>>                  enqueued = 0;
>>                  mutex_lock(&fs_devices->device_list_mutex);
>> @@ -758,6 +759,10 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info)
>>                  mutex_unlock(&fs_devices->device_list_mutex);
>>                  total += enqueued;
>>          } while (enqueued && total < 10000);
>> +       if (fs_devices->seed) {
>> +               fs_devices = fs_devices->seed;
>> +               goto again;
>> +       }
>>
>>          if (enqueued == 0)
>>                  return;
>> --
>> 2.21.0
>>
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: start readahead also in seed devices
  2019-06-06  7:54 [PATCH] btrfs: start readahead also in seed devices Naohiro Aota
  2019-06-06 11:14 ` Filipe Manana
@ 2019-06-07 13:39 ` David Sterba
  1 sibling, 0 replies; 4+ messages in thread
From: David Sterba @ 2019-06-07 13:39 UTC (permalink / raw)
  To: Naohiro Aota; +Cc: linux-btrfs, David Sterba, stable

On Thu, Jun 06, 2019 at 04:54:44PM +0900, Naohiro Aota wrote:
> Currently, btrfs does not consult seed devices to start readahead. As a
> result, if readahead zone is added to the seed devices, btrfs_reada_wait()
> indefinitely wait for the reada_ctl to finish.
> 
> You can reproduce the hung by modifying btrfs/163 to have larger initial
> file size (e.g. xfs_io pwrite 4M instead of current 256K).
> 
> Fixes: 7414a03fbf9e ("btrfs: initial readahead code and prototypes")
> Cc: stable@vger.kernel.org # 3.2+: ce7791ffee1e: Btrfs: fix race between readahead and device replace/removal
> Cc: stable@vger.kernel.org # 3.2+
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

Thanks, added to misc-next.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-07 13:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-06  7:54 [PATCH] btrfs: start readahead also in seed devices Naohiro Aota
2019-06-06 11:14 ` Filipe Manana
2019-06-07  2:29   ` Naohiro Aota
2019-06-07 13:39 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).