Skip to content

Commit dcb5220

Browse files
Christoph Hellwigaxboe
Christoph Hellwig
authored andcommitted
Revert "blk-cgroup: simplify blkg freeing from initialization failure paths"
It turns out this was too soon. blkg_conf_prep does to funky locking games with the queue lock for this to work properly. This reverts commit 27b642b. Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent c43332f commit dcb5220

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

Diff for: block/blk-cgroup.c

+20-7
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@ static bool blkcg_policy_enabled(struct gendisk *disk,
114114
return pol && test_bit(pol->plid, disk->blkcg_pols);
115115
}
116116

117-
static void blkg_free(struct blkcg_gq *blkg)
117+
static void blkg_free_workfn(struct work_struct *work)
118118
{
119+
struct blkcg_gq *blkg = container_of(work, struct blkcg_gq,
120+
free_work);
119121
int i;
120122

121123
/*
@@ -140,9 +142,23 @@ static void blkg_free(struct blkcg_gq *blkg)
140142
kfree(blkg);
141143
}
142144

143-
static void blkg_free_workfn(struct work_struct *work)
145+
/**
146+
* blkg_free - free a blkg
147+
* @blkg: blkg to free
148+
*
149+
* Free @blkg which may be partially allocated.
150+
*/
151+
static void blkg_free(struct blkcg_gq *blkg)
144152
{
145-
blkg_free(container_of(work, struct blkcg_gq, free_work));
153+
if (!blkg)
154+
return;
155+
156+
/*
157+
* Both ->pd_free_fn() and request queue's release handler may
158+
* sleep, so free us by scheduling one work func
159+
*/
160+
INIT_WORK(&blkg->free_work, blkg_free_workfn);
161+
schedule_work(&blkg->free_work);
146162
}
147163

148164
static void __blkg_release(struct rcu_head *rcu)
@@ -153,10 +169,7 @@ static void __blkg_release(struct rcu_head *rcu)
153169

154170
/* release the blkcg and parent blkg refs this blkg has been holding */
155171
css_put(&blkg->blkcg->css);
156-
157-
/* ->pd_free_fn() may sleep, so free from a work queue */
158-
INIT_WORK(&blkg->free_work, blkg_free_workfn);
159-
schedule_work(&blkg->free_work);
172+
blkg_free(blkg);
160173
}
161174

162175
/*

0 commit comments

Comments
 (0)