diff mbox series

[1/4] xfs_db: port the unlink command to use libxfs_droplink

Message ID 172783103046.4038482.15065839752033832714.stgit@frogsfrogsfrogs (mailing list archive)
State Not Applicable, archived
Headers show
Series [1/4] xfs_db: port the unlink command to use libxfs_droplink | expand

Commit Message

Darrick J. Wong Oct. 2, 2024, 1:24 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Port this command to use the libxfs droplink implementation instead of
opencoding it.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 db/namei.c |   23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

Comments

Christoph Hellwig Oct. 2, 2024, 5:52 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/db/namei.c b/db/namei.c
index d57ead4f1..8c7f4932f 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)