Skip to contentSkip to conversation

xfs: move XFS_LSN_CMP to xfs_log_format.h

PATCH Applied Christoph Hellwig 3 participants 4 messages Jun 8 – Jun 12 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: move XFS_LSN_CMP to xfs_log_format.h

Because CYCLE_LSN/BLOCK_LSN are defined in xfs_log_format.h, XFS_LSN_CMP forces a xfs_log_format.h dependency in xfs_log.h. Move XFS_LSN_CMP to xfs_log_format.h and drop the macro/inline indirection to clean up our header mess a little bit.

This also helps xfsprogs, which doesn't have xfs_log.h, but needs XFS_LSN_CMP.

---
 fs/xfs/libxfs/xfs_log_format.h | 13 +++++++++++++
 fs/xfs/libxfs/xfs_parent.c     |  1 -
 fs/xfs/xfs_log.h               | 17 -----------------
 3 files changed, 13 insertions(+), 18 deletions(-)
fs/xfs/libxfs/xfs_log_format.h +13 -0
index 3f5a24dda907..a4e1b3eb425c 100644
@@ -52,6 +52,19 @@ typedef uint32_t xlog_tid_t;
 #define CYCLE_LSN(lsn) ((uint)((lsn)>>32))
 #define BLOCK_LSN(lsn) ((uint)(lsn))
 
