]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
md/md-llbitmap: fix percpu_ref not resurrected on suspend timeout
authorYu Kuai <yukuai@fnnas.com>
Fri, 23 Jan 2026 18:26:23 +0000 (02:26 +0800)
committerYu Kuai <yukuai@fnnas.com>
Mon, 26 Jan 2026 05:25:31 +0000 (13:25 +0800)
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.

Link: https://lore.kernel.org/linux-raid/20260123182623.3718551-3-yukuai@fnnas.com
Fixes: 5ab829f1971d ("md/md-llbitmap: introduce new lockless bitmap")
Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Reviewed-by: Li Nan <linan122@huawei.com>
drivers/md/md-llbitmap.c

index 9c1ade19b7741ecddff22e04567ea940545ec618..cd713a7dc27064779255299e817f4f1388134968 100644 (file)
@@ -712,8 +712,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;
 }