dm vdo thread-utils: further cleanup of thread functions
authorMike Snitzer <snitzer@kernel.org>
Fri, 9 Feb 2024 18:08:09 +0000 (12:08 -0600)
committerMike Snitzer <snitzer@kernel.org>
Fri, 1 Mar 2024 14:26:07 +0000 (09:26 -0500)
Change thread function prefix from "uds_" to "vdo_" and fix
vdo_join_threads() to return void.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
drivers/md/dm-vdo/funnel-requestqueue.c
drivers/md/dm-vdo/index.c
drivers/md/dm-vdo/status-codes.c
drivers/md/dm-vdo/thread-utils.c
drivers/md/dm-vdo/thread-utils.h
drivers/md/dm-vdo/volume.c

index e7a3a49622959bbd871d7e0a4d26bcd62b07ff87..d2b49e39550c91ce8c37b1d47440453c47d7482e 100644 (file)
@@ -219,7 +219,7 @@ int uds_make_request_queue(const char *queue_name,
                return result;
        }
 
-       result = uds_create_thread(request_queue_worker, queue, queue_name,
+       result = vdo_create_thread(request_queue_worker, queue, queue_name,
                                   &queue->thread);
        if (result != UDS_SUCCESS) {
                uds_request_queue_finish(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)
 {
-       int result;
-
        if (queue == NULL)
                return;
 
@@ -272,9 +270,7 @@ void uds_request_queue_finish(struct uds_request_queue *queue)
 
        if (queue->started) {
                wake_up_worker(queue);
-               result = uds_join_threads(queue->thread);
-               if (result != UDS_SUCCESS)
-                       uds_log_warning_strerror(result, "Failed to join worker thread");
+               vdo_join_threads(queue->thread);
        }
 
        uds_free_funnel_queue(queue->main_queue);
index 5c9906e73c841b234013eebdc9d641eac5df70d1..9d4a8e5cbaadbd36dac09f9a1ef0bbb90b99e250 100644 (file)
@@ -744,7 +744,7 @@ static void stop_chapter_writer(struct chapter_writer *writer)
        mutex_unlock(&writer->mutex);
 
        if (writer_thread != NULL)
-               uds_join_threads(writer_thread);
+               vdo_join_threads(writer_thread);
 }
 
 static void free_chapter_writer(struct chapter_writer *writer)
@@ -796,7 +796,7 @@ static int make_chapter_writer(struct uds_index *index,
                               collated_records_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) {
                free_chapter_writer(writer);
                return result;
index d77bc5e4a99a3f61ed222d9198f9e50308981d2a..efba1ead0acaef53b3c50a7847961bea1888bdd9 100644 (file)
@@ -82,7 +82,7 @@ static void do_status_code_registration(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;
 }
 
index 30760b1c4d30e74558636b8b060f8848a873dcc1..0b80247c7f1b02ed2dbf6bc82189877de88b9421 100644 (file)
@@ -33,7 +33,7 @@ enum {
 };
 
 /* 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 (;;) {
                switch (atomic_cmpxchg(once, ONCE_NOT_DONE, ONCE_IN_PROGRESS)) {
@@ -63,7 +63,7 @@ static int thread_starter(void *arg)
        struct thread *thread = arg;
 
        thread->thread_task = current;
-       uds_perform_once(&thread_once, thread_init);
+       vdo_perform_once(&thread_once, thread_init);
        mutex_lock(&thread_mutex);
        hlist_add_head(&thread->thread_links, &thread_list);
        mutex_unlock(&thread_mutex);
@@ -74,7 +74,7 @@ static int thread_starter(void *arg)
        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)
 {
        char *name_colon = strchr(name, ':');
@@ -123,7 +123,7 @@ int uds_create_thread(void (*thread_function)(void *), void *thread_data,
        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))
                fsleep(1000);
@@ -132,5 +132,4 @@ int uds_join_threads(struct thread *thread)
        hlist_del(&thread->thread_links);
        mutex_unlock(&thread_mutex);
        uds_free(thread);
-       return UDS_SUCCESS;
 }
index 8b55f0d1ab802d566b8d87ff61a05bf3eb57cd8e..ebe032e066ff883450e2a0089260d899c0756cd1 100644 (file)
 
 #include "errors.h"
 
-/* Thread and synchronization utilities for UDS */
+/* Thread and synchronization utilities */
 
 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);
+void vdo_join_threads(struct thread *thread);
 
-void uds_perform_once(atomic_t *once_state, void (*function) (void));
-
-int uds_join_threads(struct thread *thread);
+void vdo_perform_once(atomic_t *once_state, void (*function) (void));
 
 #endif /* UDS_THREADS_H */
index 0fb06fd315effd182f6ea7cf3b36f488f0ce7fc5..37c2ef0777e5d5e52cb2e80bb2671315f71cd824 100644 (file)
@@ -1633,7 +1633,7 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layout
        }
 
        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]);
                if (result != UDS_SUCCESS) {
                        uds_free_volume(volume);
@@ -1675,7 +1675,7 @@ void uds_free_volume(struct volume *volume)
                uds_broadcast_cond(&volume->read_threads_cond);
                mutex_unlock(&volume->read_threads_mutex);
                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);
                volume->reader_threads = NULL;
        }