+/*
+ * By comparing each component, we don't have to worry about extra endian issues
+ * in treating two 32 bit numbers as one 64 bit number
+ */
+static inline xfs_lsn_t XFS_LSN_CMP(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
+{
+	if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
+		return CYCLE_LSN(lsn1) < CYCLE_LSN(lsn2) ? -999 : 999;
+	if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
+		return BLOCK_LSN(lsn1) < BLOCK_LSN(lsn2) ? -999 : 999;
+	return 0;
+}
+
 /* this is used in a spot where we might otherwise double-endian-flip */
 #define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0])
 
fs/xfs/libxfs/xfs_parent.c +0 -1
index 3509cc4b2175..a902d6871ea0 100644
@@ -23,7 +23,6 @@
 #include "xfs_attr_sf.h"
 #include "xfs_bmap.h"
 #include "xfs_defer.h"
-#include "xfs_log.h"
 #include "xfs_xattr.h"
 #include "xfs_parent.h"
 #include "xfs_trans_space.h"
fs/xfs/xfs_log.h +0 -17
index 0f23812b0b31..ca66429bf6c9 100644
@@ -80,23 +80,6 @@ xlog_format_copy(
 	return buf;
 }
 
-/*
- * By comparing each component, we don't have to worry about extra
- * endian issues in treating two 32 bit numbers as one 64 bit number
- */
-static inline xfs_lsn_t	_lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
-{
-	if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
-		return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999;
-
-	if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
-		return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999;
-
-	return 0;
-}
-
-#define	XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
-
 /*
  * Flags to xfs_log_force()
  *
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Christoph Hellwig

Because CYCLE_LSN/BLOCK_LSN are defined in xfs_log_format.h, XFS_LSN_CMP forces a xfs_log_format.h dependency in xfs_log.h. Move XFS_LSN_CMP to xfs_log_format.h and drop the macro/inline indirection to clean up our header mess a little bit.

This also helps xfsprogs, which doesn't have xfs_log.h, but needs XFS_LSN_CMP.

Thank you!

Quoted 74 lines
---
 fs/xfs/libxfs/xfs_log_format.h | 13 +++++++++++++
 fs/xfs/libxfs/xfs_parent.c     |  1 -
 fs/xfs/xfs_log.h               | 17 -----------------
 3 files changed, 13 insertions(+), 18 deletions(-)
fs/xfs/libxfs/xfs_log_format.h +13 -0
index 3f5a24dda907..a4e1b3eb425c 100644
@@ -52,6 +52,19 @@ typedef uint32_t xlog_tid_t;
 #define CYCLE_LSN(lsn) ((uint)((lsn)>>32))
 #define BLOCK_LSN(lsn) ((uint)(lsn))
 
+/*
+ * By comparing each component, we don't have to worry about extra endian issues
+ * in treating two 32 bit numbers as one 64 bit number
+ */
+static inline xfs_lsn_t XFS_LSN_CMP(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
+{
+	if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
+		return CYCLE_LSN(lsn1) < CYCLE_LSN(lsn2) ? -999 : 999;
+	if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
+		return BLOCK_LSN(lsn1) < BLOCK_LSN(lsn2) ? -999 : 999;
+	return 0;
+}
+
 /* this is used in a spot where we might otherwise double-endian-flip */
 #define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0])
 
fs/xfs/libxfs/xfs_parent.c +0 -1
index 3509cc4b2175..a902d6871ea0 100644
@@ -23,7 +23,6 @@
 #include "xfs_attr_sf.h"
 #include "xfs_bmap.h"
 #include "xfs_defer.h"
-#include "xfs_log.h"
 #include "xfs_xattr.h"
 #include "xfs_parent.h"
 #include "xfs_trans_space.h"
fs/xfs/xfs_log.h +0 -17
index 0f23812b0b31..ca66429bf6c9 100644
@@ -80,23 +80,6 @@ xlog_format_copy(
 	return buf;
 }
 
-/*
- * By comparing each component, we don't have to worry about extra
- * endian issues in treating two 32 bit numbers as one 64 bit number
- */
-static inline xfs_lsn_t	_lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
-{
-	if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
-		return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999;
-
-	if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
-		return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999;
-
-	return 0;
-}
-
-#define	XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
-
 /*
  * Flags to xfs_log_force()
  *
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#2 lore raw
In reply to Christoph Hellwig
Quoted 9 lines · Christoph Hellwig

Because CYCLE_LSN/BLOCK_LSN are defined in xfs_log_format.h, XFS_LSN_CMP forces a xfs_log_format.h dependency in xfs_log.h. Move XFS_LSN_CMP to xfs_log_format.h and drop the macro/inline indirection to clean up our header mess a little bit.

This also helps xfsprogs, which doesn't have xfs_log.h, but needs XFS_LSN_CMP.

Makes sense, since the only use of XFS_LSN_CMP in xfsprogs is in libxfs/xfs_defer.c.

--D

Quoted 74 lines
---
 fs/xfs/libxfs/xfs_log_format.h | 13 +++++++++++++
 fs/xfs/libxfs/xfs_parent.c     |  1 -
 fs/xfs/xfs_log.h               | 17 -----------------
 3 files changed, 13 insertions(+), 18 deletions(-)
fs/xfs/libxfs/xfs_log_format.h +13 -0
index 3f5a24dda907..a4e1b3eb425c 100644
@@ -52,6 +52,19 @@ typedef uint32_t xlog_tid_t;
 #define CYCLE_LSN(lsn) ((uint)((lsn)>>32))
 #define BLOCK_LSN(lsn) ((uint)(lsn))
 
+/*
+ * By comparing each component, we don't have to worry about extra endian issues
+ * in treating two 32 bit numbers as one 64 bit number
+ */
+static inline xfs_lsn_t XFS_LSN_CMP(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
+{
+	if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
+		return CYCLE_LSN(lsn1) < CYCLE_LSN(lsn2) ? -999 : 999;
+	if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
+		return BLOCK_LSN(lsn1) < BLOCK_LSN(lsn2) ? -999 : 999;
+	return 0;
+}
+
 /* this is used in a spot where we might otherwise double-endian-flip */
 #define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0])
 
fs/xfs/libxfs/xfs_parent.c +0 -1
index 3509cc4b2175..a902d6871ea0 100644
@@ -23,7 +23,6 @@
 #include "xfs_attr_sf.h"
 #include "xfs_bmap.h"
 #include "xfs_defer.h"
-#include "xfs_log.h"
 #include "xfs_xattr.h"
 #include "xfs_parent.h"
 #include "xfs_trans_space.h"
fs/xfs/xfs_log.h +0 -17
index 0f23812b0b31..ca66429bf6c9 100644
@@ -80,23 +80,6 @@ xlog_format_copy(
 	return buf;
 }
 
-/*
- * By comparing each component, we don't have to worry about extra
- * endian issues in treating two 32 bit numbers as one 64 bit number
- */
-static inline xfs_lsn_t	_lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
-{
-	if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
-		return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999;
-
-	if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
-		return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999;
-
-	return 0;
-}
-
-#define	XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
-
 /*
  * Flags to xfs_log_force()
  *
Signature · 1 line
2.53.0
maintainer Applied
#3 lore raw
In reply to Christoph Hellwig
Quoted 9 lines · Christoph Hellwig

Because CYCLE_LSN/BLOCK_LSN are defined in xfs_log_format.h, XFS_LSN_CMP forces a xfs_log_format.h dependency in xfs_log.h. Move XFS_LSN_CMP to xfs_log_format.h and drop the macro/inline indirection to clean up our header mess a little bit.

This also helps xfsprogs, which doesn't have xfs_log.h, but needs XFS_LSN_CMP.

[...]

Applied to for-next, thanks!

[1/1] xfs: move XFS_LSN_CMP to xfs_log_format.h

      commit: 202ff980a464198616e53e85e5276e68c00a1031

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>