linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jinpu Wang <jinpu.wang@ionos.com>
To: Guoqing Jiang <guoqing.jiang@linux.dev>
Cc: haris.iqbal@ionos.com, axboe@kernel.dk, linux-block@vger.kernel.org
Subject: Re: [PATCH V1 6/8] rnbd-clt: check capacity inside rnbd_clt_change_capacity
Date: Thu, 23 Jun 2022 09:20:43 +0200	[thread overview]
Message-ID: <CAMGffEnFbdPWaBzW6htXkH1F6yudPBioAJK_58nNFT-Ln1-SHw@mail.gmail.com> (raw)
In-Reply-To: <20220623062116.15976-7-guoqing.jiang@linux.dev>

On Thu, Jun 23, 2022 at 8:22 AM Guoqing Jiang <guoqing.jiang@linux.dev> wrote:
>
> Currently, process_msg_open_rsp checks if capacity changed or not before
> call rnbd_clt_change_capacity while the checking also make sense for
> rnbd_clt_resize_dev_store, let's move the checking into the function.
>
> Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
> ---
>  drivers/block/rnbd/rnbd-clt.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
> index da2ba9477b1e..a9bfab53bbf7 100644
> --- a/drivers/block/rnbd/rnbd-clt.c
> +++ b/drivers/block/rnbd/rnbd-clt.c
> @@ -71,6 +71,12 @@ static inline bool rnbd_clt_get_dev(struct rnbd_clt_dev *dev)
>  static int rnbd_clt_change_capacity(struct rnbd_clt_dev *dev,
>                                     size_t new_nsectors)
>  {
> +       if (get_capacity(dev->gd) == new_nsectors)
> +               return 0;
> +
> +       /*
> +        * If the size changed, we need to revalidate it
> +        */
>         rnbd_clt_info(dev, "Device size changed from %llu to %zu sectors\n",
>                       get_capacity(dev->gd), new_nsectors);
>         set_capacity_and_notify(dev->gd, new_nsectors);
> @@ -93,12 +99,7 @@ static int process_msg_open_rsp(struct rnbd_clt_dev *dev,
>         if (dev->dev_state == DEV_STATE_MAPPED_DISCONNECTED) {
>                 u64 nsectors = le64_to_cpu(rsp->nsectors);
>
> -               /*
> -                * If the device was remapped and the size changed in the
> -                * meantime we need to revalidate it
> -                */
> -               if (get_capacity(dev->gd) != nsectors)
> -                       rnbd_clt_change_capacity(dev, nsectors);
> +               rnbd_clt_change_capacity(dev, nsectors);
>                 gd_kobj = &disk_to_dev(dev->gd)->kobj;
>                 kobject_uevent(gd_kobj, KOBJ_ONLINE);
>                 rnbd_clt_info(dev, "Device online, device remapped successfully\n");
> --
> 2.34.1
>

  reply	other threads:[~2022-06-23  7:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23  6:21 [PATCH V1 0/8] reduce the size of rnbd_clt_dev Guoqing Jiang
2022-06-23  6:21 ` [PATCH V1 1/8] rnbd-clt: open code send_msg_open in rnbd_clt_map_device Guoqing Jiang
2022-06-23  7:20   ` Jinpu Wang
2022-06-23  6:21 ` [PATCH V1 2/8] rnbd-clt: don't free rsp in msg_open_conf for map scenario Guoqing Jiang
2022-06-23  6:21 ` [PATCH V1 3/8] rnbd-clt: kill read_only from struct rnbd_clt_dev Guoqing Jiang
2022-06-23  6:21 ` [PATCH V1 4/8] rnbd-clt: reduce the size of " Guoqing Jiang
2022-06-23  6:21 ` [PATCH V1 5/8] rnbd-clt: adjust the layout " Guoqing Jiang
2022-06-23  6:21 ` [PATCH V1 6/8] rnbd-clt: check capacity inside rnbd_clt_change_capacity Guoqing Jiang
2022-06-23  7:20   ` Jinpu Wang [this message]
2022-06-23  6:21 ` [PATCH V1 7/8] rnbd-clt: pass sector_t type for resize capacity Guoqing Jiang
2022-06-23  7:21   ` Jinpu Wang
2022-06-23  6:21 ` [PATCH V1 8/8] rnbd-clt: make rnbd_clt_change_capacity return void Guoqing Jiang
2022-06-23  7:22   ` Jinpu Wang

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=CAMGffEnFbdPWaBzW6htXkH1F6yudPBioAJK_58nNFT-Ln1-SHw@mail.gmail.com \
    --to=jinpu.wang@ionos.com \
    --cc=axboe@kernel.dk \
    --cc=guoqing.jiang@linux.dev \
    --cc=haris.iqbal@ionos.com \
    --cc=linux-block@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 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).