[PATCH 2/8] libxfs: port list_cmp_func_t to userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

Synchronize our list_sort ABI to match the kernel's.  This will make it
easier to port the log item precommit sorting code to userspace as-is in
the next patch.

Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 include/list.h      |    7 ++++---
 libfrog/list_sort.c |   10 +++-------
 libxfs/defer_item.c |   32 ++++++++++++++++----------------
 scrub/repair.c      |   12 ++++++------
 4 files changed, 29 insertions(+), 32 deletions(-)


diff --git a/include/list.h b/include/list.h
index dab4e23b..e59cbd53 100644
--- a/include/list.h
+++ b/include/list.h
@@ -156,9 +156,10 @@ static inline void list_splice_init(struct list_head *list,
 	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
 	(type *)( (char *)__mptr - offsetof(type,member) );})
 
-void list_sort(void *priv, struct list_head *head,
-	       int (*cmp)(void *priv, struct list_head *a,
-			  struct list_head *b));
+typedef int (*list_cmp_func_t)(void *priv, const struct list_head *a,
+		const struct list_head *b);
+
+void list_sort(void *priv, struct list_head *head, list_cmp_func_t cmp);
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
diff --git a/libfrog/list_sort.c b/libfrog/list_sort.c
index b77eece5..994a51fe 100644
--- a/libfrog/list_sort.c
+++ b/libfrog/list_sort.c
@@ -12,8 +12,7 @@
  * sentinel head node, "prev" links not maintained.
  */
 static struct list_head *merge(void *priv,
-				int (*cmp)(void *priv, struct list_head *a,
-					struct list_head *b),
+			        list_cmp_func_t cmp,
 				struct list_head *a, struct list_head *b)
 {
 	struct list_head head, *tail = &head;
@@ -41,8 +40,7 @@ static struct list_head *merge(void *priv,
  * throughout.
  */
 static void merge_and_restore_back_links(void *priv,
-				int (*cmp)(void *priv, struct list_head *a,
-					struct list_head *b),
+				list_cmp_func_t cmp,
 				struct list_head *head,
 				struct list_head *a, struct list_head *b)
 {
@@ -96,9 +94,7 @@ static void merge_and_restore_back_links(void *priv,
  * @b. If @a and @b are equivalent, and their original relative
  * ordering is to be preserved, @cmp must return 0.
  */
-void list_sort(void *priv, struct list_head *head,
-		int (*cmp)(void *priv, struct list_head *a,
-			struct list_head *b))
+void list_sort(void *priv, struct list_head *head, list_cmp_func_t cmp)
 {
 	struct list_head *part[MAX_LIST_LENGTH_BITS+1]; /* sorted partial lists
 						-- last slot is a sentinel */
diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c
index 6c5c7dd5..3f519252 100644
--- a/libxfs/defer_item.c
+++ b/libxfs/defer_item.c
@@ -33,11 +33,11 @@
 static int
 xfs_extent_free_diff_items(
 	void				*priv,
-	struct list_head		*a,
-	struct list_head		*b)
+	const struct list_head		*a,
+	const struct list_head		*b)
 {
-	struct xfs_extent_free_item	*ra;
-	struct xfs_extent_free_item	*rb;
+	const struct xfs_extent_free_item *ra;
+	const struct xfs_extent_free_item *rb;
 
 	ra = container_of(a, struct xfs_extent_free_item, xefi_list);
 	rb = container_of(b, struct xfs_extent_free_item, xefi_list);
@@ -197,11 +197,11 @@ const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
 static int
 xfs_rmap_update_diff_items(
 	void				*priv,
-	struct list_head		*a,
-	struct list_head		*b)
+	const struct list_head		*a,
+	const struct list_head		*b)
 {
-	struct xfs_rmap_intent		*ra;
-	struct xfs_rmap_intent		*rb;
+	const struct xfs_rmap_intent	*ra;
+	const struct xfs_rmap_intent	*rb;
 
 	ra = container_of(a, struct xfs_rmap_intent, ri_list);
 	rb = container_of(b, struct xfs_rmap_intent, ri_list);
@@ -309,11 +309,11 @@ const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
 static int
 xfs_refcount_update_diff_items(
 	void				*priv,
-	struct list_head		*a,
-	struct list_head		*b)
+	const struct list_head		*a,
+	const struct list_head		*b)
 {
-	struct xfs_refcount_intent	*ra;
-	struct xfs_refcount_intent	*rb;
+	const struct xfs_refcount_intent *ra;
+	const struct xfs_refcount_intent *rb;
 
 	ra = container_of(a, struct xfs_refcount_intent, ri_list);
 	rb = container_of(b, struct xfs_refcount_intent, ri_list);
@@ -427,11 +427,11 @@ const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
 static int
 xfs_bmap_update_diff_items(
 	void				*priv,
-	struct list_head		*a,
-	struct list_head		*b)
+	const struct list_head		*a,
+	const struct list_head		*b)
 {
-	struct xfs_bmap_intent		*ba;
-	struct xfs_bmap_intent		*bb;
+	const struct xfs_bmap_intent	*ba;
+	const struct xfs_bmap_intent	*bb;
 
 	ba = container_of(a, struct xfs_bmap_intent, bi_list);
 	bb = container_of(b, struct xfs_bmap_intent, bi_list);
diff --git a/scrub/repair.c b/scrub/repair.c
index 67900ea4..5fc5ab83 100644
--- a/scrub/repair.c
+++ b/scrub/repair.c
@@ -37,7 +37,7 @@
 /* Sort action items in severity order. */
 static int
 PRIO(
-	struct action_item	*aitem,
+	const struct action_item *aitem,
 	int			order)
 {
 	if (aitem->flags & XFS_SCRUB_OFLAG_CORRUPT)
@@ -54,7 +54,7 @@ PRIO(
 /* Sort the repair items in dependency order. */
 static int
 xfs_action_item_priority(
-	struct action_item	*aitem)
+	const struct action_item	*aitem)
 {
 	switch (aitem->type) {
 	case XFS_SCRUB_TYPE_SB:
@@ -95,11 +95,11 @@ xfs_action_item_priority(
 static int
 xfs_action_item_compare(
 	void				*priv,
-	struct list_head		*a,
-	struct list_head		*b)
+	const struct list_head		*a,
+	const struct list_head		*b)
 {
-	struct action_item		*ra;
-	struct action_item		*rb;
+	const struct action_item	*ra;
+	const struct action_item	*rb;
 
 	ra = container_of(a, struct action_item, list);
 	rb = container_of(b, struct action_item, list);




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux