Commit d7b78de2 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

rnbd-srv: remove struct rnbd_dev_blk_io

Only the priv field of rnbd_dev_blk_io is used, so store the value of
that in bio->bi_private directly and remove the entire bio_set overhead.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJack Wang <jinpu.wang@ionos.com>
Link: https://lore.kernel.org/r/20220124091107.642561-12-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 1fe0640f
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
#include "rnbd-srv-dev.h" #include "rnbd-srv-dev.h"
#include "rnbd-log.h" #include "rnbd-log.h"
struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags, struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags)
struct bio_set *bs)
{ {
struct rnbd_dev *dev; struct rnbd_dev *dev;
int ret; int ret;
...@@ -30,7 +29,6 @@ struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags, ...@@ -30,7 +29,6 @@ struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags,
dev->blk_open_flags = flags; dev->blk_open_flags = flags;
bdevname(dev->bdev, dev->name); bdevname(dev->bdev, dev->name);
dev->ibd_bio_set = bs;
return dev; return dev;
......
...@@ -14,25 +14,16 @@ ...@@ -14,25 +14,16 @@
struct rnbd_dev { struct rnbd_dev {
struct block_device *bdev; struct block_device *bdev;
struct bio_set *ibd_bio_set;
fmode_t blk_open_flags; fmode_t blk_open_flags;
char name[BDEVNAME_SIZE]; char name[BDEVNAME_SIZE];
}; };
struct rnbd_dev_blk_io {
struct rnbd_dev *dev;
void *priv;
/* have to be last member for front_pad usage of bioset_init */
struct bio bio;
};
/** /**
* rnbd_dev_open() - Open a device * rnbd_dev_open() - Open a device
* @path: path to open
* @flags: open flags * @flags: open flags
* @bs: bio_set to use during block io,
*/ */
struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags, struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags);
struct bio_set *bs);
/** /**
* rnbd_dev_close() - Close a device * rnbd_dev_close() - Close a device
......
...@@ -116,9 +116,7 @@ rnbd_get_sess_dev(int dev_id, struct rnbd_srv_session *srv_sess) ...@@ -116,9 +116,7 @@ rnbd_get_sess_dev(int dev_id, struct rnbd_srv_session *srv_sess)
static void rnbd_dev_bi_end_io(struct bio *bio) static void rnbd_dev_bi_end_io(struct bio *bio)
{ {
struct rnbd_dev_blk_io *io = bio->bi_private; rnbd_endio(bio->bi_private, blk_status_to_errno(bio->bi_status));
rnbd_endio(io->priv, blk_status_to_errno(bio->bi_status));
bio_put(bio); bio_put(bio);
} }
...@@ -131,7 +129,6 @@ static int process_rdma(struct rnbd_srv_session *srv_sess, ...@@ -131,7 +129,6 @@ static int process_rdma(struct rnbd_srv_session *srv_sess,
struct rnbd_srv_sess_dev *sess_dev; struct rnbd_srv_sess_dev *sess_dev;
u32 dev_id; u32 dev_id;
int err; int err;
struct rnbd_dev_blk_io *io;
struct bio *bio; struct bio *bio;
short prio; short prio;
...@@ -152,7 +149,7 @@ static int process_rdma(struct rnbd_srv_session *srv_sess, ...@@ -152,7 +149,7 @@ static int process_rdma(struct rnbd_srv_session *srv_sess,
priv->sess_dev = sess_dev; priv->sess_dev = sess_dev;
priv->id = id; priv->id = id;
bio = bio_alloc_bioset(GFP_KERNEL, 1, sess_dev->rnbd_dev->ibd_bio_set); bio = bio_alloc(GFP_KERNEL, 1);
if (bio_add_page(bio, virt_to_page(data), datalen, if (bio_add_page(bio, virt_to_page(data), datalen,
offset_in_page(data)) != datalen) { offset_in_page(data)) != datalen) {
rnbd_srv_err(sess_dev, "Failed to map data to bio\n"); rnbd_srv_err(sess_dev, "Failed to map data to bio\n");
...@@ -160,12 +157,8 @@ static int process_rdma(struct rnbd_srv_session *srv_sess, ...@@ -160,12 +157,8 @@ static int process_rdma(struct rnbd_srv_session *srv_sess,
goto bio_put; goto bio_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_end_io = rnbd_dev_bi_end_io;
bio->bi_private = io; bio->bi_private = priv;
bio->bi_opf = rnbd_to_bio_flags(le32_to_cpu(msg->rw)); 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_sector = le64_to_cpu(msg->sector);
bio->bi_iter.bi_size = le32_to_cpu(msg->bi_size); bio->bi_iter.bi_size = le32_to_cpu(msg->bi_size);
...@@ -260,7 +253,6 @@ static void destroy_sess(struct rnbd_srv_session *srv_sess) ...@@ -260,7 +253,6 @@ static void destroy_sess(struct rnbd_srv_session *srv_sess)
out: out:
xa_destroy(&srv_sess->index_idr); xa_destroy(&srv_sess->index_idr);
bioset_exit(&srv_sess->sess_bio_set);
pr_info("RTRS Session %s disconnected\n", srv_sess->sessname); pr_info("RTRS Session %s disconnected\n", srv_sess->sessname);
...@@ -289,16 +281,6 @@ static int create_sess(struct rtrs_srv_sess *rtrs) ...@@ -289,16 +281,6 @@ static int create_sess(struct rtrs_srv_sess *rtrs)
return -ENOMEM; return -ENOMEM;
srv_sess->queue_depth = rtrs_srv_get_queue_depth(rtrs); srv_sess->queue_depth = rtrs_srv_get_queue_depth(rtrs);
err = bioset_init(&srv_sess->sess_bio_set, srv_sess->queue_depth,
offsetof(struct rnbd_dev_blk_io, bio),
BIOSET_NEED_BVECS);
if (err) {
pr_err("Allocating srv_session for path %s failed\n",
pathname);
kfree(srv_sess);
return err;
}
xa_init_flags(&srv_sess->index_idr, XA_FLAGS_ALLOC); xa_init_flags(&srv_sess->index_idr, XA_FLAGS_ALLOC);
INIT_LIST_HEAD(&srv_sess->sess_dev_list); INIT_LIST_HEAD(&srv_sess->sess_dev_list);
mutex_init(&srv_sess->lock); mutex_init(&srv_sess->lock);
...@@ -747,8 +729,7 @@ static int process_msg_open(struct rnbd_srv_session *srv_sess, ...@@ -747,8 +729,7 @@ static int process_msg_open(struct rnbd_srv_session *srv_sess,
goto reject; goto reject;
} }
rnbd_dev = rnbd_dev_open(full_path, open_flags, rnbd_dev = rnbd_dev_open(full_path, open_flags);
&srv_sess->sess_bio_set);
if (IS_ERR(rnbd_dev)) { if (IS_ERR(rnbd_dev)) {
pr_err("Opening device '%s' on session %s failed, failed to open the block device, err: %ld\n", pr_err("Opening device '%s' on session %s failed, failed to open the block device, err: %ld\n",
full_path, srv_sess->sessname, PTR_ERR(rnbd_dev)); full_path, srv_sess->sessname, PTR_ERR(rnbd_dev));
......
...@@ -23,7 +23,6 @@ struct rnbd_srv_session { ...@@ -23,7 +23,6 @@ struct rnbd_srv_session {
struct rtrs_srv_sess *rtrs; struct rtrs_srv_sess *rtrs;
char sessname[NAME_MAX]; char sessname[NAME_MAX];
int queue_depth; int queue_depth;
struct bio_set sess_bio_set;
struct xarray index_idr; struct xarray index_idr;
/* List of struct rnbd_srv_sess_dev */ /* List of struct rnbd_srv_sess_dev */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment