summaryrefslogtreecommitdiffstats
path: root/block/blk-ioc.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-11-26 12:58:05 +0100
committerJens Axboe <axboe@kernel.dk>2021-11-29 14:41:29 +0100
commit88c9a2ce520ba381bb70658c80ec704f4d60f728 (patch)
treebec031fdc97a07949add2831079700f163184f95 /block/blk-ioc.c
parentRDMA/qib: rename copy_io to qib_copy_io (diff)
downloadlinux-88c9a2ce520ba381bb70658c80ec704f4d60f728.tar.xz
linux-88c9a2ce520ba381bb70658c80ec704f4d60f728.zip
fork: move copy_io to block/blk-ioc.c
Move the copying of the I/O context to the block layer as that is where we can use the proper low-level interfaces. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20211126115817.2087431-3-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-ioc.c')
-rw-r--r--block/blk-ioc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/block/blk-ioc.c b/block/blk-ioc.c
index 70c99e85aee5..3b31cfad4b75 100644
--- a/block/blk-ioc.c
+++ b/block/blk-ioc.c
@@ -322,6 +322,33 @@ struct io_context *get_task_io_context(struct task_struct *task,
return NULL;
}
+int __copy_io(unsigned long clone_flags, struct task_struct *tsk)
+{
+ struct io_context *ioc = current->io_context;
+ struct io_context *new_ioc;
+
+ /*
+ * Share io context with parent, if CLONE_IO is set
+ */
+ if (clone_flags & CLONE_IO) {
+ get_io_context_active(ioc);
+
+ WARN_ON_ONCE(atomic_read(&ioc->nr_tasks) <= 0);
+ atomic_inc(&ioc->nr_tasks);
+
+ tsk->io_context = ioc;
+ } else if (ioprio_valid(ioc->ioprio)) {
+ new_ioc = get_task_io_context(tsk, GFP_KERNEL, NUMA_NO_NODE);
+ if (unlikely(!new_ioc))
+ return -ENOMEM;
+
+ new_ioc->ioprio = ioc->ioprio;
+ put_io_context(new_ioc);
+ }
+
+ return 0;
+}
+
/**
* ioc_lookup_icq - lookup io_cq from ioc
* @ioc: the associated io_context