Commit 650e3107 authored by Mike Snitzer's avatar Mike Snitzer

dm vdo thread-utils: further cleanup of thread functions

Change thread function prefix from "uds_" to "vdo_" and fix
vdo_join_threads() to return void.
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
Signed-off-by: default avatarMatthew Sakai <msakai@redhat.com>
parent fe6e4ccb
...@@ -219,7 +219,7 @@ int uds_make_request_queue(const char *queue_name, ...@@ -219,7 +219,7 @@ int uds_make_request_queue(const char *queue_name,
return result; return result;
} }
result = uds_create_thread(request_queue_worker, queue, queue_name, result = vdo_create_thread(request_queue_worker, queue, queue_name,
&queue->thread); &queue->thread);
if (result != UDS_SUCCESS) { if (result != UDS_SUCCESS) {
uds_request_queue_finish(queue); uds_request_queue_finish(queue);
...@@ -256,8 +256,6 @@ void uds_request_queue_enqueue(struct uds_request_queue *queue, ...@@ -256,8 +256,6 @@ void uds_request_queue_enqueue(struct uds_request_queue *queue,
void uds_request_queue_finish(struct uds_request_queue *queue) void uds_request_queue_finish(struct uds_request_queue *queue)
{ {
int result;
if (queue == NULL) if (queue == NULL)
return; return;
...@@ -272,9 +270,7 @@ void uds_request_queue_finish(struct uds_request_queue *queue) ...@@ -272,9 +270,7 @@ void uds_request_queue_finish(struct uds_request_queue *queue)
if (queue->started) { if (queue->started) {
wake_up_worker(queue); wake_up_worker(queue);
result = uds_join_threads(queue->thread); vdo_join_threads(queue->thread);
if (result != UDS_SUCCESS)
uds_log_warning_strerror(result, "Failed to join worker thread");
} }
uds_free_funnel_queue(queue->main_queue); uds_free_funnel_queue(queue->main_queue);
......
...@@ -744,7 +744,7 @@ static void stop_chapter_writer(struct chapter_writer *writer) ...@@ -744,7 +744,7 @@ static void stop_chapter_writer(struct chapter_writer *writer)
mutex_unlock(&writer->mutex); mutex_unlock(&writer->mutex);
if (writer_thread != NULL) if (writer_thread != NULL)
uds_join_threads(writer_thread); vdo_join_threads(writer_thread);
} }
static void free_chapter_writer(struct chapter_writer *writer) static void free_chapter_writer(struct chapter_writer *writer)
...@@ -796,7 +796,7 @@ static int make_chapter_writer(struct uds_index *index, ...@@ -796,7 +796,7 @@ static int make_chapter_writer(struct uds_index *index,
collated_records_size + collated_records_size +
writer->open_chapter_index->memory_size); writer->open_chapter_index->memory_size);
result = uds_create_thread(close_chapters, writer, "writer", &writer->thread); result = vdo_create_thread(close_chapters, writer, "writer", &writer->thread);
if (result != UDS_SUCCESS) { if (result != UDS_SUCCESS) {
free_chapter_writer(writer); free_chapter_writer(writer);
return result; return result;
......
...@@ -82,7 +82,7 @@ static void do_status_code_registration(void) ...@@ -82,7 +82,7 @@ static void do_status_code_registration(void)
*/ */
int vdo_register_status_codes(void) int vdo_register_status_codes(void)
{ {
uds_perform_once(&vdo_status_codes_registered, do_status_code_registration); vdo_perform_once(&vdo_status_codes_registered, do_status_code_registration);
return status_code_registration_result; return status_code_registration_result;
} }
......
...@@ -33,7 +33,7 @@ enum { ...@@ -33,7 +33,7 @@ enum {
}; };
/* Run a function once only, and record that fact in the atomic value. */ /* Run a function once only, and record that fact in the atomic value. */
void uds_perform_once(atomic_t *once, void (*function)(void)) void vdo_perform_once(atomic_t *once, void (*function)(void))
{ {
for (;;) { for (;;) {
switch (atomic_cmpxchg(once, ONCE_NOT_DONE, ONCE_IN_PROGRESS)) { switch (atomic_cmpxchg(once, ONCE_NOT_DONE, ONCE_IN_PROGRESS)) {
...@@ -63,7 +63,7 @@ static int thread_starter(void *arg) ...@@ -63,7 +63,7 @@ static int thread_starter(void *arg)
struct thread *thread = arg; struct thread *thread = arg;
thread->thread_task = current; thread->thread_task = current;
uds_perform_once(&thread_once, thread_init); vdo_perform_once(&thread_once, thread_init);
mutex_lock(&thread_mutex); mutex_lock(&thread_mutex);
hlist_add_head(&thread->thread_links, &thread_list); hlist_add_head(&thread->thread_links, &thread_list);
mutex_unlock(&thread_mutex); mutex_unlock(&thread_mutex);
...@@ -74,7 +74,7 @@ static int thread_starter(void *arg) ...@@ -74,7 +74,7 @@ static int thread_starter(void *arg)
return 0; return 0;
} }
int uds_create_thread(void (*thread_function)(void *), void *thread_data, int vdo_create_thread(void (*thread_function)(void *), void *thread_data,
const char *name, struct thread **new_thread) const char *name, struct thread **new_thread)
{ {
char *name_colon = strchr(name, ':'); char *name_colon = strchr(name, ':');
...@@ -123,7 +123,7 @@ int uds_create_thread(void (*thread_function)(void *), void *thread_data, ...@@ -123,7 +123,7 @@ int uds_create_thread(void (*thread_function)(void *), void *thread_data,
return UDS_SUCCESS; return UDS_SUCCESS;
} }
int uds_join_threads(struct thread *thread) void vdo_join_threads(struct thread *thread)
{ {
while (wait_for_completion_interruptible(&thread->thread_done)) while (wait_for_completion_interruptible(&thread->thread_done))
fsleep(1000); fsleep(1000);
...@@ -132,5 +132,4 @@ int uds_join_threads(struct thread *thread) ...@@ -132,5 +132,4 @@ int uds_join_threads(struct thread *thread)
hlist_del(&thread->thread_links); hlist_del(&thread->thread_links);
mutex_unlock(&thread_mutex); mutex_unlock(&thread_mutex);
uds_free(thread); uds_free(thread);
return UDS_SUCCESS;
} }
...@@ -14,16 +14,15 @@ ...@@ -14,16 +14,15 @@
#include "errors.h" #include "errors.h"
/* Thread and synchronization utilities for UDS */ /* Thread and synchronization utilities */
struct thread; struct thread;
int __must_check uds_create_thread(void (*thread_function)(void *), void *thread_data, int __must_check vdo_create_thread(void (*thread_function)(void *), void *thread_data,
const char *name, struct thread **new_thread); const char *name, struct thread **new_thread);
void vdo_join_threads(struct thread *thread);
void uds_perform_once(atomic_t *once_state, void (*function) (void)); void vdo_perform_once(atomic_t *once_state, void (*function) (void));
int uds_join_threads(struct thread *thread);
#endif /* UDS_THREADS_H */ #endif /* UDS_THREADS_H */
...@@ -1633,7 +1633,7 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layout ...@@ -1633,7 +1633,7 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layout
} }
for (i = 0; i < config->read_threads; i++) { for (i = 0; i < config->read_threads; i++) {
result = uds_create_thread(read_thread_function, (void *) volume, result = vdo_create_thread(read_thread_function, (void *) volume,
"reader", &volume->reader_threads[i]); "reader", &volume->reader_threads[i]);
if (result != UDS_SUCCESS) { if (result != UDS_SUCCESS) {
uds_free_volume(volume); uds_free_volume(volume);
...@@ -1675,7 +1675,7 @@ void uds_free_volume(struct volume *volume) ...@@ -1675,7 +1675,7 @@ void uds_free_volume(struct volume *volume)
uds_broadcast_cond(&volume->read_threads_cond); uds_broadcast_cond(&volume->read_threads_cond);
mutex_unlock(&volume->read_threads_mutex); mutex_unlock(&volume->read_threads_mutex);
for (i = 0; i < volume->read_thread_count; i++) for (i = 0; i < volume->read_thread_count; i++)
uds_join_threads(volume->reader_threads[i]); vdo_join_threads(volume->reader_threads[i]);
uds_free(volume->reader_threads); uds_free(volume->reader_threads);
volume->reader_threads = NULL; volume->reader_threads = NULL;
} }
......
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