summaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-02-03 16:03:45 +0100
committerJens Axboe <axboe@kernel.dk>2023-02-03 16:20:05 +0100
commit27b642b07a4a5eb44dffa94a5171ce468bdc46f9 (patch)
treef2735afab6856de17c0ae4cfab67a93694b52ae2 /block/blk-cgroup.c
parentblk-cgroup: improve error unwinding in blkg_alloc (diff)
downloadlinux-27b642b07a4a5eb44dffa94a5171ce468bdc46f9.tar.xz
linux-27b642b07a4a5eb44dffa94a5171ce468bdc46f9.zip
blk-cgroup: simplify blkg freeing from initialization failure paths
There is no need to delay freeing a blkg to a workqueue when freeing it after an initialization failure. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20230203150400.3199230-5-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r--block/blk-cgroup.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 9df02a6d04d3..103868856892 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -114,10 +114,8 @@ static bool blkcg_policy_enabled(struct request_queue *q,
return pol && test_bit(pol->plid, q->blkcg_pols);
}
-static void blkg_free_workfn(struct work_struct *work)
+static void blkg_free(struct blkcg_gq *blkg)
{
- struct blkcg_gq *blkg = container_of(work, struct blkcg_gq,
- free_work);
struct request_queue *q = blkg->q;
int i;
@@ -143,23 +141,9 @@ static void blkg_free_workfn(struct work_struct *work)
kfree(blkg);
}
-/**
- * blkg_free - free a blkg
- * @blkg: blkg to free
- *
- * Free @blkg which may be partially allocated.
- */
-static void blkg_free(struct blkcg_gq *blkg)
+static void blkg_free_workfn(struct work_struct *work)
{
- if (!blkg)
- return;
-
- /*
- * Both ->pd_free_fn() and request queue's release handler may
- * sleep, so free us by scheduling one work func
- */
- INIT_WORK(&blkg->free_work, blkg_free_workfn);
- schedule_work(&blkg->free_work);
+ blkg_free(container_of(work, struct blkcg_gq, free_work));
}
static void __blkg_release(struct rcu_head *rcu)
@@ -170,7 +154,10 @@ static void __blkg_release(struct rcu_head *rcu)
/* release the blkcg and parent blkg refs this blkg has been holding */
css_put(&blkg->blkcg->css);
- blkg_free(blkg);
+
+ /* ->pd_free_fn() may sleep, so free from a work queue */
+ INIT_WORK(&blkg->free_work, blkg_free_workfn);
+ schedule_work(&blkg->free_work);
}
/*