diff mbox

[04/10] xfs_repair: replace rmap_compare with libxfs version

Message ID 149643309903.15899.5862825605175613525.stgit@birch.djwong.org (mailing list archive)
State Superseded
Headers show

Commit Message

Darrick J. Wong June 2, 2017, 7:51 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Now that libxfs has a function to compare rmaps, replace xfs_repair's
helper function with that.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/libxfs_api_defs.h |    1 +
 repair/rmap.c            |   32 ++------------------------------
 2 files changed, 3 insertions(+), 30 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Eric Sandeen June 13, 2017, 10:34 p.m. UTC | #1
On 6/2/17 2:51 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Now that libxfs has a function to compare rmaps, replace xfs_repair's
> helper function with that.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  libxfs/libxfs_api_defs.h |    1 +
>  repair/rmap.c            |   32 ++------------------------------
>  2 files changed, 3 insertions(+), 30 deletions(-)
> 
> 
> diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
> index 31239ca..2d8d9c8 100644
> --- a/libxfs/libxfs_api_defs.h
> +++ b/libxfs/libxfs_api_defs.h
> @@ -144,5 +144,6 @@
>  #define xfs_refcount_get_rec		libxfs_refcount_get_rec
>  #define xfs_rmap_lookup_le_range	libxfs_rmap_lookup_le_range
>  #define xfs_refc_block			libxfs_refc_block
> +#define xfs_rmap_compare		libxfs_rmap_compare
>  
>  #endif /* __LIBXFS_API_DEFS_H__ */
> diff --git a/repair/rmap.c b/repair/rmap.c
> index 7508973..ab6e583 100644
> --- a/repair/rmap.c
> +++ b/repair/rmap.c
> @@ -49,37 +49,9 @@ static struct xfs_ag_rmap *ag_rmaps;
>  static bool rmapbt_suspect;
>  static bool refcbt_suspect;
>  
> -/*
> - * Compare rmap observations for array sorting.
> - */
> -static int
> -rmap_compare(
> -	const void		*a,
> -	const void		*b)
> +static inline int rmap_compare(const void *a, const void *b)
>  {
> -	const struct xfs_rmap_irec	*pa;
> -	const struct xfs_rmap_irec	*pb;
> -	__u64			oa;
> -	__u64			ob;
> -
> -	pa = a; pb = b;
> -	oa = libxfs_rmap_irec_offset_pack(pa);
> -	ob = libxfs_rmap_irec_offset_pack(pb);
> -
> -	if (pa->rm_startblock < pb->rm_startblock)
> -		return -1;
> -	else if (pa->rm_startblock > pb->rm_startblock)
> -		return 1;
> -	else if (pa->rm_owner < pb->rm_owner)
> -		return -1;
> -	else if (pa->rm_owner > pb->rm_owner)
> -		return 1;
> -	else if (oa < ob)
> -		return -1;
> -	else if (oa > ob)
> -		return 1;
> -	else
> -		return 0;
> +	return libxfs_rmap_compare(a, b);
>  }
>  
>  /*
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index 31239ca..2d8d9c8 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -144,5 +144,6 @@ 
 #define xfs_refcount_get_rec		libxfs_refcount_get_rec
 #define xfs_rmap_lookup_le_range	libxfs_rmap_lookup_le_range
 #define xfs_refc_block			libxfs_refc_block
+#define xfs_rmap_compare		libxfs_rmap_compare
 
 #endif /* __LIBXFS_API_DEFS_H__ */
diff --git a/repair/rmap.c b/repair/rmap.c
index 7508973..ab6e583 100644
--- a/repair/rmap.c
+++ b/repair/rmap.c
@@ -49,37 +49,9 @@  static struct xfs_ag_rmap *ag_rmaps;
 static bool rmapbt_suspect;
 static bool refcbt_suspect;
 
-/*
- * Compare rmap observations for array sorting.
- */
-static int
-rmap_compare(
-	const void		*a,
-	const void		*b)
+static inline int rmap_compare(const void *a, const void *b)
 {
-	const struct xfs_rmap_irec	*pa;
-	const struct xfs_rmap_irec	*pb;
-	__u64			oa;
-	__u64			ob;
-
-	pa = a; pb = b;
-	oa = libxfs_rmap_irec_offset_pack(pa);
-	ob = libxfs_rmap_irec_offset_pack(pb);
-
-	if (pa->rm_startblock < pb->rm_startblock)
-		return -1;
-	else if (pa->rm_startblock > pb->rm_startblock)
-		return 1;
-	else if (pa->rm_owner < pb->rm_owner)
-		return -1;
-	else if (pa->rm_owner > pb->rm_owner)
-		return 1;
-	else if (oa < ob)
-		return -1;
-	else if (oa > ob)
-		return 1;
-	else
-		return 0;
+	return libxfs_rmap_compare(a, b);
 }
 
 /*