bcachefs: return -EMLINK instead of -EINVAL when hard link count exceeds limit
PATCH 1/1 bcachefs: return -EMLINK instead of -EINVAL when hard link count exceeds limit
From: Youling Tang <[email protected]>
Currently bcachefs returns -EINVAL when the hard link count reaches U32_MAX. However, -EINVAL is a generic invalid argument error that doesn't accurately convey the specific "too many links" condition.
This patch changes the error return code from -EINVAL to -EMLINK when the hard link count limit is exceeded, providing more precise error information to userspace and making it consistent with other filesystems' behavior.
Signed-off-by Youling Tang <[email protected]>
--- fs/bcachefs/errcode.h | 1 + fs/bcachefs/inode.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
fs/bcachefs/errcode.h +1 -0
@@ -215,6 +215,7 @@ x(EINVAL, varint_decode_error) \ x(EINVAL, erasure_coding_found_btree_node) \ x(EINVAL, option_negative) \ + x(EMLINK, too_many_links) \ x(EOPNOTSUPP, may_not_use_incompat_feature) \ x(EROFS, erofs_trans_commit) \x (EROFS , erofs_no_writes) \
fs/bcachefs/inode.c +1 -1
@@ -1193,7 +1193,7 @@ int bch2_inode_nlink_inc(struct bch_inode_unpacked *bi) bi->bi_flags &= ~BCH_INODE_unlinked; else {if (bi->bi_nlink ==U32_MAX ) -return -EINVAL ; +return -BCH_ERR_too_many_links; bi->bi_nlink++; }
Signature · 1 line
2.43.0