From: Xiao Ni <xni@redhat.com>
To: Yu Kuai <yukuai1@huaweicloud.com>
Cc: song@kernel.org, neilb@suse.de, akpm@osdl.org,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
yukuai3@huawei.com, yi.zhang@huawei.com, yangerkun@huawei.com
Subject: Re: [PATCH -next v3 3/7] md/raid1-10: factor out a helper to submit normal write
Date: Wed, 31 May 2023 15:20:59 +0800 [thread overview]
Message-ID: <CALTww29_d7H6DG+qZOOJvQ5A8AieXkDfKWgN38HeCP9W-r5RQg@mail.gmail.com> (raw)
In-Reply-To: <20230529131106.2123367-4-yukuai1@huaweicloud.com>
On Mon, May 29, 2023 at 9:14 PM Yu Kuai <yukuai1@huaweicloud.com> wrote:
>
> From: Yu Kuai <yukuai3@huawei.com>
>
> There are multiple places to do the same thing, factor out a helper to
> prevent redundant code, and the helper will be used in following patch
> as well.
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> drivers/md/raid1-10.c | 17 +++++++++++++++++
> drivers/md/raid1.c | 13 ++-----------
> drivers/md/raid10.c | 26 ++++----------------------
> 3 files changed, 23 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c
> index 9bf19a3409ce..506299bd55cb 100644
> --- a/drivers/md/raid1-10.c
> +++ b/drivers/md/raid1-10.c
> @@ -110,6 +110,23 @@ static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp,
> } while (idx++ < RESYNC_PAGES && size > 0);
> }
>
> +
> +static inline void raid1_submit_write(struct bio *bio)
Hi Kuai
Is it better to change the name to rdev_submit_write? It's just a
suggestion. The patch looks good to me.
Regards
Xiao
> +{
> + struct md_rdev *rdev = (struct md_rdev *)bio->bi_bdev;
> +
> + bio->bi_next = NULL;
> + bio_set_dev(bio, rdev->bdev);
> + if (test_bit(Faulty, &rdev->flags))
> + bio_io_error(bio);
> + else if (unlikely(bio_op(bio) == REQ_OP_DISCARD &&
> + !bdev_max_discard_sectors(bio->bi_bdev)))
> + /* Just ignore it */
> + bio_endio(bio);
> + else
> + submit_bio_noacct(bio);
> +}
> +
> static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio,
> blk_plug_cb_fn unplug)
> {
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index e86c5e71c604..0778e398584c 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -799,17 +799,8 @@ static void flush_bio_list(struct r1conf *conf, struct bio *bio)
>
> while (bio) { /* submit pending writes */
> struct bio *next = bio->bi_next;
> - struct md_rdev *rdev = (void *)bio->bi_bdev;
> - bio->bi_next = NULL;
> - bio_set_dev(bio, rdev->bdev);
> - if (test_bit(Faulty, &rdev->flags)) {
> - bio_io_error(bio);
> - } else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) &&
> - !bdev_max_discard_sectors(bio->bi_bdev)))
> - /* Just ignore it */
> - bio_endio(bio);
> - else
> - submit_bio_noacct(bio);
> +
> + raid1_submit_write(bio);
> bio = next;
> cond_resched();
> }
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 18702051ebd1..6640507ecb0d 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -909,17 +909,8 @@ static void flush_pending_writes(struct r10conf *conf)
>
> while (bio) { /* submit pending writes */
> struct bio *next = bio->bi_next;
> - struct md_rdev *rdev = (void*)bio->bi_bdev;
> - bio->bi_next = NULL;
> - bio_set_dev(bio, rdev->bdev);
> - if (test_bit(Faulty, &rdev->flags)) {
> - bio_io_error(bio);
> - } else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) &&
> - !bdev_max_discard_sectors(bio->bi_bdev)))
> - /* Just ignore it */
> - bio_endio(bio);
> - else
> - submit_bio_noacct(bio);
> +
> + raid1_submit_write(bio);
> bio = next;
> cond_resched();
> }
> @@ -1134,17 +1125,8 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
>
> while (bio) { /* submit pending writes */
> struct bio *next = bio->bi_next;
> - struct md_rdev *rdev = (void*)bio->bi_bdev;
> - bio->bi_next = NULL;
> - bio_set_dev(bio, rdev->bdev);
> - if (test_bit(Faulty, &rdev->flags)) {
> - bio_io_error(bio);
> - } else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) &&
> - !bdev_max_discard_sectors(bio->bi_bdev)))
> - /* Just ignore it */
> - bio_endio(bio);
> - else
> - submit_bio_noacct(bio);
> +
> + raid1_submit_write(bio);
> bio = next;
> cond_resched();
> }
> --
> 2.39.2
>
next prev parent reply other threads:[~2023-05-31 7:23 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-29 13:10 [PATCH -next v3 0/7] limit the number of plugged bio Yu Kuai
2023-05-29 13:11 ` [PATCH -next v3 1/7] md/raid10: prevent soft lockup while flush writes Yu Kuai
2023-05-29 13:11 ` [PATCH -next v3 2/7] md/raid1-10: factor out a helper to add bio to plug Yu Kuai
2023-05-29 13:11 ` [PATCH -next v3 3/7] md/raid1-10: factor out a helper to submit normal write Yu Kuai
2023-05-31 7:20 ` Xiao Ni [this message]
2023-05-31 7:56 ` Yu Kuai
2023-05-29 13:11 ` [PATCH -next v3 4/7] md/raid1-10: submit write io directly if bitmap is not enabled Yu Kuai
2023-05-31 7:26 ` Xiao Ni
2023-05-31 8:25 ` Yu Kuai
2023-05-31 15:19 ` Xiao Ni
2023-05-29 13:11 ` [PATCH -next v3 5/7] md/md-bitmap: add a new helper to unplug bitmap asynchrously Yu Kuai
2023-06-06 17:34 ` Song Liu
2023-05-29 13:11 ` [PATCH -next v3 6/7] md/raid1-10: don't handle pluged bio by daemon thread Yu Kuai
2023-05-31 7:50 ` Xiao Ni
2023-05-31 7:55 ` Yu Kuai
2023-05-31 8:00 ` Xiao Ni
2023-05-31 8:06 ` Yu Kuai
2023-05-31 15:23 ` Xiao Ni
2023-05-31 7:57 ` Paul Menzel
2023-05-29 13:11 ` [PATCH -next v3 7/7] md/raid1-10: limit the number of plugged bio Yu Kuai
2023-05-31 15:42 ` Xiao Ni
2023-06-01 1:41 ` Yu Kuai
2023-06-06 21:54 ` [PATCH -next v3 0/7] " Song Liu
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=CALTww29_d7H6DG+qZOOJvQ5A8AieXkDfKWgN38HeCP9W-r5RQg@mail.gmail.com \
--to=xni@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
--cc=song@kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@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;
as well as URLs for NNTP newsgroup(s).