Skip to content

Commit 6efddf1

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: fix soft lockup in status_resync
status_resync() will calculate 'curr_resync - recovery_active' to show user a progress bar like following: [============>........] resync = 61.4% 'curr_resync' and 'recovery_active' is updated in md_do_sync(), and status_resync() can read them concurrently, hence it's possible that 'curr_resync - recovery_active' can overflow to a huge number. In this case status_resync() will be stuck in the loop to print a large amount of '=', which will end up soft lockup. Fix the problem by setting 'resync' to MD_RESYNC_ACTIVE in this case, this way resync in progress will be reported to user. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20230310073855.1337560-3-yukuai1@huaweicloud.com
1 parent c31fea2 commit 6efddf1

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/md/md.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8032,16 +8032,16 @@ static int status_resync(struct seq_file *seq, struct mddev *mddev)
80328032
} else if (resync > max_sectors) {
80338033
resync = max_sectors;
80348034
} else {
8035-
resync -= atomic_read(&mddev->recovery_active);
8036-
if (resync < MD_RESYNC_ACTIVE) {
8037-
/*
8038-
* Resync has started, but the subtraction has
8039-
* yielded one of the special values. Force it
8040-
* to active to ensure the status reports an
8041-
* active resync.
8042-
*/
8035+
res = atomic_read(&mddev->recovery_active);
8036+
/*
8037+
* Resync has started, but the subtraction has overflowed or
8038+
* yielded one of the special values. Force it to active to
8039+
* ensure the status reports an active resync.
8040+
*/
8041+
if (resync < res || resync - res < MD_RESYNC_ACTIVE)
80438042
resync = MD_RESYNC_ACTIVE;
8044-
}
8043+
else
8044+
resync -= res;
80458045
}
80468046

80478047
if (resync == MD_RESYNC_NONE) {

0 commit comments

Comments
 (0)