linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Cc: "hch@lst.de" <hch@lst.de>,
	"kbusch@kernel.org" <kbusch@kernel.org>,
	"sagi@grimberg.me" <sagi@grimberg.me>
Subject: Re: [PATCH V12 3/3] nvmet: add nvmet_req_bio put helper for backends
Date: Fri, 12 Mar 2021 00:37:17 +0000	[thread overview]
Message-ID: <BL0PR04MB6514705F1E1E609E22F673B4E76F9@BL0PR04MB6514.namprd04.prod.outlook.com> (raw)
In-Reply-To: 20210311071530.18680-4-chaitanya.kulkarni@wdc.com

On 2021/03/11 16:16, Chaitanya Kulkarni wrote:
> With the addition of zns backend now we have three different backends
> with inline bio optimization. That leads to having duplicate code in
> for freeing the bio in all three backends: generic bdev, passsthru and
> generic zns.
> 
> Add a helper function to avoid duplicate code and update the
> respective backends.
> 
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>  drivers/nvme/target/io-cmd-bdev.c | 3 +--
>  drivers/nvme/target/nvmet.h       | 6 ++++++
>  drivers/nvme/target/passthru.c    | 3 +--
>  drivers/nvme/target/zns.c         | 3 +--
>  4 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
> index ada0215f5e56..ca39d787d71f 100644
> --- a/drivers/nvme/target/io-cmd-bdev.c
> +++ b/drivers/nvme/target/io-cmd-bdev.c
> @@ -173,8 +173,7 @@ static void nvmet_bio_done(struct bio *bio)
>  	struct nvmet_req *req = bio->bi_private;
>  
>  	nvmet_req_complete(req, blk_to_nvme_status(req, bio->bi_status));
> -	if (bio != &req->b.inline_bio)
> -		bio_put(bio);
> +	nvmet_req_bio_put(req, bio);
>  }
>  
>  #ifdef CONFIG_BLK_DEV_INTEGRITY
> diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
> index f3fccc49de03..2f1bd3ac34a2 100644
> --- a/drivers/nvme/target/nvmet.h
> +++ b/drivers/nvme/target/nvmet.h
> @@ -654,4 +654,10 @@ static inline sector_t nvmet_lba_to_sect(struct nvmet_ns *ns, __le64 lba)
>  	return le64_to_cpu(lba) << (ns->blksize_shift - SECTOR_SHIFT);
>  }
>  
> +static inline void nvmet_req_bio_put(struct nvmet_req *req, struct bio *bio)
> +{
> +	if (bio != &req->b.inline_bio)
> +		bio_put(bio);
> +}
> +
>  #endif /* _NVMET_H */
> diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
> index 26c587ccd152..011aeebace55 100644
> --- a/drivers/nvme/target/passthru.c
> +++ b/drivers/nvme/target/passthru.c
> @@ -206,8 +206,7 @@ static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq)
>  	for_each_sg(req->sg, sg, req->sg_cnt, i) {
>  		if (bio_add_pc_page(rq->q, bio, sg_page(sg), sg->length,
>  				    sg->offset) < sg->length) {
> -			if (bio != &req->p.inline_bio)
> -				bio_put(bio);
> +			nvmet_req_bio_put(req, bio);
>  			return -EINVAL;
>  		}
>  	}
> diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
> index e12629b02320..112d213583ea 100644
> --- a/drivers/nvme/target/zns.c
> +++ b/drivers/nvme/target/zns.c
> @@ -326,7 +326,6 @@ void nvmet_bdev_execute_zone_append(struct nvmet_req *req)
>  						 bio->bi_iter.bi_sector);
>  
>  out_bio_put:
> -	if (bio != &req->b.inline_bio)
> -		bio_put(bio);
> +	nvmet_req_bio_put(req, bio);
>  	nvmet_req_complete(req, ret < 0 ? NVME_SC_INTERNAL : status);
>  }
> 

Looks good to me.

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>

-- 
Damien Le Moal
Western Digital Research

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

      reply	other threads:[~2021-03-12  0:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11  7:15 [PATCH V12 0/3] nvmet: add ZBD backend support Chaitanya Kulkarni
2021-03-11  7:15 ` [PATCH V12 1/3] nvmet: add NVM Command Set Identifier support Chaitanya Kulkarni
2021-03-11  7:15 ` [PATCH V12 2/3] nvmet: add ZBD over ZNS backend support Chaitanya Kulkarni
2021-03-12  1:15   ` Damien Le Moal
2021-03-12  6:29     ` Chaitanya Kulkarni
2021-03-12  7:25       ` Damien Le Moal
2021-03-13  2:40         ` Chaitanya Kulkarni
2021-03-15  3:54         ` Chaitanya Kulkarni
2021-03-15  4:09           ` Damien Le Moal
2021-03-15  4:53             ` Chaitanya Kulkarni
2021-03-11  7:15 ` [PATCH V12 3/3] nvmet: add nvmet_req_bio put helper for backends Chaitanya Kulkarni
2021-03-12  0:37   ` Damien Le Moal [this message]

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=BL0PR04MB6514705F1E1E609E22F673B4E76F9@BL0PR04MB6514.namprd04.prod.outlook.com \
    --to=damien.lemoal@wdc.com \
    --cc=Chaitanya.Kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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).