Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH V2 0/2] Two patches for rnbd
@ 2020-07-30  9:13 Guoqing Jiang
  2020-07-30  9:13 ` [PATCH V2 1/2] rnbd: remove rnbd_dev_submit_io Guoqing Jiang
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Guoqing Jiang @ 2020-07-30  9:13 UTC (permalink / raw)
  To: axboe, danil.kipnis, jinpu.wang; +Cc: linux-block, Guoqing Jiang

V2:
* add Acked-by tag from Danil and Jack.

Hi Jens,

Could you take a look at this patchset?

Thanks,
Guoqing

Guoqing Jiang (2):
  rnbd: remove rnbd_dev_submit_io
  rnbd: no need to set bi_end_io in rnbd_bio_map_kern

 drivers/block/rnbd/rnbd-srv-dev.c | 37 +++----------------------------
 drivers/block/rnbd/rnbd-srv-dev.h | 19 +++++-----------
 drivers/block/rnbd/rnbd-srv.c     | 32 ++++++++++++++++++--------
 3 files changed, 31 insertions(+), 57 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2 1/2] rnbd: remove rnbd_dev_submit_io
  2020-07-30  9:13 [PATCH V2 0/2] Two patches for rnbd Guoqing Jiang
@ 2020-07-30  9:13 ` Guoqing Jiang
  2020-07-30  9:13 ` [PATCH V2 2/2] rnbd: no need to set bi_end_io in rnbd_bio_map_kern Guoqing Jiang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Guoqing Jiang @ 2020-07-30  9:13 UTC (permalink / raw)
  To: axboe, danil.kipnis, jinpu.wang; +Cc: linux-block, Guoqing Jiang

The function only has one caller, so let's open code it in process_rdma.
Another bonus is we can avoid push/pop stack, since we need to pass 8
arguments to rnbd_dev_submit_io.

Acked-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
---
 drivers/block/rnbd/rnbd-srv-dev.c | 36 +++----------------------------
 drivers/block/rnbd/rnbd-srv-dev.h | 19 +++++-----------
 drivers/block/rnbd/rnbd-srv.c     | 32 +++++++++++++++++++--------
 3 files changed, 31 insertions(+), 56 deletions(-)

diff --git a/drivers/block/rnbd/rnbd-srv-dev.c b/drivers/block/rnbd/rnbd-srv-dev.c
index 5eddfd29ab64..49c62b506c9b 100644
--- a/drivers/block/rnbd/rnbd-srv-dev.c
+++ b/drivers/block/rnbd/rnbd-srv-dev.c
@@ -45,7 +45,7 @@ void rnbd_dev_close(struct rnbd_dev *dev)
 	kfree(dev);
 }
 
-static void rnbd_dev_bi_end_io(struct bio *bio)
+void rnbd_dev_bi_end_io(struct bio *bio)
 {
 	struct rnbd_dev_blk_io *io = bio->bi_private;
 
@@ -63,8 +63,8 @@ static void rnbd_dev_bi_end_io(struct bio *bio)
  *	Map the kernel address into a bio suitable for io to a block
  *	device. Returns an error pointer in case of error.
  */
-static struct bio *rnbd_bio_map_kern(void *data, struct bio_set *bs,
-				     unsigned int len, gfp_t gfp_mask)
+struct bio *rnbd_bio_map_kern(void *data, struct bio_set *bs,
+			      unsigned int len, gfp_t gfp_mask)
 {
 	unsigned long kaddr = (unsigned long)data;
 	unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -102,33 +102,3 @@ static struct bio *rnbd_bio_map_kern(void *data, struct bio_set *bs,
 	bio->bi_end_io = bio_put;
 	return bio;
 }
-
-int rnbd_dev_submit_io(struct rnbd_dev *dev, sector_t sector, void *data,
-		       size_t len, u32 bi_size, enum rnbd_io_flags flags,
-		       short prio, void *priv)
-{
-	struct rnbd_dev_blk_io *io;
-	struct bio *bio;
-
-	/* Generate bio with pages pointing to the rdma buffer */
-	bio = rnbd_bio_map_kern(data, dev->ibd_bio_set, len, GFP_KERNEL);
-	if (IS_ERR(bio))
-		return PTR_ERR(bio);
-
-	io = container_of(bio, struct rnbd_dev_blk_io, bio);
-
-	io->dev	= dev;
-	io->priv = priv;
-
-	bio->bi_end_io = rnbd_dev_bi_end_io;
-	bio->bi_private	= io;
-	bio->bi_opf = rnbd_to_bio_flags(flags);
-	bio->bi_iter.bi_sector = sector;
-	bio->bi_iter.bi_size = bi_size;
-	bio_set_prio(bio, prio);
-	bio_set_dev(bio, dev->bdev);
-
-	submit_bio(bio);
-
-	return 0;
-}
diff --git a/drivers/block/rnbd/rnbd-srv-dev.h b/drivers/block/rnbd/rnbd-srv-dev.h
index 0f65b09a270e..0eb23850afb9 100644
--- a/drivers/block/rnbd/rnbd-srv-dev.h
+++ b/drivers/block/rnbd/rnbd-srv-dev.h
@@ -41,6 +41,11 @@ void rnbd_dev_close(struct rnbd_dev *dev);
 
 void rnbd_endio(void *priv, int error);
 
+void rnbd_dev_bi_end_io(struct bio *bio);
+
+struct bio *rnbd_bio_map_kern(void *data, struct bio_set *bs,
+			      unsigned int len, gfp_t gfp_mask);
+
 static inline int rnbd_dev_get_max_segs(const struct rnbd_dev *dev)
 {
 	return queue_max_segments(bdev_get_queue(dev->bdev));
@@ -75,18 +80,4 @@ static inline int rnbd_dev_get_discard_alignment(const struct rnbd_dev *dev)
 	return bdev_get_queue(dev->bdev)->limits.discard_alignment;
 }
 
-/**
- * rnbd_dev_submit_io() - Submit an I/O to the disk
- * @dev:	device to that the I/O is submitted
- * @sector:	address to read/write data to
- * @data:	I/O data to write or buffer to read I/O date into
- * @len:	length of @data
- * @bi_size:	Amount of data that will be read/written
- * @prio:       IO priority
- * @priv:	private data passed to @io_fn
- */
-int rnbd_dev_submit_io(struct rnbd_dev *dev, sector_t sector, void *data,
-			size_t len, u32 bi_size, enum rnbd_io_flags flags,
-			short prio, void *priv);
-
 #endif /* RNBD_SRV_DEV_H */
diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c
index 86e61523907b..0fb94843a495 100644
--- a/drivers/block/rnbd/rnbd-srv.c
+++ b/drivers/block/rnbd/rnbd-srv.c
@@ -124,6 +124,9 @@ static int process_rdma(struct rtrs_srv *sess,
 	struct rnbd_srv_sess_dev *sess_dev;
 	u32 dev_id;
 	int err;
+	struct rnbd_dev_blk_io *io;
+	struct bio *bio;
+	short prio;
 
 	priv = kmalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -142,18 +145,29 @@ static int process_rdma(struct rtrs_srv *sess,
 	priv->sess_dev = sess_dev;
 	priv->id = id;
 
-	err = rnbd_dev_submit_io(sess_dev->rnbd_dev, le64_to_cpu(msg->sector),
-				  data, datalen, le32_to_cpu(msg->bi_size),
-				  le32_to_cpu(msg->rw),
-				  srv_sess->ver < RNBD_PROTO_VER_MAJOR ||
-				  usrlen < sizeof(*msg) ?
-				  0 : le16_to_cpu(msg->prio), priv);
-	if (unlikely(err)) {
-		rnbd_srv_err(sess_dev, "Submitting I/O to device failed, err: %d\n",
-			      err);
+	/* Generate bio with pages pointing to the rdma buffer */
+	bio = rnbd_bio_map_kern(data, sess_dev->rnbd_dev->ibd_bio_set, datalen, GFP_KERNEL);
+	if (IS_ERR(bio)) {
+		rnbd_srv_err(sess_dev, "Failed to generate bio, err: %ld\n", PTR_ERR(bio));
 		goto sess_dev_put;
 	}
 
+	io = container_of(bio, struct rnbd_dev_blk_io, bio);
+	io->dev = sess_dev->rnbd_dev;
+	io->priv = priv;
+
+	bio->bi_end_io = rnbd_dev_bi_end_io;
+	bio->bi_private = io;
+	bio->bi_opf = rnbd_to_bio_flags(le32_to_cpu(msg->rw));
+	bio->bi_iter.bi_sector = le64_to_cpu(msg->sector);
+	bio->bi_iter.bi_size = le32_to_cpu(msg->bi_size);
+	prio = srv_sess->ver < RNBD_PROTO_VER_MAJOR ||
+	       usrlen < sizeof(*msg) ? 0 : le16_to_cpu(msg->prio);
+	bio_set_prio(bio, prio);
+	bio_set_dev(bio, sess_dev->rnbd_dev->bdev);
+
+	submit_bio(bio);
+
 	return 0;
 
 sess_dev_put:
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2 2/2] rnbd: no need to set bi_end_io in rnbd_bio_map_kern
  2020-07-30  9:13 [PATCH V2 0/2] Two patches for rnbd Guoqing Jiang
  2020-07-30  9:13 ` [PATCH V2 1/2] rnbd: remove rnbd_dev_submit_io Guoqing Jiang
