]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: port the unlink command to use libxfs_droplink
authorDarrick J. Wong <djwong@kernel.org>
Wed, 2 Oct 2024 01:24:44 +0000 (18:24 -0700)
committerAndrey Albershteyn <aalbersh@redhat.com>
Fri, 4 Oct 2024 10:43:44 +0000 (12:43 +0200)
Port this command to use the libxfs droplink implementation instead of
opencoding it.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
db/namei.c

index d57ead4f165d809b466c8c5fb67274d3b13dee26..8c7f4932fce4a3d86aabbcad6e295c36bd885717 100644 (file)
@@ -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)