From: Darrick J. Wong Date: Wed, 2 Oct 2024 01:24:44 +0000 (-0700) Subject: xfs_db: port the unlink command to use libxfs_droplink X-Git-Tag: v6.11.0~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6431fe69edb6d5ba80323b6417c7742b47b7bd1d;p=thirdparty%2Fxfsprogs-dev.git xfs_db: port the unlink command to use libxfs_droplink Port this command to use the libxfs droplink implementation instead of opencoding it. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- diff --git a/db/namei.c b/db/namei.c index d57ead4f..8c7f4932 100644 --- a/db/namei.c +++ b/db/namei.c @@ -1142,21 +1142,6 @@ unlink_help(void) )); } -static void -droplink( - struct xfs_trans *tp, - struct xfs_inode *ip) -{ - struct inode *inode = VFS_I(ip); - - libxfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); - - if (inode->i_nlink != XFS_NLINK_PINNED) - drop_nlink(VFS_I(ip)); - - libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); -} - static int remove_child( struct xfs_mount *mp, @@ -1206,13 +1191,17 @@ remove_child( if (S_ISDIR(VFS_I(ip)->i_mode)) { /* drop ip's dotdot link to dp */ - droplink(tp, dp); + error = -libxfs_droplink(tp, dp); + if (error) + goto out_trans; } else { libxfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); } /* drop dp's link to ip */ - droplink(tp, ip); + error = -libxfs_droplink(tp, ip); + if (error) + goto out_trans; error = -libxfs_dir_removename(tp, dp, &xname, ip->i_ino, resblks); if (error)