mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Yu Kuai" <yukuai@fnnas.com>
To: <linan666@huaweicloud.com>, <song@kernel.org>, <neil@brown.name>,
	 <namhyung@gmail.com>
Cc: <linux-raid@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	 <k@mgml.me>, <yangerkun@huawei.com>, <yi.zhang@huawei.com>,
	 <yukuai@fnnas.com>
Subject: Re: [PATCH v3 04/13] md/raid1,raid10: set Uptodate and clear badblocks if narrow_write_error success
Date: Sat, 3 Jan 2026 18:16:04 +0800	[thread overview]
Message-ID: <989e77fa-43ec-4a44-b762-72073593ed77@fnnas.com> (raw)
In-Reply-To: <20251215030444.1318434-5-linan666@huaweicloud.com>

Hi,

在 2025/12/15 11:04, linan666@huaweicloud.com 写道:
> From: Li Nan <linan122@huawei.com>
>
> narrow_write_error() returns true when all sectors are rewritten
> successfully. In this case, set R1BIO_Uptodate to return success
> to upper layers and clear correspondinga badblocks.
>
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
>   drivers/md/raid1.c  | 24 ++++++++++++++++++++----
>   drivers/md/raid10.c | 17 +++++++++++++++--
>   2 files changed, 35 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index 9ffa3ab0fdcc..bd63cf039381 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -2587,9 +2587,10 @@ static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
>   	int m, idx;
>   	bool fail = false;
>   
> -	for (m = 0; m < conf->raid_disks * 2 ; m++)
> +	for (m = 0; m < conf->raid_disks * 2 ; m++) {
> +		struct md_rdev *rdev = conf->mirrors[m].rdev;
> +
>   		if (r1_bio->bios[m] == IO_MADE_GOOD) {
> -			struct md_rdev *rdev = conf->mirrors[m].rdev;
>   			rdev_clear_badblocks(rdev,
>   					     r1_bio->sector,
>   					     r1_bio->sectors, 0);
> @@ -2599,11 +2600,26 @@ static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
>   			 * narrow down and record precise write
>   			 * errors.
>   			 */
> -			fail = true;
> -			narrow_write_error(r1_bio, m);
> +			if (narrow_write_error(r1_bio, m)) {
> +				/* re-write success */
> +				if (rdev_has_badblock(rdev,
> +						      r1_bio->sector,
> +						      r1_bio->sectors))
> +					rdev_clear_badblocks(rdev,
> +							     r1_bio->sector,
> +							     r1_bio->sectors, 0);
> +				if (test_bit(In_sync, &rdev->flags) &&
> +				    !test_bit(Faulty, &rdev->flags))
> +					set_bit(R1BIO_Uptodate,
> +						&r1_bio->state);

Clear badblocks is fine, although I can't think of any case write io can be
issued to rdev with badblocks existing. And I think it's fine to move above
codes into narrow_write_error() and keep declaring it as void.

> +			} else {
> +				fail = true;

Why change the fail here, you also change the logic to return this r1bio early,
before this change, r1bio is returned from raid1d() after updating sb. And you
don't explain why this is safe.

                 /*
                  * In case freeze_array() is waiting for condition
                  * get_unqueued_pending() == extra to be true.
                  */

> +			}
> +
>   			rdev_dec_pending(conf->mirrors[m].rdev,
>   					 conf->mddev);
>   		}
> +	}
>   	if (fail) {
>   		spin_lock_irq(&conf->device_lock);
>   		list_add(&r1_bio->retry_list, &conf->bio_end_io_list);
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 21a347c4829b..db6fbd423726 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -2939,8 +2939,21 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
>   					r10_bio->sectors, 0);
>   				rdev_dec_pending(rdev, conf->mddev);
>   			} else if (bio != NULL && bio->bi_status) {
> -				fail = true;
> -				narrow_write_error(r10_bio, m);
> +				if (narrow_write_error(r10_bio, m)) {
> +					/* re-write success */
> +					if (rdev_has_badblock(rdev,
> +							r10_bio->devs[m].addr,
> +							r10_bio->sectors))
> +						rdev_clear_badblocks(
> +							rdev,
> +							r10_bio->devs[m].addr,
> +							r10_bio->sectors, 0);
> +					if (test_bit(In_sync, &rdev->flags) &&
> +					    !test_bit(Faulty, &rdev->flags))
> +						set_bit(R10BIO_Uptodate, &r10_bio->state);
> +				} else {
> +					fail = true;
> +				}
>   				rdev_dec_pending(rdev, conf->mddev);
>   			}
>   			bio = r10_bio->devs[m].repl_bio;

-- 
Thansk,
Kuai

  reply	other threads:[~2026-01-03 10:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15  3:04 [PATCH v3 00/13] cleanup and bugfix of sync linan666
2025-12-15  3:04 ` [PATCH v3 01/13] md/raid1: simplify uptodate handling in end_sync_write linan666
2025-12-15  3:04 ` [PATCH v3 02/13] md: factor error handling out of md_done_sync into helper linan666
2025-12-15  3:04 ` [PATCH v3 03/13] md/raid1,raid10: return actual write status in narrow_write_error linan666
2026-01-03  9:37   ` Yu Kuai
2026-01-03 10:16     ` Yu Kuai
2025-12-15  3:04 ` [PATCH v3 04/13] md/raid1,raid10: set Uptodate and clear badblocks if narrow_write_error success linan666
2026-01-03 10:16   ` Yu Kuai [this message]
2025-12-15  3:04 ` [PATCH v3 05/13] md/raid1,raid10: support narrow_write_error when badblocks is disabled linan666
2026-01-03 10:23   ` Yu Kuai
2025-12-15  3:04 ` [PATCH v3 06/13] md: mark rdev Faulty when badblocks setting fails linan666
2025-12-15  3:04 ` [PATCH v3 07/13] md: update curr_resync_completed even when MD_RECOVERY_INTR is set linan666
2026-01-03 10:33   ` Yu Kuai
2025-12-15  3:04 ` [PATCH v3 08/13] md: remove MD_RECOVERY_ERROR handling and simplify resync_offset update linan666
2026-01-03 10:36   ` Yu Kuai
2025-12-15  3:04 ` [PATCH v3 09/13] md: factor out sync completion update into helper linan666
2025-12-15  3:04 ` [PATCH v3 10/13] md: move finish_reshape to md_finish_sync() linan666
2025-12-15  3:04 ` [PATCH v3 11/13] md/raid10: fix any_working flag handling in raid10_sync_request linan666
2025-12-15  3:04 ` [PATCH v3 12/13] md/raid10: cleanup skip " linan666
2025-12-15  3:04 ` [PATCH v3 13/13] md: remove recovery_disabled linan666

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=989e77fa-43ec-4a44-b762-72073593ed77@fnnas.com \
    --to=yukuai@fnnas.com \
    --cc=k@mgml.me \
    --cc=linan666@huaweicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=namhyung@gmail.com \
    --cc=neil@brown.name \
    --cc=song@kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®