diff --git a/include/ublksrv_priv.h b/include/ublksrv_priv.h index 47b2b804..d7e6fa9e 100644 --- a/include/ublksrv_priv.h +++ b/include/ublksrv_priv.h @@ -215,17 +215,12 @@ static inline int is_target_io(__u64 user_data) return (user_data & (1ULL << 63)) != 0; } -/* two helpers for setting up io_uring */ -static inline int ublksrv_setup_ring(struct io_uring *r, int depth, +static inline void ublksrv_setup_ring_params(struct io_uring_params *p, int cq_depth, unsigned flags) { - struct io_uring_params p; - - memset(&p, 0, sizeof(p)); - p.flags = flags | IORING_SETUP_CQSIZE; - p.cq_entries = cq_depth; - - return io_uring_queue_init_params(depth, r, &p); + memset(p, 0, sizeof(*p)); + p->flags = flags | IORING_SETUP_CQSIZE; + p->cq_entries = cq_depth; } static inline struct io_uring_sqe *ublksrv_uring_get_sqe(struct io_uring *r, diff --git a/lib/ublksrv.c b/lib/ublksrv.c index 216d7698..2b2adc65 100644 --- a/lib/ublksrv.c +++ b/lib/ublksrv.c @@ -509,6 +509,7 @@ static void ublksrv_calculate_depths(const struct _ublksrv_dev *dev, int const struct ublksrv_queue *ublksrv_queue_init(const struct ublksrv_dev *tdev, unsigned short q_id, void *queue_data) { + struct io_uring_params p; struct _ublksrv_dev *dev = tdev_to_local(tdev); struct _ublksrv_queue *q; const struct ublksrv_ctrl_dev *ctrl_dev = dev->ctrl_dev; @@ -595,8 +596,9 @@ const struct ublksrv_queue *ublksrv_queue_init(const struct ublksrv_dev *tdev, //ublk_assert(io_data_size ^ (unsigned long)q->ios[i].data.private_data); } - ret = ublksrv_setup_ring(&q->ring, ring_depth, cq_depth, + ublksrv_setup_ring_params(&p, cq_depth, IORING_SETUP_SQE128 | IORING_SETUP_COOP_TASKRUN); + ret = io_uring_queue_init_params(ring_depth, &q->ring, &p); if (ret < 0) { ublk_err("ublk dev %d queue %d setup io_uring failed %d", q->dev->ctrl_dev->dev_info.dev_id, q->q_id, ret); diff --git a/lib/ublksrv_cmd.c b/lib/ublksrv_cmd.c index c6c81ec7..8a02bd84 100644 --- a/lib/ublksrv_cmd.c +++ b/lib/ublksrv_cmd.c @@ -145,6 +145,7 @@ void ublksrv_ctrl_deinit(struct ublksrv_ctrl_dev *dev) struct ublksrv_ctrl_dev *ublksrv_ctrl_init(struct ublksrv_dev_data *data) { + struct io_uring_params p; struct ublksrv_ctrl_dev *dev = (struct ublksrv_ctrl_dev *)calloc(1, sizeof(*dev)); struct ublksrv_ctrl_dev_info *info = &dev->dev_info; @@ -171,7 +172,8 @@ struct ublksrv_ctrl_dev *ublksrv_ctrl_init(struct ublksrv_dev_data *data) dev->tgt_argv = data->tgt_argv; /* 32 is enough to send ctrl commands */ - ret = ublksrv_setup_ring(&dev->ring, 32, 32, IORING_SETUP_SQE128); + ublksrv_setup_ring_params(&p, 32, IORING_SETUP_SQE128); + ret = io_uring_queue_init_params(32, &dev->ring, &p); if (ret < 0) { fprintf(stderr, "queue_init: %s\n", strerror(-ret)); free(dev);