All of lore.kernel.org
 help / color / mirror / Atom feed
From: Song Liu <song@kernel.org>
To: Guoqing Jiang <jgq516@gmail.com>
Cc: linux-raid <linux-raid@vger.kernel.org>,
	Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Subject: Re: [PATCH V2 2/7] md: add accounting_bio for raid0 and raid5
Date: Sun, 23 May 2021 22:48:14 -0700	[thread overview]
Message-ID: <CAPhsuW6qYrDMU8zEsXZQKzn-VwFjoiRKcXax-vwpqPz438KnjQ@mail.gmail.com> (raw)
In-Reply-To: <20210521005521.713106-3-jiangguoqing@kylinos.cn>

On Thu, May 20, 2021 at 5:56 PM Guoqing Jiang <jgq516@gmail.com> wrote:
>
> Let's introduce accounting_bio which checks if md needs clone the bio
> for accounting.
>
> And add relevant function to raid0 and raid5 given both don't have
> their own clone infrastrure, also checks if it is split bio.
>
> Signed-off-by: Guoqing Jiang <jiangguoqing@kylinos.cn>
> ---
>  drivers/md/md.h    |  2 ++
>  drivers/md/raid0.c | 14 ++++++++++++++
>  drivers/md/raid5.c | 17 +++++++++++++++++
>  3 files changed, 33 insertions(+)
>
> diff --git a/drivers/md/md.h b/drivers/md/md.h
> index 4da240ffe2c5..5125ccf9df06 100644
> --- a/drivers/md/md.h
> +++ b/drivers/md/md.h
> @@ -605,6 +605,8 @@ struct md_personality
>         void *(*takeover) (struct mddev *mddev);
>         /* Changes the consistency policy of an active array. */
>         int (*change_consistency_policy)(struct mddev *mddev, const char *buf);
> +       /* check if need to clone bio for accounting in md layer */
> +       bool (*accounting_bio)(struct mddev *mddev, struct bio *bio);
>  };
>
>  struct md_sysfs_entry {
> diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
> index e5d7411cba9b..d309b639b5d9 100644
> --- a/drivers/md/raid0.c
> +++ b/drivers/md/raid0.c
> @@ -748,6 +748,19 @@ static void raid0_quiesce(struct mddev *mddev, int quiesce)
>  {
>  }
>
> +/*
> + * Don't account the bio if it was split from mddev->bio_set.
> + */
> +static bool raid0_accounting_bio(struct mddev *mddev, struct bio *bio)
> +{
> +       bool ret = true;
> +
> +       if (bio->bi_pool == &mddev->bio_set)
> +               ret = false;

We can simply do "return bio->bi_pool != &mddev->bio_set;". And same for
raid5_accouting_bio.

> +
> +       return ret;
> +}
> +
>  static struct md_personality raid0_personality=
>  {
>         .name           = "raid0",
> @@ -760,6 +773,7 @@ static struct md_personality raid0_personality=
>         .size           = raid0_size,
>         .takeover       = raid0_takeover,
>         .quiesce        = raid0_quiesce,
> +       .accounting_bio = raid0_accounting_bio,
>  };
>
>  static int __init raid0_init (void)
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 841e1c1aa5e6..bcc1ceb69c73 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -8596,6 +8596,20 @@ static void *raid6_takeover(struct mddev *mddev)
>         return setup_conf(mddev);
>  }
>
> +/*
> + * Don't account the bio if it was split from r5conf->bio_split.
> + */
> +static bool raid5_accounting_bio(struct mddev *mddev, struct bio *bio)
> +{
> +       bool ret = true;
> +       struct r5conf *conf = mddev->private;
> +
> +       if (bio->bi_pool == &conf->bio_split)
> +               ret = false;
> +
> +       return ret;
> +}
> +
>  static int raid5_change_consistency_policy(struct mddev *mddev, const char *buf)
>  {
>         struct r5conf *conf;
> @@ -8688,6 +8702,7 @@ static struct md_personality raid6_personality =
>         .quiesce        = raid5_quiesce,
>         .takeover       = raid6_takeover,
>         .change_consistency_policy = raid5_change_consistency_policy,
> +       .accounting_bio = raid5_accounting_bio,
>  };
>  static struct md_personality raid5_personality =
>  {
> @@ -8712,6 +8727,7 @@ static struct md_personality raid5_personality =
>         .quiesce        = raid5_quiesce,
>         .takeover       = raid5_takeover,
>         .change_consistency_policy = raid5_change_consistency_policy,
> +       .accounting_bio = raid5_accounting_bio,
>  };
>
>  static struct md_personality raid4_personality =
> @@ -8737,6 +8753,7 @@ static struct md_personality raid4_personality =
>         .quiesce        = raid5_quiesce,
>         .takeover       = raid4_takeover,
>         .change_consistency_policy = raid5_change_consistency_policy,
> +       .accounting_bio = raid5_accounting_bio,
>  };
>
>  static int __init raid5_init(void)
> --
> 2.25.1
>

  reply	other threads:[~2021-05-24  5:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21  0:55 [PATCH V2 0/7] md: io stats accounting Guoqing Jiang
2021-05-21  0:55 ` [PATCH V2 1/7] md: revert " Guoqing Jiang
2021-05-21  0:55 ` [PATCH V2 2/7] md: add accounting_bio for raid0 and raid5 Guoqing Jiang
2021-05-24  5:48   ` Song Liu [this message]
2021-05-24  8:45   ` Christoph Hellwig
2021-05-21  0:55 ` [PATCH V2 3/7] md: the latest try for improve io stats accounting Guoqing Jiang
2021-05-21  7:32   ` Artur Paszkiewicz
2021-05-21  7:43     ` Guoqing Jiang
2021-05-21  0:55 ` [PATCH V2 4/7] md/raid1: rename print_msg with r1bio_existed Guoqing Jiang
2021-05-21  0:55 ` [PATCH V2 5/7] md/raid1: enable io accounting Guoqing Jiang
2021-05-21  0:55 ` [PATCH V2 6/7] md/raid10: " Guoqing Jiang
2021-05-21  0:55 ` [PATCH V2 7/7] md: mark some personalities as deprecated Guoqing Jiang
2021-05-21  8:00 ` [UPDATE PATCH V2 3/7] md: the latest try for improve io stats accounting Guoqing Jiang
2021-05-24  5:49   ` Song Liu
2021-05-24  6:04 ` [PATCH V2 0/7] md: " Song Liu
2021-05-27 14:09   ` Paweł Wiejacha

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=CAPhsuW6qYrDMU8zEsXZQKzn-VwFjoiRKcXax-vwpqPz438KnjQ@mail.gmail.com \
    --to=song@kernel.org \
    --cc=artur.paszkiewicz@intel.com \
    --cc=jgq516@gmail.com \
    --cc=linux-raid@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.