Commit e1a0202c authored by Chen Linxuan's avatar Chen Linxuan Committed by Jens Axboe
Browse files

blk-cgroup: improve policy registration error handling



This patch improve the returned error code of blkcg_policy_register().

1. Move the validation check for cpd/pd_alloc_fn and cpd/pd_free_fn
   function pairs to the start of blkcg_policy_register(). This ensures
   we immediately return -EINVAL if the function pairs are not correctly
   provided, rather than returning -ENOSPC after locking and unlocking
   mutexes unnecessarily.

   Those locks should not contention any problems, as error of policy
   registration is a super cold path.

2. Return -ENOMEM when cpd_alloc_fn() failed.

Co-authored-by: default avatarWen Tao <wentao@uniontech.com>
Signed-off-by: default avatarWen Tao <wentao@uniontech.com>
Signed-off-by: default avatarChen Linxuan <chenlinxuan@uniontech.com>
Reviewed-by: default avatarMichal Koutný <mkoutny@suse.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Reviewed-by: default avatarYu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/3E333A73B6B6DFC0+20250317022924.150907-1-chenlinxuan@uniontech.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 86947bdc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment