]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: hoist xfs_{bump,drop}link to libxfs
authorDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:22:41 +0000 (11:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:36:58 +0000 (11:36 -0700)
Move xfs_bumplink and xfs_droplink to libxfs.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_inode_util.c
fs/xfs/libxfs/xfs_inode_util.h
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h

index 5739871ac3705e329b14bf87cdd5956ae9e2efcd..214976ecefd7783b0860774c6a65df2806d10c3c 100644 (file)
@@ -626,3 +626,56 @@ xfs_iunlink_remove(
 
        return xfs_iunlink_remove_inode(tp, pag, agibp, ip);
 }
+
+/*
+ * Decrement the link count on an inode & log the change.  If this causes the
+ * link count to go to zero, move the inode to AGI unlinked list so that it can
+ * be freed when the last active reference goes away via xfs_inactive().
+ */
+int
+xfs_droplink(
+       struct xfs_trans        *tp,
+       struct xfs_inode        *ip)
+{
+       struct inode            *inode = VFS_I(ip);
+
+       xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
+
+       if (inode->i_nlink == 0) {
+               xfs_info_ratelimited(tp->t_mountp,
+ "Inode 0x%llx link count dropped below zero.  Pinning link count.",
+                               ip->i_ino);
+               set_nlink(inode, XFS_NLINK_PINNED);
+       }
+       if (inode->i_nlink != XFS_NLINK_PINNED)
+               drop_nlink(inode);
+
+       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
+
+       if (inode->i_nlink)
+               return 0;
+
+       return xfs_iunlink(tp, ip);
+}
+
+/*
+ * Increment the link count on an inode & log the change.
+ */
+void
+xfs_bumplink(
+       struct xfs_trans        *tp,
+       struct xfs_inode        *ip)
+{
+       struct inode            *inode = VFS_I(ip);
+
+       xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
+
+       if (inode->i_nlink == XFS_NLINK_PINNED - 1)
+               xfs_info_ratelimited(tp->t_mountp,
+ "Inode 0x%llx link count exceeded maximum.  Pinning link count.",
+                               ip->i_ino);
+       if (inode->i_nlink != XFS_NLINK_PINNED)
+               inc_nlink(inode);
+
+       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
+}
index 42a032afe3cacebe52acc7ce774f38e76ea915b2..50c14ba6ca5a2c7b7988a4ea00726f208f9f87df 100644 (file)
@@ -50,5 +50,7 @@ void xfs_inode_init(struct xfs_trans *tp, const struct xfs_icreate_args *args,
 int xfs_iunlink(struct xfs_trans *tp, struct xfs_inode *ip);
 int xfs_iunlink_remove(struct xfs_trans *tp, struct xfs_perag *pag,
                struct xfs_inode *ip);
+int xfs_droplink(struct xfs_trans *tp, struct xfs_inode *ip);
+void xfs_bumplink(struct xfs_trans *tp, struct xfs_inode *ip);
 
 #endif /* __XFS_INODE_UTIL_H__ */
index ac5826ce5fece06e41407e89e55b59ead2422175..004f277e589155e2a99b681e09390d9c08dd8920 100644 (file)
@@ -600,59 +600,6 @@ xfs_icreate(
        return 0;
 }
 
-/*
- * Decrement the link count on an inode & log the change.  If this causes the
- * link count to go to zero, move the inode to AGI unlinked list so that it can
- * be freed when the last active reference goes away via xfs_inactive().
- */
-int
-xfs_droplink(
-       struct xfs_trans        *tp,
-       struct xfs_inode        *ip)
-{
-       struct inode            *inode = VFS_I(ip);
-
-       xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
-
-       if (inode->i_nlink == 0) {
-               xfs_info_ratelimited(tp->t_mountp,
- "Inode 0x%llx link count dropped below zero.  Pinning link count.",
-                               ip->i_ino);
-               set_nlink(inode, XFS_NLINK_PINNED);
-       }
-       if (inode->i_nlink != XFS_NLINK_PINNED)
-               drop_nlink(inode);
-
-       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
-
-       if (inode->i_nlink)
-               return 0;
-
-       return xfs_iunlink(tp, ip);
-}
-
-/*
- * Increment the link count on an inode & log the change.
- */
-void
-xfs_bumplink(
-       struct xfs_trans        *tp,
-       struct xfs_inode        *ip)
-{
-       struct inode            *inode = VFS_I(ip);
-
-       xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
-
-       if (inode->i_nlink == XFS_NLINK_PINNED - 1)
-               xfs_info_ratelimited(tp->t_mountp,
- "Inode 0x%llx link count exceeded maximum.  Pinning link count.",
-                               ip->i_ino);
-       if (inode->i_nlink != XFS_NLINK_PINNED)
-               inc_nlink(inode);
-
-       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
-}
-
 #ifdef CONFIG_XFS_LIVE_HOOKS
 /*
  * Use a static key here to reduce the overhead of directory live update hooks.
index 47d3a11a0e7eff8ad555fbb8a946372230a88431..5ee044674c3ab1ff6240fb62a4127595f56939dd 100644 (file)
@@ -615,8 +615,6 @@ void xfs_end_io(struct work_struct *work);
 int xfs_ilock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2);
 void xfs_iunlock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2);
 void xfs_iunlock2_remapping(struct xfs_inode *ip1, struct xfs_inode *ip2);
-int xfs_droplink(struct xfs_trans *tp, struct xfs_inode *ip);
-void xfs_bumplink(struct xfs_trans *tp, struct xfs_inode *ip);
 void xfs_lock_inodes(struct xfs_inode **ips, int inodes, uint lock_mode);
 void xfs_sort_inodes(struct xfs_inode **i_tab, unsigned int num_inodes);