aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-06-15 18:37:07 -0700
committerCarlos Maiolino <cem@kernel.org>2023-06-22 14:07:03 +0200
commitc6b593ee4398b747856a1d9d0a2436b34d0d447a (patch)
treef65e949e8553d0dadd3719dd87706a0fb5b01180
parent4d3226b6ec5af8a114280ac9c745c29235928f13 (diff)
downloadxfsprogs-dev-c6b593ee4398b747856a1d9d0a2436b34d0d447a.tar.gz
libxfs: port list_cmp_func_t to userspace
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>
-rw-r--r--include/list.h7
-rw-r--r--libfrog/list_sort.c10
-rw-r--r--libxfs/defer_item.c32
-rw-r--r--scrub/repair.c12
4 files changed, 29 insertions, 32 deletions
diff --git a/include/list.h b/include/list.h
index dab4e23bd1..e59cbd5373 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 b77eece5a2..994a51fe4d 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 6c5c7dd567..3f51925204 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 67900ea420..5fc5ab836c 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);