@ 2020-07-30  9:13 ` Guoqing Jiang
  2020-08-06  4:50 ` [PATCH V2 0/2] Two patches for rnbd Jinpu Wang
  2020-08-06 13:30 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Guoqing Jiang @ 2020-07-30  9:13 UTC (permalink / raw)
  To: axboe, danil.kipnis, jinpu.wang; +Cc: linux-block, Guoqing Jiang

Since we always set bi_end_io after call rnbd_bio_map_kern, so the
setting in rnbd_bio_map_kern is redundant.

Acked-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
---
 drivers/block/rnbd/rnbd-srv-dev.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/block/rnbd/rnbd-srv-dev.c b/drivers/block/rnbd/rnbd-srv-dev.c
index 49c62b506c9b..b241a099aeae 100644
--- a/drivers/block/rnbd/rnbd-srv-dev.c
+++ b/drivers/block/rnbd/rnbd-srv-dev.c
@@ -99,6 +99,5 @@ struct bio *rnbd_bio_map_kern(void *data, struct bio_set *bs,
 		offset = 0;
 	}
 
-	bio->bi_end_io = bio_put;
 	return bio;
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2 0/2] Two patches for rnbd
  2020-07-30  9:13 [PATCH V2 0/2] Two patches for rnbd Guoqing Jiang
  2020-07-30  9:13 ` [PATCH V2 1/2] rnbd: remove rnbd_dev_submit_io Guoqing Jiang
  2020-07-30  9:13 ` [PATCH V2 2/2] rnbd: no need to set bi_end_io in rnbd_bio_map_kern Guoqing Jiang
