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>,
	 <xni@redhat.com>, <k@mgml.me>, <yangerkun@huawei.com>,
	 <yi.zhang@huawei.com>, <yukuai@fnnas.com>
Subject: Re: [PATCH v2 03/11] md/raid1,raid10: return actual write status in narrow_write_error
Date: Sat, 8 Nov 2025 18:07:50 +0800	[thread overview]
Message-ID: <63857ce2-0521-4f38-b3d4-d95c8eafc175@fnnas.com> (raw)
In-Reply-To: <20251106115935.2148714-4-linan666@huaweicloud.com>

Hi,

在 2025/11/6 19:59, linan666@huaweicloud.com 写道:
> From: Li Nan <linan122@huawei.com>
>
> narrow_write_error() currently returns true when setting badblocks fails.
> Instead, return actual status of all retried writes, succeeding only when
> all retried writes complete successfully. This gives upper layers accurate
> information about write outcomes.
>
> When setting badblocks fails, mark the device as faulty and return at once.
> No need to continue processing remaining sections in such cases.
>
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
>   drivers/md/raid1.c  | 17 +++++++++--------
>   drivers/md/raid10.c | 15 +++++++++------
>   2 files changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index e65d104cb9c5..090fe8f71224 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -2541,11 +2541,15 @@ static bool narrow_write_error(struct r1bio *r1_bio, int i)
>   		bio_trim(wbio, sector - r1_bio->sector, sectors);
>   		wbio->bi_iter.bi_sector += rdev->data_offset;
>   
> -		if (submit_bio_wait(wbio) < 0)
> +		if (submit_bio_wait(wbio)) {
>   			/* failure! */
> -			ok = rdev_set_badblocks(rdev, sector,
> -						sectors, 0)
> -				&& ok;
> +			ok = false;
> +			if (!rdev_set_badblocks(rdev, sector, sectors, 0)) {
> +				md_error(mddev, rdev);
> +				bio_put(wbio);
> +				break;
> +			}
> +		}
>   
>   		bio_put(wbio);
>   		sect_to_write -= sectors;
> @@ -2596,10 +2600,7 @@ static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
>   			 * errors.
>   			 */
>   			fail = true;
> -			if (!narrow_write_error(r1_bio, m))
> -				md_error(conf->mddev,
> -					 conf->mirrors[m].rdev);
> -				/* an I/O failed, we can't clear the bitmap */
> +			narrow_write_error(r1_bio, m);

Now that return value is not used, you can make this helper void.

Thanks,
Kuai

>   			rdev_dec_pending(conf->mirrors[m].rdev,
>   					 conf->mddev);
>   		}
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 231177cee928..9c43c380d7e8 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -2820,11 +2820,15 @@ static bool narrow_write_error(struct r10bio *r10_bio, int i)
>   				   choose_data_offset(r10_bio, rdev);
>   		wbio->bi_opf = REQ_OP_WRITE;
>   
> -		if (submit_bio_wait(wbio) < 0)
> +		if (submit_bio_wait(wbio)) {
>   			/* Failure! */
> -			ok = rdev_set_badblocks(rdev, wsector,
> -						sectors, 0)
> -				&& ok;
> +			ok = false;
> +			if (!rdev_set_badblocks(rdev, wsector, sectors, 0)) {
> +				md_error(mddev, rdev);
> +				bio_put(wbio);
> +				break;
> +			}
> +		}
>   
>   		bio_put(wbio);
>   		sect_to_write -= sectors;
> @@ -2936,8 +2940,7 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
>   				rdev_dec_pending(rdev, conf->mddev);
>   			} else if (bio != NULL && bio->bi_status) {
>   				fail = true;
> -				if (!narrow_write_error(r10_bio, m))
> -					md_error(conf->mddev, rdev);
> +				narrow_write_error(r10_bio, m);
>   				rdev_dec_pending(rdev, conf->mddev);
>   			}
>   			bio = r10_bio->devs[m].repl_bio;

  reply	other threads:[~2025-11-08 10:08 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06 11:59 [PATCH v2 00/11] cleanup and bugfix of sync linan666
2025-11-06 11:59 ` [PATCH v2 01/11] md/raid1: simplify uptodate handling in end_sync_write linan666
2025-11-08 10:02   ` Yu Kuai
2025-11-06 11:59 ` [PATCH v2 02/11] md: factor error handling out of md_done_sync into helper linan666
2025-11-06 11:59 ` [PATCH v2 03/11] md/raid1,raid10: return actual write status in narrow_write_error linan666
2025-11-08 10:07   ` Yu Kuai [this message]
2025-11-10 11:56     ` Li Nan
2025-11-28  2:45       ` Yu Kuai
2025-11-06 11:59 ` [PATCH v2 04/11] md/raid1,raid10: support narrow_write_error when badblocks is disabled linan666
2025-11-08 10:11   ` Yu Kuai
2025-11-06 11:59 ` [PATCH v2 05/11] md: mark rdev Faulty when badblocks setting fails linan666
2025-11-08 10:15   ` Yu Kuai
2025-11-06 11:59 ` [PATCH v2 06/11] md: remove MD_RECOVERY_ERROR handling and simplify resync_offset update linan666
2025-11-08 10:22   ` Yu Kuai
2025-11-10 12:17     ` Li Nan
2025-11-28  2:47       ` Yu Kuai
2025-11-06 11:59 ` [PATCH v2 07/11] md: factor out sync completion update into helper linan666
2025-11-08 10:30   ` Yu Kuai
2025-11-06 11:59 ` [PATCH v2 08/11] md: move finish_reshape to md_finish_sync() linan666
2025-11-08 10:37   ` Yu Kuai
2025-11-06 11:59 ` [PATCH v2 09/11] md/raid10: fix any_working flag handling in raid10_sync_request linan666
2025-11-06 11:59 ` [PATCH v2 10/11] md/raid10: cleanup skip " linan666
2025-11-08 10:54   ` Yu Kuai
2025-11-06 11:59 ` [PATCH v2 11/11] 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=63857ce2-0521-4f38-b3d4-d95c8eafc175@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=xni@redhat.com \
    --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®