Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

blk-cgroup: check for pd_(alloc|free)_fn in blkcg_activate_policy()

Currently all policies implement pd_(alloc|free)_fn, however, this is
not necessary for ioprio that only works for blkcg, not blkg.

There are no functional changes, prepare to cleanup activating ioprio
policy.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20240719071506.158075-2-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Yu Kuai and committed by
Jens Axboe
ae8650b4 8400291e

+13 -2
+13 -2
block/blk-cgroup.c
··· 1554 1554 if (blkcg_policy_enabled(q, pol)) 1555 1555 return 0; 1556 1556 1557 + /* 1558 + * Policy is allowed to be registered without pd_alloc_fn/pd_free_fn, 1559 + * for example, ioprio. Such policy will work on blkcg level, not disk 1560 + * level, and don't need to be activated. 1561 + */ 1562 + if (WARN_ON_ONCE(!pol->pd_alloc_fn || !pol->pd_free_fn)) 1563 + return -EINVAL; 1564 + 1557 1565 if (queue_is_mq(q)) 1558 1566 blk_mq_freeze_queue(q); 1559 1567 retry: ··· 1741 1733 goto err_unlock; 1742 1734 } 1743 1735 1744 - /* Make sure cpd/pd_alloc_fn and cpd/pd_free_fn in pairs */ 1736 + /* 1737 + * Make sure cpd/pd_alloc_fn and cpd/pd_free_fn in pairs, and policy 1738 + * without pd_alloc_fn/pd_free_fn can't be activated. 1739 + */ 1745 1740 if ((!pol->cpd_alloc_fn ^ !pol->cpd_free_fn) || 1746 - (!pol->pd_alloc_fn ^ !pol->pd_free_fn)) 1741 + (!pol->pd_alloc_fn ^ !pol->pd_free_fn)) 1747 1742 goto err_unlock; 1748 1743 1749 1744 /* register @pol */