btrfs-progs: sync ulist.[ch] from kernel

Minor updates from kernel, 6.4-rc1.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2023-05-12 16:33:50 +02:00
parent 2a6810615b
commit 1b1ce74821
2 changed files with 26 additions and 18 deletions

View File

@ -19,7 +19,7 @@
*/
#include "kerncompat.h"
#include "ulist.h"
#include "kernel-shared/ulist.h"
#include "kernel-shared/ctree.h"
#include "kernel-shared/messages.h"
@ -52,8 +52,9 @@
* loop would be similar to the above.
*/
/**
* ulist_init - freshly initialize a ulist
/*
* Freshly initialize a ulist.
*
* @ulist: the ulist to initialize
*
* Note: don't use this function to init an already used ulist, use
@ -66,14 +67,15 @@ void ulist_init(struct ulist *ulist)
ulist->nnodes = 0;
}
/**
* ulist_release - free up additionally allocated memory for the ulist
/*
* Free up additionally allocated memory for the ulist.
*
* @ulist: the ulist from which to free the additional memory
*
* This is useful in cases where the base 'struct ulist' has been statically
* allocated.
*/
static void ulist_release(struct ulist *ulist)
void ulist_release(struct ulist *ulist)
{
struct ulist_node *node;
struct ulist_node *next;
@ -85,8 +87,9 @@ static void ulist_release(struct ulist *ulist)
INIT_LIST_HEAD(&ulist->nodes);
}
/**
* ulist_reinit - prepare a ulist for reuse
/*
* Prepare a ulist for reuse.
*
* @ulist: ulist to be reused
*
* Free up all additional memory allocated for the list elements and reinit
@ -98,8 +101,9 @@ void ulist_reinit(struct ulist *ulist)
ulist_init(ulist);
}
/**
* ulist_alloc - dynamically allocate a ulist
/*
* Dynamically allocate a ulist.
*
* @gfp_mask: allocation flags to for base allocation
*
* The allocated ulist will be returned in an initialized state.
@ -116,8 +120,9 @@ struct ulist *ulist_alloc(gfp_t gfp_mask)
return ulist;
}
/**
* ulist_free - free dynamically allocated ulist
/*
* Free dynamically allocated ulist.
*
* @ulist: ulist to free
*
* It is not necessary to call ulist_release before.
@ -178,8 +183,9 @@ static int ulist_rbtree_insert(struct ulist *ulist, struct ulist_node *ins)
return 0;
}
/**
* ulist_add - add an element to the ulist
/*
* Add an element to the ulist.
*
* @ulist: ulist to add the element to
* @val: value to add to ulist
* @aux: auxiliary value to store along with val
@ -257,8 +263,9 @@ int ulist_del(struct ulist *ulist, u64 val, u64 aux)
return 0;
}
/**
* ulist_next - iterate ulist
/*
* Iterate ulist.
*
* @ulist: ulist to iterate
* @uiter: iterator variable, initialized with ULIST_ITER_INIT(&iterator)
*
@ -273,7 +280,7 @@ int ulist_del(struct ulist *ulist, u64 val, u64 aux)
* It is allowed to call ulist_add during an enumeration. Newly added items
* are guaranteed to show up in the running enumeration.
*/
struct ulist_node *ulist_next(struct ulist *ulist, struct ulist_iterator *uiter)
struct ulist_node *ulist_next(const struct ulist *ulist, struct ulist_iterator *uiter)
{
struct ulist_node *node;

View File

@ -58,6 +58,7 @@ struct ulist {
};
void ulist_init(struct ulist *ulist);
void ulist_release(struct ulist *ulist);
void ulist_reinit(struct ulist *ulist);
struct ulist *ulist_alloc(gfp_t gfp_mask);
void ulist_free(struct ulist *ulist);
@ -80,7 +81,7 @@ static inline int ulist_add_merge_ptr(struct ulist *ulist, u64 val, void *aux,
#endif
}
struct ulist_node *ulist_next(struct ulist *ulist,
struct ulist_node *ulist_next(const struct ulist *ulist,
struct ulist_iterator *uiter);
#define ULIST_ITER_INIT(uiter) ((uiter)->cur_list = NULL)