[PATCH 10/13] dm vdo thread-utils: further cleanup of thread functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mike Snitzer <snitzer@xxxxxxxxxx>

Change thread function prefix from "uds_" to "vdo_" and fix
vdo_join_threads() to return void.

Signed-off-by: Mike Snitzer <snitzer@xxxxxxxxxx>
Signed-off-by: Matthew Sakai <msakai@xxxxxxxxxx>
---
 drivers/md/dm-vdo/funnel-requestqueue.c | 8 ++------
 drivers/md/dm-vdo/index.c               | 4 ++--
 drivers/md/dm-vdo/status-codes.c        | 2 +-
 drivers/md/dm-vdo/thread-utils.c        | 9 ++++-----
 drivers/md/dm-vdo/thread-utils.h        | 9 ++++-----
 drivers/md/dm-vdo/volume.c              | 4 ++--
 6 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/drivers/md/dm-vdo/funnel-requestqueue.c b/drivers/md/dm-vdo/funnel-requestqueue.c
index e7a3a4962295..d2b49e39550c 100644
--- a/drivers/md/dm-vdo/funnel-requestqueue.c
+++ b/drivers/md/dm-vdo/funnel-requestqueue.c
@@ -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);
diff --git a/drivers/md/dm-vdo/index.c b/drivers/md/dm-vdo/index.c
index 5c9906e73c84..9d4a8e5cbaad 100644
--- a/drivers/md/dm-vdo/index.c
+++ b/drivers/md/dm-vdo/index.c
@@ -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;
diff --git a/drivers/md/dm-vdo/status-codes.c b/drivers/md/dm-vdo/status-codes.c
index d77bc5e4a99a..efba1ead0aca 100644
--- a/drivers/md/dm-vdo/status-codes.c
+++ b/drivers/md/dm-vdo/status-codes.c
@@ -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;
 }
 
diff --git a/drivers/md/dm-vdo/thread-utils.c b/drivers/md/dm-vdo/thread-utils.c
index 30760b1c4d30..0b80247c7f1b 100644
--- a/drivers/md/dm-vdo/thread-utils.c
+++ b/drivers/md/dm-vdo/thread-utils.c
@@ -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;
 }
diff --git a/drivers/md/dm-vdo/thread-utils.h b/drivers/md/dm-vdo/thread-utils.h
index 8b55f0d1ab80..ebe032e066ff 100644
--- a/drivers/md/dm-vdo/thread-utils.h
+++ b/drivers/md/dm-vdo/thread-utils.h
@@ -14,16 +14,15 @@
 
 #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 */
diff --git a/drivers/md/dm-vdo/volume.c b/drivers/md/dm-vdo/volume.c
index 0fb06fd315ef..37c2ef0777e5 100644
--- a/drivers/md/dm-vdo/volume.c
+++ b/drivers/md/dm-vdo/volume.c
@@ -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;
 	}
-- 
2.42.0





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux