Commit e1a0202
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: Wen Tao <[email protected]>
Signed-off-by: Wen Tao <[email protected]>
Signed-off-by: Chen Linxuan <[email protected]>
Reviewed-by: Michal Koutný <[email protected]>
Acked-by: Tejun Heo <[email protected]>
Reviewed-by: Yu Kuai <[email protected]>
Link: https://lore.kernel.org/r/3E333A73B6B6DFC0+20250317022924.150907-1-chenlinxuan@uniontech.com
Signed-off-by: Jens Axboe <[email protected]>1 parent 86947bd commit e1a0202
1 file changed
+12
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1727 | 1727 | | |
1728 | 1728 | | |
1729 | 1729 | | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
1730 | 1738 | | |
1731 | 1739 | | |
1732 | 1740 | | |
1733 | 1741 | | |
1734 | | - | |
1735 | 1742 | | |
1736 | 1743 | | |
1737 | 1744 | | |
1738 | 1745 | | |
1739 | 1746 | | |
| 1747 | + | |
1740 | 1748 | | |
1741 | 1749 | | |
1742 | 1750 | | |
1743 | | - | |
1744 | | - | |
1745 | | - | |
1746 | | - | |
1747 | | - | |
1748 | | - | |
1749 | | - | |
1750 | | - | |
1751 | 1751 | | |
1752 | 1752 | | |
1753 | 1753 | | |
| |||
1758 | 1758 | | |
1759 | 1759 | | |
1760 | 1760 | | |
1761 | | - | |
| 1761 | + | |
| 1762 | + | |
1762 | 1763 | | |
| 1764 | + | |
1763 | 1765 | | |
1764 | 1766 | | |
1765 | 1767 | | |
| |||
0 commit comments