From: Damien Le Moal <Damien.LeMoal@wdc.com> To: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>, "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>, "linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org> Cc: "hch@lst.de" <hch@lst.de>, "sagi@grimberg.me" <sagi@grimberg.me> Subject: Re: [PATCH V9 6/9] nvmet: add bio init helper for different backends Date: Tue, 12 Jan 2021 05:40:13 +0000 [thread overview] Message-ID: <BL0PR04MB6514DF0B740BE6F4AB3141AEE7AA0@BL0PR04MB6514.namprd04.prod.outlook.com> (raw) In-Reply-To: 20210112042623.6316-7-chaitanya.kulkarni@wdc.com On 2021/01/12 13:27, Chaitanya Kulkarni wrote: > With the addition of the zns backend now we have two different backends > with the same bio initialization code. That leads to having duplicate > code in two backends: generic bdev and generic zns. > > Add a helper function to reduce the duplicate code such that helper > function initializes the various bio initialization parameters such as > bio block device, op flags, sector, end io callback, and private member, > > Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> > --- > drivers/nvme/target/io-cmd-bdev.c | 6 +----- > drivers/nvme/target/nvmet.h | 11 +++++++++++ > drivers/nvme/target/zns.c | 6 +++--- > 3 files changed, 15 insertions(+), 8 deletions(-) > > diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c > index 72746e29cb0d..b1fb0bb1f39f 100644 > --- a/drivers/nvme/target/io-cmd-bdev.c > +++ b/drivers/nvme/target/io-cmd-bdev.c > @@ -267,11 +267,7 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req) > sector = nvmet_lba_to_sect(req->ns, req->cmd->rw.slba); > > bio = nvmet_req_bio_get(req, NULL); > - bio_set_dev(bio, req->ns->bdev); > - bio->bi_iter.bi_sector = sector; > - bio->bi_private = req; > - bio->bi_end_io = nvmet_bio_done; > - bio->bi_opf = op; > + nvmet_bio_init(bio, req->ns->bdev, op, sector, req, nvmet_bio_done); > > blk_start_plug(&plug); > if (req->metadata_len) > diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h > index 3fc84f79cce1..1ec9e1b35c67 100644 > --- a/drivers/nvme/target/nvmet.h > +++ b/drivers/nvme/target/nvmet.h > @@ -668,4 +668,15 @@ static inline struct bio *nvmet_req_bio_get(struct nvmet_req *req, > return bio; > } > > +static inline void nvmet_bio_init(struct bio *bio, struct block_device *bdev, > + unsigned int op, sector_t sect, void *private, > + bio_end_io_t *bi_end_io) > +{ > + bio_set_dev(bio, bdev); > + bio->bi_opf = op; > + bio->bi_iter.bi_sector = sect; > + bio->bi_private = private; > + bio->bi_end_io = bi_end_io; > +} > + > #endif /* _NVMET_H */ > diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c > index c32e93a3c7e1..92213bed0006 100644 > --- a/drivers/nvme/target/zns.c > +++ b/drivers/nvme/target/zns.c > @@ -281,6 +281,7 @@ void nvmet_bdev_execute_zone_append(struct nvmet_req *req) > { > sector_t sect = nvmet_lba_to_sect(req->ns, req->cmd->rw.slba); > struct request_queue *q = req->ns->bdev->bd_disk->queue; > + unsigned int op = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE; > unsigned int max_sects = queue_max_zone_append_sectors(q); > u16 status = NVME_SC_SUCCESS; > unsigned int total_len = 0; > @@ -297,9 +298,8 @@ void nvmet_bdev_execute_zone_append(struct nvmet_req *req) > } > > bio = nvmet_req_bio_get(req, NULL); > - bio_set_dev(bio, req->ns->bdev); > - bio->bi_iter.bi_sector = sect; > - bio->bi_opf = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE; > + nvmet_bio_init(bio, req->ns->bdev, op, sect, NULL, NULL); op is used only here I think. So is that variable really necessary ? > + > if (req->cmd->rw.control & cpu_to_le16(NVME_RW_FUA)) > bio->bi_opf |= REQ_FUA; > > Apart from the nit above, looks good to me. Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> -- Damien Le Moal Western Digital Research
WARNING: multiple messages have this Message-ID (diff)
From: Damien Le Moal <Damien.LeMoal@wdc.com> To: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>, "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>, "linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org> Cc: "hch@lst.de" <hch@lst.de>, "sagi@grimberg.me" <sagi@grimberg.me> Subject: Re: [PATCH V9 6/9] nvmet: add bio init helper for different backends Date: Tue, 12 Jan 2021 05:40:13 +0000 [thread overview] Message-ID: <BL0PR04MB6514DF0B740BE6F4AB3141AEE7AA0@BL0PR04MB6514.namprd04.prod.outlook.com> (raw) In-Reply-To: 20210112042623.6316-7-chaitanya.kulkarni@wdc.com On 2021/01/12 13:27, Chaitanya Kulkarni wrote: > With the addition of the zns backend now we have two different backends > with the same bio initialization code. That leads to having duplicate > code in two backends: generic bdev and generic zns. > > Add a helper function to reduce the duplicate code such that helper > function initializes the various bio initialization parameters such as > bio block device, op flags, sector, end io callback, and private member, > > Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> > --- > drivers/nvme/target/io-cmd-bdev.c | 6 +----- > drivers/nvme/target/nvmet.h | 11 +++++++++++ > drivers/nvme/target/zns.c | 6 +++--- > 3 files changed, 15 insertions(+), 8 deletions(-) > > diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c > index 72746e29cb0d..b1fb0bb1f39f 100644 > --- a/drivers/nvme/target/io-cmd-bdev.c > +++ b/drivers/nvme/target/io-cmd-bdev.c > @@ -267,11 +267,7 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req) > sector = nvmet_lba_to_sect(req->ns, req->cmd->rw.slba); > > bio = nvmet_req_bio_get(req, NULL); > - bio_set_dev(bio, req->ns->bdev); > - bio->bi_iter.bi_sector = sector; > - bio->bi_private = req; > - bio->bi_end_io = nvmet_bio_done; > - bio->bi_opf = op; > + nvmet_bio_init(bio, req->ns->bdev, op, sector, req, nvmet_bio_done); > > blk_start_plug(&plug); > if (req->metadata_len) > diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h > index 3fc84f79cce1..1ec9e1b35c67 100644 > --- a/drivers/nvme/target/nvmet.h > +++ b/drivers/nvme/target/nvmet.h > @@ -668,4 +668,15 @@ static inline struct bio *nvmet_req_bio_get(struct nvmet_req *req, > return bio; > } > > +static inline void nvmet_bio_init(struct bio *bio, struct block_device *bdev, > + unsigned int op, sector_t sect, void *private, > + bio_end_io_t *bi_end_io) > +{ > + bio_set_dev(bio, bdev); > + bio->bi_opf = op; > + bio->bi_iter.bi_sector = sect; > + bio->bi_private = private; > + bio->bi_end_io = bi_end_io; > +} > + > #endif /* _NVMET_H */ > diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c > index c32e93a3c7e1..92213bed0006 100644 > --- a/drivers/nvme/target/zns.c > +++ b/drivers/nvme/target/zns.c > @@ -281,6 +281,7 @@ void nvmet_bdev_execute_zone_append(struct nvmet_req *req) > { > sector_t sect = nvmet_lba_to_sect(req->ns, req->cmd->rw.slba); > struct request_queue *q = req->ns->bdev->bd_disk->queue; > + unsigned int op = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE; > unsigned int max_sects = queue_max_zone_append_sectors(q); > u16 status = NVME_SC_SUCCESS; > unsigned int total_len = 0; > @@ -297,9 +298,8 @@ void nvmet_bdev_execute_zone_append(struct nvmet_req *req) > } > > bio = nvmet_req_bio_get(req, NULL); > - bio_set_dev(bio, req->ns->bdev); > - bio->bi_iter.bi_sector = sect; > - bio->bi_opf = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE; > + nvmet_bio_init(bio, req->ns->bdev, op, sect, NULL, NULL); op is used only here I think. So is that variable really necessary ? > + > if (req->cmd->rw.control & cpu_to_le16(NVME_RW_FUA)) > bio->bi_opf |= REQ_FUA; > > Apart from the nit above, 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
next prev parent reply other threads:[~2021-01-12 5:41 UTC|newest] Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-12 4:26 [PATCH V9 0/9] nvmet: add ZBD backend support Chaitanya Kulkarni 2021-01-12 4:26 ` Chaitanya Kulkarni 2021-01-12 4:26 ` [PATCH V9 1/9] block: export bio_add_hw_pages() Chaitanya Kulkarni 2021-01-12 4:26 ` Chaitanya Kulkarni 2021-01-12 5:40 ` Damien Le Moal 2021-01-12 5:40 ` Damien Le Moal 2021-01-12 7:24 ` Christoph Hellwig 2021-01-12 7:24 ` Christoph Hellwig 2021-01-13 1:20 ` Chaitanya Kulkarni 2021-01-13 1:20 ` Chaitanya Kulkarni 2021-01-12 4:26 ` [PATCH V9 2/9] nvmet: add lba to sect conversion helpers Chaitanya Kulkarni 2021-01-12 4:26 ` Chaitanya Kulkarni 2021-01-12 5:08 ` Damien Le Moal 2021-01-12 5:08 ` Damien Le Moal 2021-01-18 18:19 ` Christoph Hellwig 2021-01-18 18:19 ` Christoph Hellwig 2021-01-12 4:26 ` [PATCH V9 3/9] nvmet: add NVM command set identifier support Chaitanya Kulkarni 2021-01-12 4:26 ` Chaitanya Kulkarni 2021-01-12 7:27 ` Christoph Hellwig 2021-01-12 7:27 ` Christoph Hellwig 2021-01-13 4:16 ` Chaitanya Kulkarni 2021-01-13 4:16 ` Chaitanya Kulkarni 2021-01-18 18:21 ` Christoph Hellwig 2021-01-18 18:21 ` Christoph Hellwig 2021-01-12 4:26 ` [PATCH V9 4/9] nvmet: add ZBD over ZNS backend support Chaitanya Kulkarni 2021-01-12 4:26 ` Chaitanya Kulkarni 2021-01-12 5:32 ` Damien Le Moal 2021-01-12 5:32 ` Damien Le Moal 2021-01-12 6:11 ` Chaitanya Kulkarni 2021-01-12 6:11 ` Chaitanya Kulkarni 2021-01-12 6:31 ` Damien Le Moal 2021-01-12 6:31 ` Damien Le Moal 2021-01-12 7:48 ` Christoph Hellwig 2021-01-12 7:48 ` Christoph Hellwig 2021-01-12 7:52 ` Damien Le Moal 2021-01-12 7:52 ` Damien Le Moal 2021-01-18 18:25 ` Christoph Hellwig 2021-01-18 18:25 ` Christoph Hellwig 2021-01-19 0:02 ` Damien Le Moal 2021-01-19 0:02 ` Damien Le Moal 2021-01-19 4:28 ` Damien Le Moal 2021-01-19 4:28 ` Damien Le Moal 2021-01-19 6:15 ` hch 2021-01-19 6:15 ` hch 2021-01-13 4:57 ` Chaitanya Kulkarni 2021-01-13 4:57 ` Chaitanya Kulkarni 2021-01-18 18:27 ` Christoph Hellwig 2021-01-18 18:27 ` Christoph Hellwig 2021-01-12 4:26 ` [PATCH V9 5/9] nvmet: add bio get helper for different backends Chaitanya Kulkarni 2021-01-12 4:26 ` Chaitanya Kulkarni 2021-01-12 5:37 ` Damien Le Moal 2021-01-12 5:37 ` Damien Le Moal 2021-01-12 5:55 ` Chaitanya Kulkarni 2021-01-12 5:55 ` Chaitanya Kulkarni 2021-01-12 7:33 ` Christoph Hellwig 2021-01-12 7:33 ` Christoph Hellwig 2021-01-13 5:03 ` Chaitanya Kulkarni 2021-01-13 5:03 ` Chaitanya Kulkarni 2021-01-18 18:28 ` Christoph Hellwig 2021-01-18 18:28 ` Christoph Hellwig 2021-01-19 4:57 ` Chaitanya Kulkarni 2021-01-19 4:57 ` Chaitanya Kulkarni 2021-01-12 4:26 ` [PATCH V9 6/9] nvmet: add bio init " Chaitanya Kulkarni 2021-01-12 4:26 ` Chaitanya Kulkarni 2021-01-12 5:40 ` Damien Le Moal [this message] 2021-01-12 5:40 ` Damien Le Moal 2021-01-12 5:57 ` Chaitanya Kulkarni 2021-01-12 5:57 ` Chaitanya Kulkarni 2021-01-12 6:27 ` Damien Le Moal 2021-01-12 6:27 ` Damien Le Moal 2021-01-12 7:33 ` Christoph Hellwig 2021-01-12 7:33 ` Christoph Hellwig 2021-01-13 5:04 ` Chaitanya Kulkarni 2021-01-13 5:04 ` Chaitanya Kulkarni 2021-01-18 18:33 ` Christoph Hellwig 2021-01-18 18:33 ` Christoph Hellwig 2021-01-12 4:26 ` [PATCH V9 7/9] nvmet: add bio put " Chaitanya Kulkarni 2021-01-12 4:26 ` Chaitanya Kulkarni 2021-01-12 4:26 ` [PATCH V9 8/9] nvmet: add common I/O length check helper Chaitanya Kulkarni 2021-01-12 4:26 ` Chaitanya Kulkarni 2021-01-12 7:35 ` Christoph Hellwig 2021-01-12 7:35 ` Christoph Hellwig 2021-01-13 5:07 ` Chaitanya Kulkarni 2021-01-13 5:07 ` Chaitanya Kulkarni 2021-01-18 18:34 ` Christoph Hellwig 2021-01-18 18:34 ` Christoph Hellwig 2021-01-12 4:26 ` [PATCH V9 9/9] nvmet: call nvmet_bio_done() for zone append Chaitanya Kulkarni 2021-01-12 4:26 ` Chaitanya Kulkarni 2021-01-12 7:36 ` Christoph Hellwig 2021-01-12 7:36 ` Christoph Hellwig 2021-01-13 5:13 ` Chaitanya Kulkarni 2021-01-13 5:13 ` Chaitanya Kulkarni 2021-01-12 6:12 ` [PATCH V9 0/9] nvmet: add ZBD backend support Chaitanya Kulkarni 2021-01-12 6:12 ` Chaitanya Kulkarni 2021-02-10 22:42 ` Chaitanya Kulkarni 2021-02-10 22:42 ` Chaitanya Kulkarni 2021-02-11 7:20 ` hch 2021-02-11 7:20 ` hch
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=BL0PR04MB6514DF0B740BE6F4AB3141AEE7AA0@BL0PR04MB6514.namprd04.prod.outlook.com \ --to=damien.lemoal@wdc.com \ --cc=Chaitanya.Kulkarni@wdc.com \ --cc=hch@lst.de \ --cc=linux-block@vger.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: linkBe 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.