xfs: introduce protection for drop nlink
PATCH v6 1/1 xfs: introduce protection for drop nlink
From: Cheng Lin <[email protected]>
When abnormal drop_nlink are detected on the inode, return error, to avoid corruption propagation.
--- fs/xfs/xfs_inode.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/xfs/xfs_inode.c +7 -0
@@ -919,6 +919,13 @@ xfs_droplink( xfs_trans_t *tp, xfs_inode_t *ip) { +if (VFS_I (ip)->i_nlink ==0 ) { +xfs_alert (ip->i_mount, +"%s: Attempt to drop inode (%llu) with nlink zero." , + __func__, ip->i_ino); +return -EFSCORRUPTED ; + } +xfs_trans_ichgtime (tp, ip,XFS_ICHGTIME_CHG );drop_nlink (VFS_I (ip));
Signature · 1 line
2.18.1
Quoted 4 lines · On Tue, Oct 10, 2023 at 10:09:01AM +0800, [email protected] wrote:
From: Cheng Lin <[email protected]>
When abnormal
drop_nlinkare detected on the inode, return error, to avoid corruption propagation.
I know this has been through a few cycles, but wouldn't it be useful to have at least a little description here how that case could happen?
Quoted 7 lines · On Tue, Oct 10, 2023 at 10:09:01AM +0800, [email protected] wrote:
Quoted 4 lines
From: Cheng Lin <[email protected]>
When abnormal
drop_nlinkare detected on the inode, return error, to avoid corruption propagation.I know this has been through a few cycles, but wouldn't it be useful to have at least a little description here how that case could happen?
Unfortunately, I don't know how the underflow happened. The purpose of this patch is to prevent the situation from getting worse and provide users can repair it at the appropriate moment afterwards.