mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] md/md-llbimtap: fix two corner case problems
@ 2026-01-23 18:26 Yu Kuai
  2026-01-23 18:26 ` [PATCH 1/2] md/raid5: fix IO hang with degraded array with llbitmap Yu Kuai
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Yu Kuai @ 2026-01-23 18:26 UTC (permalink / raw)
  To: axboe, linux-block, linux-raid; +Cc: linux-kernel, yukuai, linan122, xni

Yu Kuai (2):
  md/raid5: fix IO hang with degraded array with llbitmap
  md/md-llbitmap: fix percpu_ref not resurrected on suspend timeout

 drivers/md/md-llbitmap.c | 4 +++-
 drivers/md/raid5.c       | 7 ++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

-- 
2.51.0


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

* [PATCH 1/2] md/raid5: fix IO hang with degraded array with llbitmap
  2026-01-23 18:26 [PATCH 0/2] md/md-llbimtap: fix two corner case problems Yu Kuai
@ 2026-01-23 18:26 ` Yu Kuai
  2026-01-24  6:42   ` Li Nan
  2026-01-23 18:26 ` [PATCH 2/2] md/md-llbitmap: fix percpu_ref not resurrected on suspend timeout Yu Kuai
  2026-01-24  3:38 ` [PATCH 0/2] md/md-llbimtap: fix two corner case problems Jens Axboe
  2 siblings, 1 reply; 7+ messages in thread
From: Yu Kuai @ 2026-01-23 18:26 UTC (permalink / raw)
  To: axboe, linux-block, linux-raid; +Cc: linux-kernel, yukuai, linan122, xni

When llbitmap bit state is still unwritten, any new write should force
rcw, as bitmap_ops->blocks_synced() is checked in handle_stripe_dirting().
However, later the same check is missing in need_this_block(), causing
stripe to deadloop during handling because handle_stripe() will decide
to go to handle_stripe_fill(), meanwhile need_this_block() always return
0 and nothing is handled.

Fixes: 5ab829f1971d ("md/md-llbitmap: introduce new lockless bitmap")
Signed-off-by: Yu Kuai <yukuai@fnnas.com>
---
 drivers/md/raid5.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 8dc98f545969..93e672b3432b 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3751,9 +3751,14 @@ static int need_this_block(struct stripe_head *sh, struct stripe_head_state *s,
 	struct r5dev *dev = &sh->dev[disk_idx];
 	struct r5dev *fdev[2] = { &sh->dev[s->failed_num[0]],
 				  &sh->dev[s->failed_num[1]] };
+	struct mddev *mddev = sh->raid_conf->mddev;
+	bool force_rcw = false;
 	int i;
-	bool force_rcw = (sh->raid_conf->rmw_level == PARITY_DISABLE_RMW);
 
+	if (sh->raid_conf->rmw_level == PARITY_DISABLE_RMW ||
+	    (mddev->bitmap_ops && mddev->bitmap_ops->blocks_synced &&
+	     !mddev->bitmap_ops->blocks_synced(mddev, sh->sector)))
+		force_rcw = true;
 
 	if (test_bit(R5_LOCKED, &dev->flags) ||
 	    test_bit(R5_UPTODATE, &dev->flags))
-- 
2.51.0


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

* [PATCH 2/2] md/md-llbitmap: fix percpu_ref not resurrected on suspend timeout
  2026-01-23 18:26 [PATCH 0/2] md/md-llbimtap: fix two corner case problems Yu Kuai
  2026-01-23 18:26 ` [PATCH 1/2] md/raid5: fix IO hang with degraded array with llbitmap Yu Kuai