@ 2020-08-06  4:50 ` Jinpu Wang
  2020-08-06 13:30 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jinpu Wang @ 2020-08-06  4:50 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Guoqing Jiang, Danil Kipnis, linux-block

On Thu, Jul 30, 2020 at 11:14 AM Guoqing Jiang
<guoqing.jiang@cloud.ionos.com> wrote:
>
> V2:
> * add Acked-by tag from Danil and Jack.
>
> Hi Jens,
>
> Could you take a look at this patchset?
ping! Jens, can you take these in your queue?

Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2 0/2] Two patches for rnbd
  2020-07-30  9:13 [PATCH V2 0/2] Two patches for rnbd Guoqing Jiang
                   ` (2 preceding siblings ...)
  2020-08-06  4:50 ` [PATCH V2 0/2] Two patches for rnbd Jinpu Wang
@ 2020-08-06 13:30 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2020-08-06 13:30 UTC (permalink / raw)
  To: Guoqing Jiang, danil.kipnis, jinpu.wang; +Cc: linux-block

On 7/30/20 3:13 AM, Guoqing Jiang wrote:
> V2:
> * add Acked-by tag from Danil and Jack.
> 
> Hi Jens,
> 
> Could you take a look at this patchset?
> 
> Thanks,
> Guoqing
> 
> Guoqing Jiang (2):
>   rnbd: remove rnbd_dev_submit_io
>   rnbd: no need to set bi_end_io in rnbd_bio_map_kern
> 
>  drivers/block/rnbd/rnbd-srv-dev.c | 37 +++----------------------------
>  drivers/block/rnbd/rnbd-srv-dev.h | 19 +++++-----------
>  drivers/block/rnbd/rnbd-srv.c     | 32 ++++++++++++++++++--------
>  3 files changed, 31 insertions(+), 57 deletions(-)

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-30  9:13 [PATCH V2 0/2] Two patches for rnbd Guoqing Jiang
2020-07-30  9:13 ` [PATCH V2 1/2] rnbd: remove rnbd_dev_submit_io Guoqing Jiang
2020-07-30  9:13 ` [PATCH V2 2/2] rnbd: no need to set bi_end_io in rnbd_bio_map_kern Guoqing Jiang
2020-08-06  4:50 ` [PATCH V2 0/2] Two patches for rnbd Jinpu Wang
2020-08-06 13:30 ` Jens Axboe

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org
	public-inbox-index linux-block

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git