All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: Fix possible softlock on single core machines
@ 2018-04-05  7:40 Nikolay Borisov
  2018-04-05 13:55 ` David Sterba
  2018-04-09  3:36 ` Sasha Levin
  0 siblings, 2 replies; 5+ messages in thread
From: Nikolay Borisov @ 2018-04-05  7:40 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

do_chunk_alloc implements a loop checking whether there is a pending
chunk allocation and if so causes the caller do loop. Generally this
loop is executed only once, however testing with btrfs/072 on a
single core vm machines uncovered an extreme case where the system
could loop indefinitely. This is due to a missing cond_resched when
loop which doesn't give a chance to the previous chunk allocator finish
its job.

The fix is to simply add the missing cond_resched.

Fixes: 6d74119f1a3e ("Btrfs: avoid taking the chunk_mutex in do_chunk_alloc")
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/extent-tree.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 0cf1d4c518e9..070227b78d4e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4645,6 +4645,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
 	if (wait_for_alloc) {
 		mutex_unlock(&fs_info->chunk_mutex);
 		wait_for_alloc = 0;
+		cond_resched();
 		goto again;
 	}
 
-- 
2.7.4


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

* Re: [PATCH] btrfs: Fix possible softlock on single core machines
  2018-04-05  7:40 [PATCH] btrfs: Fix possible softlock on single core machines Nikolay Borisov
@ 2018-04-05 13:55 ` David Sterba
  2018-04-05 15:04   ` Nikolay Borisov
  2018-04-09  3:36 ` Sasha Levin
  1 sibling, 1 reply; 5+ messages in thread
From: David Sterba @ 2018-04-05 13:55 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Thu, Apr 05, 2018 at 10:40:15AM +0300, Nikolay Borisov wrote:
> do_chunk_alloc implements a loop checking whether there is a pending
> chunk allocation and if so causes the caller do loop. Generally this
> loop is executed only once, however testing with btrfs/072 on a
> single core vm machines uncovered an extreme case where the system
> could loop indefinitely. This is due to a missing cond_resched when
> loop which doesn't give a chance to the previous chunk allocator finish
> its job.
> 
> The fix is to simply add the missing cond_resched.
> 
> Fixes: 6d74119f1a3e ("Btrfs: avoid taking the chunk_mutex in do_chunk_alloc")

Does this commit really lead to the endless loop on UP? I don't see any
obvious connection.

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

* Re: [PATCH] btrfs: Fix possible softlock on single core machines
  2018-04-05 13:55 ` David Sterba
@ 2018-04-05 15:04   ` Nikolay Borisov
  2018-04-05 15:29     ` David Sterba
  0 siblings, 1 reply; 5+ messages in thread
From: Nikolay Borisov @ 2018-04-05 15:04 UTC (permalink / raw)
  To: dsterba, linux-btrfs



On  5.04.2018 16:55, David Sterba wrote:
> On Thu, Apr 05, 2018 at 10:40:15AM +0300, Nikolay Borisov wrote:
>> do_chunk_alloc implements a loop checking whether there is a pending
>> chunk allocation and if so causes the caller do loop. Generally this
>> loop is executed only once, however testing with btrfs/072 on a
>> single core vm machines uncovered an extreme case where the system
>> could loop indefinitely. This is due to a missing cond_resched when
>> loop which doesn't give a chance to the previous chunk allocator finish
>> its job.
>>
>> The fix is to simply add the missing cond_resched.
>>
>> Fixes: 6d74119f1a3e ("Btrfs: avoid taking the chunk_mutex in do_chunk_alloc")
> 
> Does this commit really lead to the endless loop on UP? I don't see any
> obvious connection.

This is the commit that introduced the loop there without adding
cond_resched, hence the fixes tag.
> 

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

* Re: [PATCH] btrfs: Fix possible softlock on single core machines
  2018-04-05 15:04   ` Nikolay Borisov
@ 2018-04-05 15:29     ` David Sterba
  0 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2018-04-05 15:29 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: dsterba, linux-btrfs

On Thu, Apr 05, 2018 at 06:04:12PM +0300, Nikolay Borisov wrote:
> 
> 
> On  5.04.2018 16:55, David Sterba wrote:
> > On Thu, Apr 05, 2018 at 10:40:15AM +0300, Nikolay Borisov wrote:
> >> do_chunk_alloc implements a loop checking whether there is a pending
> >> chunk allocation and if so causes the caller do loop. Generally this
> >> loop is executed only once, however testing with btrfs/072 on a
> >> single core vm machines uncovered an extreme case where the system
> >> could loop indefinitely. This is due to a missing cond_resched when
> >> loop which doesn't give a chance to the previous chunk allocator finish
> >> its job.
> >>
> >> The fix is to simply add the missing cond_resched.
> >>
> >> Fixes: 6d74119f1a3e ("Btrfs: avoid taking the chunk_mutex in do_chunk_alloc")
> > 
> > Does this commit really lead to the endless loop on UP? I don't see any
> > obvious connection.
> 
> This is the commit that introduced the loop there without adding
> cond_resched, hence the fixes tag.

Makes sense, thanks.

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

* Re: [PATCH] btrfs: Fix possible softlock on single core machines
  2018-04-05  7:40 [PATCH] btrfs: Fix possible softlock on single core machines Nikolay Borisov
  2018-04-05 13:55 ` David Sterba
@ 2018-04-09  3:36 ` Sasha Levin
  1 sibling, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2018-04-09  3:36 UTC (permalink / raw)
  To: Sasha Levin, Nikolay Borisov, linux-btrfs; +Cc: Nikolay Borisov, stable

Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 6d74119f1a3e Btrfs: avoid taking the chunk_mutex in do_chunk_alloc.

The bot has also determined it's probably a bug fixing patch. (score: 55.2868)

The bot has tested the following trees: v4.16, v4.15.15, v4.14.32, v4.9.92, v4.4.126.

v4.16: Build OK!
v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

--
Thanks,
Sasha

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

end of thread, other threads:[~2018-04-09  3:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-05  7:40 [PATCH] btrfs: Fix possible softlock on single core machines Nikolay Borisov
2018-04-05 13:55 ` David Sterba
2018-04-05 15:04   ` Nikolay Borisov
2018-04-05 15:29     ` David Sterba
2018-04-09  3:36 ` Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.