@ 2026-01-23 18:26 ` Yu Kuai
  2026-01-24  1:58   ` Li Nan
  2026-01-24  3:38 ` [PATCH 0/2] md/md-llbimtap: fix two corner case problems Jens Axboe
  2 siblings, 1 reply; 7+ messages in thread
From: Yu Kuai @ 2026-01-23 18:26 UTC (permalink / raw)
  To: axboe, linux-block, linux-raid; +Cc: linux-kernel, yukuai, linan122, xni

When llbitmap_suspend_timeout() times out waiting for percpu_ref to
become zero, it returns -ETIMEDOUT without resurrecting the percpu_ref.
The caller (md_llbitmap_daemon_fn) then continues to the next page
without calling llbitmap_resume(), leaving the percpu_ref in a killed
state permanently.

Fix this by resurrecting the percpu_ref before returning the error,
ensuring the page control structure remains usable for subsequent
operations.

Fixes: 5ab829f1971d ("md/md-llbitmap: introduce new lockless bitmap")
Signed-off-by: Yu Kuai <yukuai@fnnas.com>
---
 drivers/md/md-llbitmap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/md/md-llbitmap.c b/drivers/md/md-llbitmap.c
index b482a1db0861..7df15756142d 100644
--- a/drivers/md/md-llbitmap.c
+++ b/drivers/md/md-llbitmap.c
@@ -779,8 +779,10 @@ static int llbitmap_suspend_timeout(struct llbitmap *llbitmap, int page_idx)
 	percpu_ref_kill(&pctl->active);
 
 	if (!wait_event_timeout(pctl->wait, percpu_ref_is_zero(&pctl->active),
-			llbitmap->mddev->bitmap_info.daemon_sleep * HZ))
+			llbitmap->mddev->bitmap_info.daemon_sleep * HZ)) {
+		percpu_ref_resurrect(&pctl->active);
 		return -ETIMEDOUT;
+	}
 
 	return 0;
 }
-- 
2.51.0


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

* Re: [PATCH 2/2] md/md-llbitmap: fix percpu_ref not resurrected on suspend timeout
  2026-01-23 18:26 ` [PATCH 2/2] md/md-llbitmap: fix percpu_ref not resurrected on suspend timeout Yu Kuai
@ 2026-01-24  1:58   ` Li Nan
  0 siblings, 0 replies; 7+ messages in thread
From: Li Nan @ 2026-01-24  1:58 UTC (permalink / raw)
  To: Yu Kuai, axboe, linux-block, linux-raid; +Cc: linux-kernel, xni



在 2026/1/24 2:26, Yu Kuai 写道:
> When llbitmap_suspend_timeout() times out waiting for percpu_ref to
> become zero, it returns -ETIMEDOUT without resurrecting the percpu_ref.
> The caller (md_llbitmap_daemon_fn) then continues to the next page
> without calling llbitmap_resume(), leaving the percpu_ref in a killed
> state permanently.
> 
> Fix this by resurrecting the percpu_ref before returning the error,
> ensuring the page control structure remains usable for subsequent
> operations.
> 
> Fixes: 5ab829f1971d ("md/md-llbitmap: introduce new lockless bitmap")
> Signed-off-by: Yu Kuai <yukuai@fnnas.com>
> ---
>   drivers/md/md-llbitmap.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/md-llbitmap.c b/drivers/md/md-llbitmap.c
> index b482a1db0861..7df15756142d 100644
> --- a/drivers/md/md-llbitmap.c
> +++ b/drivers/md/md-llbitmap.c
> @@ -779,8 +779,10 @@ static int llbitmap_suspend_timeout(struct llbitmap *llbitmap, int page_idx)
>   	percpu_ref_kill(&pctl->active);
>   
>   	if (!wait_event_timeout(pctl->wait, percpu_ref_is_zero(&pctl->active),
> -			llbitmap->mddev->bitmap_info.daemon_sleep * HZ))
> +			llbitmap->mddev->bitmap_info.daemon_sleep * HZ)) {
> +		percpu_ref_resurrect(&pctl->active);
>   		return -ETIMEDOUT;
> +	}
>   
>   	return 0;
>   }

LGTM

Reviewed-by: Li Nan <linan122@huawei.com>

-- 
Thanks,
Nan


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

* Re: [PATCH 0/2] md/md-llbimtap: fix two corner case problems
  2026-01-23 18:26 [PATCH 0/2] md/md-llbimtap: fix two corner case problems Yu Kuai
  2026-01-23 18:26 ` [PATCH 1/2] md/raid5: fix IO hang with degraded array with llbitmap Yu Kuai
  2026-01-23 18:26 ` [PATCH 2/2] md/md-llbitmap: fix percpu_ref not resurrected on suspend timeout Yu Kuai
@ 2026-01-24  3:38 ` Jens Axboe
  2026-01-24 15:04   ` Yu Kuai
  2 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2026-01-24  3:38 UTC (permalink / raw)
  To: Yu Kuai, linux-block, linux-raid; +Cc: linux-kernel, linan122, xni

On 1/23/26 11:26 AM, Yu Kuai wrote:
> Yu Kuai (2):
>   md/raid5: fix IO hang with degraded array with llbitmap
>   md/md-llbitmap: fix percpu_ref not resurrected on suspend timeout
> 
>  drivers/md/md-llbitmap.c | 4 +++-
>  drivers/md/raid5.c       | 7 ++++++-
>  2 files changed, 9 insertions(+), 2 deletions(-)

Is this just for review, or do you want them picked up off the list
too?

Both look fine to me, fwiw.

-- 
Jens Axboe


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

* Re: [PATCH 1/2] md/raid5: fix IO hang with degraded array with llbitmap
  2026-01-23 18:26 ` [PATCH 1/2] md/raid5: fix IO hang with degraded array with llbitmap Yu Kuai
