Add buddy_get_next_off_*

parent 0c07b475
......@@ -298,6 +298,7 @@ struct i_wait {
#define I_WAIT_MAGIC 0x7f6303bc
uint8_t alloced; // how many of n
uint8_t finid;
uint8_t next;
enum i_wait_state state;
VTAILQ_ENTRY(buddy_reqs) list;
pthread_mutex_t wait_mtx;
......@@ -524,6 +525,7 @@ BUDDYF(take_ptr_extent)(buddy_t *buddy, const struct buddy_ptr_extent *rs,
.magic = I_WAIT_MAGIC, \
.alloced = 0, \
.finid = 0, \
.next = 0, \
.state = IW_ARMED, \
.list = { NULL }, \
.wait_mtx = PTHREAD_MUTEX_INITIALIZER, \
......@@ -826,6 +828,17 @@ buddy_get_off_extent(const struct buddy_reqs *reqs, uint8_t n)
return (_buddy_get_off_extent(reqs, n));
}
static inline struct buddy_off_extent
buddy_get_next_off_extent(struct buddy_reqs *reqs)
{
CHECK_OBJ_NOTNULL(reqs, BUDDY_REQS_MAGIC);
if (reqs->i_wait.next == reqs->i_wait.finid)
return (buddy_off_extent_nil);
return (buddy_get_off_extent(reqs, reqs->i_wait.next++));
}
#endif
static inline struct buddy_ptr_extent
......@@ -861,6 +874,16 @@ buddy_get_off_page(const struct buddy_reqs *reqs, uint8_t n)
{
return (_buddy_get_off_page(reqs, n));
}
static inline struct buddy_off_page
buddy_get_next_off_page(struct buddy_reqs *reqs)
{
CHECK_OBJ_NOTNULL(reqs, BUDDY_REQS_MAGIC);
if (reqs->i_wait.next == reqs->i_wait.finid)
return (buddy_off_page_nil);
return (buddy_get_off_page(reqs, reqs->i_wait.next++));
}
#endif
static inline struct buddy_ptr_page
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment