summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-11-26 12:58:13 +0100
committerJens Axboe <axboe@kernel.dk>2021-11-29 14:41:29 +0100
commita0f14d8baaca3e2f3e57bdb062eb476175c90e83 (patch)
tree4d9962e28c96657a90d0bc02f6415fbadd77301d /block
parentblock: remove get_io_context_active (diff)
downloadlinux-a0f14d8baaca3e2f3e57bdb062eb476175c90e83.tar.xz
linux-a0f14d8baaca3e2f3e57bdb062eb476175c90e83.zip
block: factor out a alloc_io_context helper
Factor out a helper that just allocate an I/O context. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20211126115817.2087431-11-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-ioc.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/block/blk-ioc.c b/block/blk-ioc.c
index cc4eb2ba87f7..b42fbb82d5c0 100644
--- a/block/blk-ioc.c
+++ b/block/blk-ioc.c
@@ -249,18 +249,15 @@ void ioc_clear_queue(struct request_queue *q)
__ioc_clear_queue(&icq_list);
}
-static int create_task_io_context(struct task_struct *task, gfp_t gfp_flags,
- int node)
+static struct io_context *alloc_io_context(gfp_t gfp_flags, int node)
{
struct io_context *ioc;
- int ret;
ioc = kmem_cache_alloc_node(iocontext_cachep, gfp_flags | __GFP_ZERO,
node);
if (unlikely(!ioc))
- return -ENOMEM;
+ return NULL;
- /* initialize */
atomic_long_set(&ioc->refcount, 1);
atomic_set(&ioc->nr_tasks, 1);
atomic_set(&ioc->active_ref, 1);
@@ -268,6 +265,18 @@ static int create_task_io_context(struct task_struct *task, gfp_t gfp_flags,
INIT_RADIX_TREE(&ioc->icq_tree, GFP_ATOMIC);
INIT_HLIST_HEAD(&ioc->icq_list);
INIT_WORK(&ioc->release_work, ioc_release_fn);
+ return ioc;
+}
+
+static int create_task_io_context(struct task_struct *task, gfp_t gfp_flags,
+ int node)
+{
+ struct io_context *ioc;
+ int ret;
+
+ ioc = alloc_io_context(gfp_flags, node);
+ if (!ioc)
+ return -ENOMEM;
/*
* Try to install. ioc shouldn't be installed if someone else