Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a322baad authored by Arianna Avanzini's avatar Arianna Avanzini Committed by Jens Axboe
Browse files

block/blk-cgroup.c: free per-blkcg data when freeing the blkcg



Currently, per-blkcg data is freed each time a policy is deactivated,
that is also upon scheduler switch. However, when switching from a
scheduler implementing a policy which requires per-blkcg data to
another one, that same policy might be active on other devices, and
therefore those same per-blkcg data could be still in use.
This commit lets per-blkcg data be freed when the blkcg is freed
instead of on policy deactivation.

Signed-off-by: default avatarArianna Avanzini <avanzini.arianna@gmail.com>
Reported-and-tested-by: default avatarMichael Kaminsky <kaminsky@cs.cmu.edu>
Fixes: e48453c3 ("block, cgroup: implement policy-specific per-blkcg data")
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 0762b23d
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -822,9 +822,14 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
{
	struct blkcg *blkcg = css_to_blkcg(css);

	if (blkcg != &blkcg_root)
	if (blkcg != &blkcg_root) {
		int i;

		for (i = 0; i < BLKCG_MAX_POLS; i++)
			kfree(blkcg->pd[i]);
		kfree(blkcg);
	}
}

static struct cgroup_subsys_state *
blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
@@ -1162,8 +1167,6 @@ void blkcg_deactivate_policy(struct request_queue *q,

		kfree(blkg->pd[pol->plid]);
		blkg->pd[pol->plid] = NULL;
		kfree(blkg->blkcg->pd[pol->plid]);
		blkg->blkcg->pd[pol->plid] = NULL;

		spin_unlock(&blkg->blkcg->lock);
	}