Remove all block device related info from ublksrv_ctrl_dev_info, meantime reduce its size into 64 bytes because: 1) ublksrv_ctrl_dev_info becomes cleaner without including any block related info 2) generic set/get parameter command can be used to set block related setting easily and cleanly 3) generic set/get parameter command can be used for extending ublk without needing more info in ublksrv_ctrl_dev_info
Unified · Split
| @@ -122,7 +122,6 @@ struct ublk_device { · 121 unmodified lines | ||
| 122 | 122 | char *__queues; |
| 123 | 123 | |
| 124 | 124 | unsigned short queue_size; |
| 125 | − unsigned short bs_shift; | |
| 126 | 125 | struct ublksrv_ctrl_dev_info dev_info; |
| 127 | 126 | |
| 128 | 127 | struct blk_mq_tag_set tag_set; |
| @@ -223,8 +222,7 @@ static int ublk_validate_params(const struct ublk_device *ub) · 94 unmodified lines | ||
| 223 | 222 | if (p->logical_bs_shift > p->physical_bs_shift) |
| 224 | 223 | return -EINVAL; |
| 225 | 224 | |
| 226 | − if (p->max_sectors > (ub->dev_info.rq_max_blocks << | |
| 227 | − (ub->bs_shift - 9))) | |
| 225 | + if (p->max_sectors > (ub->dev_info.max_io_buf_bytes >> 9)) | |
| 228 | 226 | return -EINVAL; |
| 229 | 227 | } else |
| 230 | 228 | return -EINVAL; |
| @@ -1185,13 +1183,13 @@ static void ublk_stop_work_fn(struct work_struct *work) · 954 unmodified lines | ||
| 1185 | 1183 | ublk_stop_dev(ub); |
| 1186 | 1184 | } |
| 1187 | 1185 | |
| 1188 | −/* align maximum I/O size to PAGE_SIZE */ | |
| 1186 | +/* align max io buffer size with PAGE_SIZE */ | |
| 1189 | 1187 | static void ublk_align_max_io_size(struct ublk_device *ub) |
| 1190 | 1188 | { |
| 1191 | − unsigned int max_rq_bytes = ub->dev_info.rq_max_blocks << ub->bs_shift; | |
| 1189 | + unsigned int max_io_bytes = ub->dev_info.max_io_buf_bytes; | |
| 1192 | 1190 | |
| 1193 | − ub->dev_info.rq_max_blocks = | |
| 1194 | − round_down(max_rq_bytes, PAGE_SIZE) >> ub->bs_shift; | |
| 1191 | + ub->dev_info.max_io_buf_bytes = | |
| 1192 | + round_down(max_io_bytes, PAGE_SIZE); | |
| 1195 | 1193 | } |
| 1196 | 1194 | |
| 1197 | 1195 | static int ublk_add_tag_set(struct ublk_device *ub) |
| @@ -1348,9 +1346,8 @@ static inline void ublk_dump_dev_info(struct ublksrv_ctrl_dev_info *info) · 150 unmodified lines | ||
| 1348 | 1346 | { |
| 1349 | 1347 | pr_devel("%s: dev id %d flags %llx\n", __func__, |
| 1350 | 1348 | info->dev_id, info->flags); |
| 1351 | − pr_devel("\t nr_hw_queues %d queue_depth %d block size %d dev_capacity %lld\n", | |
| 1352 | − info->nr_hw_queues, info->queue_depth, | |
| 1353 | − info->block_size, info->dev_blocks); | |
| 1349 | + pr_devel("\t nr_hw_queues %d queue_depth %d\n", | |
| 1350 | + info->nr_hw_queues, info->queue_depth); | |
| 1354 | 1351 | } |
| 1355 | 1352 | |
| 1356 | 1353 | static int ublk_ctrl_add_dev(struct io_uring_cmd *cmd) |
| @@ -1410,7 +1407,6 @@ static int ublk_ctrl_add_dev(struct io_uring_cmd *cmd) · 53 unmodified lines | ||
| 1410 | 1407 | /* We are not ready to support zero copy */ |
| 1411 | 1408 | ub->dev_info.flags &= ~UBLK_F_SUPPORT_ZERO_COPY; |
| 1412 | 1409 | |
| 1413 | − ub->bs_shift = ilog2(ub->dev_info.block_size); | |
| 1414 | 1410 | ub->dev_info.nr_hw_queues = min_t(unsigned int, |
| 1415 | 1411 | ub->dev_info.nr_hw_queues, nr_cpu_ids); |
| 1416 | 1412 | ublk_align_max_io_size(ub); |
| @@ -80,22 +80,23 @@ struct ublksrv_ctrl_cmd { · 79 unmodified lines | ||
| 80 | 80 | struct ublksrv_ctrl_dev_info { |
| 81 | 81 | __u16 nr_hw_queues; |
| 82 | 82 | __u16 queue_depth; |
| 83 | − __u16 block_size; | |
| 84 | 83 | __u16 state; |
| 84 | + __u16 pad0; | |
| 85 | 85 | |
| 86 | − __u32 rq_max_blocks; | |
| 86 | + __u32 max_io_buf_bytes; | |
| 87 | 87 | __u32 dev_id; |
| 88 | 88 | |
| 89 | − __u64 dev_blocks; | |
| 90 | − | |
| 91 | 89 | __s32 ublksrv_pid; |
| 92 | − __s32 reserved0; | |
| 90 | + __u32 pad1; | |
| 91 | + | |
| 93 | 92 | __u64 flags; |
| 94 | − __u64 flags_reserved; | |
| 95 | 93 | |
| 96 | 94 | /* For ublksrv internal use, invisible to ublk driver */ |
| 97 | 95 | __u64 ublksrv_flags; |
| 98 | − __u64 reserved1[9]; | |
| 96 | + | |
| 97 | + __u64 reserved0; | |
| 98 | + __u64 reserved1; | |
| 99 | + __u64 reserved2; | |
| 99 | 100 | }; |
| 100 | 101 | |
| 101 | 102 | #define UBLK_IO_OP_READ 0 |