@@ -230,36 +230,21 @@ static int __must_check make_empty_index_session(struct uds_index_session **inde
return result;
}
- result = uds_init_cond(&session->request_cond);
- if (result != UDS_SUCCESS) {
- uds_destroy_mutex(&session->request_mutex);
- uds_free(session);
- return result;
- }
+ uds_init_cond(&session->request_cond);
result = uds_init_mutex(&session->load_context.mutex);
if (result != UDS_SUCCESS) {
- uds_destroy_cond(&session->request_cond);
uds_destroy_mutex(&session->request_mutex);
uds_free(session);
return result;
}
- result = uds_init_cond(&session->load_context.cond);
- if (result != UDS_SUCCESS) {
- uds_destroy_mutex(&session->load_context.mutex);
- uds_destroy_cond(&session->request_cond);
- uds_destroy_mutex(&session->request_mutex);
- uds_free(session);
- return result;
- }
+ uds_init_cond(&session->load_context.cond);
result = uds_make_request_queue("callbackW", &handle_callbacks,
&session->callback_queue);
if (result != UDS_SUCCESS) {
- uds_destroy_cond(&session->load_context.cond);
uds_destroy_mutex(&session->load_context.mutex);
- uds_destroy_cond(&session->request_cond);
uds_destroy_mutex(&session->request_mutex);
uds_free(session);
return result;
@@ -700,9 +685,7 @@ int uds_destroy_index_session(struct uds_index_session *index_session)
result = save_and_free_index(index_session);
uds_request_queue_finish(index_session->callback_queue);
index_session->callback_queue = NULL;
- uds_destroy_cond(&index_session->load_context.cond);
uds_destroy_mutex(&index_session->load_context.mutex);
- uds_destroy_cond(&index_session->request_cond);
uds_destroy_mutex(&index_session->request_mutex);
uds_log_debug("Destroyed index session");
uds_free(index_session);
@@ -758,3 +741,14 @@ int uds_get_index_session_stats(struct uds_index_session *index_session,
return UDS_SUCCESS;
}
+
+void uds_wait_cond(struct cond_var *cv, struct mutex *mutex)
+{
+ DEFINE_WAIT(__wait);
+
+ prepare_to_wait(&cv->wait_queue, &__wait, TASK_IDLE);
+ uds_unlock_mutex(mutex);
+ schedule();
+ finish_wait(&cv->wait_queue, &__wait);
+ uds_lock_mutex(mutex);
+}
@@ -754,7 +754,6 @@ static void free_chapter_writer(struct chapter_writer *writer)
stop_chapter_writer(writer);
uds_destroy_mutex(&writer->mutex);
- uds_destroy_cond(&writer->cond);
uds_free_open_chapter_index(writer->open_chapter_index);
uds_free(writer->collated_records);
uds_free(writer);
@@ -781,12 +780,7 @@ static int make_chapter_writer(struct uds_index *index,
return result;
}
- result = uds_init_cond(&writer->cond);
- if (result != UDS_SUCCESS) {
- uds_destroy_mutex(&writer->mutex);
- uds_free(writer);
- return result;
- }
+ uds_init_cond(&writer->cond);
result = uds_allocate_cache_aligned(collated_records_size, "collated records",
&writer->collated_records);
@@ -6,7 +6,10 @@
#ifndef INDEXER_H
#define INDEXER_H
+#include <linux/mutex.h>
+#include <linux/sched.h>
#include <linux/types.h>
+#include <linux/wait.h>
#include "funnel-queue.h"
@@ -326,4 +329,25 @@ int __must_check uds_get_index_session_stats(struct uds_index_session *session,
/* This function will fail if any required field of the request is not set. */
int __must_check uds_launch_request(struct uds_request *request);
+struct cond_var {
+ wait_queue_head_t wait_queue;
+};
+
+static inline void uds_init_cond(struct cond_var *cv)
+{
+ init_waitqueue_head(&cv->wait_queue);
+}
+
+static inline void uds_signal_cond(struct cond_var *cv)
+{
+ wake_up(&cv->wait_queue);
+}
+
+static inline void uds_broadcast_cond(struct cond_var *cv)
+{
+ wake_up_all(&cv->wait_queue);
+}
+
+void uds_wait_cond(struct cond_var *cv, struct mutex *mutex);
+
#endif /* INDEXER_H */
@@ -9,7 +9,6 @@
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/kthread.h>
-#include <linux/sched.h>
#include "errors.h"
#include "logger.h"
@@ -135,14 +134,3 @@ int uds_join_threads(struct thread *thread)
uds_free(thread);
return UDS_SUCCESS;
}
-
-void uds_wait_cond(struct cond_var *cv, struct mutex *mutex)
-{
- DEFINE_WAIT(__wait);
-
- prepare_to_wait(&cv->wait_queue, &__wait, TASK_IDLE);
- uds_unlock_mutex(mutex);
- schedule();
- finish_wait(&cv->wait_queue, &__wait);
- uds_lock_mutex(mutex);
-}
@@ -11,16 +11,11 @@
#include <linux/jiffies.h>
#include <linux/mutex.h>
#include <linux/semaphore.h>
-#include <linux/wait.h>
#include "errors.h"
/* Thread and synchronization utilities for UDS */
-struct cond_var {
- wait_queue_head_t wait_queue;
-};
-
struct thread;
@@ -31,30 +26,8 @@ void uds_perform_once(atomic_t *once_state, void (*function) (void));
int uds_join_threads(struct thread *thread);
-static inline int __must_check uds_init_cond(struct cond_var *cv)
-{
- init_waitqueue_head(&cv->wait_queue);
- return UDS_SUCCESS;
-}
-
-static inline void uds_signal_cond(struct cond_var *cv)
-{
- wake_up(&cv->wait_queue);
-}
-
-static inline void uds_broadcast_cond(struct cond_var *cv)
-{
- wake_up_all(&cv->wait_queue);
-}
-
-void uds_wait_cond(struct cond_var *cv, struct mutex *mutex);
-
/* FIXME: all below wrappers should be removed! */
-static inline void uds_destroy_cond(struct cond_var *cv)
-{
-}
-
static inline int __must_check uds_init_mutex(struct mutex *mutex)
{
mutex_init(mutex);
@@ -76,5 +49,4 @@ static inline void uds_unlock_mutex(struct mutex *mutex)
mutex_unlock(mutex);
}
-
#endif /* UDS_THREADS_H */
@@ -1627,17 +1627,8 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layout
return result;
}
- result = uds_init_cond(&volume->read_threads_read_done_cond);
- if (result != UDS_SUCCESS) {
- uds_free_volume(volume);
- return result;
- }
-
- result = uds_init_cond(&volume->read_threads_cond);
- if (result != UDS_SUCCESS) {
- uds_free_volume(volume);
- return result;
- }
+ uds_init_cond(&volume->read_threads_read_done_cond);
+ uds_init_cond(&volume->read_threads_cond);
result = uds_allocate(config->read_threads, struct thread *, "reader threads",
&volume->reader_threads);
@@ -1700,8 +1691,6 @@ void uds_free_volume(struct volume *volume)
if (volume->client != NULL)
dm_bufio_client_destroy(uds_forget(volume->client));
- uds_destroy_cond(&volume->read_threads_cond);
- uds_destroy_cond(&volume->read_threads_read_done_cond);
uds_destroy_mutex(&volume->read_threads_mutex);
uds_free_index_page_map(volume->index_page_map);
uds_free_radix_sorter(volume->radix_sorter);