]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: port list_cmp_func_t to userspace
authorDarrick J. Wong <djwong@kernel.org>
Fri, 16 Jun 2023 01:37:07 +0000 (18:37 -0700)
committerCarlos Maiolino <cem@kernel.org>
Thu, 22 Jun 2023 12:07:03 +0000 (14:07 +0200)
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@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
include/list.h
libfrog/list_sort.c
libxfs/defer_item.c
scrub/repair.c

index dab4e23bd10c2e6f941558c458c299707239a802..e59cbd53734b42240ae62eceadde581a3e1c7990 100644 (file)
@@ -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]))
 
index b77eece5a229b601039609364edd61a089b0ee95..994a51fe4d3c89c3f42860ea72bd9fee02e6972b 100644 (file)
@@ -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 */
index 6c5c7dd5677c833cd968ac519ef06db44df10279..3f519252046eb9af851246c9fcbb0703e79451b0 100644 (file)
 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);
index 67900ea4208b4b4daed2fa6e4de4305e86d9dc7c..5fc5ab836c7e51dfd8ef749833fa71ccdc3a2008 100644 (file)
@@ -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);