@ 2026-01-24  6:42   ` Li Nan
  0 siblings, 0 replies; 7+ messages in thread
From: Li Nan @ 2026-01-24  6:42 UTC (permalink / raw)
  To: Yu Kuai, axboe, linux-block, linux-raid; +Cc: linux-kernel, xni



在 2026/1/24 2:26, Yu Kuai 写道:
> When llbitmap bit state is still unwritten, any new write should force
> rcw, as bitmap_ops->blocks_synced() is checked in handle_stripe_dirting().

s/handle_stripe_dirting/handle_stripe_dirtying/

Besides this, LGTM

Reviewed-by: Li Nan <linan122@huawei.com>

> However, later the same check is missing in need_this_block(), causing
> stripe to deadloop during handling because handle_stripe() will decide
> to go to handle_stripe_fill(), meanwhile need_this_block() always return
> 0 and nothing is handled.
> 
> Fixes: 5ab829f1971d ("md/md-llbitmap: introduce new lockless bitmap")
> Signed-off-by: Yu Kuai <yukuai@fnnas.com>
> ---
>   drivers/md/raid5.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 8dc98f545969..93e672b3432b 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -3751,9 +3751,14 @@ static int need_this_block(struct stripe_head *sh, struct stripe_head_state *s,
>   	struct r5dev *dev = &sh->dev[disk_idx];
>   	struct r5dev *fdev[2] = { &sh->dev[s->failed_num[0]],
>   				  &sh->dev[s->failed_num[1]] };
> +	struct mddev *mddev = sh->raid_conf->mddev;
> +	bool force_rcw = false;
>   	int i;
> -	bool force_rcw = (sh->raid_conf->rmw_level == PARITY_DISABLE_RMW);
>   
> +	if (sh->raid_conf->rmw_level == PARITY_DISABLE_RMW ||
> +	    (mddev->bitmap_ops && mddev->bitmap_ops->blocks_synced &&
> +	     !mddev->bitmap_ops->blocks_synced(mddev, sh->sector)))
> +		force_rcw = true;
>   
>   	if (test_bit(R5_LOCKED, &dev->flags) ||
>   	    test_bit(R5_UPTODATE, &dev->flags))

-- 
Thanks,
Nan


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

* Re: [PATCH 0/2] md/md-llbimtap: fix two corner case problems
  2026-01-24  3:38 ` [PATCH 0/2] md/md-llbimtap: fix two corner case problems Jens Axboe
@ 2026-01-24 15:04   ` Yu Kuai
  0 siblings, 0 replies; 7+ messages in thread
From: Yu Kuai @ 2026-01-24 15:04 UTC (permalink / raw)
  To: Jens Axboe, linux-block, linux-raid; +Cc: linux-kernel, linan122, xni

Hi,

在 2026/1/24 11:38, Jens Axboe 写道:
> On 1/23/26 11:26 AM, Yu Kuai wrote:
>> Yu Kuai (2):
>>    md/raid5: fix IO hang with degraded array with llbitmap
>>    md/md-llbitmap: fix percpu_ref not resurrected on suspend timeout
>>
>>   drivers/md/md-llbitmap.c | 4 +++-
>>   drivers/md/raid5.c       | 7 ++++++-
>>   2 files changed, 9 insertions(+), 2 deletions(-)
> Is this just for review, or do you want them picked up off the list
> too?
>
> Both look fine to me, fwiw.

I'll send a pull request soon.

Sorry for the noise, I used the wrong script that is used to send pull
request for this set.

>
-- 
Thansk,
Kuai

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

end of thread, other threads:[~2026-01-24 15:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-23 18:26 [PATCH 0/2] md/md-llbimtap: fix two corner case problems Yu Kuai
2026-01-23 18:26 ` [PATCH 1/2] md/raid5: fix IO hang with degraded array with llbitmap Yu Kuai
2026-01-24  6:42   ` Li Nan
2026-01-23 18:26 ` [PATCH 2/2] md/md-llbitmap: fix percpu_ref not resurrected on suspend timeout Yu Kuai
2026-01-24  1:58   ` Li Nan
2026-01-24  3:38 ` [PATCH 0/2] md/md-llbimtap: fix two corner case problems Jens Axboe
2026-01-24 15:04   ` Yu Kuai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®