* [PATCH 00/13] dm vdo: clean up and simplify thread utilities
@ 2024-03-01 3:52 Matthew Sakai
2024-03-01 3:52 ` [PATCH 01/13] dm vdo: make uds_*_semaphore interface private to uds-threads.c Matthew Sakai
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:52 UTC (permalink / raw
To: dm-devel; +Cc: Matthew Sakai
Rename uds-threads to thread-utils, and simplify thread and
synchronization utilities. Move some utilities closer to their
only users.
Mike Snitzer (13):
dm vdo: make uds_*_semaphore interface private to uds-threads.c
dm vdo uds-threads: eliminate uds_*_semaphore interfaces
dm vdo uds-threads: push 'barrier' down to sparse-cache
dm vdo indexer sparse-cache: cleanup threads_barrier code
dm vdo: rename uds-threads.[ch] to thread-utils.[ch]
dm vdo indexer: rename uds.h to indexer.h
dm vdo: fold thread-cond-var.c into thread-utils
dm vdo thread-utils: push uds_*_cond interface down to indexer
dm vdo thread-utils: remove all uds_*_mutex wrappers
dm vdo thread-utils: further cleanup of thread functions
dm vdo thread-utils: cleanup included headers
dm vdo thread-registry: rename all methods to reflect vdo-only use
dm vdo thread-device: rename all methods to reflect vdo-only use
drivers/md/dm-vdo/Makefile | 3 +-
drivers/md/dm-vdo/chapter-index.c | 2 +-
drivers/md/dm-vdo/config.c | 2 +-
drivers/md/dm-vdo/config.h | 2 +-
drivers/md/dm-vdo/data-vio.h | 2 +-
drivers/md/dm-vdo/dedupe.c | 2 +-
drivers/md/dm-vdo/dedupe.h | 2 +-
drivers/md/dm-vdo/delta-index.c | 2 +-
drivers/md/dm-vdo/dm-vdo-target.c | 30 ++--
drivers/md/dm-vdo/encodings.h | 2 +-
drivers/md/dm-vdo/funnel-queue.c | 1 -
drivers/md/dm-vdo/funnel-requestqueue.c | 10 +-
drivers/md/dm-vdo/funnel-requestqueue.h | 2 +-
drivers/md/dm-vdo/geometry.c | 2 +-
drivers/md/dm-vdo/geometry.h | 2 +-
drivers/md/dm-vdo/hash-utils.h | 2 +-
drivers/md/dm-vdo/index-layout.h | 2 +-
drivers/md/dm-vdo/index-page-map.c | 4 +-
drivers/md/dm-vdo/index-session.c | 138 ++++++++----------
drivers/md/dm-vdo/index-session.h | 4 +-
drivers/md/dm-vdo/index.c | 54 +++----
drivers/md/dm-vdo/{uds.h => indexer.h} | 30 +++-
drivers/md/dm-vdo/logger.c | 5 +-
drivers/md/dm-vdo/memory-alloc.c | 12 +-
drivers/md/dm-vdo/sparse-cache.c | 105 +++++++++----
drivers/md/dm-vdo/sparse-cache.h | 2 +-
drivers/md/dm-vdo/status-codes.c | 4 +-
drivers/md/dm-vdo/thread-cond-var.c | 46 ------
drivers/md/dm-vdo/thread-device.c | 18 +--
drivers/md/dm-vdo/thread-device.h | 14 +-
drivers/md/dm-vdo/thread-registry.c | 8 +-
drivers/md/dm-vdo/thread-registry.h | 14 +-
.../dm-vdo/{uds-threads.c => thread-utils.c} | 62 +-------
drivers/md/dm-vdo/thread-utils.h | 22 +++
drivers/md/dm-vdo/uds-sysfs.c | 2 +-
drivers/md/dm-vdo/uds-threads.h | 115 ---------------
drivers/md/dm-vdo/vdo.h | 2 +-
drivers/md/dm-vdo/volume-index.c | 44 +++---
drivers/md/dm-vdo/volume-index.h | 4 +-
drivers/md/dm-vdo/volume.c | 59 +++-----
drivers/md/dm-vdo/volume.h | 4 +-
41 files changed, 328 insertions(+), 514 deletions(-)
rename drivers/md/dm-vdo/{uds.h => indexer.h} (95%)
delete mode 100644 drivers/md/dm-vdo/thread-cond-var.c
rename drivers/md/dm-vdo/{uds-threads.c => thread-utils.c} (70%)
create mode 100644 drivers/md/dm-vdo/thread-utils.h
delete mode 100644 drivers/md/dm-vdo/uds-threads.h
--
2.42.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 01/13] dm vdo: make uds_*_semaphore interface private to uds-threads.c
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
@ 2024-03-01 3:52 ` Matthew Sakai
2024-03-01 3:52 ` [PATCH 02/13] dm vdo uds-threads: eliminate uds_*_semaphore interfaces Matthew Sakai
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:52 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/uds-threads.c | 39 +++++++++++++++++++++++++++++++++
drivers/md/dm-vdo/uds-threads.h | 37 -------------------------------
2 files changed, 39 insertions(+), 37 deletions(-)
diff --git a/drivers/md/dm-vdo/uds-threads.c b/drivers/md/dm-vdo/uds-threads.c
index 769c783e342a..33117f68cf36 100644
--- a/drivers/md/dm-vdo/uds-threads.c
+++ b/drivers/md/dm-vdo/uds-threads.c
@@ -136,10 +136,49 @@ int uds_join_threads(struct thread *thread)
return UDS_SUCCESS;
}
+static inline int __must_check uds_initialize_semaphore(struct semaphore *semaphore,
+ unsigned int value)
+{
+ sema_init(semaphore, value);
+ return UDS_SUCCESS;
+}
+
+static inline int uds_destroy_semaphore(struct semaphore *semaphore)
+{
+ return UDS_SUCCESS;
+}
+
+static inline void uds_acquire_semaphore(struct semaphore *semaphore)
+{
+ /*
+ * Do not use down(semaphore). Instead use down_interruptible so that
+ * we do not get 120 second stall messages in kern.log.
+ */
+ while (down_interruptible(semaphore) != 0) {
+ /*
+ * If we're called from a user-mode process (e.g., "dmsetup
+ * remove") while waiting for an operation that may take a
+ * while (e.g., UDS index save), and a signal is sent (SIGINT,
+ * SIGUSR2), then down_interruptible will not block. If that
+ * happens, sleep briefly to avoid keeping the CPU locked up in
+ * this loop. We could just call cond_resched, but then we'd
+ * still keep consuming CPU time slices and swamp other threads
+ * trying to do computational work. [VDO-4980]
+ */
+ fsleep(1000);
+ }
+}
+
+static inline void uds_release_semaphore(struct semaphore *semaphore)
+{
+ up(semaphore);
+}
+
int uds_initialize_barrier(struct barrier *barrier, unsigned int thread_count)
{
int result;
+ /* FIXME: must cleanup, uds_initialize_semaphore never fails! */
result = uds_initialize_semaphore(&barrier->mutex, 1);
if (result != UDS_SUCCESS)
return result;
diff --git a/drivers/md/dm-vdo/uds-threads.h b/drivers/md/dm-vdo/uds-threads.h
index 9f3bf7991383..b77a2d46da80 100644
--- a/drivers/md/dm-vdo/uds-threads.h
+++ b/drivers/md/dm-vdo/uds-threads.h
@@ -74,42 +74,5 @@ static inline void uds_unlock_mutex(struct mutex *mutex)
mutex_unlock(mutex);
}
-static inline int __must_check uds_initialize_semaphore(struct semaphore *semaphore,
- unsigned int value)
-{
- sema_init(semaphore, value);
- return UDS_SUCCESS;
-}
-
-static inline int uds_destroy_semaphore(struct semaphore *semaphore)
-{
- return UDS_SUCCESS;
-}
-
-static inline void uds_acquire_semaphore(struct semaphore *semaphore)
-{
- /*
- * Do not use down(semaphore). Instead use down_interruptible so that
- * we do not get 120 second stall messages in kern.log.
- */
- while (down_interruptible(semaphore) != 0) {
- /*
- * If we're called from a user-mode process (e.g., "dmsetup
- * remove") while waiting for an operation that may take a
- * while (e.g., UDS index save), and a signal is sent (SIGINT,
- * SIGUSR2), then down_interruptible will not block. If that
- * happens, sleep briefly to avoid keeping the CPU locked up in
- * this loop. We could just call cond_resched, but then we'd
- * still keep consuming CPU time slices and swamp other threads
- * trying to do computational work. [VDO-4980]
- */
- fsleep(1000);
- }
-}
-
-static inline void uds_release_semaphore(struct semaphore *semaphore)
-{
- up(semaphore);
-}
#endif /* UDS_THREADS_H */
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 02/13] dm vdo uds-threads: eliminate uds_*_semaphore interfaces
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
2024-03-01 3:52 ` [PATCH 01/13] dm vdo: make uds_*_semaphore interface private to uds-threads.c Matthew Sakai
@ 2024-03-01 3:52 ` Matthew Sakai
2024-03-01 3:52 ` [PATCH 03/13] dm vdo uds-threads: push 'barrier' down to sparse-cache Matthew Sakai
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:52 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
The implementation of thread 'barrier' data structure does not require
overdone private semaphore wrappers. Also rename the barrier
structure's 'mutex' member (a semaphore) to 'lock'.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/uds-threads.c | 55 ++++++++-------------------------
drivers/md/dm-vdo/uds-threads.h | 4 +--
2 files changed, 15 insertions(+), 44 deletions(-)
diff --git a/drivers/md/dm-vdo/uds-threads.c b/drivers/md/dm-vdo/uds-threads.c
index 33117f68cf36..af6c58eaf449 100644
--- a/drivers/md/dm-vdo/uds-threads.c
+++ b/drivers/md/dm-vdo/uds-threads.c
@@ -136,19 +136,7 @@ int uds_join_threads(struct thread *thread)
return UDS_SUCCESS;
}
-static inline int __must_check uds_initialize_semaphore(struct semaphore *semaphore,
- unsigned int value)
-{
- sema_init(semaphore, value);
- return UDS_SUCCESS;
-}
-
-static inline int uds_destroy_semaphore(struct semaphore *semaphore)
-{
- return UDS_SUCCESS;
-}
-
-static inline void uds_acquire_semaphore(struct semaphore *semaphore)
+static inline void __down(struct semaphore *semaphore)
{
/*
* Do not use down(semaphore). Instead use down_interruptible so that
@@ -169,53 +157,36 @@ static inline void uds_acquire_semaphore(struct semaphore *semaphore)
}
}
-static inline void uds_release_semaphore(struct semaphore *semaphore)
-{
- up(semaphore);
-}
-
int uds_initialize_barrier(struct barrier *barrier, unsigned int thread_count)
{
- int result;
-
- /* FIXME: must cleanup, uds_initialize_semaphore never fails! */
- result = uds_initialize_semaphore(&barrier->mutex, 1);
- if (result != UDS_SUCCESS)
- return result;
-
+ sema_init(&barrier->lock, 1);
barrier->arrived = 0;
barrier->thread_count = thread_count;
- return uds_initialize_semaphore(&barrier->wait, 0);
+ sema_init(&barrier->wait, 0);
+
+ return UDS_SUCCESS;
}
int uds_destroy_barrier(struct barrier *barrier)
{
- int result;
-
- result = uds_destroy_semaphore(&barrier->mutex);
- if (result != UDS_SUCCESS)
- return result;
-
- return uds_destroy_semaphore(&barrier->wait);
+ return UDS_SUCCESS;
}
int uds_enter_barrier(struct barrier *barrier)
{
- bool last_thread;
-
- uds_acquire_semaphore(&barrier->mutex);
- last_thread = (++barrier->arrived == barrier->thread_count);
- if (last_thread) {
+ __down(&barrier->lock);
+ if (++barrier->arrived == barrier->thread_count) {
+ /* last thread */
int i;
for (i = 1; i < barrier->thread_count; i++)
- uds_release_semaphore(&barrier->wait);
+ up(&barrier->wait);
barrier->arrived = 0;
- uds_release_semaphore(&barrier->mutex);
+ up(&barrier->lock);
} else {
- uds_release_semaphore(&barrier->mutex);
- uds_acquire_semaphore(&barrier->wait);
+ up(&barrier->lock);
+ __down(&barrier->wait);
}
return UDS_SUCCESS;
diff --git a/drivers/md/dm-vdo/uds-threads.h b/drivers/md/dm-vdo/uds-threads.h
index b77a2d46da80..e6fa32af1feb 100644
--- a/drivers/md/dm-vdo/uds-threads.h
+++ b/drivers/md/dm-vdo/uds-threads.h
@@ -25,8 +25,8 @@ struct cond_var {
struct thread;
struct barrier {
- /* Mutex for this barrier object */
- struct semaphore mutex;
+ /* Lock for this barrier object */
+ struct semaphore lock;
/* Semaphore for threads waiting at the barrier */
struct semaphore wait;
/* Number of threads which have arrived */
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 03/13] dm vdo uds-threads: push 'barrier' down to sparse-cache
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
2024-03-01 3:52 ` [PATCH 01/13] dm vdo: make uds_*_semaphore interface private to uds-threads.c Matthew Sakai
2024-03-01 3:52 ` [PATCH 02/13] dm vdo uds-threads: eliminate uds_*_semaphore interfaces Matthew Sakai
@ 2024-03-01 3:52 ` Matthew Sakai
2024-03-01 3:52 ` [PATCH 04/13] dm vdo indexer sparse-cache: cleanup threads_barrier code Matthew Sakai
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:52 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
The sparse-cache is the only user of the 'barrier' data structure,
so just move it private to it.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/sparse-cache.c | 69 +++++++++++++++++++++++++++++++-
drivers/md/dm-vdo/uds-threads.c | 56 --------------------------
drivers/md/dm-vdo/uds-threads.h | 15 -------
3 files changed, 68 insertions(+), 72 deletions(-)
diff --git a/drivers/md/dm-vdo/sparse-cache.c b/drivers/md/dm-vdo/sparse-cache.c
index 5b41c94f53fa..dcd5ef25b360 100644
--- a/drivers/md/dm-vdo/sparse-cache.c
+++ b/drivers/md/dm-vdo/sparse-cache.c
@@ -6,6 +6,7 @@
#include "sparse-cache.h"
#include <linux/cache.h>
+#include <linux/delay.h>
#include <linux/dm-bufio.h>
#include "chapter-index.h"
@@ -14,7 +15,6 @@
#include "logger.h"
#include "memory-alloc.h"
#include "permassert.h"
-#include "uds-threads.h"
/*
* Since the cache is small, it is implemented as a simple array of cache entries. Searching for a
@@ -141,6 +141,17 @@ struct search_list {
struct cached_chapter_index *entries[];
};
+struct barrier {
+ /* Lock for this barrier object */
+ struct semaphore lock;
+ /* Semaphore for threads waiting at this barrier */
+ struct semaphore wait;
+ /* Number of threads which have arrived */
+ int arrived;
+ /* Total number of threads using this barrier */
+ int thread_count;
+};
+
struct sparse_cache {
const struct index_geometry *geometry;
unsigned int capacity;
@@ -156,6 +167,62 @@ struct sparse_cache {
struct cached_chapter_index chapters[];
};
+static int uds_initialize_barrier(struct barrier *barrier, unsigned int thread_count)
+{
+ sema_init(&barrier->lock, 1);
+ barrier->arrived = 0;
+ barrier->thread_count = thread_count;
+ sema_init(&barrier->wait, 0);
+
+ return UDS_SUCCESS;
+}
+
+static int uds_destroy_barrier(struct barrier *barrier)
+{
+ return UDS_SUCCESS;
+}
+
+static inline void __down(struct semaphore *semaphore)
+{
+ /*
+ * Do not use down(semaphore). Instead use down_interruptible so that
+ * we do not get 120 second stall messages in kern.log.
+ */
+ while (down_interruptible(semaphore) != 0) {
+ /*
+ * If we're called from a user-mode process (e.g., "dmsetup
+ * remove") while waiting for an operation that may take a
+ * while (e.g., UDS index save), and a signal is sent (SIGINT,
+ * SIGUSR2), then down_interruptible will not block. If that
+ * happens, sleep briefly to avoid keeping the CPU locked up in
+ * this loop. We could just call cond_resched, but then we'd
+ * still keep consuming CPU time slices and swamp other threads
+ * trying to do computational work. [VDO-4980]
+ */
+ fsleep(1000);
+ }
+}
+
+static int uds_enter_barrier(struct barrier *barrier)
+{
+ __down(&barrier->lock);
+ if (++barrier->arrived == barrier->thread_count) {
+ /* last thread */
+ int i;
+
+ for (i = 1; i < barrier->thread_count; i++)
+ up(&barrier->wait);
+
+ barrier->arrived = 0;
+ up(&barrier->lock);
+ } else {
+ up(&barrier->lock);
+ __down(&barrier->wait);
+ }
+
+ return UDS_SUCCESS;
+}
+
static int __must_check initialize_cached_chapter_index(struct cached_chapter_index *chapter,
const struct index_geometry *geometry)
{
diff --git a/drivers/md/dm-vdo/uds-threads.c b/drivers/md/dm-vdo/uds-threads.c
index af6c58eaf449..3bfd22bae8b1 100644
--- a/drivers/md/dm-vdo/uds-threads.c
+++ b/drivers/md/dm-vdo/uds-threads.c
@@ -135,59 +135,3 @@ int uds_join_threads(struct thread *thread)
uds_free(thread);
return UDS_SUCCESS;
}
-
-static inline void __down(struct semaphore *semaphore)
-{
- /*
- * Do not use down(semaphore). Instead use down_interruptible so that
- * we do not get 120 second stall messages in kern.log.
- */
- while (down_interruptible(semaphore) != 0) {
- /*
- * If we're called from a user-mode process (e.g., "dmsetup
- * remove") while waiting for an operation that may take a
- * while (e.g., UDS index save), and a signal is sent (SIGINT,
- * SIGUSR2), then down_interruptible will not block. If that
- * happens, sleep briefly to avoid keeping the CPU locked up in
- * this loop. We could just call cond_resched, but then we'd
- * still keep consuming CPU time slices and swamp other threads
- * trying to do computational work. [VDO-4980]
- */
- fsleep(1000);
- }
-}
-
-int uds_initialize_barrier(struct barrier *barrier, unsigned int thread_count)
-{
- sema_init(&barrier->lock, 1);
- barrier->arrived = 0;
- barrier->thread_count = thread_count;
- sema_init(&barrier->wait, 0);
-
- return UDS_SUCCESS;
-}
-
-int uds_destroy_barrier(struct barrier *barrier)
-{
- return UDS_SUCCESS;
-}
-
-int uds_enter_barrier(struct barrier *barrier)
-{
- __down(&barrier->lock);
- if (++barrier->arrived == barrier->thread_count) {
- /* last thread */
- int i;
-
- for (i = 1; i < barrier->thread_count; i++)
- up(&barrier->wait);
-
- barrier->arrived = 0;
- up(&barrier->lock);
- } else {
- up(&barrier->lock);
- __down(&barrier->wait);
- }
-
- return UDS_SUCCESS;
-}
diff --git a/drivers/md/dm-vdo/uds-threads.h b/drivers/md/dm-vdo/uds-threads.h
index e6fa32af1feb..2a0580e4482b 100644
--- a/drivers/md/dm-vdo/uds-threads.h
+++ b/drivers/md/dm-vdo/uds-threads.h
@@ -24,16 +24,6 @@ struct cond_var {
struct thread;
-struct barrier {
- /* Lock for this barrier object */
- struct semaphore lock;
- /* Semaphore for threads waiting at the barrier */
- struct semaphore wait;
- /* Number of threads which have arrived */
- int arrived;
- /* Total number of threads using this barrier */
- int thread_count;
-};
int __must_check uds_create_thread(void (*thread_function)(void *), void *thread_data,
const char *name, struct thread **new_thread);
@@ -42,11 +32,6 @@ void uds_perform_once(atomic_t *once_state, void (*function) (void));
int uds_join_threads(struct thread *thread);
-int __must_check uds_initialize_barrier(struct barrier *barrier,
- unsigned int thread_count);
-int uds_destroy_barrier(struct barrier *barrier);
-int uds_enter_barrier(struct barrier *barrier);
-
int __must_check uds_init_cond(struct cond_var *cond);
int uds_signal_cond(struct cond_var *cond);
int uds_broadcast_cond(struct cond_var *cond);
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 04/13] dm vdo indexer sparse-cache: cleanup threads_barrier code
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
` (2 preceding siblings ...)
2024-03-01 3:52 ` [PATCH 03/13] dm vdo uds-threads: push 'barrier' down to sparse-cache Matthew Sakai
@ 2024-03-01 3:52 ` Matthew Sakai
2024-03-01 3:52 ` [PATCH 05/13] dm vdo: rename uds-threads.[ch] to thread-utils.[ch] Matthew Sakai
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:52 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Rename 'barrier' to 'threads_barrier', remove useless
uds_destroy_barrier(), return void from remaining methods and
clean up uds_make_sparse_cache() accordingly.
Also remove uds_ prefix from the 2 remaining threads_barrier
functions.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/sparse-cache.c | 60 ++++++++++----------------------
1 file changed, 19 insertions(+), 41 deletions(-)
diff --git a/drivers/md/dm-vdo/sparse-cache.c b/drivers/md/dm-vdo/sparse-cache.c
index dcd5ef25b360..216c8d6256a9 100644
--- a/drivers/md/dm-vdo/sparse-cache.c
+++ b/drivers/md/dm-vdo/sparse-cache.c
@@ -141,7 +141,7 @@ struct search_list {
struct cached_chapter_index *entries[];
};
-struct barrier {
+struct threads_barrier {
/* Lock for this barrier object */
struct semaphore lock;
/* Semaphore for threads waiting at this barrier */
@@ -161,25 +161,19 @@ struct sparse_cache {
struct search_list *search_lists[MAX_ZONES];
struct cached_chapter_index **scratch_entries;
- struct barrier begin_update_barrier;
- struct barrier end_update_barrier;
+ struct threads_barrier begin_update_barrier;
+ struct threads_barrier end_update_barrier;
struct cached_chapter_index chapters[];
};
-static int uds_initialize_barrier(struct barrier *barrier, unsigned int thread_count)
+static void initialize_threads_barrier(struct threads_barrier *barrier,
+ unsigned int thread_count)
{
sema_init(&barrier->lock, 1);
barrier->arrived = 0;
barrier->thread_count = thread_count;
sema_init(&barrier->wait, 0);
-
- return UDS_SUCCESS;
-}
-
-static int uds_destroy_barrier(struct barrier *barrier)
-{
- return UDS_SUCCESS;
}
static inline void __down(struct semaphore *semaphore)
@@ -203,7 +197,7 @@ static inline void __down(struct semaphore *semaphore)
}
}
-static int uds_enter_barrier(struct barrier *barrier)
+static void enter_threads_barrier(struct threads_barrier *barrier)
{
__down(&barrier->lock);
if (++barrier->arrived == barrier->thread_count) {
@@ -219,8 +213,6 @@ static int uds_enter_barrier(struct barrier *barrier)
up(&barrier->lock);
__down(&barrier->wait);
}
-
- return UDS_SUCCESS;
}
static int __must_check initialize_cached_chapter_index(struct cached_chapter_index *chapter,
@@ -287,44 +279,32 @@ int uds_make_sparse_cache(const struct index_geometry *geometry, unsigned int ca
*/
cache->skip_threshold = (SKIP_SEARCH_THRESHOLD / zone_count);
- result = uds_initialize_barrier(&cache->begin_update_barrier, zone_count);
- if (result != UDS_SUCCESS) {
- uds_free_sparse_cache(cache);
- return result;
- }
-
- result = uds_initialize_barrier(&cache->end_update_barrier, zone_count);
- if (result != UDS_SUCCESS) {
- uds_free_sparse_cache(cache);
- return result;
- }
+ initialize_threads_barrier(&cache->begin_update_barrier, zone_count);
+ initialize_threads_barrier(&cache->end_update_barrier, zone_count);
for (i = 0; i < capacity; i++) {
result = initialize_cached_chapter_index(&cache->chapters[i], geometry);
- if (result != UDS_SUCCESS) {
- uds_free_sparse_cache(cache);
- return result;
- }
+ if (result != UDS_SUCCESS)
+ goto out;
}
for (i = 0; i < zone_count; i++) {
result = make_search_list(cache, &cache->search_lists[i]);
- if (result != UDS_SUCCESS) {
- uds_free_sparse_cache(cache);
- return result;
- }
+ if (result != UDS_SUCCESS)
+ goto out;
}
/* purge_search_list() needs some temporary lists for sorting. */
result = uds_allocate(capacity * 2, struct cached_chapter_index *,
"scratch entries", &cache->scratch_entries);
- if (result != UDS_SUCCESS) {
- uds_free_sparse_cache(cache);
- return result;
- }
+ if (result != UDS_SUCCESS)
+ goto out;
*cache_ptr = cache;
return UDS_SUCCESS;
+out:
+ uds_free_sparse_cache(cache);
+ return result;
}
static inline void set_skip_search(struct cached_chapter_index *chapter,
@@ -381,8 +361,6 @@ void uds_free_sparse_cache(struct sparse_cache *cache)
uds_free(cache->chapters[i].page_buffers);
}
- uds_destroy_barrier(&cache->begin_update_barrier);
- uds_destroy_barrier(&cache->end_update_barrier);
uds_free(cache);
}
@@ -525,7 +503,7 @@ int uds_update_sparse_cache(struct index_zone *zone, u64 virtual_chapter)
* Wait for every zone thread to reach its corresponding barrier request and invoke this
* function before starting to modify the cache.
*/
- uds_enter_barrier(&cache->begin_update_barrier);
+ enter_threads_barrier(&cache->begin_update_barrier);
/*
* This is the start of the critical section: the zone zero thread is captain, effectively
@@ -553,7 +531,7 @@ int uds_update_sparse_cache(struct index_zone *zone, u64 virtual_chapter)
/*
* This is the end of the critical section. All cache invariants must have been restored.
*/
- uds_enter_barrier(&cache->end_update_barrier);
+ enter_threads_barrier(&cache->end_update_barrier);
return result;
}
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 05/13] dm vdo: rename uds-threads.[ch] to thread-utils.[ch]
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
` (3 preceding siblings ...)
2024-03-01 3:52 ` [PATCH 04/13] dm vdo indexer sparse-cache: cleanup threads_barrier code Matthew Sakai
@ 2024-03-01 3:52 ` Matthew Sakai
2024-03-01 3:52 ` [PATCH 06/13] dm vdo indexer: rename uds.h to indexer.h Matthew Sakai
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:52 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/Makefile | 2 +-
drivers/md/dm-vdo/config.c | 2 +-
drivers/md/dm-vdo/funnel-requestqueue.c | 2 +-
drivers/md/dm-vdo/index-page-map.c | 2 +-
drivers/md/dm-vdo/index-session.h | 2 +-
drivers/md/dm-vdo/logger.c | 2 +-
drivers/md/dm-vdo/status-codes.c | 2 +-
drivers/md/dm-vdo/thread-cond-var.c | 2 +-
drivers/md/dm-vdo/{uds-threads.c => thread-utils.c} | 2 +-
drivers/md/dm-vdo/{uds-threads.h => thread-utils.h} | 5 ++---
drivers/md/dm-vdo/volume-index.c | 2 +-
drivers/md/dm-vdo/volume-index.h | 2 +-
drivers/md/dm-vdo/volume.c | 2 +-
drivers/md/dm-vdo/volume.h | 2 +-
14 files changed, 15 insertions(+), 16 deletions(-)
rename drivers/md/dm-vdo/{uds-threads.c => thread-utils.c} (99%)
rename drivers/md/dm-vdo/{uds-threads.h => thread-utils.h} (94%)
diff --git a/drivers/md/dm-vdo/Makefile b/drivers/md/dm-vdo/Makefile
index 8c06c3b969e3..be5020b81c47 100644
--- a/drivers/md/dm-vdo/Makefile
+++ b/drivers/md/dm-vdo/Makefile
@@ -51,8 +51,8 @@ dm-vdo-objs := \
thread-cond-var.o \
thread-device.o \
thread-registry.o \
+ thread-utils.o \
uds-sysfs.o \
- uds-threads.o \
vdo.o \
vio.o \
volume-index.o \
diff --git a/drivers/md/dm-vdo/config.c b/drivers/md/dm-vdo/config.c
index e9c7e9bdbce0..0bf315e7b5d1 100644
--- a/drivers/md/dm-vdo/config.c
+++ b/drivers/md/dm-vdo/config.c
@@ -9,7 +9,7 @@
#include "memory-alloc.h"
#include "numeric.h"
#include "string-utils.h"
-#include "uds-threads.h"
+#include "thread-utils.h"
static const u8 INDEX_CONFIG_MAGIC[] = "ALBIC";
static const u8 INDEX_CONFIG_VERSION_6_02[] = "06.02";
diff --git a/drivers/md/dm-vdo/funnel-requestqueue.c b/drivers/md/dm-vdo/funnel-requestqueue.c
index c8ba04c1089c..e7a3a4962295 100644
--- a/drivers/md/dm-vdo/funnel-requestqueue.c
+++ b/drivers/md/dm-vdo/funnel-requestqueue.c
@@ -12,7 +12,7 @@
#include "funnel-queue.h"
#include "logger.h"
#include "memory-alloc.h"
-#include "uds-threads.h"
+#include "thread-utils.h"
/*
* This queue will attempt to handle requests in reasonably sized batches instead of reacting
diff --git a/drivers/md/dm-vdo/index-page-map.c b/drivers/md/dm-vdo/index-page-map.c
index f3748a915c03..8441f86ef3a4 100644
--- a/drivers/md/dm-vdo/index-page-map.c
+++ b/drivers/md/dm-vdo/index-page-map.c
@@ -12,7 +12,7 @@
#include "numeric.h"
#include "permassert.h"
#include "string-utils.h"
-#include "uds-threads.h"
+#include "thread-utils.h"
#include "uds.h"
/*
diff --git a/drivers/md/dm-vdo/index-session.h b/drivers/md/dm-vdo/index-session.h
index c77ee021d510..62a9020dd9fa 100644
--- a/drivers/md/dm-vdo/index-session.h
+++ b/drivers/md/dm-vdo/index-session.h
@@ -10,7 +10,7 @@
#include <linux/cache.h>
#include "config.h"
-#include "uds-threads.h"
+#include "thread-utils.h"
#include "uds.h"
/*
diff --git a/drivers/md/dm-vdo/logger.c b/drivers/md/dm-vdo/logger.c
index 1efbf8d52f2c..ff1c570f81bf 100644
--- a/drivers/md/dm-vdo/logger.c
+++ b/drivers/md/dm-vdo/logger.c
@@ -12,7 +12,7 @@
#include <linux/sched.h>
#include "thread-device.h"
-#include "uds-threads.h"
+#include "thread-utils.h"
struct priority_name {
const char *name;
diff --git a/drivers/md/dm-vdo/status-codes.c b/drivers/md/dm-vdo/status-codes.c
index b4d7eb7f94ff..d77bc5e4a99a 100644
--- a/drivers/md/dm-vdo/status-codes.c
+++ b/drivers/md/dm-vdo/status-codes.c
@@ -8,7 +8,7 @@
#include "errors.h"
#include "logger.h"
#include "permassert.h"
-#include "uds-threads.h"
+#include "thread-utils.h"
const struct error_info vdo_status_list[] = {
{ "VDO_NOT_IMPLEMENTED", "Not implemented" },
diff --git a/drivers/md/dm-vdo/thread-cond-var.c b/drivers/md/dm-vdo/thread-cond-var.c
index ed7f0b79ca0a..82b80338b448 100644
--- a/drivers/md/dm-vdo/thread-cond-var.c
+++ b/drivers/md/dm-vdo/thread-cond-var.c
@@ -7,8 +7,8 @@
#include <linux/minmax.h>
#include "errors.h"
+#include "thread-utils.h"
#include "time-utils.h"
-#include "uds-threads.h"
int uds_init_cond(struct cond_var *cv)
{
diff --git a/drivers/md/dm-vdo/uds-threads.c b/drivers/md/dm-vdo/thread-utils.c
similarity index 99%
rename from drivers/md/dm-vdo/uds-threads.c
rename to drivers/md/dm-vdo/thread-utils.c
index 3bfd22bae8b1..1a1eb9ae9e33 100644
--- a/drivers/md/dm-vdo/uds-threads.c
+++ b/drivers/md/dm-vdo/thread-utils.c
@@ -3,7 +3,7 @@
* Copyright 2023 Red Hat
*/
-#include "uds-threads.h"
+#include "thread-utils.h"
#include <linux/completion.h>
#include <linux/delay.h>
diff --git a/drivers/md/dm-vdo/uds-threads.h b/drivers/md/dm-vdo/thread-utils.h
similarity index 94%
rename from drivers/md/dm-vdo/uds-threads.h
rename to drivers/md/dm-vdo/thread-utils.h
index 2a0580e4482b..30637dd264cc 100644
--- a/drivers/md/dm-vdo/uds-threads.h
+++ b/drivers/md/dm-vdo/thread-utils.h
@@ -3,8 +3,8 @@
* Copyright 2023 Red Hat
*/
-#ifndef UDS_THREADS_H
-#define UDS_THREADS_H
+#ifndef THREAD_UTILS_H
+#define THREAD_UTILS_H
#include <linux/atomic.h>
#include <linux/delay.h>
@@ -14,7 +14,6 @@
#include <linux/wait.h>
#include "errors.h"
-#include "time-utils.h"
/* Thread and synchronization utilities for UDS */
diff --git a/drivers/md/dm-vdo/volume-index.c b/drivers/md/dm-vdo/volume-index.c
index eebc19fe7d6f..daeafe7691ea 100644
--- a/drivers/md/dm-vdo/volume-index.c
+++ b/drivers/md/dm-vdo/volume-index.c
@@ -18,8 +18,8 @@
#include "memory-alloc.h"
#include "numeric.h"
#include "permassert.h"
+#include "thread-utils.h"
#include "uds.h"
-#include "uds-threads.h"
/*
* The volume index is a combination of two separate subindexes, one containing sparse hook entries
diff --git a/drivers/md/dm-vdo/volume-index.h b/drivers/md/dm-vdo/volume-index.h
index 537e9947cf4a..2eb2cee7ee58 100644
--- a/drivers/md/dm-vdo/volume-index.h
+++ b/drivers/md/dm-vdo/volume-index.h
@@ -10,8 +10,8 @@
#include "config.h"
#include "delta-index.h"
+#include "thread-utils.h"
#include "uds.h"
-#include "uds-threads.h"
/*
* The volume index is the primary top-level index for UDS. It contains records which map a record
diff --git a/drivers/md/dm-vdo/volume.c b/drivers/md/dm-vdo/volume.c
index 8bd64057c2ca..5b3cb5d89e47 100644
--- a/drivers/md/dm-vdo/volume.c
+++ b/drivers/md/dm-vdo/volume.c
@@ -20,7 +20,7 @@
#include "permassert.h"
#include "sparse-cache.h"
#include "string-utils.h"
-#include "uds-threads.h"
+#include "thread-utils.h"
/*
* The first block of the volume layout is reserved for the volume header, which is no longer used.
diff --git a/drivers/md/dm-vdo/volume.h b/drivers/md/dm-vdo/volume.h
index 066680282340..7ef9945d8403 100644
--- a/drivers/md/dm-vdo/volume.h
+++ b/drivers/md/dm-vdo/volume.h
@@ -19,8 +19,8 @@
#include "permassert.h"
#include "radix-sort.h"
#include "sparse-cache.h"
+#include "thread-utils.h"
#include "uds.h"
-#include "uds-threads.h"
/*
* The volume manages deduplication records on permanent storage. The term "volume" can also refer
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 06/13] dm vdo indexer: rename uds.h to indexer.h
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
` (4 preceding siblings ...)
2024-03-01 3:52 ` [PATCH 05/13] dm vdo: rename uds-threads.[ch] to thread-utils.[ch] Matthew Sakai
@ 2024-03-01 3:52 ` Matthew Sakai
2024-03-01 3:52 ` [PATCH 07/13] dm vdo: fold thread-cond-var.c into thread-utils Matthew Sakai
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:52 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Also remove unnecessary include from funnel-queue.c.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/chapter-index.c | 2 +-
drivers/md/dm-vdo/config.h | 2 +-
drivers/md/dm-vdo/data-vio.h | 2 +-
drivers/md/dm-vdo/dedupe.c | 2 +-
drivers/md/dm-vdo/dedupe.h | 2 +-
drivers/md/dm-vdo/delta-index.c | 2 +-
drivers/md/dm-vdo/encodings.h | 2 +-
drivers/md/dm-vdo/funnel-queue.c | 1 -
drivers/md/dm-vdo/funnel-requestqueue.h | 2 +-
drivers/md/dm-vdo/geometry.c | 2 +-
drivers/md/dm-vdo/geometry.h | 2 +-
drivers/md/dm-vdo/hash-utils.h | 2 +-
drivers/md/dm-vdo/index-layout.h | 2 +-
drivers/md/dm-vdo/index-page-map.c | 2 +-
drivers/md/dm-vdo/index-session.h | 2 +-
drivers/md/dm-vdo/{uds.h => indexer.h} | 6 +++---
drivers/md/dm-vdo/sparse-cache.h | 2 +-
drivers/md/dm-vdo/uds-sysfs.c | 2 +-
drivers/md/dm-vdo/vdo.h | 2 +-
drivers/md/dm-vdo/volume-index.c | 2 +-
drivers/md/dm-vdo/volume-index.h | 2 +-
drivers/md/dm-vdo/volume.h | 2 +-
22 files changed, 23 insertions(+), 24 deletions(-)
rename drivers/md/dm-vdo/{uds.h => indexer.h} (99%)
diff --git a/drivers/md/dm-vdo/chapter-index.c b/drivers/md/dm-vdo/chapter-index.c
index 363991d56218..9b9185c2c237 100644
--- a/drivers/md/dm-vdo/chapter-index.c
+++ b/drivers/md/dm-vdo/chapter-index.c
@@ -7,10 +7,10 @@
#include "errors.h"
#include "hash-utils.h"
+#include "indexer.h"
#include "logger.h"
#include "memory-alloc.h"
#include "permassert.h"
-#include "uds.h"
int uds_make_open_chapter_index(struct open_chapter_index **chapter_index,
const struct index_geometry *geometry, u64 volume_nonce)
diff --git a/drivers/md/dm-vdo/config.h b/drivers/md/dm-vdo/config.h
index 7d19863800d6..08507dc2f7a1 100644
--- a/drivers/md/dm-vdo/config.h
+++ b/drivers/md/dm-vdo/config.h
@@ -7,8 +7,8 @@
#define UDS_CONFIG_H
#include "geometry.h"
+#include "indexer.h"
#include "io-factory.h"
-#include "uds.h"
/*
* The uds_configuration records a variety of parameters used to configure a new UDS index. Some
diff --git a/drivers/md/dm-vdo/data-vio.h b/drivers/md/dm-vdo/data-vio.h
index 78744d064e96..e7729623a6bb 100644
--- a/drivers/md/dm-vdo/data-vio.h
+++ b/drivers/md/dm-vdo/data-vio.h
@@ -10,8 +10,8 @@
#include <linux/bio.h>
#include <linux/list.h>
+#include "indexer.h"
#include "permassert.h"
-#include "uds.h"
#include "block-map.h"
#include "completion.h"
diff --git a/drivers/md/dm-vdo/dedupe.c b/drivers/md/dm-vdo/dedupe.c
index 2a1902c4423c..942a50ef8b0d 100644
--- a/drivers/md/dm-vdo/dedupe.c
+++ b/drivers/md/dm-vdo/dedupe.c
@@ -126,12 +126,12 @@
#include <linux/spinlock.h>
#include <linux/timer.h>
+#include "indexer.h"
#include "logger.h"
#include "memory-alloc.h"
#include "numeric.h"
#include "permassert.h"
#include "string-utils.h"
-#include "uds.h"
#include "action-manager.h"
#include "admin-state.h"
diff --git a/drivers/md/dm-vdo/dedupe.h b/drivers/md/dm-vdo/dedupe.h
index 773dde5f9365..1566fc972ea7 100644
--- a/drivers/md/dm-vdo/dedupe.h
+++ b/drivers/md/dm-vdo/dedupe.h
@@ -9,7 +9,7 @@
#include <linux/list.h>
#include <linux/timer.h>
-#include "uds.h"
+#include "indexer.h"
#include "admin-state.h"
#include "constants.h"
diff --git a/drivers/md/dm-vdo/delta-index.c b/drivers/md/dm-vdo/delta-index.c
index 6306777bb202..66f51b5f8fd2 100644
--- a/drivers/md/dm-vdo/delta-index.c
+++ b/drivers/md/dm-vdo/delta-index.c
@@ -13,13 +13,13 @@
#include "config.h"
#include "cpu.h"
#include "errors.h"
+#include "indexer.h"
#include "logger.h"
#include "memory-alloc.h"
#include "numeric.h"
#include "permassert.h"
#include "string-utils.h"
#include "time-utils.h"
-#include "uds.h"
/*
* The entries in a delta index could be stored in a single delta list, but to reduce search times
diff --git a/drivers/md/dm-vdo/encodings.h b/drivers/md/dm-vdo/encodings.h
index ba3db9867f4a..18794fd59b0b 100644
--- a/drivers/md/dm-vdo/encodings.h
+++ b/drivers/md/dm-vdo/encodings.h
@@ -11,8 +11,8 @@
#include <linux/limits.h>
#include <linux/uuid.h>
+#include "indexer.h"
#include "numeric.h"
-#include "uds.h"
#include "constants.h"
#include "types.h"
diff --git a/drivers/md/dm-vdo/funnel-queue.c b/drivers/md/dm-vdo/funnel-queue.c
index 6940b282086d..d5d96bb38b94 100644
--- a/drivers/md/dm-vdo/funnel-queue.c
+++ b/drivers/md/dm-vdo/funnel-queue.c
@@ -8,7 +8,6 @@
#include "cpu.h"
#include "memory-alloc.h"
#include "permassert.h"
-#include "uds.h"
int uds_make_funnel_queue(struct funnel_queue **queue_ptr)
{
diff --git a/drivers/md/dm-vdo/funnel-requestqueue.h b/drivers/md/dm-vdo/funnel-requestqueue.h
index e74c231fe269..9b0f53939b4d 100644
--- a/drivers/md/dm-vdo/funnel-requestqueue.h
+++ b/drivers/md/dm-vdo/funnel-requestqueue.h
@@ -6,7 +6,7 @@
#ifndef UDS_REQUEST_QUEUE_H
#define UDS_REQUEST_QUEUE_H
-#include "uds.h"
+#include "indexer.h"
/*
* A simple request queue which will handle new requests in the order in which they are received,
diff --git a/drivers/md/dm-vdo/geometry.c b/drivers/md/dm-vdo/geometry.c
index 0e83bba4184a..04c07195a01c 100644
--- a/drivers/md/dm-vdo/geometry.c
+++ b/drivers/md/dm-vdo/geometry.c
@@ -10,10 +10,10 @@
#include "delta-index.h"
#include "errors.h"
+#include "indexer.h"
#include "logger.h"
#include "memory-alloc.h"
#include "permassert.h"
-#include "uds.h"
/*
* An index volume is divided into a fixed number of fixed-size chapters, each consisting of a
diff --git a/drivers/md/dm-vdo/geometry.h b/drivers/md/dm-vdo/geometry.h
index 9a4a66ac2e46..a2ecdb238cf2 100644
--- a/drivers/md/dm-vdo/geometry.h
+++ b/drivers/md/dm-vdo/geometry.h
@@ -6,7 +6,7 @@
#ifndef UDS_INDEX_GEOMETRY_H
#define UDS_INDEX_GEOMETRY_H
-#include "uds.h"
+#include "indexer.h"
/*
* The index_geometry records parameters that define the layout of a UDS index volume, and the size and
diff --git a/drivers/md/dm-vdo/hash-utils.h b/drivers/md/dm-vdo/hash-utils.h
index e22be69695be..e3b865bbe9b2 100644
--- a/drivers/md/dm-vdo/hash-utils.h
+++ b/drivers/md/dm-vdo/hash-utils.h
@@ -7,8 +7,8 @@
#define UDS_HASH_UTILS_H
#include "geometry.h"
+#include "indexer.h"
#include "numeric.h"
-#include "uds.h"
/* Utilities for extracting portions of a request name for various uses. */
diff --git a/drivers/md/dm-vdo/index-layout.h b/drivers/md/dm-vdo/index-layout.h
index 84a9eb43a49d..e9ac6f4302d6 100644
--- a/drivers/md/dm-vdo/index-layout.h
+++ b/drivers/md/dm-vdo/index-layout.h
@@ -7,8 +7,8 @@
#define UDS_INDEX_LAYOUT_H
#include "config.h"
+#include "indexer.h"
#include "io-factory.h"
-#include "uds.h"
/*
* The index layout describes the format of the index on the underlying storage, and is responsible
diff --git a/drivers/md/dm-vdo/index-page-map.c b/drivers/md/dm-vdo/index-page-map.c
index 8441f86ef3a4..1bb12066ad1a 100644
--- a/drivers/md/dm-vdo/index-page-map.c
+++ b/drivers/md/dm-vdo/index-page-map.c
@@ -7,13 +7,13 @@
#include "errors.h"
#include "hash-utils.h"
+#include "indexer.h"
#include "logger.h"
#include "memory-alloc.h"
#include "numeric.h"
#include "permassert.h"
#include "string-utils.h"
#include "thread-utils.h"
-#include "uds.h"
/*
* The index page map is conceptually a two-dimensional array indexed by chapter number and index
diff --git a/drivers/md/dm-vdo/index-session.h b/drivers/md/dm-vdo/index-session.h
index 62a9020dd9fa..733d10f8a56c 100644
--- a/drivers/md/dm-vdo/index-session.h
+++ b/drivers/md/dm-vdo/index-session.h
@@ -10,8 +10,8 @@
#include <linux/cache.h>
#include "config.h"
+#include "indexer.h"
#include "thread-utils.h"
-#include "uds.h"
/*
* The index session mediates all interactions with a UDS index. Once the index session is created,
diff --git a/drivers/md/dm-vdo/uds.h b/drivers/md/dm-vdo/indexer.h
similarity index 99%
rename from drivers/md/dm-vdo/uds.h
rename to drivers/md/dm-vdo/indexer.h
index 1264362f8372..59e6a5ca2acb 100644
--- a/drivers/md/dm-vdo/uds.h
+++ b/drivers/md/dm-vdo/indexer.h
@@ -3,8 +3,8 @@
* Copyright 2023 Red Hat
*/
-#ifndef UDS_H
-#define UDS_H
+#ifndef INDEXER_H
+#define INDEXER_H
#include <linux/types.h>
@@ -326,4 +326,4 @@ 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);
-#endif /* UDS_H */
+#endif /* INDEXER_H */
diff --git a/drivers/md/dm-vdo/sparse-cache.h b/drivers/md/dm-vdo/sparse-cache.h
index 90b0be155453..45e2dcf165b5 100644
--- a/drivers/md/dm-vdo/sparse-cache.h
+++ b/drivers/md/dm-vdo/sparse-cache.h
@@ -7,7 +7,7 @@
#define UDS_SPARSE_CACHE_H
#include "geometry.h"
-#include "uds.h"
+#include "indexer.h"
/*
* The sparse cache is a cache of entire chapter indexes from sparse chapters used for searching
diff --git a/drivers/md/dm-vdo/uds-sysfs.c b/drivers/md/dm-vdo/uds-sysfs.c
index eee8a5b7d147..1548092e7de1 100644
--- a/drivers/md/dm-vdo/uds-sysfs.c
+++ b/drivers/md/dm-vdo/uds-sysfs.c
@@ -9,10 +9,10 @@
#include <linux/module.h>
#include <linux/slab.h>
+#include "indexer.h"
#include "logger.h"
#include "memory-alloc.h"
#include "string-utils.h"
-#include "uds.h"
#define UDS_SYSFS_NAME "uds"
diff --git a/drivers/md/dm-vdo/vdo.h b/drivers/md/dm-vdo/vdo.h
index 772317e6db52..3938e519ae6a 100644
--- a/drivers/md/dm-vdo/vdo.h
+++ b/drivers/md/dm-vdo/vdo.h
@@ -17,12 +17,12 @@
#include "admin-state.h"
#include "encodings.h"
#include "funnel-workqueue.h"
+#include "indexer.h"
#include "packer.h"
#include "physical-zone.h"
#include "statistics.h"
#include "thread-registry.h"
#include "types.h"
-#include "uds.h"
enum notifier_state {
/* Notifications are allowed but not in progress */
diff --git a/drivers/md/dm-vdo/volume-index.c b/drivers/md/dm-vdo/volume-index.c
index daeafe7691ea..39c4be06780f 100644
--- a/drivers/md/dm-vdo/volume-index.c
+++ b/drivers/md/dm-vdo/volume-index.c
@@ -14,12 +14,12 @@
#include "errors.h"
#include "geometry.h"
#include "hash-utils.h"
+#include "indexer.h"
#include "logger.h"
#include "memory-alloc.h"
#include "numeric.h"
#include "permassert.h"
#include "thread-utils.h"
-#include "uds.h"
/*
* The volume index is a combination of two separate subindexes, one containing sparse hook entries
diff --git a/drivers/md/dm-vdo/volume-index.h b/drivers/md/dm-vdo/volume-index.h
index 2eb2cee7ee58..66bf14fddc90 100644
--- a/drivers/md/dm-vdo/volume-index.h
+++ b/drivers/md/dm-vdo/volume-index.h
@@ -10,8 +10,8 @@
#include "config.h"
#include "delta-index.h"
+#include "indexer.h"
#include "thread-utils.h"
-#include "uds.h"
/*
* The volume index is the primary top-level index for UDS. It contains records which map a record
diff --git a/drivers/md/dm-vdo/volume.h b/drivers/md/dm-vdo/volume.h
index 7ef9945d8403..290de5cbf9ec 100644
--- a/drivers/md/dm-vdo/volume.h
+++ b/drivers/md/dm-vdo/volume.h
@@ -14,13 +14,13 @@
#include "chapter-index.h"
#include "config.h"
#include "geometry.h"
+#include "indexer.h"
#include "index-layout.h"
#include "index-page-map.h"
#include "permassert.h"
#include "radix-sort.h"
#include "sparse-cache.h"
#include "thread-utils.h"
-#include "uds.h"
/*
* The volume manages deduplication records on permanent storage. The term "volume" can also refer
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 07/13] dm vdo: fold thread-cond-var.c into thread-utils
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
` (5 preceding siblings ...)
2024-03-01 3:52 ` [PATCH 06/13] dm vdo indexer: rename uds.h to indexer.h Matthew Sakai
@ 2024-03-01 3:52 ` Matthew Sakai
2024-03-01 3:53 ` [PATCH 08/13] dm vdo thread-utils: push uds_*_cond interface down to indexer Matthew Sakai
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:52 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Further cleanup is needed for thread-utils interfaces given many
functions should return void or be removed entirely because they
amount to obfuscation via wrappers.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/Makefile | 1 -
drivers/md/dm-vdo/thread-cond-var.c | 46 -----------------------------
drivers/md/dm-vdo/thread-utils.c | 11 +++++++
drivers/md/dm-vdo/thread-utils.h | 28 ++++++++++++++----
4 files changed, 34 insertions(+), 52 deletions(-)
delete mode 100644 drivers/md/dm-vdo/thread-cond-var.c
diff --git a/drivers/md/dm-vdo/Makefile b/drivers/md/dm-vdo/Makefile
index be5020b81c47..32266ab04cc1 100644
--- a/drivers/md/dm-vdo/Makefile
+++ b/drivers/md/dm-vdo/Makefile
@@ -48,7 +48,6 @@ dm-vdo-objs := \
status-codes.o \
string-utils.o \
sysfs.o \
- thread-cond-var.o \
thread-device.o \
thread-registry.o \
thread-utils.o \
diff --git a/drivers/md/dm-vdo/thread-cond-var.c b/drivers/md/dm-vdo/thread-cond-var.c
deleted file mode 100644
index 82b80338b448..000000000000
--- a/drivers/md/dm-vdo/thread-cond-var.c
+++ /dev/null
@@ -1,46 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright 2023 Red Hat
- */
-
-#include <linux/jiffies.h>
-#include <linux/minmax.h>
-
-#include "errors.h"
-#include "thread-utils.h"
-#include "time-utils.h"
-
-int uds_init_cond(struct cond_var *cv)
-{
- init_waitqueue_head(&cv->wait_queue);
- return UDS_SUCCESS;
-}
-
-int uds_signal_cond(struct cond_var *cv)
-{
- wake_up(&cv->wait_queue);
- return UDS_SUCCESS;
-}
-
-int uds_broadcast_cond(struct cond_var *cv)
-{
- wake_up_all(&cv->wait_queue);
- return UDS_SUCCESS;
-}
-
-int 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);
- return UDS_SUCCESS;
-}
-
-int uds_destroy_cond(struct cond_var *cv)
-{
- return UDS_SUCCESS;
-}
diff --git a/drivers/md/dm-vdo/thread-utils.c b/drivers/md/dm-vdo/thread-utils.c
index 1a1eb9ae9e33..5d371bfba8ff 100644
--- a/drivers/md/dm-vdo/thread-utils.c
+++ b/drivers/md/dm-vdo/thread-utils.c
@@ -135,3 +135,14 @@ 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);
+}
diff --git a/drivers/md/dm-vdo/thread-utils.h b/drivers/md/dm-vdo/thread-utils.h
index 30637dd264cc..c7a5d2d948a4 100644
--- a/drivers/md/dm-vdo/thread-utils.h
+++ b/drivers/md/dm-vdo/thread-utils.h
@@ -31,11 +31,29 @@ void uds_perform_once(atomic_t *once_state, void (*function) (void));
int uds_join_threads(struct thread *thread);
-int __must_check uds_init_cond(struct cond_var *cond);
-int uds_signal_cond(struct cond_var *cond);
-int uds_broadcast_cond(struct cond_var *cond);
-int uds_wait_cond(struct cond_var *cond, struct mutex *mutex);
-int uds_destroy_cond(struct cond_var *cond);
+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)
{
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 08/13] dm vdo thread-utils: push uds_*_cond interface down to indexer
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
` (6 preceding siblings ...)
2024-03-01 3:52 ` [PATCH 07/13] dm vdo: fold thread-cond-var.c into thread-utils Matthew Sakai
@ 2024-03-01 3:53 ` Matthew Sakai
2024-03-01 3:53 ` [PATCH 09/13] dm vdo thread-utils: remove all uds_*_mutex wrappers Matthew Sakai
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:53 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Only used by indexer components. Also return void from
uds_init_cond(), remove uds_destroy_cond(), and fix up
all callers.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/index-session.c | 32 +++++++++++++------------------
drivers/md/dm-vdo/index.c | 8 +-------
drivers/md/dm-vdo/indexer.h | 24 +++++++++++++++++++++++
drivers/md/dm-vdo/thread-utils.c | 12 ------------
drivers/md/dm-vdo/thread-utils.h | 28 ---------------------------
drivers/md/dm-vdo/volume.c | 15 ++-------------
6 files changed, 40 insertions(+), 79 deletions(-)
diff --git a/drivers/md/dm-vdo/index-session.c b/drivers/md/dm-vdo/index-session.c
index 7afc19748712..4837621c16db 100644
--- a/drivers/md/dm-vdo/index-session.c
+++ b/drivers/md/dm-vdo/index-session.c
@@ -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);
+}
diff --git a/drivers/md/dm-vdo/index.c b/drivers/md/dm-vdo/index.c
index 1596f6ba43a5..edd81f03c2b5 100644
--- a/drivers/md/dm-vdo/index.c
+++ b/drivers/md/dm-vdo/index.c
@@ -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);
diff --git a/drivers/md/dm-vdo/indexer.h b/drivers/md/dm-vdo/indexer.h
index 59e6a5ca2acb..3744aaf625b0 100644
--- a/drivers/md/dm-vdo/indexer.h
+++ b/drivers/md/dm-vdo/indexer.h
@@ -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 */
diff --git a/drivers/md/dm-vdo/thread-utils.c b/drivers/md/dm-vdo/thread-utils.c
index 5d371bfba8ff..30760b1c4d30 100644
--- a/drivers/md/dm-vdo/thread-utils.c
+++ b/drivers/md/dm-vdo/thread-utils.c
@@ -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);
-}
diff --git a/drivers/md/dm-vdo/thread-utils.h b/drivers/md/dm-vdo/thread-utils.h
index c7a5d2d948a4..fb71f8f1b46e 100644
--- a/drivers/md/dm-vdo/thread-utils.h
+++ b/drivers/md/dm-vdo/thread-utils.h
@@ -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 */
diff --git a/drivers/md/dm-vdo/volume.c b/drivers/md/dm-vdo/volume.c
index 5b3cb5d89e47..3b256a78fb02 100644
--- a/drivers/md/dm-vdo/volume.c
+++ b/drivers/md/dm-vdo/volume.c
@@ -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);
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 09/13] dm vdo thread-utils: remove all uds_*_mutex wrappers
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
` (7 preceding siblings ...)
2024-03-01 3:53 ` [PATCH 08/13] dm vdo thread-utils: push uds_*_cond interface down to indexer Matthew Sakai
@ 2024-03-01 3:53 ` Matthew Sakai
2024-03-01 3:53 ` [PATCH 10/13] dm vdo thread-utils: further cleanup of thread functions Matthew Sakai
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:53 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Just use mutex_init, mutex_lock and mutex_unlock.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/index-session.c | 110 +++++++++++++-----------------
drivers/md/dm-vdo/index.c | 42 +++++-------
drivers/md/dm-vdo/thread-utils.h | 23 -------
drivers/md/dm-vdo/volume-index.c | 40 ++++-------
drivers/md/dm-vdo/volume.c | 38 +++++------
5 files changed, 96 insertions(+), 157 deletions(-)
diff --git a/drivers/md/dm-vdo/index-session.c b/drivers/md/dm-vdo/index-session.c
index 4837621c16db..a482ccd3981e 100644
--- a/drivers/md/dm-vdo/index-session.c
+++ b/drivers/md/dm-vdo/index-session.c
@@ -61,10 +61,10 @@ enum index_session_flag {
/* Release a reference to an index session. */
static void release_index_session(struct uds_index_session *index_session)
{
- uds_lock_mutex(&index_session->request_mutex);
+ mutex_lock(&index_session->request_mutex);
if (--index_session->request_count == 0)
uds_broadcast_cond(&index_session->request_cond);
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
}
/*
@@ -76,10 +76,10 @@ static int get_index_session(struct uds_index_session *index_session)
unsigned int state;
int result = UDS_SUCCESS;
- uds_lock_mutex(&index_session->request_mutex);
+ mutex_lock(&index_session->request_mutex);
index_session->request_count++;
state = index_session->state;
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
if (state == IS_FLAG_LOADED) {
return UDS_SUCCESS;
@@ -141,9 +141,9 @@ static void enter_callback_stage(struct uds_request *request)
{
if (request->status != UDS_SUCCESS) {
/* All request errors are considered unrecoverable */
- uds_lock_mutex(&request->session->request_mutex);
+ mutex_lock(&request->session->request_mutex);
request->session->state |= IS_FLAG_DISABLED;
- uds_unlock_mutex(&request->session->request_mutex);
+ mutex_unlock(&request->session->request_mutex);
}
uds_request_queue_enqueue(request->session->callback_queue, request);
@@ -224,28 +224,14 @@ static int __must_check make_empty_index_session(struct uds_index_session **inde
if (result != UDS_SUCCESS)
return result;
- result = uds_init_mutex(&session->request_mutex);
- if (result != UDS_SUCCESS) {
- uds_free(session);
- return result;
- }
-
+ mutex_init(&session->request_mutex);
uds_init_cond(&session->request_cond);
-
- result = uds_init_mutex(&session->load_context.mutex);
- if (result != UDS_SUCCESS) {
- uds_destroy_mutex(&session->request_mutex);
- uds_free(session);
- return result;
- }
-
+ mutex_init(&session->load_context.mutex);
uds_init_cond(&session->load_context.cond);
result = uds_make_request_queue("callbackW", &handle_callbacks,
&session->callback_queue);
if (result != UDS_SUCCESS) {
- uds_destroy_mutex(&session->load_context.mutex);
- uds_destroy_mutex(&session->request_mutex);
uds_free(session);
return result;
}
@@ -268,7 +254,7 @@ static int __must_check start_loading_index_session(struct uds_index_session *in
{
int result;
- uds_lock_mutex(&index_session->request_mutex);
+ mutex_lock(&index_session->request_mutex);
if (index_session->state & IS_FLAG_SUSPENDED) {
uds_log_info("Index session is suspended");
result = -EBUSY;
@@ -279,20 +265,20 @@ static int __must_check start_loading_index_session(struct uds_index_session *in
index_session->state |= IS_FLAG_LOADING;
result = UDS_SUCCESS;
}
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
return result;
}
static void finish_loading_index_session(struct uds_index_session *index_session,
int result)
{
- uds_lock_mutex(&index_session->request_mutex);
+ mutex_lock(&index_session->request_mutex);
index_session->state &= ~IS_FLAG_LOADING;
if (result == UDS_SUCCESS)
index_session->state |= IS_FLAG_LOADED;
uds_broadcast_cond(&index_session->request_cond);
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
}
static int initialize_index_session(struct uds_index_session *index_session,
@@ -376,12 +362,12 @@ int uds_open_index(enum uds_open_index_type open_type,
static void wait_for_no_requests_in_progress(struct uds_index_session *index_session)
{
- uds_lock_mutex(&index_session->request_mutex);
+ mutex_lock(&index_session->request_mutex);
while (index_session->request_count > 0) {
uds_wait_cond(&index_session->request_cond,
&index_session->request_mutex);
}
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
}
static int __must_check save_index(struct uds_index_session *index_session)
@@ -392,7 +378,7 @@ static int __must_check save_index(struct uds_index_session *index_session)
static void suspend_rebuild(struct uds_index_session *session)
{
- uds_lock_mutex(&session->load_context.mutex);
+ mutex_lock(&session->load_context.mutex);
switch (session->load_context.status) {
case INDEX_OPENING:
session->load_context.status = INDEX_SUSPENDING;
@@ -419,7 +405,7 @@ static void suspend_rebuild(struct uds_index_session *session)
session->load_context.status);
break;
}
- uds_unlock_mutex(&session->load_context.mutex);
+ mutex_unlock(&session->load_context.mutex);
}
/*
@@ -433,7 +419,7 @@ int uds_suspend_index_session(struct uds_index_session *session, bool save)
bool rebuilding = false;
/* Wait for any current index state change to complete. */
- uds_lock_mutex(&session->request_mutex);
+ mutex_lock(&session->request_mutex);
while (session->state & IS_FLAG_CLOSING)
uds_wait_cond(&session->request_cond, &session->request_mutex);
@@ -453,7 +439,7 @@ int uds_suspend_index_session(struct uds_index_session *session, bool save)
session->state |= IS_FLAG_SUSPENDED;
uds_broadcast_cond(&session->request_cond);
}
- uds_unlock_mutex(&session->request_mutex);
+ mutex_unlock(&session->request_mutex);
if (no_work)
return uds_status_to_errno(result);
@@ -465,11 +451,11 @@ int uds_suspend_index_session(struct uds_index_session *session, bool save)
else
result = uds_flush_index_session(session);
- uds_lock_mutex(&session->request_mutex);
+ mutex_lock(&session->request_mutex);
session->state &= ~IS_FLAG_WAITING;
session->state |= IS_FLAG_SUSPENDED;
uds_broadcast_cond(&session->request_cond);
- uds_unlock_mutex(&session->request_mutex);
+ mutex_unlock(&session->request_mutex);
return uds_status_to_errno(result);
}
@@ -496,7 +482,7 @@ int uds_resume_index_session(struct uds_index_session *session,
bool no_work = false;
bool resume_replay = false;
- uds_lock_mutex(&session->request_mutex);
+ mutex_lock(&session->request_mutex);
if (session->state & IS_FLAG_WAITING) {
uds_log_info("Index session is already changing state");
no_work = true;
@@ -510,7 +496,7 @@ int uds_resume_index_session(struct uds_index_session *session,
if (session->state & IS_FLAG_LOADING)
resume_replay = true;
}
- uds_unlock_mutex(&session->request_mutex);
+ mutex_unlock(&session->request_mutex);
if (no_work)
return result;
@@ -518,16 +504,16 @@ int uds_resume_index_session(struct uds_index_session *session,
if ((session->index != NULL) && (bdev != session->parameters.bdev)) {
result = replace_device(session, bdev);
if (result != UDS_SUCCESS) {
- uds_lock_mutex(&session->request_mutex);
+ mutex_lock(&session->request_mutex);
session->state &= ~IS_FLAG_WAITING;
uds_broadcast_cond(&session->request_cond);
- uds_unlock_mutex(&session->request_mutex);
+ mutex_unlock(&session->request_mutex);
return uds_status_to_errno(result);
}
}
if (resume_replay) {
- uds_lock_mutex(&session->load_context.mutex);
+ mutex_lock(&session->load_context.mutex);
switch (session->load_context.status) {
case INDEX_SUSPENDED:
session->load_context.status = INDEX_OPENING;
@@ -548,14 +534,14 @@ int uds_resume_index_session(struct uds_index_session *session,
session->load_context.status);
break;
}
- uds_unlock_mutex(&session->load_context.mutex);
+ mutex_unlock(&session->load_context.mutex);
}
- uds_lock_mutex(&session->request_mutex);
+ mutex_lock(&session->request_mutex);
session->state &= ~IS_FLAG_WAITING;
session->state &= ~IS_FLAG_SUSPENDED;
uds_broadcast_cond(&session->request_cond);
- uds_unlock_mutex(&session->request_mutex);
+ mutex_unlock(&session->request_mutex);
return UDS_SUCCESS;
}
@@ -568,9 +554,9 @@ static int save_and_free_index(struct uds_index_session *index_session)
if (index == NULL)
return UDS_SUCCESS;
- uds_lock_mutex(&index_session->request_mutex);
+ mutex_lock(&index_session->request_mutex);
suspended = (index_session->state & IS_FLAG_SUSPENDED);
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
if (!suspended) {
result = uds_save_index(index);
@@ -585,14 +571,14 @@ static int save_and_free_index(struct uds_index_session *index_session)
* Reset all index state that happens to be in the index
* session, so it doesn't affect any future index.
*/
- uds_lock_mutex(&index_session->load_context.mutex);
+ mutex_lock(&index_session->load_context.mutex);
index_session->load_context.status = INDEX_OPENING;
- uds_unlock_mutex(&index_session->load_context.mutex);
+ mutex_unlock(&index_session->load_context.mutex);
- uds_lock_mutex(&index_session->request_mutex);
+ mutex_lock(&index_session->request_mutex);
/* Only the suspend bit will remain relevant. */
index_session->state &= IS_FLAG_SUSPENDED;
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
return result;
}
@@ -603,7 +589,7 @@ int uds_close_index(struct uds_index_session *index_session)
int result = UDS_SUCCESS;
/* Wait for any current index state change to complete. */
- uds_lock_mutex(&index_session->request_mutex);
+ mutex_lock(&index_session->request_mutex);
while ((index_session->state & IS_FLAG_WAITING) ||
(index_session->state & IS_FLAG_CLOSING)) {
uds_wait_cond(&index_session->request_cond,
@@ -620,7 +606,7 @@ int uds_close_index(struct uds_index_session *index_session)
} else {
index_session->state |= IS_FLAG_CLOSING;
}
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
if (result != UDS_SUCCESS)
return uds_status_to_errno(result);
@@ -629,10 +615,10 @@ int uds_close_index(struct uds_index_session *index_session)
result = save_and_free_index(index_session);
uds_log_debug("Closed index");
- uds_lock_mutex(&index_session->request_mutex);
+ mutex_lock(&index_session->request_mutex);
index_session->state &= ~IS_FLAG_CLOSING;
uds_broadcast_cond(&index_session->request_cond);
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
return uds_status_to_errno(result);
}
@@ -645,7 +631,7 @@ int uds_destroy_index_session(struct uds_index_session *index_session)
uds_log_debug("Destroying index session");
/* Wait for any current index state change to complete. */
- uds_lock_mutex(&index_session->request_mutex);
+ mutex_lock(&index_session->request_mutex);
while ((index_session->state & IS_FLAG_WAITING) ||
(index_session->state & IS_FLAG_CLOSING)) {
uds_wait_cond(&index_session->request_cond,
@@ -653,7 +639,7 @@ int uds_destroy_index_session(struct uds_index_session *index_session)
}
if (index_session->state & IS_FLAG_DESTROYING) {
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
uds_log_info("Index session is already closing");
return -EBUSY;
}
@@ -661,32 +647,30 @@ int uds_destroy_index_session(struct uds_index_session *index_session)
index_session->state |= IS_FLAG_DESTROYING;
load_pending = ((index_session->state & IS_FLAG_LOADING) &&
(index_session->state & IS_FLAG_SUSPENDED));
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
if (load_pending) {
/* Tell the index to terminate the rebuild. */
- uds_lock_mutex(&index_session->load_context.mutex);
+ mutex_lock(&index_session->load_context.mutex);
if (index_session->load_context.status == INDEX_SUSPENDED) {
index_session->load_context.status = INDEX_FREEING;
uds_broadcast_cond(&index_session->load_context.cond);
}
- uds_unlock_mutex(&index_session->load_context.mutex);
+ mutex_unlock(&index_session->load_context.mutex);
/* Wait until the load exits before proceeding. */
- uds_lock_mutex(&index_session->request_mutex);
+ mutex_lock(&index_session->request_mutex);
while (index_session->state & IS_FLAG_LOADING) {
uds_wait_cond(&index_session->request_cond,
&index_session->request_mutex);
}
- uds_unlock_mutex(&index_session->request_mutex);
+ mutex_unlock(&index_session->request_mutex);
}
wait_for_no_requests_in_progress(index_session);
result = save_and_free_index(index_session);
uds_request_queue_finish(index_session->callback_queue);
index_session->callback_queue = NULL;
- uds_destroy_mutex(&index_session->load_context.mutex);
- uds_destroy_mutex(&index_session->request_mutex);
uds_log_debug("Destroyed index session");
uds_free(index_session);
return uds_status_to_errno(result);
@@ -747,8 +731,8 @@ 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);
+ mutex_unlock(mutex);
schedule();
finish_wait(&cv->wait_queue, &__wait);
- uds_lock_mutex(mutex);
+ mutex_lock(mutex);
}
diff --git a/drivers/md/dm-vdo/index.c b/drivers/md/dm-vdo/index.c
index edd81f03c2b5..5c9906e73c84 100644
--- a/drivers/md/dm-vdo/index.c
+++ b/drivers/md/dm-vdo/index.c
@@ -180,11 +180,11 @@ static int finish_previous_chapter(struct uds_index *index, u64 current_chapter_
int result;
struct chapter_writer *writer = index->chapter_writer;
- uds_lock_mutex(&writer->mutex);
+ mutex_lock(&writer->mutex);
while (index->newest_virtual_chapter < current_chapter_number)
uds_wait_cond(&writer->cond, &writer->mutex);
result = writer->result;
- uds_unlock_mutex(&writer->mutex);
+ mutex_unlock(&writer->mutex);
if (result != UDS_SUCCESS)
return uds_log_error_strerror(result,
@@ -219,11 +219,11 @@ static unsigned int start_closing_chapter(struct uds_index *index,
unsigned int finished_zones;
struct chapter_writer *writer = index->chapter_writer;
- uds_lock_mutex(&writer->mutex);
+ mutex_lock(&writer->mutex);
finished_zones = ++writer->zones_to_write;
writer->chapters[zone_number] = chapter;
uds_broadcast_cond(&writer->cond);
- uds_unlock_mutex(&writer->mutex);
+ mutex_unlock(&writer->mutex);
return finished_zones;
}
@@ -678,7 +678,7 @@ static void close_chapters(void *arg)
struct uds_index *index = writer->index;
uds_log_debug("chapter writer starting");
- uds_lock_mutex(&writer->mutex);
+ mutex_lock(&writer->mutex);
for (;;) {
while (writer->zones_to_write < index->zone_count) {
if (writer->stop && (writer->zones_to_write == 0)) {
@@ -686,7 +686,7 @@ static void close_chapters(void *arg)
* We've been told to stop, and all of the zones are in the same
* open chapter, so we can exit now.
*/
- uds_unlock_mutex(&writer->mutex);
+ mutex_unlock(&writer->mutex);
uds_log_debug("chapter writer stopping");
return;
}
@@ -698,7 +698,7 @@ static void close_chapters(void *arg)
* it seems safer in principle. It's OK to access the chapter and chapter_number
* fields without the lock since those aren't allowed to change until we're done.
*/
- uds_unlock_mutex(&writer->mutex);
+ mutex_unlock(&writer->mutex);
if (index->has_saved_open_chapter) {
/*
@@ -719,7 +719,7 @@ static void close_chapters(void *arg)
writer->collated_records,
index->newest_virtual_chapter);
- uds_lock_mutex(&writer->mutex);
+ mutex_lock(&writer->mutex);
index->newest_virtual_chapter++;
index->oldest_virtual_chapter +=
uds_chapters_to_expire(index->volume->geometry,
@@ -734,14 +734,14 @@ static void stop_chapter_writer(struct chapter_writer *writer)
{
struct thread *writer_thread = NULL;
- uds_lock_mutex(&writer->mutex);
+ mutex_lock(&writer->mutex);
if (writer->thread != NULL) {
writer_thread = writer->thread;
writer->thread = NULL;
writer->stop = true;
uds_broadcast_cond(&writer->cond);
}
- uds_unlock_mutex(&writer->mutex);
+ mutex_unlock(&writer->mutex);
if (writer_thread != NULL)
uds_join_threads(writer_thread);
@@ -753,7 +753,6 @@ static void free_chapter_writer(struct chapter_writer *writer)
return;
stop_chapter_writer(writer);
- uds_destroy_mutex(&writer->mutex);
uds_free_open_chapter_index(writer->open_chapter_index);
uds_free(writer->collated_records);
uds_free(writer);
@@ -774,12 +773,7 @@ static int make_chapter_writer(struct uds_index *index,
return result;
writer->index = index;
- result = uds_init_mutex(&writer->mutex);
- if (result != UDS_SUCCESS) {
- uds_free(writer);
- return result;
- }
-
+ mutex_init(&writer->mutex);
uds_init_cond(&writer->cond);
result = uds_allocate_cache_aligned(collated_records_size, "collated records",
@@ -957,9 +951,9 @@ static bool check_for_suspend(struct uds_index *index)
if (index->load_context == NULL)
return false;
- uds_lock_mutex(&index->load_context->mutex);
+ mutex_lock(&index->load_context->mutex);
if (index->load_context->status != INDEX_SUSPENDING) {
- uds_unlock_mutex(&index->load_context->mutex);
+ mutex_unlock(&index->load_context->mutex);
return false;
}
@@ -972,7 +966,7 @@ static bool check_for_suspend(struct uds_index *index)
uds_wait_cond(&index->load_context->cond, &index->load_context->mutex);
closing = (index->load_context->status == INDEX_FREEING);
- uds_unlock_mutex(&index->load_context->mutex);
+ mutex_unlock(&index->load_context->mutex);
return closing;
}
@@ -1261,14 +1255,14 @@ int uds_make_index(struct uds_configuration *config, enum uds_open_index_type op
}
if (index->load_context != NULL) {
- uds_lock_mutex(&index->load_context->mutex);
+ mutex_lock(&index->load_context->mutex);
index->load_context->status = INDEX_READY;
/*
* If we get here, suspend is meaningless, but notify any thread trying to suspend
* us so it doesn't hang.
*/
uds_broadcast_cond(&index->load_context->cond);
- uds_unlock_mutex(&index->load_context->mutex);
+ mutex_unlock(&index->load_context->mutex);
}
index->has_saved_open_chapter = loaded;
@@ -1307,10 +1301,10 @@ void uds_wait_for_idle_index(struct uds_index *index)
{
struct chapter_writer *writer = index->chapter_writer;
- uds_lock_mutex(&writer->mutex);
+ mutex_lock(&writer->mutex);
while (writer->zones_to_write > 0)
uds_wait_cond(&writer->cond, &writer->mutex);
- uds_unlock_mutex(&writer->mutex);
+ mutex_unlock(&writer->mutex);
}
/* This function assumes that all requests have been drained. */
diff --git a/drivers/md/dm-vdo/thread-utils.h b/drivers/md/dm-vdo/thread-utils.h
index fb71f8f1b46e..8b55f0d1ab80 100644
--- a/drivers/md/dm-vdo/thread-utils.h
+++ b/drivers/md/dm-vdo/thread-utils.h
@@ -26,27 +26,4 @@ void uds_perform_once(atomic_t *once_state, void (*function) (void));
int uds_join_threads(struct thread *thread);
-/* FIXME: all below wrappers should be removed! */
-
-static inline int __must_check uds_init_mutex(struct mutex *mutex)
-{
- mutex_init(mutex);
- return UDS_SUCCESS;
-}
-
-static inline int uds_destroy_mutex(struct mutex *mutex)
-{
- return UDS_SUCCESS;
-}
-
-static inline void uds_lock_mutex(struct mutex *mutex)
-{
- mutex_lock(mutex);
-}
-
-static inline void uds_unlock_mutex(struct mutex *mutex)
-{
- mutex_unlock(mutex);
-}
-
#endif /* UDS_THREADS_H */
diff --git a/drivers/md/dm-vdo/volume-index.c b/drivers/md/dm-vdo/volume-index.c
index 39c4be06780f..36e3c2e3d799 100644
--- a/drivers/md/dm-vdo/volume-index.c
+++ b/drivers/md/dm-vdo/volume-index.c
@@ -286,13 +286,8 @@ void uds_free_volume_index(struct volume_index *volume_index)
if (volume_index == NULL)
return;
- if (volume_index->zones != NULL) {
- unsigned int zone;
-
- for (zone = 0; zone < volume_index->zone_count; zone++)
- uds_destroy_mutex(&volume_index->zones[zone].hook_mutex);
+ if (volume_index->zones != NULL)
uds_free(uds_forget(volume_index->zones));
- }
uninitialize_volume_sub_index(&volume_index->vi_non_hook);
uninitialize_volume_sub_index(&volume_index->vi_hook);
@@ -546,10 +541,10 @@ int uds_get_volume_index_record(struct volume_index *volume_index,
get_volume_sub_index_zone(&volume_index->vi_hook, name);
struct mutex *mutex = &volume_index->zones[zone].hook_mutex;
- uds_lock_mutex(mutex);
+ mutex_lock(mutex);
result = get_volume_sub_index_record(&volume_index->vi_hook, name,
record);
- uds_unlock_mutex(mutex);
+ mutex_unlock(mutex);
/* Remember the mutex so that other operations on the index record can use it. */
record->mutex = mutex;
} else {
@@ -578,13 +573,13 @@ int uds_put_volume_index_record(struct volume_index_record *record, u64 virtual_
}
address = extract_address(sub_index, record->name);
if (unlikely(record->mutex != NULL))
- uds_lock_mutex(record->mutex);
+ mutex_lock(record->mutex);
result = uds_put_delta_index_entry(&record->delta_entry, address,
convert_virtual_to_index(sub_index,
virtual_chapter),
record->is_found ? record->name->name : NULL);
if (unlikely(record->mutex != NULL))
- uds_unlock_mutex(record->mutex);
+ mutex_unlock(record->mutex);
switch (result) {
case UDS_SUCCESS:
record->virtual_chapter = virtual_chapter;
@@ -614,10 +609,10 @@ int uds_remove_volume_index_record(struct volume_index_record *record)
/* Mark the record so that it cannot be used again */
record->is_found = false;
if (unlikely(record->mutex != NULL))
- uds_lock_mutex(record->mutex);
+ mutex_lock(record->mutex);
result = uds_remove_delta_index_entry(&record->delta_entry);
if (unlikely(record->mutex != NULL))
- uds_unlock_mutex(record->mutex);
+ mutex_unlock(record->mutex);
return result;
}
@@ -688,10 +683,10 @@ void uds_set_volume_index_zone_open_chapter(struct volume_index *volume_index,
* chapter number is changing.
*/
if (has_sparse(volume_index)) {
- uds_lock_mutex(mutex);
+ mutex_lock(mutex);
set_volume_sub_index_zone_open_chapter(&volume_index->vi_hook,
zone_number, virtual_chapter);
- uds_unlock_mutex(mutex);
+ mutex_unlock(mutex);
}
}
@@ -730,12 +725,12 @@ int uds_set_volume_index_record_chapter(struct volume_index_record *record,
}
if (unlikely(record->mutex != NULL))
- uds_lock_mutex(record->mutex);
+ mutex_lock(record->mutex);
result = uds_set_delta_entry_value(&record->delta_entry,
convert_virtual_to_index(sub_index,
virtual_chapter));
if (unlikely(record->mutex != NULL))
- uds_unlock_mutex(record->mutex);
+ mutex_unlock(record->mutex);
if (result != UDS_SUCCESS)
return result;
@@ -785,9 +780,9 @@ u64 uds_lookup_volume_index_name(const struct volume_index *volume_index,
if (!uds_is_volume_index_sample(volume_index, name))
return NO_CHAPTER;
- uds_lock_mutex(mutex);
+ mutex_lock(mutex);
virtual_chapter = lookup_volume_sub_index_name(&volume_index->vi_hook, name);
- uds_unlock_mutex(mutex);
+ mutex_unlock(mutex);
return virtual_chapter;
}
@@ -1258,13 +1253,8 @@ int uds_make_volume_index(const struct uds_configuration *config, u64 volume_non
return result;
}
- for (zone = 0; zone < config->zone_count; zone++) {
- result = uds_init_mutex(&volume_index->zones[zone].hook_mutex);
- if (result != UDS_SUCCESS) {
- uds_free_volume_index(volume_index);
- return result;
- }
- }
+ for (zone = 0; zone < config->zone_count; zone++)
+ mutex_init(&volume_index->zones[zone].hook_mutex);
split_configuration(config, &split);
result = initialize_volume_sub_index(&split.non_hook_config, volume_nonce, 'd',
diff --git a/drivers/md/dm-vdo/volume.c b/drivers/md/dm-vdo/volume.c
index 3b256a78fb02..0fb06fd315ef 100644
--- a/drivers/md/dm-vdo/volume.c
+++ b/drivers/md/dm-vdo/volume.c
@@ -554,7 +554,7 @@ static int process_entry(struct volume *volume, struct queued_read *entry)
page = select_victim_in_cache(&volume->page_cache);
- uds_unlock_mutex(&volume->read_threads_mutex);
+ mutex_unlock(&volume->read_threads_mutex);
page_data = dm_bufio_read(volume->client, page_number, &page->buffer);
if (IS_ERR(page_data)) {
result = -PTR_ERR(page_data);
@@ -564,7 +564,7 @@ static int process_entry(struct volume *volume, struct queued_read *entry)
cancel_page_in_cache(&volume->page_cache, page_number, page);
return result;
}
- uds_lock_mutex(&volume->read_threads_mutex);
+ mutex_lock(&volume->read_threads_mutex);
if (entry->invalid) {
uds_log_warning("Page %u invalidated after read", page_number);
@@ -626,7 +626,7 @@ static void read_thread_function(void *arg)
struct volume *volume = arg;
uds_log_debug("reader starting");
- uds_lock_mutex(&volume->read_threads_mutex);
+ mutex_lock(&volume->read_threads_mutex);
while (true) {
struct queued_read *queue_entry;
int result;
@@ -638,7 +638,7 @@ static void read_thread_function(void *arg)
result = process_entry(volume, queue_entry);
release_queued_requests(volume, queue_entry, result);
}
- uds_unlock_mutex(&volume->read_threads_mutex);
+ mutex_unlock(&volume->read_threads_mutex);
uds_log_debug("reader done");
}
@@ -769,7 +769,7 @@ static int get_volume_page_protected(struct volume *volume, struct uds_request *
/* Prepare to enqueue a read for the page. */
end_pending_search(&volume->page_cache, request->zone_number);
- uds_lock_mutex(&volume->read_threads_mutex);
+ mutex_lock(&volume->read_threads_mutex);
/*
* Do the lookup again while holding the read mutex (no longer the fast case so this should
@@ -787,7 +787,7 @@ static int get_volume_page_protected(struct volume *volume, struct uds_request *
* turns out to be significant in some cases. The page is not available yet so
* the order does not matter for correctness as it does below.
*/
- uds_unlock_mutex(&volume->read_threads_mutex);
+ mutex_unlock(&volume->read_threads_mutex);
begin_pending_search(&volume->page_cache, physical_page,
request->zone_number);
return UDS_QUEUED;
@@ -799,7 +799,7 @@ static int get_volume_page_protected(struct volume *volume, struct uds_request *
* the caller gets to look at it.
*/
begin_pending_search(&volume->page_cache, physical_page, request->zone_number);
- uds_unlock_mutex(&volume->read_threads_mutex);
+ mutex_unlock(&volume->read_threads_mutex);
*page_ptr = page;
return UDS_SUCCESS;
}
@@ -810,9 +810,9 @@ static int get_volume_page(struct volume *volume, u32 chapter, u32 page_number,
int result;
u32 physical_page = map_to_physical_page(volume->geometry, chapter, page_number);
- uds_lock_mutex(&volume->read_threads_mutex);
+ mutex_lock(&volume->read_threads_mutex);
result = get_volume_page_locked(volume, physical_page, page_ptr);
- uds_unlock_mutex(&volume->read_threads_mutex);
+ mutex_unlock(&volume->read_threads_mutex);
return result;
}
@@ -1053,10 +1053,10 @@ void uds_forget_chapter(struct volume *volume, u64 virtual_chapter)
u32 i;
uds_log_debug("forgetting chapter %llu", (unsigned long long) virtual_chapter);
- uds_lock_mutex(&volume->read_threads_mutex);
+ mutex_lock(&volume->read_threads_mutex);
for (i = 0; i < volume->geometry->pages_per_chapter; i++)
invalidate_page(&volume->page_cache, first_page + i);
- uds_unlock_mutex(&volume->read_threads_mutex);
+ mutex_unlock(&volume->read_threads_mutex);
}
/*
@@ -1141,10 +1141,10 @@ static int write_index_pages(struct volume *volume, u32 physical_chapter_number,
physical_chapter_number, index_page_number,
delta_list_number - 1);
- uds_lock_mutex(&volume->read_threads_mutex);
+ mutex_lock(&volume->read_threads_mutex);
result = donate_index_page_locked(volume, physical_chapter_number,
index_page_number, page_buffer);
- uds_unlock_mutex(&volume->read_threads_mutex);
+ mutex_unlock(&volume->read_threads_mutex);
if (result != UDS_SUCCESS) {
dm_bufio_release(page_buffer);
return result;
@@ -1621,12 +1621,7 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layout
return result;
}
- result = uds_init_mutex(&volume->read_threads_mutex);
- if (result != UDS_SUCCESS) {
- uds_free_volume(volume);
- return result;
- }
-
+ mutex_init(&volume->read_threads_mutex);
uds_init_cond(&volume->read_threads_read_done_cond);
uds_init_cond(&volume->read_threads_cond);
@@ -1675,10 +1670,10 @@ void uds_free_volume(struct volume *volume)
unsigned int i;
/* This works even if some threads weren't started. */
- uds_lock_mutex(&volume->read_threads_mutex);
+ mutex_lock(&volume->read_threads_mutex);
volume->read_threads_exiting = true;
uds_broadcast_cond(&volume->read_threads_cond);
- uds_unlock_mutex(&volume->read_threads_mutex);
+ mutex_unlock(&volume->read_threads_mutex);
for (i = 0; i < volume->read_thread_count; i++)
uds_join_threads(volume->reader_threads[i]);
uds_free(volume->reader_threads);
@@ -1691,7 +1686,6 @@ void uds_free_volume(struct volume *volume)
if (volume->client != NULL)
dm_bufio_client_destroy(uds_forget(volume->client));
- uds_destroy_mutex(&volume->read_threads_mutex);
uds_free_index_page_map(volume->index_page_map);
uds_free_radix_sorter(volume->radix_sorter);
uds_free(volume->geometry);
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 10/13] dm vdo thread-utils: further cleanup of thread functions
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
` (8 preceding siblings ...)
2024-03-01 3:53 ` [PATCH 09/13] dm vdo thread-utils: remove all uds_*_mutex wrappers Matthew Sakai
@ 2024-03-01 3:53 ` Matthew Sakai
2024-03-01 3:53 ` [PATCH 11/13] dm vdo thread-utils: cleanup included headers Matthew Sakai
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:53 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
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 | 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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 11/13] dm vdo thread-utils: cleanup included headers
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
` (9 preceding siblings ...)
2024-03-01 3:53 ` [PATCH 10/13] dm vdo thread-utils: further cleanup of thread functions Matthew Sakai
@ 2024-03-01 3:53 ` Matthew Sakai
2024-03-01 3:53 ` [PATCH 12/13] dm vdo thread-registry: rename all methods to reflect vdo-only use Matthew Sakai
2024-03-01 3:53 ` [PATCH 13/13] dm vdo thread-device: " Matthew Sakai
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:53 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/logger.c | 1 +
drivers/md/dm-vdo/thread-utils.c | 4 ++--
drivers/md/dm-vdo/thread-utils.h | 6 ------
3 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/md/dm-vdo/logger.c b/drivers/md/dm-vdo/logger.c
index ff1c570f81bf..969f10771ada 100644
--- a/drivers/md/dm-vdo/logger.c
+++ b/drivers/md/dm-vdo/logger.c
@@ -11,6 +11,7 @@
#include <linux/printk.h>
#include <linux/sched.h>
+#include "errors.h"
#include "thread-device.h"
#include "thread-utils.h"
diff --git a/drivers/md/dm-vdo/thread-utils.c b/drivers/md/dm-vdo/thread-utils.c
index 0b80247c7f1b..160679984d72 100644
--- a/drivers/md/dm-vdo/thread-utils.c
+++ b/drivers/md/dm-vdo/thread-utils.c
@@ -5,10 +5,10 @@
#include "thread-utils.h"
-#include <linux/completion.h>
#include <linux/delay.h>
-#include <linux/err.h>
#include <linux/kthread.h>
+#include <linux/mutex.h>
+#include <linux/types.h>
#include "errors.h"
#include "logger.h"
diff --git a/drivers/md/dm-vdo/thread-utils.h b/drivers/md/dm-vdo/thread-utils.h
index ebe032e066ff..f3619a581c5e 100644
--- a/drivers/md/dm-vdo/thread-utils.h
+++ b/drivers/md/dm-vdo/thread-utils.h
@@ -7,12 +7,6 @@
#define THREAD_UTILS_H
#include <linux/atomic.h>
-#include <linux/delay.h>
-#include <linux/jiffies.h>
-#include <linux/mutex.h>
-#include <linux/semaphore.h>
-
-#include "errors.h"
/* Thread and synchronization utilities */
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 12/13] dm vdo thread-registry: rename all methods to reflect vdo-only use
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
` (10 preceding siblings ...)
2024-03-01 3:53 ` [PATCH 11/13] dm vdo thread-utils: cleanup included headers Matthew Sakai
@ 2024-03-01 3:53 ` Matthew Sakai
2024-03-01 3:53 ` [PATCH 13/13] dm vdo thread-device: " Matthew Sakai
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:53 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Otherwise, uds_ prefix is misleading (vdo_ is the new catch-all for
code that is used by vdo-only or _both_ vdo and the indexer code).
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/memory-alloc.c | 12 ++++++------
drivers/md/dm-vdo/thread-device.c | 8 ++++----
drivers/md/dm-vdo/thread-registry.c | 8 ++++----
drivers/md/dm-vdo/thread-registry.h | 14 +++++++-------
4 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/drivers/md/dm-vdo/memory-alloc.c b/drivers/md/dm-vdo/memory-alloc.c
index 46dd5bda6825..3b2bda9248cb 100644
--- a/drivers/md/dm-vdo/memory-alloc.c
+++ b/drivers/md/dm-vdo/memory-alloc.c
@@ -15,14 +15,14 @@
/*
* UDS and VDO keep track of which threads are allowed to allocate memory freely, and which threads
- * must be careful to not do a memory allocation that does an I/O request. The allocating_threads
- * threads_registry and its associated methods implement this tracking.
+ * must be careful to not do a memory allocation that does an I/O request. The 'allocating_threads'
+ * thread_registry and its associated methods implement this tracking.
*/
static struct thread_registry allocating_threads;
static bool allocations_allowed(void)
{
- const bool *pointer = uds_lookup_thread(&allocating_threads);
+ const bool *pointer = vdo_lookup_thread(&allocating_threads);
return (pointer != NULL) ? *pointer : false;
}
@@ -48,13 +48,13 @@ void uds_register_allocating_thread(struct registered_thread *new_thread,
flag_ptr = &allocation_always_allowed;
}
- uds_register_thread(&allocating_threads, new_thread, flag_ptr);
+ vdo_register_thread(&allocating_threads, new_thread, flag_ptr);
}
/* Unregister the current thread as an allocating thread. */
void uds_unregister_allocating_thread(void)
{
- uds_unregister_thread(&allocating_threads);
+ vdo_unregister_thread(&allocating_threads);
}
/*
@@ -384,7 +384,7 @@ int uds_duplicate_string(const char *string, const char *what, char **new_string
void uds_memory_init(void)
{
spin_lock_init(&memory_stats.lock);
- uds_initialize_thread_registry(&allocating_threads);
+ vdo_initialize_thread_registry(&allocating_threads);
}
void uds_memory_exit(void)
diff --git a/drivers/md/dm-vdo/thread-device.c b/drivers/md/dm-vdo/thread-device.c
index b87de448a83b..2bf14b9f67f8 100644
--- a/drivers/md/dm-vdo/thread-device.c
+++ b/drivers/md/dm-vdo/thread-device.c
@@ -14,23 +14,23 @@ static struct thread_registry device_id_thread_registry;
void uds_register_thread_device_id(struct registered_thread *new_thread,
unsigned int *id_ptr)
{
- uds_register_thread(&device_id_thread_registry, new_thread, id_ptr);
+ vdo_register_thread(&device_id_thread_registry, new_thread, id_ptr);
}
void uds_unregister_thread_device_id(void)
{
- uds_unregister_thread(&device_id_thread_registry);
+ vdo_unregister_thread(&device_id_thread_registry);
}
int uds_get_thread_device_id(void)
{
const unsigned int *pointer;
- pointer = uds_lookup_thread(&device_id_thread_registry);
+ pointer = vdo_lookup_thread(&device_id_thread_registry);
return (pointer != NULL) ? *pointer : -1;
}
void uds_initialize_thread_device_registry(void)
{
- uds_initialize_thread_registry(&device_id_thread_registry);
+ vdo_initialize_thread_registry(&device_id_thread_registry);
}
diff --git a/drivers/md/dm-vdo/thread-registry.c b/drivers/md/dm-vdo/thread-registry.c
index 8c887158c224..1314d2b6a26f 100644
--- a/drivers/md/dm-vdo/thread-registry.c
+++ b/drivers/md/dm-vdo/thread-registry.c
@@ -14,14 +14,14 @@
* their normal operation. For example, we do not want to invoke the logger while holding a lock.
*/
-void uds_initialize_thread_registry(struct thread_registry *registry)
+void vdo_initialize_thread_registry(struct thread_registry *registry)
{
INIT_LIST_HEAD(®istry->links);
spin_lock_init(®istry->lock);
}
/* Register the current thread and associate it with a data pointer. */
-void uds_register_thread(struct thread_registry *registry,
+void vdo_register_thread(struct thread_registry *registry,
struct registered_thread *new_thread, const void *pointer)
{
struct registered_thread *thread;
@@ -51,7 +51,7 @@ void uds_register_thread(struct thread_registry *registry,
}
}
-void uds_unregister_thread(struct thread_registry *registry)
+void vdo_unregister_thread(struct thread_registry *registry)
{
struct registered_thread *thread;
bool found_it = false;
@@ -74,7 +74,7 @@ void uds_unregister_thread(struct thread_registry *registry)
}
}
-const void *uds_lookup_thread(struct thread_registry *registry)
+const void *vdo_lookup_thread(struct thread_registry *registry)
{
struct registered_thread *thread;
const void *result = NULL;
diff --git a/drivers/md/dm-vdo/thread-registry.h b/drivers/md/dm-vdo/thread-registry.h
index f70f755568a1..cc6d78312b9e 100644
--- a/drivers/md/dm-vdo/thread-registry.h
+++ b/drivers/md/dm-vdo/thread-registry.h
@@ -3,8 +3,8 @@
* Copyright 2023 Red Hat
*/
-#ifndef UDS_THREAD_REGISTRY_H
-#define UDS_THREAD_REGISTRY_H
+#ifndef VDO_THREAD_REGISTRY_H
+#define VDO_THREAD_REGISTRY_H
#include <linux/list.h>
#include <linux/spinlock.h>
@@ -20,13 +20,13 @@ struct registered_thread {
struct task_struct *task;
};
-void uds_initialize_thread_registry(struct thread_registry *registry);
+void vdo_initialize_thread_registry(struct thread_registry *registry);
-void uds_register_thread(struct thread_registry *registry,
+void vdo_register_thread(struct thread_registry *registry,
struct registered_thread *new_thread, const void *pointer);
-void uds_unregister_thread(struct thread_registry *registry);
+void vdo_unregister_thread(struct thread_registry *registry);
-const void *uds_lookup_thread(struct thread_registry *registry);
+const void *vdo_lookup_thread(struct thread_registry *registry);
-#endif /* UDS_THREAD_REGISTRY_H */
+#endif /* VDO_THREAD_REGISTRY_H */
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 13/13] dm vdo thread-device: rename all methods to reflect vdo-only use
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
` (11 preceding siblings ...)
2024-03-01 3:53 ` [PATCH 12/13] dm vdo thread-registry: rename all methods to reflect vdo-only use Matthew Sakai
@ 2024-03-01 3:53 ` Matthew Sakai
12 siblings, 0 replies; 14+ messages in thread
From: Matthew Sakai @ 2024-03-01 3:53 UTC (permalink / raw
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Also moved vdo_init()'s call to vdo_initialize_thread_device_registry
next to other registry initialization.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/dm-vdo-target.c | 30 +++++++++++++++---------------
drivers/md/dm-vdo/logger.c | 2 +-
drivers/md/dm-vdo/thread-device.c | 10 ++++------
drivers/md/dm-vdo/thread-device.h | 14 +++++++-------
4 files changed, 27 insertions(+), 29 deletions(-)
diff --git a/drivers/md/dm-vdo/dm-vdo-target.c b/drivers/md/dm-vdo/dm-vdo-target.c
index e754b9e30cab..7afd1dfec649 100644
--- a/drivers/md/dm-vdo/dm-vdo-target.c
+++ b/drivers/md/dm-vdo/dm-vdo-target.c
@@ -1107,7 +1107,7 @@ static int vdo_message(struct dm_target *ti, unsigned int argc, char **argv,
vdo = get_vdo_for_target(ti);
uds_register_allocating_thread(&allocating_thread, NULL);
- uds_register_thread_device_id(&instance_thread, &vdo->instance);
+ vdo_register_thread_device_id(&instance_thread, &vdo->instance);
/*
* Must be done here so we don't map return codes. The code in dm-ioctl expects a 1 for a
@@ -1120,7 +1120,7 @@ static int vdo_message(struct dm_target *ti, unsigned int argc, char **argv,
result = vdo_status_to_errno(process_vdo_message(vdo, argc, argv));
}
- uds_unregister_thread_device_id();
+ vdo_unregister_thread_device_id();
uds_unregister_allocating_thread();
return result;
}
@@ -1632,9 +1632,9 @@ static int construct_new_vdo(struct dm_target *ti, unsigned int argc, char **arg
if (result != VDO_SUCCESS)
return -ENOMEM;
- uds_register_thread_device_id(&instance_thread, &instance);
+ vdo_register_thread_device_id(&instance_thread, &instance);
result = construct_new_vdo_registered(ti, argc, argv, instance);
- uds_unregister_thread_device_id();
+ vdo_unregister_thread_device_id();
return result;
}
@@ -1913,9 +1913,9 @@ static int vdo_ctr(struct dm_target *ti, unsigned int argc, char **argv)
if (vdo == NULL) {
result = construct_new_vdo(ti, argc, argv);
} else {
- uds_register_thread_device_id(&instance_thread, &vdo->instance);
+ vdo_register_thread_device_id(&instance_thread, &vdo->instance);
result = update_existing_vdo(device_name, ti, argc, argv, vdo);
- uds_unregister_thread_device_id();
+ vdo_unregister_thread_device_id();
}
uds_unregister_allocating_thread();
@@ -1935,7 +1935,7 @@ static void vdo_dtr(struct dm_target *ti)
unsigned int instance = vdo->instance;
struct registered_thread allocating_thread, instance_thread;
- uds_register_thread_device_id(&instance_thread, &instance);
+ vdo_register_thread_device_id(&instance_thread, &instance);
uds_register_allocating_thread(&allocating_thread, NULL);
device_name = vdo_get_device_name(ti);
@@ -1945,7 +1945,7 @@ static void vdo_dtr(struct dm_target *ti)
vdo_destroy(uds_forget(vdo));
uds_log_info("device '%s' stopped", device_name);
- uds_unregister_thread_device_id();
+ vdo_unregister_thread_device_id();
uds_unregister_allocating_thread();
release_instance(instance);
} else if (config == vdo->device_config) {
@@ -2104,7 +2104,7 @@ static void vdo_postsuspend(struct dm_target *ti)
const char *device_name;
int result;
- uds_register_thread_device_id(&instance_thread, &vdo->instance);
+ vdo_register_thread_device_id(&instance_thread, &vdo->instance);
device_name = vdo_get_device_name(vdo->device_config->owning_target);
uds_log_info("suspending device '%s'", device_name);
@@ -2129,7 +2129,7 @@ static void vdo_postsuspend(struct dm_target *ti)
device_name);
}
- uds_unregister_thread_device_id();
+ vdo_unregister_thread_device_id();
}
/**
@@ -2846,11 +2846,11 @@ static int vdo_preresume(struct dm_target *ti)
struct vdo *vdo = get_vdo_for_target(ti);
int result;
- uds_register_thread_device_id(&instance_thread, &vdo->instance);
+ vdo_register_thread_device_id(&instance_thread, &vdo->instance);
result = vdo_preresume_registered(ti, vdo);
if ((result == VDO_PARAMETER_MISMATCH) || (result == VDO_INVALID_ADMIN_STATE))
result = -EINVAL;
- uds_unregister_thread_device_id();
+ vdo_unregister_thread_device_id();
return vdo_status_to_errno(result);
}
@@ -2858,10 +2858,10 @@ static void vdo_resume(struct dm_target *ti)
{
struct registered_thread instance_thread;
- uds_register_thread_device_id(&instance_thread,
+ vdo_register_thread_device_id(&instance_thread,
&get_vdo_for_target(ti)->instance);
uds_log_info("device '%s' resumed", vdo_get_device_name(ti));
- uds_unregister_thread_device_id();
+ vdo_unregister_thread_device_id();
}
/*
@@ -2912,10 +2912,10 @@ static int __init vdo_init(void)
/*
* UDS module level initialization must be done first, as VDO initialization depends on it
*/
- uds_initialize_thread_device_registry();
uds_memory_init();
uds_init_sysfs();
+ vdo_initialize_thread_device_registry();
vdo_initialize_device_registry_once();
uds_log_info("loaded version %s", CURRENT_VERSION);
diff --git a/drivers/md/dm-vdo/logger.c b/drivers/md/dm-vdo/logger.c
index 969f10771ada..6ba7e99ee8f9 100644
--- a/drivers/md/dm-vdo/logger.c
+++ b/drivers/md/dm-vdo/logger.c
@@ -176,7 +176,7 @@ static void emit_log_message(int priority, const char *module, const char *prefi
}
/* Not at interrupt level; we have a process we can look at, and might have a device ID. */
- device_instance = uds_get_thread_device_id();
+ device_instance = vdo_get_thread_device_id();
if (device_instance >= 0) {
emit_log_message_to_kernel(priority, "%s%u:%s: %s%pV%pV\n", module,
device_instance, current->comm, prefix, vaf1,
diff --git a/drivers/md/dm-vdo/thread-device.c b/drivers/md/dm-vdo/thread-device.c
index 2bf14b9f67f8..df13ca914db8 100644
--- a/drivers/md/dm-vdo/thread-device.c
+++ b/drivers/md/dm-vdo/thread-device.c
@@ -5,24 +5,22 @@
#include "thread-device.h"
-#include "thread-registry.h"
-
/* A registry of threads associated with device id numbers. */
static struct thread_registry device_id_thread_registry;
/* Any registered thread must be unregistered. */
-void uds_register_thread_device_id(struct registered_thread *new_thread,
+void vdo_register_thread_device_id(struct registered_thread *new_thread,
unsigned int *id_ptr)
{
vdo_register_thread(&device_id_thread_registry, new_thread, id_ptr);
}
-void uds_unregister_thread_device_id(void)
+void vdo_unregister_thread_device_id(void)
{
vdo_unregister_thread(&device_id_thread_registry);
}
-int uds_get_thread_device_id(void)
+int vdo_get_thread_device_id(void)
{
const unsigned int *pointer;
@@ -30,7 +28,7 @@ int uds_get_thread_device_id(void)
return (pointer != NULL) ? *pointer : -1;
}
-void uds_initialize_thread_device_registry(void)
+void vdo_initialize_thread_device_registry(void)
{
vdo_initialize_thread_registry(&device_id_thread_registry);
}
diff --git a/drivers/md/dm-vdo/thread-device.h b/drivers/md/dm-vdo/thread-device.h
index 428b2908541d..494d9c9ef3f6 100644
--- a/drivers/md/dm-vdo/thread-device.h
+++ b/drivers/md/dm-vdo/thread-device.h
@@ -3,18 +3,18 @@
* Copyright 2023 Red Hat
*/
-#ifndef UDS_THREAD_DEVICE_H
-#define UDS_THREAD_DEVICE_H
+#ifndef VDO_THREAD_DEVICE_H
+#define VDO_THREAD_DEVICE_H
#include "thread-registry.h"
-void uds_register_thread_device_id(struct registered_thread *new_thread,
+void vdo_register_thread_device_id(struct registered_thread *new_thread,
unsigned int *id_ptr);
-void uds_unregister_thread_device_id(void);
+void vdo_unregister_thread_device_id(void);
-int uds_get_thread_device_id(void);
+int vdo_get_thread_device_id(void);
-void uds_initialize_thread_device_registry(void);
+void vdo_initialize_thread_device_registry(void);
-#endif /* UDS_THREAD_DEVICE_H */
+#endif /* VDO_THREAD_DEVICE_H */
--
2.42.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2024-03-01 3:53 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-01 3:52 [PATCH 00/13] dm vdo: clean up and simplify thread utilities Matthew Sakai
2024-03-01 3:52 ` [PATCH 01/13] dm vdo: make uds_*_semaphore interface private to uds-threads.c Matthew Sakai
2024-03-01 3:52 ` [PATCH 02/13] dm vdo uds-threads: eliminate uds_*_semaphore interfaces Matthew Sakai
2024-03-01 3:52 ` [PATCH 03/13] dm vdo uds-threads: push 'barrier' down to sparse-cache Matthew Sakai
2024-03-01 3:52 ` [PATCH 04/13] dm vdo indexer sparse-cache: cleanup threads_barrier code Matthew Sakai
2024-03-01 3:52 ` [PATCH 05/13] dm vdo: rename uds-threads.[ch] to thread-utils.[ch] Matthew Sakai
2024-03-01 3:52 ` [PATCH 06/13] dm vdo indexer: rename uds.h to indexer.h Matthew Sakai
2024-03-01 3:52 ` [PATCH 07/13] dm vdo: fold thread-cond-var.c into thread-utils Matthew Sakai
2024-03-01 3:53 ` [PATCH 08/13] dm vdo thread-utils: push uds_*_cond interface down to indexer Matthew Sakai
2024-03-01 3:53 ` [PATCH 09/13] dm vdo thread-utils: remove all uds_*_mutex wrappers Matthew Sakai
2024-03-01 3:53 ` [PATCH 10/13] dm vdo thread-utils: further cleanup of thread functions Matthew Sakai
2024-03-01 3:53 ` [PATCH 11/13] dm vdo thread-utils: cleanup included headers Matthew Sakai
2024-03-01 3:53 ` [PATCH 12/13] dm vdo thread-registry: rename all methods to reflect vdo-only use Matthew Sakai
2024-03-01 3:53 ` [PATCH 13/13] dm vdo thread-device: " Matthew Sakai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).