Commit 66214ed0 authored by Mike Snitzer's avatar Mike Snitzer

dm vdo funnel-queue: change from uds_ to vdo_ namespace

Also return VDO_SUCCESS from vdo_make_funnel_queue.
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
Signed-off-by: default avatarChung Chung <cchung@redhat.com>
Signed-off-by: default avatarMatthew Sakai <msakai@redhat.com>
parent 41c58a36
...@@ -718,7 +718,7 @@ static void process_release_callback(struct vdo_completion *completion) ...@@ -718,7 +718,7 @@ static void process_release_callback(struct vdo_completion *completion)
for (processed = 0; processed < DATA_VIO_RELEASE_BATCH_SIZE; processed++) { for (processed = 0; processed < DATA_VIO_RELEASE_BATCH_SIZE; processed++) {
struct data_vio *data_vio; struct data_vio *data_vio;
struct funnel_queue_entry *entry = uds_funnel_queue_poll(pool->queue); struct funnel_queue_entry *entry = vdo_funnel_queue_poll(pool->queue);
if (entry == NULL) if (entry == NULL)
break; break;
...@@ -748,7 +748,7 @@ static void process_release_callback(struct vdo_completion *completion) ...@@ -748,7 +748,7 @@ static void process_release_callback(struct vdo_completion *completion)
/* Pairs with the barrier in schedule_releases(). */ /* Pairs with the barrier in schedule_releases(). */
smp_mb(); smp_mb();
reschedule = !uds_is_funnel_queue_empty(pool->queue); reschedule = !vdo_is_funnel_queue_empty(pool->queue);
drained = (!reschedule && drained = (!reschedule &&
vdo_is_state_draining(&pool->state) && vdo_is_state_draining(&pool->state) &&
check_for_drain_complete_locked(pool)); check_for_drain_complete_locked(pool));
...@@ -865,8 +865,8 @@ int make_data_vio_pool(struct vdo *vdo, data_vio_count_t pool_size, ...@@ -865,8 +865,8 @@ int make_data_vio_pool(struct vdo *vdo, data_vio_count_t pool_size,
process_release_callback, vdo->thread_config.cpu_thread, process_release_callback, vdo->thread_config.cpu_thread,
NULL); NULL);
result = uds_make_funnel_queue(&pool->queue); result = vdo_make_funnel_queue(&pool->queue);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
free_data_vio_pool(vdo_forget(pool)); free_data_vio_pool(vdo_forget(pool));
return result; return result;
} }
...@@ -924,7 +924,7 @@ void free_data_vio_pool(struct data_vio_pool *pool) ...@@ -924,7 +924,7 @@ void free_data_vio_pool(struct data_vio_pool *pool)
destroy_data_vio(data_vio); destroy_data_vio(data_vio);
} }
uds_free_funnel_queue(vdo_forget(pool->queue)); vdo_free_funnel_queue(vdo_forget(pool->queue));
vdo_free(pool); vdo_free(pool);
} }
...@@ -1283,7 +1283,7 @@ static void finish_cleanup(struct data_vio *data_vio) ...@@ -1283,7 +1283,7 @@ static void finish_cleanup(struct data_vio *data_vio)
(completion->result != VDO_SUCCESS)) { (completion->result != VDO_SUCCESS)) {
struct data_vio_pool *pool = completion->vdo->data_vio_pool; struct data_vio_pool *pool = completion->vdo->data_vio_pool;
uds_funnel_queue_put(pool->queue, &completion->work_queue_entry_link); vdo_funnel_queue_put(pool->queue, &completion->work_queue_entry_link);
schedule_releases(pool); schedule_releases(pool);
return; return;
} }
......
...@@ -2246,7 +2246,7 @@ static void finish_index_operation(struct uds_request *request) ...@@ -2246,7 +2246,7 @@ static void finish_index_operation(struct uds_request *request)
atomic_read(&context->state)); atomic_read(&context->state));
} }
uds_funnel_queue_put(context->zone->timed_out_complete, &context->queue_entry); vdo_funnel_queue_put(context->zone->timed_out_complete, &context->queue_entry);
} }
/** /**
...@@ -2275,7 +2275,7 @@ static void check_for_drain_complete(struct hash_zone *zone) ...@@ -2275,7 +2275,7 @@ static void check_for_drain_complete(struct hash_zone *zone)
struct dedupe_context *context; struct dedupe_context *context;
struct funnel_queue_entry *entry; struct funnel_queue_entry *entry;
entry = uds_funnel_queue_poll(zone->timed_out_complete); entry = vdo_funnel_queue_poll(zone->timed_out_complete);
if (entry == NULL) if (entry == NULL)
break; break;
...@@ -2373,7 +2373,7 @@ static int __must_check initialize_zone(struct vdo *vdo, struct hash_zones *zone ...@@ -2373,7 +2373,7 @@ static int __must_check initialize_zone(struct vdo *vdo, struct hash_zones *zone
INIT_LIST_HEAD(&zone->available); INIT_LIST_HEAD(&zone->available);
INIT_LIST_HEAD(&zone->pending); INIT_LIST_HEAD(&zone->pending);
result = uds_make_funnel_queue(&zone->timed_out_complete); result = vdo_make_funnel_queue(&zone->timed_out_complete);
if (result != VDO_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
...@@ -2475,7 +2475,7 @@ void vdo_free_hash_zones(struct hash_zones *zones) ...@@ -2475,7 +2475,7 @@ void vdo_free_hash_zones(struct hash_zones *zones)
for (i = 0; i < zones->zone_count; i++) { for (i = 0; i < zones->zone_count; i++) {
struct hash_zone *zone = &zones->zones[i]; struct hash_zone *zone = &zones->zones[i];
uds_free_funnel_queue(vdo_forget(zone->timed_out_complete)); vdo_free_funnel_queue(vdo_forget(zone->timed_out_complete));
vdo_int_map_free(vdo_forget(zone->hash_lock_map)); vdo_int_map_free(vdo_forget(zone->hash_lock_map));
vdo_free(vdo_forget(zone->lock_array)); vdo_free(vdo_forget(zone->lock_array));
} }
...@@ -2875,7 +2875,7 @@ static struct dedupe_context * __must_check acquire_context(struct hash_zone *zo ...@@ -2875,7 +2875,7 @@ static struct dedupe_context * __must_check acquire_context(struct hash_zone *zo
return context; return context;
} }
entry = uds_funnel_queue_poll(zone->timed_out_complete); entry = vdo_funnel_queue_poll(zone->timed_out_complete);
return ((entry == NULL) ? return ((entry == NULL) ?
NULL : container_of(entry, struct dedupe_context, queue_entry)); NULL : container_of(entry, struct dedupe_context, queue_entry));
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "memory-alloc.h" #include "memory-alloc.h"
#include "permassert.h" #include "permassert.h"
int uds_make_funnel_queue(struct funnel_queue **queue_ptr) int vdo_make_funnel_queue(struct funnel_queue **queue_ptr)
{ {
int result; int result;
struct funnel_queue *queue; struct funnel_queue *queue;
...@@ -27,10 +27,10 @@ int uds_make_funnel_queue(struct funnel_queue **queue_ptr) ...@@ -27,10 +27,10 @@ int uds_make_funnel_queue(struct funnel_queue **queue_ptr)
queue->oldest = &queue->stub; queue->oldest = &queue->stub;
*queue_ptr = queue; *queue_ptr = queue;
return UDS_SUCCESS; return VDO_SUCCESS;
} }
void uds_free_funnel_queue(struct funnel_queue *queue) void vdo_free_funnel_queue(struct funnel_queue *queue)
{ {
vdo_free(queue); vdo_free(queue);
} }
...@@ -40,7 +40,7 @@ static struct funnel_queue_entry *get_oldest(struct funnel_queue *queue) ...@@ -40,7 +40,7 @@ static struct funnel_queue_entry *get_oldest(struct funnel_queue *queue)
/* /*
* Barrier requirements: We need a read barrier between reading a "next" field pointer * Barrier requirements: We need a read barrier between reading a "next" field pointer
* value and reading anything it points to. There's an accompanying barrier in * value and reading anything it points to. There's an accompanying barrier in
* uds_funnel_queue_put() between its caller setting up the entry and making it visible. * vdo_funnel_queue_put() between its caller setting up the entry and making it visible.
*/ */
struct funnel_queue_entry *oldest = queue->oldest; struct funnel_queue_entry *oldest = queue->oldest;
struct funnel_queue_entry *next = READ_ONCE(oldest->next); struct funnel_queue_entry *next = READ_ONCE(oldest->next);
...@@ -80,7 +80,7 @@ static struct funnel_queue_entry *get_oldest(struct funnel_queue *queue) ...@@ -80,7 +80,7 @@ static struct funnel_queue_entry *get_oldest(struct funnel_queue *queue)
* Put the stub entry back on the queue, ensuring a successor will eventually be * Put the stub entry back on the queue, ensuring a successor will eventually be
* seen. * seen.
*/ */
uds_funnel_queue_put(queue, &queue->stub); vdo_funnel_queue_put(queue, &queue->stub);
/* Check again for a successor. */ /* Check again for a successor. */
next = READ_ONCE(oldest->next); next = READ_ONCE(oldest->next);
...@@ -100,7 +100,7 @@ static struct funnel_queue_entry *get_oldest(struct funnel_queue *queue) ...@@ -100,7 +100,7 @@ static struct funnel_queue_entry *get_oldest(struct funnel_queue *queue)
* Poll a queue, removing the oldest entry if the queue is not empty. This function must only be * Poll a queue, removing the oldest entry if the queue is not empty. This function must only be
* called from a single consumer thread. * called from a single consumer thread.
*/ */
struct funnel_queue_entry *uds_funnel_queue_poll(struct funnel_queue *queue) struct funnel_queue_entry *vdo_funnel_queue_poll(struct funnel_queue *queue)
{ {
struct funnel_queue_entry *oldest = get_oldest(queue); struct funnel_queue_entry *oldest = get_oldest(queue);
...@@ -134,7 +134,7 @@ struct funnel_queue_entry *uds_funnel_queue_poll(struct funnel_queue *queue) ...@@ -134,7 +134,7 @@ struct funnel_queue_entry *uds_funnel_queue_poll(struct funnel_queue *queue)
* or more entries being added such that the list view is incomplete, this function will report the * or more entries being added such that the list view is incomplete, this function will report the
* queue as empty. * queue as empty.
*/ */
bool uds_is_funnel_queue_empty(struct funnel_queue *queue) bool vdo_is_funnel_queue_empty(struct funnel_queue *queue)
{ {
return get_oldest(queue) == NULL; return get_oldest(queue) == NULL;
} }
...@@ -143,9 +143,9 @@ bool uds_is_funnel_queue_empty(struct funnel_queue *queue) ...@@ -143,9 +143,9 @@ bool uds_is_funnel_queue_empty(struct funnel_queue *queue)
* Check whether the funnel queue is idle or not. If the queue has entries available to be * Check whether the funnel queue is idle or not. If the queue has entries available to be
* retrieved, it is not idle. If the queue is in a transition state with one or more entries being * retrieved, it is not idle. If the queue is in a transition state with one or more entries being
* added such that the list view is incomplete, it may not be possible to retrieve an entry with * added such that the list view is incomplete, it may not be possible to retrieve an entry with
* the uds_funnel_queue_poll() function, but the queue will not be considered idle. * the vdo_funnel_queue_poll() function, but the queue will not be considered idle.
*/ */
bool uds_is_funnel_queue_idle(struct funnel_queue *queue) bool vdo_is_funnel_queue_idle(struct funnel_queue *queue)
{ {
/* /*
* Oldest is not the stub, so there's another entry, though if next is NULL we can't * Oldest is not the stub, so there's another entry, though if next is NULL we can't
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
* Copyright 2023 Red Hat * Copyright 2023 Red Hat
*/ */
#ifndef UDS_FUNNEL_QUEUE_H #ifndef VDO_FUNNEL_QUEUE_H
#define UDS_FUNNEL_QUEUE_H #define VDO_FUNNEL_QUEUE_H
#include <linux/atomic.h> #include <linux/atomic.h>
#include <linux/cache.h> #include <linux/cache.h>
...@@ -25,19 +25,19 @@ ...@@ -25,19 +25,19 @@
* the queue entries, and pointers to those structures are used exclusively by the queue. No macros * the queue entries, and pointers to those structures are used exclusively by the queue. No macros
* are defined to template the queue, so the offset of the funnel_queue_entry in the records placed * are defined to template the queue, so the offset of the funnel_queue_entry in the records placed
* in the queue must all be the same so the client can derive their structure pointer from the * in the queue must all be the same so the client can derive their structure pointer from the
* entry pointer returned by uds_funnel_queue_poll(). * entry pointer returned by vdo_funnel_queue_poll().
* *
* Callers are wholly responsible for allocating and freeing the entries. Entries may be freed as * Callers are wholly responsible for allocating and freeing the entries. Entries may be freed as
* soon as they are returned since this queue is not susceptible to the "ABA problem" present in * soon as they are returned since this queue is not susceptible to the "ABA problem" present in
* many lock-free data structures. The queue is dynamically allocated to ensure cache-line * many lock-free data structures. The queue is dynamically allocated to ensure cache-line
* alignment, but no other dynamic allocation is used. * alignment, but no other dynamic allocation is used.
* *
* The algorithm is not actually 100% lock-free. There is a single point in uds_funnel_queue_put() * The algorithm is not actually 100% lock-free. There is a single point in vdo_funnel_queue_put()
* at which a preempted producer will prevent the consumers from seeing items added to the queue by * at which a preempted producer will prevent the consumers from seeing items added to the queue by
* later producers, and only if the queue is short enough or the consumer fast enough for it to * later producers, and only if the queue is short enough or the consumer fast enough for it to
* reach what was the end of the queue at the time of the preemption. * reach what was the end of the queue at the time of the preemption.
* *
* The consumer function, uds_funnel_queue_poll(), will return NULL when the queue is empty. To * The consumer function, vdo_funnel_queue_poll(), will return NULL when the queue is empty. To
* wait for data to consume, spin (if safe) or combine the queue with a struct event_count to * wait for data to consume, spin (if safe) or combine the queue with a struct event_count to
* signal the presence of new entries. * signal the presence of new entries.
*/ */
...@@ -51,7 +51,7 @@ struct funnel_queue_entry { ...@@ -51,7 +51,7 @@ struct funnel_queue_entry {
/* /*
* The dynamically allocated queue structure, which is allocated on a cache line boundary so the * The dynamically allocated queue structure, which is allocated on a cache line boundary so the
* producer and consumer fields in the structure will land on separate cache lines. This should be * producer and consumer fields in the structure will land on separate cache lines. This should be
* consider opaque but it is exposed here so uds_funnel_queue_put() can be inlined. * consider opaque but it is exposed here so vdo_funnel_queue_put() can be inlined.
*/ */
struct __aligned(L1_CACHE_BYTES) funnel_queue { struct __aligned(L1_CACHE_BYTES) funnel_queue {
/* /*
...@@ -67,9 +67,9 @@ struct __aligned(L1_CACHE_BYTES) funnel_queue { ...@@ -67,9 +67,9 @@ struct __aligned(L1_CACHE_BYTES) funnel_queue {
struct funnel_queue_entry stub; struct funnel_queue_entry stub;
}; };
int __must_check uds_make_funnel_queue(struct funnel_queue **queue_ptr); int __must_check vdo_make_funnel_queue(struct funnel_queue **queue_ptr);
void uds_free_funnel_queue(struct funnel_queue *queue); void vdo_free_funnel_queue(struct funnel_queue *queue);
/* /*
* Put an entry on the end of the queue. * Put an entry on the end of the queue.
...@@ -79,7 +79,7 @@ void uds_free_funnel_queue(struct funnel_queue *queue); ...@@ -79,7 +79,7 @@ void uds_free_funnel_queue(struct funnel_queue *queue);
* from the pointer that passed in here, so every entry in the queue must have the struct * from the pointer that passed in here, so every entry in the queue must have the struct
* funnel_queue_entry at the same offset within the client's structure. * funnel_queue_entry at the same offset within the client's structure.
*/ */
static inline void uds_funnel_queue_put(struct funnel_queue *queue, static inline void vdo_funnel_queue_put(struct funnel_queue *queue,
struct funnel_queue_entry *entry) struct funnel_queue_entry *entry)
{ {
struct funnel_queue_entry *previous; struct funnel_queue_entry *previous;
...@@ -101,10 +101,10 @@ static inline void uds_funnel_queue_put(struct funnel_queue *queue, ...@@ -101,10 +101,10 @@ static inline void uds_funnel_queue_put(struct funnel_queue *queue,
WRITE_ONCE(previous->next, entry); WRITE_ONCE(previous->next, entry);
} }
struct funnel_queue_entry *__must_check uds_funnel_queue_poll(struct funnel_queue *queue); struct funnel_queue_entry *__must_check vdo_funnel_queue_poll(struct funnel_queue *queue);
bool __must_check uds_is_funnel_queue_empty(struct funnel_queue *queue); bool __must_check vdo_is_funnel_queue_empty(struct funnel_queue *queue);
bool __must_check uds_is_funnel_queue_idle(struct funnel_queue *queue); bool __must_check vdo_is_funnel_queue_idle(struct funnel_queue *queue);
#endif /* UDS_FUNNEL_QUEUE_H */ #endif /* VDO_FUNNEL_QUEUE_H */
...@@ -98,7 +98,7 @@ static struct vdo_completion *poll_for_completion(struct simple_work_queue *queu ...@@ -98,7 +98,7 @@ static struct vdo_completion *poll_for_completion(struct simple_work_queue *queu
int i; int i;
for (i = queue->common.type->max_priority; i >= 0; i--) { for (i = queue->common.type->max_priority; i >= 0; i--) {
struct funnel_queue_entry *link = uds_funnel_queue_poll(queue->priority_lists[i]); struct funnel_queue_entry *link = vdo_funnel_queue_poll(queue->priority_lists[i]);
if (link != NULL) if (link != NULL)
return container_of(link, struct vdo_completion, work_queue_entry_link); return container_of(link, struct vdo_completion, work_queue_entry_link);
...@@ -123,7 +123,7 @@ static void enqueue_work_queue_completion(struct simple_work_queue *queue, ...@@ -123,7 +123,7 @@ static void enqueue_work_queue_completion(struct simple_work_queue *queue,
completion->my_queue = &queue->common; completion->my_queue = &queue->common;
/* Funnel queue handles the synchronization for the put. */ /* Funnel queue handles the synchronization for the put. */
uds_funnel_queue_put(queue->priority_lists[completion->priority], vdo_funnel_queue_put(queue->priority_lists[completion->priority],
&completion->work_queue_entry_link); &completion->work_queue_entry_link);
/* /*
...@@ -275,7 +275,7 @@ static void free_simple_work_queue(struct simple_work_queue *queue) ...@@ -275,7 +275,7 @@ static void free_simple_work_queue(struct simple_work_queue *queue)
unsigned int i; unsigned int i;
for (i = 0; i <= VDO_WORK_Q_MAX_PRIORITY; i++) for (i = 0; i <= VDO_WORK_Q_MAX_PRIORITY; i++)
uds_free_funnel_queue(queue->priority_lists[i]); vdo_free_funnel_queue(queue->priority_lists[i]);
vdo_free(queue->common.name); vdo_free(queue->common.name);
vdo_free(queue); vdo_free(queue);
} }
...@@ -340,8 +340,8 @@ static int make_simple_work_queue(const char *thread_name_prefix, const char *na ...@@ -340,8 +340,8 @@ static int make_simple_work_queue(const char *thread_name_prefix, const char *na
} }
for (i = 0; i <= type->max_priority; i++) { for (i = 0; i <= type->max_priority; i++) {
result = uds_make_funnel_queue(&queue->priority_lists[i]); result = vdo_make_funnel_queue(&queue->priority_lists[i]);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
free_simple_work_queue(queue); free_simple_work_queue(queue);
return result; return result;
} }
......
...@@ -69,11 +69,11 @@ static inline struct uds_request *poll_queues(struct uds_request_queue *queue) ...@@ -69,11 +69,11 @@ static inline struct uds_request *poll_queues(struct uds_request_queue *queue)
{ {
struct funnel_queue_entry *entry; struct funnel_queue_entry *entry;
entry = uds_funnel_queue_poll(queue->retry_queue); entry = vdo_funnel_queue_poll(queue->retry_queue);
if (entry != NULL) if (entry != NULL)
return container_of(entry, struct uds_request, queue_link); return container_of(entry, struct uds_request, queue_link);
entry = uds_funnel_queue_poll(queue->main_queue); entry = vdo_funnel_queue_poll(queue->main_queue);
if (entry != NULL) if (entry != NULL)
return container_of(entry, struct uds_request, queue_link); return container_of(entry, struct uds_request, queue_link);
...@@ -82,8 +82,8 @@ static inline struct uds_request *poll_queues(struct uds_request_queue *queue) ...@@ -82,8 +82,8 @@ static inline struct uds_request *poll_queues(struct uds_request_queue *queue)
static inline bool are_queues_idle(struct uds_request_queue *queue) static inline bool are_queues_idle(struct uds_request_queue *queue)
{ {
return uds_is_funnel_queue_idle(queue->retry_queue) && return vdo_is_funnel_queue_idle(queue->retry_queue) &&
uds_is_funnel_queue_idle(queue->main_queue); vdo_is_funnel_queue_idle(queue->main_queue);
} }
/* /*
...@@ -207,14 +207,14 @@ int uds_make_request_queue(const char *queue_name, ...@@ -207,14 +207,14 @@ int uds_make_request_queue(const char *queue_name,
atomic_set(&queue->dormant, false); atomic_set(&queue->dormant, false);
init_waitqueue_head(&queue->wait_head); init_waitqueue_head(&queue->wait_head);
result = uds_make_funnel_queue(&queue->main_queue); result = vdo_make_funnel_queue(&queue->main_queue);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
uds_request_queue_finish(queue); uds_request_queue_finish(queue);
return result; return result;
} }
result = uds_make_funnel_queue(&queue->retry_queue); result = vdo_make_funnel_queue(&queue->retry_queue);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
uds_request_queue_finish(queue); uds_request_queue_finish(queue);
return result; return result;
} }
...@@ -244,7 +244,7 @@ void uds_request_queue_enqueue(struct uds_request_queue *queue, ...@@ -244,7 +244,7 @@ void uds_request_queue_enqueue(struct uds_request_queue *queue,
bool unbatched = request->unbatched; bool unbatched = request->unbatched;
sub_queue = request->requeued ? queue->retry_queue : queue->main_queue; sub_queue = request->requeued ? queue->retry_queue : queue->main_queue;
uds_funnel_queue_put(sub_queue, &request->queue_link); vdo_funnel_queue_put(sub_queue, &request->queue_link);
/* /*
* We must wake the worker thread when it is dormant. A read fence isn't needed here since * We must wake the worker thread when it is dormant. A read fence isn't needed here since
...@@ -273,7 +273,7 @@ void uds_request_queue_finish(struct uds_request_queue *queue) ...@@ -273,7 +273,7 @@ void uds_request_queue_finish(struct uds_request_queue *queue)
vdo_join_threads(queue->thread); vdo_join_threads(queue->thread);
} }
uds_free_funnel_queue(queue->main_queue); vdo_free_funnel_queue(queue->main_queue);
uds_free_funnel_queue(queue->retry_queue); vdo_free_funnel_queue(queue->retry_queue);
vdo_free(queue); vdo_free(queue);
} }
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