Re: [PATCH RESEND v2] blk-cgroup: improve policy registration error handling
From: Tejun Heo
Date: Mon Mar 17 2025 - 14:40:09 EST
On Mon, Mar 17, 2025 at 10:29:24AM +0800, Chen Linxuan wrote:
> 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: Wen Tao <wentao@xxxxxxxxxxxxx>
> Signed-off-by: Wen Tao <wentao@xxxxxxxxxxxxx>
> Signed-off-by: Chen Linxuan <chenlinxuan@xxxxxxxxxxxxx>
Acked-by: Tejun Heo <tj@xxxxxxxxxx>
Thanks.
--
tejun