Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrens committed Jan 9, 2023
1 parent 28bd9ba commit d6e7b17
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions include/sys/bqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ extern "C" {
typedef struct bqueue {
list_t bq_list;
size_t bq_size;
list_t bq_deqing_list;
size_t bq_deqing_size;
list_t bq_enqing_list;
size_t bq_enqing_size;
list_t bq_dequeuing_list;
size_t bq_dequeuing_size;
list_t bq_enqueuing_list;
size_t bq_enqueuing_size;
kmutex_t bq_lock;
kcondvar_t bq_add_cv;
kcondvar_t bq_pop_cv;
Expand Down
42 changes: 21 additions & 21 deletions module/zfs/bqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ bqueue_init(bqueue_t *q, uint_t fill_fraction, size_t size, size_t node_offset)
}
list_create(&q->bq_list, node_offset + sizeof (bqueue_node_t),
node_offset + offsetof(bqueue_node_t, bqn_node));
list_create(&q->bq_deqing_list, node_offset + sizeof (bqueue_node_t),
list_create(&q->bq_dequeuing_list, node_offset + sizeof (bqueue_node_t),
node_offset + offsetof(bqueue_node_t, bqn_node));
list_create(&q->bq_enqing_list, node_offset + sizeof (bqueue_node_t),
list_create(&q->bq_enqueuing_list, node_offset + sizeof (bqueue_node_t),
node_offset + offsetof(bqueue_node_t, bqn_node));
cv_init(&q->bq_add_cv, NULL, CV_DEFAULT, NULL);
cv_init(&q->bq_pop_cv, NULL, CV_DEFAULT, NULL);
mutex_init(&q->bq_lock, NULL, MUTEX_DEFAULT, NULL);
q->bq_node_offset = node_offset;
q->bq_size = 0;
q->bq_deqing_size = 0;
q->bq_enqing_size = 0;
q->bq_dequeuing_size = 0;
q->bq_enqueuing_size = 0;
q->bq_maxsize = size;
q->bq_fill_fraction = fill_fraction;
return (0);
Expand All @@ -82,13 +82,13 @@ bqueue_destroy(bqueue_t *q)
{
mutex_enter(&q->bq_lock);
ASSERT0(q->bq_size);
ASSERT0(q->bq_deqing_size);
ASSERT0(q->bq_enqing_size);
ASSERT0(q->bq_dequeuing_size);
ASSERT0(q->bq_enqueuing_size);
cv_destroy(&q->bq_add_cv);
cv_destroy(&q->bq_pop_cv);
list_destroy(&q->bq_list);
list_destroy(&q->bq_deqing_list);
list_destroy(&q->bq_enqing_list);
list_destroy(&q->bq_dequeuing_list);
list_destroy(&q->bq_enqueuing_list);
mutex_exit(&q->bq_lock);
mutex_destroy(&q->bq_lock);
}
Expand All @@ -100,19 +100,19 @@ bqueue_enqueue_impl(bqueue_t *q, void *data, size_t item_size, boolean_t flush)
ASSERT3U(item_size, <=, q->bq_maxsize);

obj2node(q, data)->bqn_size = item_size;
q->bq_enqing_size += item_size;
list_insert_tail(&q->bq_enqing_list, data);
q->bq_enqueuing_size += item_size;
list_insert_tail(&q->bq_enqueuing_list, data);

if (flush ||
q->bq_enqing_size >= q->bq_maxsize / q->bq_fill_fraction) {
q->bq_enqueuing_size >= q->bq_maxsize / q->bq_fill_fraction) {
/* Append the enquing list to the shared list. */
mutex_enter(&q->bq_lock);
while (q->bq_size > q->bq_maxsize) {
cv_wait_sig(&q->bq_add_cv, &q->bq_lock);
}
q->bq_size += q->bq_enqing_size;
list_move_tail(&q->bq_list, &q->bq_enqing_list);
q->bq_enqing_size = 0;
q->bq_size += q->bq_enqueuing_size;
list_move_tail(&q->bq_list, &q->bq_enqueuing_list);
q->bq_enqueuing_size = 0;
cv_broadcast(&q->bq_pop_cv);
mutex_exit(&q->bq_lock);
}
Expand Down Expand Up @@ -150,7 +150,7 @@ bqueue_enqueue_flush(bqueue_t *q, void *data, size_t item_size)
void *
bqueue_dequeue(bqueue_t *q)
{
void *ret = list_remove_head(&q->bq_deqing_list);
void *ret = list_remove_head(&q->bq_dequeuing_list);
if (ret == NULL) {
/*
* Dequeuing list is empty. Wait for there to be something on
Expand All @@ -161,15 +161,15 @@ bqueue_dequeue(bqueue_t *q)
while (q->bq_size == 0) {
cv_wait_sig(&q->bq_pop_cv, &q->bq_lock);
}
ASSERT0(q->bq_deqing_size);
ASSERT(list_is_empty(&q->bq_deqing_list));
list_move_tail(&q->bq_deqing_list, &q->bq_list);
q->bq_deqing_size = q->bq_size;
ASSERT0(q->bq_dequeuing_size);
ASSERT(list_is_empty(&q->bq_dequeuing_list));
list_move_tail(&q->bq_dequeuing_list, &q->bq_list);
q->bq_dequeuing_size = q->bq_size;
q->bq_size = 0;
cv_broadcast(&q->bq_add_cv);
mutex_exit(&q->bq_lock);
ret = list_remove_head(&q->bq_deqing_list);
ret = list_remove_head(&q->bq_dequeuing_list);
}
q->bq_deqing_size -= obj2node(q, ret)->bqn_size;
q->bq_dequeuing_size -= obj2node(q, ret)->bqn_size;
return (ret);
}

0 comments on commit d6e7b17

Please sign in to comment.