]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ublk: define ublk_ch_batch_io_fops for the coming feature F_BATCH_IO
authorMing Lei <ming.lei@redhat.com>
Fri, 16 Jan 2026 14:18:34 +0000 (22:18 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 23 Jan 2026 03:05:40 +0000 (20:05 -0700)
Introduces the basic structure for a batched I/O feature in the ublk driver.
It adds placeholder functions and a new file operations structure,
ublk_ch_batch_io_fops, which will be used for fetching and committing I/O
commands in batches. Currently, the feature is disabled.

Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c

index aaf94d2fb78971663b54eb74c100b94c0d417590..f6a4b222c71a4d19c7874612d84cc9fbca6dc1f6 100644 (file)
@@ -263,6 +263,11 @@ static inline struct request *__ublk_check_and_get_req(struct ublk_device *ub,
                u16 q_id, u16 tag, struct ublk_io *io);
 static inline unsigned int ublk_req_build_flags(struct request *req);
 
+static inline bool ublk_dev_support_batch_io(const struct ublk_device *ub)
+{
+       return false;
+}
+
 static inline struct ublksrv_io_desc *
 ublk_get_iod(const struct ublk_queue *ubq, unsigned tag)
 {
@@ -2679,6 +2684,12 @@ static int ublk_ch_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
        return ublk_ch_uring_cmd_local(cmd, issue_flags);
 }
 
+static int ublk_ch_batch_io_uring_cmd(struct io_uring_cmd *cmd,
+                                      unsigned int issue_flags)
+{
+       return -EOPNOTSUPP;
+}
+
 static inline bool ublk_check_ubuf_dir(const struct request *req,
                int ubuf_dir)
 {
@@ -2798,6 +2809,16 @@ static const struct file_operations ublk_ch_fops = {
        .mmap = ublk_ch_mmap,
 };
 
+static const struct file_operations ublk_ch_batch_io_fops = {
+       .owner = THIS_MODULE,
+       .open = ublk_ch_open,
+       .release = ublk_ch_release,
+       .read_iter = ublk_ch_read_iter,
+       .write_iter = ublk_ch_write_iter,
+       .uring_cmd = ublk_ch_batch_io_uring_cmd,
+       .mmap = ublk_ch_mmap,
+};
+
 static void ublk_deinit_queue(struct ublk_device *ub, int q_id)
 {
        struct ublk_queue *ubq = ub->queues[q_id];
@@ -2958,7 +2979,10 @@ static int ublk_add_chdev(struct ublk_device *ub)
        if (ret)
                goto fail;
 
-       cdev_init(&ub->cdev, &ublk_ch_fops);
+       if (ublk_dev_support_batch_io(ub))
+               cdev_init(&ub->cdev, &ublk_ch_batch_io_fops);
+       else
+               cdev_init(&ub->cdev, &ublk_ch_fops);
        ret = cdev_device_add(&ub->cdev, dev);
        if (ret)
                goto fail;