mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-18 11:17:07 +00:00
ublk_drv: make sure that correct flags(features) returned to userspace
Userspace may support more features or new added flags, but the driver side can be old, so make sure correct flags(features) returned to userpsace, then userspace can work as expected. Also mark the 2nd flags as reversed, just use the 1st one. When we run out of flags, the reserved one can be handled at that time. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: ZiyangZhang <ZiyangZhang@linux.alibaba.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20220722103817.631258-3-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
fa9482e0b2
commit
6d8c5afc9a
@ -46,6 +46,9 @@
|
|||||||
|
|
||||||
#define UBLK_MINORS (1U << MINORBITS)
|
#define UBLK_MINORS (1U << MINORBITS)
|
||||||
|
|
||||||
|
/* All UBLK_F_* have to be included into UBLK_F_ALL */
|
||||||
|
#define UBLK_F_ALL (UBLK_F_SUPPORT_ZERO_COPY | UBLK_F_URING_CMD_COMP_IN_TASK)
|
||||||
|
|
||||||
struct ublk_rq_data {
|
struct ublk_rq_data {
|
||||||
struct callback_head work;
|
struct callback_head work;
|
||||||
};
|
};
|
||||||
@ -953,7 +956,7 @@ static int ublk_init_queue(struct ublk_device *ub, int q_id)
|
|||||||
void *ptr;
|
void *ptr;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
ubq->flags = ub->dev_info.flags[0];
|
ubq->flags = ub->dev_info.flags;
|
||||||
ubq->q_id = q_id;
|
ubq->q_id = q_id;
|
||||||
ubq->q_depth = ub->dev_info.queue_depth;
|
ubq->q_depth = ub->dev_info.queue_depth;
|
||||||
size = ublk_queue_cmd_buf_size(ub, q_id);
|
size = ublk_queue_cmd_buf_size(ub, q_id);
|
||||||
@ -1246,7 +1249,7 @@ out_put_device:
|
|||||||
static inline void ublk_dump_dev_info(struct ublksrv_ctrl_dev_info *info)
|
static inline void ublk_dump_dev_info(struct ublksrv_ctrl_dev_info *info)
|
||||||
{
|
{
|
||||||
pr_devel("%s: dev id %d flags %llx\n", __func__,
|
pr_devel("%s: dev id %d flags %llx\n", __func__,
|
||||||
info->dev_id, info->flags[0]);
|
info->dev_id, info->flags);
|
||||||
pr_devel("\t nr_hw_queues %d queue_depth %d block size %d dev_capacity %lld\n",
|
pr_devel("\t nr_hw_queues %d queue_depth %d block size %d dev_capacity %lld\n",
|
||||||
info->nr_hw_queues, info->queue_depth,
|
info->nr_hw_queues, info->queue_depth,
|
||||||
info->block_size, info->dev_blocks);
|
info->block_size, info->dev_blocks);
|
||||||
@ -1298,8 +1301,16 @@ static int ublk_ctrl_add_dev(struct io_uring_cmd *cmd)
|
|||||||
/* update device id */
|
/* update device id */
|
||||||
ub->dev_info.dev_id = ub->ub_number;
|
ub->dev_info.dev_id = ub->ub_number;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 64bit flags will be copied back to userspace as feature
|
||||||
|
* negotiation result, so have to clear flags which driver
|
||||||
|
* doesn't support yet, then userspace can get correct flags
|
||||||
|
* (features) to handle.
|
||||||
|
*/
|
||||||
|
ub->dev_info.flags &= UBLK_F_ALL;
|
||||||
|
|
||||||
/* We are not ready to support zero copy */
|
/* We are not ready to support zero copy */
|
||||||
ub->dev_info.flags[0] &= ~UBLK_F_SUPPORT_ZERO_COPY;
|
ub->dev_info.flags &= ~UBLK_F_SUPPORT_ZERO_COPY;
|
||||||
|
|
||||||
ub->bs_shift = ilog2(ub->dev_info.block_size);
|
ub->bs_shift = ilog2(ub->dev_info.block_size);
|
||||||
ub->dev_info.nr_hw_queues = min_t(unsigned int,
|
ub->dev_info.nr_hw_queues = min_t(unsigned int,
|
||||||
|
@ -46,13 +46,13 @@
|
|||||||
* zero copy requires 4k block size, and can remap ublk driver's io
|
* zero copy requires 4k block size, and can remap ublk driver's io
|
||||||
* request into ublksrv's vm space
|
* request into ublksrv's vm space
|
||||||
*/
|
*/
|
||||||
#define UBLK_F_SUPPORT_ZERO_COPY (1UL << 0)
|
#define UBLK_F_SUPPORT_ZERO_COPY (1ULL << 0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Force to complete io cmd via io_uring_cmd_complete_in_task so that
|
* Force to complete io cmd via io_uring_cmd_complete_in_task so that
|
||||||
* performance comparison is done easily with using task_work_add
|
* performance comparison is done easily with using task_work_add
|
||||||
*/
|
*/
|
||||||
#define UBLK_F_URING_CMD_COMP_IN_TASK (1UL << 1)
|
#define UBLK_F_URING_CMD_COMP_IN_TASK (1ULL << 1)
|
||||||
|
|
||||||
/* device state */
|
/* device state */
|
||||||
#define UBLK_S_DEV_DEAD 0
|
#define UBLK_S_DEV_DEAD 0
|
||||||
@ -88,7 +88,8 @@ struct ublksrv_ctrl_dev_info {
|
|||||||
|
|
||||||
__s32 ublksrv_pid;
|
__s32 ublksrv_pid;
|
||||||
__s32 reserved0;
|
__s32 reserved0;
|
||||||
__u64 flags[2];
|
__u64 flags;
|
||||||
|
__u64 flags_reserved;
|
||||||
|
|
||||||
/* For ublksrv internal use, invisible to ublk driver */
|
/* For ublksrv internal use, invisible to ublk driver */
|
||||||
__u64 ublksrv_flags;
|
__u64 ublksrv_flags;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user