]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: hoist extent size helpers to libxfs
authorDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:22:31 +0000 (11:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:36:55 +0000 (11:36 -0700)
Move the extent size helpers to xfs_bmap.c in libxfs since they're used
there already.

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

index 6af6f744fdd6a29a9c04a1d457bf4e55b5038e51..f889123126d221f06d49684e66d358fada2e0de2 100644 (file)
@@ -6454,3 +6454,45 @@ xfs_bmap_query_all(
 
        return xfs_btree_query_all(cur, xfs_bmap_query_range_helper, &query);
 }
+
+/* Helper function to extract extent size hint from inode */
+xfs_extlen_t
+xfs_get_extsz_hint(
+       struct xfs_inode        *ip)
+{
+       /*
+        * No point in aligning allocations if we need to COW to actually
+        * write to them.
+        */
+       if (xfs_is_always_cow_inode(ip))
+               return 0;
+       if ((ip->i_diflags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
+               return ip->i_extsize;
+       if (XFS_IS_REALTIME_INODE(ip) &&
+           ip->i_mount->m_sb.sb_rextsize > 1)
+               return ip->i_mount->m_sb.sb_rextsize;
+       return 0;
+}
+
+/*
+ * Helper function to extract CoW extent size hint from inode.
+ * Between the extent size hint and the CoW extent size hint, we
+ * return the greater of the two.  If the value is zero (automatic),
+ * use the default size.
+ */
+xfs_extlen_t
+xfs_get_cowextsz_hint(
+       struct xfs_inode        *ip)
+{
+       xfs_extlen_t            a, b;
+
+       a = 0;
+       if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
+               a = ip->i_cowextsize;
+       b = xfs_get_extsz_hint(ip);
+
+       a = max(a, b);
+       if (a == 0)
+               return XFS_DEFAULT_COWEXTSZ_HINT;
+       return a;
+}
index 667b0c2b33d1d566dec92cf9913b4451818a4034..7592d46e97c661136e53978e0052d7f7caa799b8 100644 (file)
@@ -296,4 +296,7 @@ typedef int (*xfs_bmap_query_range_fn)(
 int xfs_bmap_query_all(struct xfs_btree_cur *cur, xfs_bmap_query_range_fn fn,
                void *priv);
 
+xfs_extlen_t   xfs_get_extsz_hint(struct xfs_inode *ip);
+xfs_extlen_t   xfs_get_cowextsz_hint(struct xfs_inode *ip);
+
 #endif /* __XFS_BMAP_H__ */
index dd2b80d5d34440a3a5b81cf161f7652e63e2cacc..d16e727aa62a93e1569e4fd27efbad79518fe055 100644 (file)
 
 struct kmem_cache *xfs_inode_cache;
 
-/*
- * helper function to extract extent size hint from inode
- */
-xfs_extlen_t
-xfs_get_extsz_hint(
-       struct xfs_inode        *ip)
-{
-       /*
-        * No point in aligning allocations if we need to COW to actually
-        * write to them.
-        */
-       if (xfs_is_always_cow_inode(ip))
-               return 0;
-       if ((ip->i_diflags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
-               return ip->i_extsize;
-       if (XFS_IS_REALTIME_INODE(ip) &&
-           ip->i_mount->m_sb.sb_rextsize > 1)
-               return ip->i_mount->m_sb.sb_rextsize;
-       return 0;
-}
-
-/*
- * Helper function to extract CoW extent size hint from inode.
- * Between the extent size hint and the CoW extent size hint, we
- * return the greater of the two.  If the value is zero (automatic),
- * use the default size.
- */
-xfs_extlen_t
-xfs_get_cowextsz_hint(
-       struct xfs_inode        *ip)
-{
-       xfs_extlen_t            a, b;
-
-       a = 0;
-       if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
-               a = ip->i_cowextsize;
-       b = xfs_get_extsz_hint(ip);
-
-       a = max(a, b);
-       if (a == 0)
-               return XFS_DEFAULT_COWEXTSZ_HINT;
-       return a;
-}
-
 /*
  * These two are wrapper routines around the xfs_ilock() routine used to
  * centralize some grungy code.  They are used in places that wish to lock the
index e97b2b838c69b2caaf3a8ac9bbd9155921ff9e09..0e642afa77a7ccd33038d841ae7eb4fc55ab71a7 100644 (file)
@@ -563,9 +563,6 @@ int         xfs_iflush_cluster(struct xfs_buf *);
 void           xfs_lock_two_inodes(struct xfs_inode *ip0, uint ip0_mode,
                                struct xfs_inode *ip1, uint ip1_mode);
 
-xfs_extlen_t   xfs_get_extsz_hint(struct xfs_inode *ip);
-xfs_extlen_t   xfs_get_cowextsz_hint(struct xfs_inode *ip);
-
 int xfs_init_new_inode(struct mnt_idmap *idmap, struct xfs_trans *tp,
                struct xfs_inode *pip, xfs_ino_t ino, umode_t mode,
                xfs_nlink_t nlink, dev_t rdev, prid_t prid, bool init_xattrs,
index ff222827e55087a1aa366923c9832a3fbb029cd8..35a84790d26e6b21786049a4393ef2c36a6babcf 100644 (file)
@@ -26,6 +26,7 @@
 #include "xfs_ioctl.h"
 #include "xfs_xattr.h"
 #include "xfs_file.h"
+#include "xfs_bmap.h"
 
 #include <linux/posix_acl.h>
 #include <linux/security.h>