All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 01/21] xfs: hoist extent size helpers to libxfs
Date: Tue, 31 Dec 2019 17:12:42 -0800	[thread overview]
Message-ID: <157784116204.1365473.14309906171600525443.stgit@magnolia> (raw)
In-Reply-To: <157784115560.1365473.15056496428451670757.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

Move the extent size helpers to xfs_bmap.c in libxfs since they're used
there already.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_bmap.c |   43 +++++++++++++++++++++++++++++++++++++++
 fs/xfs/libxfs/xfs_bmap.h |    3 +++
 fs/xfs/xfs_inode.c       |   51 +++++++---------------------------------------
 fs/xfs/xfs_inode.h       |    5 ++---
 fs/xfs/xfs_iops.c        |    1 +
 fs/xfs/xfs_reflink.h     |    6 -----
 6 files changed, 57 insertions(+), 52 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index a7287272b04e..e67068141e1f 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -6499,3 +6499,46 @@ 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_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_d.di_extsize)
+		return ip->i_d.di_extsize;
+	if (XFS_IS_REALTIME_INODE(ip))
+		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_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
+		a = ip->i_d.di_cowextsize;
+	b = xfs_get_extsz_hint(ip);
+
+	a = max(a, b);
+	if (a == 0)
+		return XFS_DEFAULT_COWEXTSZ_HINT;
+	return a;
+}
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index f8da2d5b81b8..e5fac18b2f28 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -298,4 +298,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__ */
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 9863081bdfe9..50123ab1c37c 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -46,49 +46,6 @@ STATIC int xfs_iflush_int(struct xfs_inode *, struct xfs_buf *);
 STATIC int xfs_iunlink(struct xfs_trans *, struct xfs_inode *);
 STATIC int xfs_iunlink_remove(struct xfs_trans *, struct xfs_inode *);
 
-/*
- * 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_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_d.di_extsize)
-		return ip->i_d.di_extsize;
-	if (XFS_IS_REALTIME_INODE(ip))
-		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_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)
-		a = ip->i_d.di_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
@@ -4220,3 +4177,11 @@ xfs_has_eofblocks(
 	*has = imap.br_startblock != HOLESTARTBLOCK || ip->i_delayed_blks;
 	return 0;
 }
+
+bool
+xfs_is_always_cow_inode(
+	struct xfs_inode	*ip)
+{
+	return ip->i_mount->m_always_cow &&
+		xfs_sb_version_hasreflink(&ip->i_mount->m_sb);
+}
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 4a3e472d7078..bc50cfa2b513 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -188,6 +188,8 @@ static inline bool xfs_is_reflink_inode(struct xfs_inode *ip)
 	return ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
 }
 
+bool xfs_is_always_cow_inode(struct xfs_inode *ip);
+
 /*
  * Check if an inode has any data in the COW fork.  This might be often false
  * even for inodes with the reflink flag when there is no pending COW operation.
@@ -444,9 +446,6 @@ int		xfs_iflush(struct xfs_inode *, 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_dir_ialloc(struct xfs_trans **, struct xfs_inode *, umode_t,
 			       xfs_nlink_t, dev_t, prid_t,
 			       struct xfs_inode **);
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index f698351cee5d..e4635b29a20d 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -22,6 +22,7 @@
 #include "xfs_iomap.h"
 #include "xfs_error.h"
 #include "xfs_health.h"
+#include "xfs_bmap.h"
 
 #include <linux/xattr.h>
 #include <linux/posix_acl.h>
diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h
index d18ad7f4fb64..668b57c84228 100644
--- a/fs/xfs/xfs_reflink.h
+++ b/fs/xfs/xfs_reflink.h
@@ -6,12 +6,6 @@
 #ifndef __XFS_REFLINK_H
 #define __XFS_REFLINK_H 1
 
-static inline bool xfs_is_always_cow_inode(struct xfs_inode *ip)
-{
-	return ip->i_mount->m_always_cow &&
-		xfs_sb_version_hasreflink(&ip->i_mount->m_sb);
-}
-
 static inline bool xfs_is_cow_inode(struct xfs_inode *ip)
 {
 	return xfs_is_reflink_inode(ip) || xfs_is_always_cow_inode(ip);


  reply	other threads:[~2020-01-01  1:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-01  1:12 [PATCH v2 00/21] xfs: hoist inode operations to libxfs Darrick J. Wong
2020-01-01  1:12 ` Darrick J. Wong [this message]
2020-01-01  1:12 ` [PATCH 02/21] xfs: hoist inode flag conversion functions Darrick J. Wong
2020-01-01  1:12 ` [PATCH 03/21] xfs: hoist project id get/set functions Darrick J. Wong
2020-01-01  1:13 ` [PATCH 04/21] xfs: pack inode allocation parameters into a separate structure Darrick J. Wong
2020-01-01  1:13 ` [PATCH 05/21] xfs: implement atime updates in xfs_trans_ichgtime Darrick J. Wong
2020-01-01  1:13 ` [PATCH 06/21] xfs: use xfs_trans_ichgtime to set times when allocating inode Darrick J. Wong
2020-01-01  1:13 ` [PATCH 07/21] xfs: split inode allocation and initialization Darrick J. Wong
2020-01-01  1:13 ` [PATCH 08/21] xfs: delegate post-allocation iget Darrick J. Wong
2020-01-01  1:13 ` [PATCH 09/21] xfs: hoist inode allocation function Darrick J. Wong
2020-01-01  1:13 ` [PATCH 10/21] xfs: push xfs_ialloc_args creation out of xfs_dir_ialloc Darrick J. Wong
2020-01-01  1:13 ` [PATCH 11/21] xfs: refactor special inode roll " Darrick J. Wong
2020-01-01  1:13 ` [PATCH 12/21] xfs: move xfs_dir_ialloc to libxfs Darrick J. Wong
2020-01-01  1:13 ` [PATCH 13/21] xfs: hoist xfs_iunlink " Darrick J. Wong
2020-01-01  1:14 ` [PATCH 14/21] xfs: hoist xfs_{bump,drop}link " Darrick J. Wong
2020-01-01  1:14 ` [PATCH 15/21] xfs: create libxfs helper to link a new inode into a directory Darrick J. Wong
2020-01-01  1:14 ` [PATCH 16/21] xfs: create libxfs helper to link an existing " Darrick J. Wong
2020-01-01  1:14 ` [PATCH 17/21] xfs: hoist inode free function to libxfs Darrick J. Wong
2020-01-01  1:14 ` [PATCH 18/21] xfs: create libxfs helper to remove an existing inode/name from a directory Darrick J. Wong
2020-01-01  1:14 ` [PATCH 19/21] xfs: create libxfs helper to exchange two directory entries Darrick J. Wong
2020-01-01  1:14 ` [PATCH 20/21] xfs: create libxfs helper to rename " Darrick J. Wong
2020-01-01  1:14 ` [PATCH 21/21] xfs: get rid of cross_rename Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=157784116204.1365473.14309906171600525443.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.