dm vdo: clean up and simplify thread utilities
Subsystems (2)
Matthew Sakai
maintainercover dm vdo: clean up and simplify thread utilities
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.hSignature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 10/13 dm vdo thread-utils: further cleanup of thread functions
From: Mike Snitzer <[email protected]>
Change thread function prefix from "uds_" to "vdo_" and fix vdo_join_threads() to return void.
--- 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(-)
drivers/md/dm-vdo/funnel-requestqueue.c +2 -6
@@ -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);
drivers/md/dm-vdo/index.c +2 -2
@@ -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;
drivers/md/dm-vdo/status-codes.c +1 -1
@@ -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; }
drivers/md/dm-vdo/thread-utils.c +4 -5
@@ -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 ; }
drivers/md/dm-vdo/thread-utils.h +4 -5
@@ -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 */
drivers/md/dm-vdo/volume.c +2 -2
@@ -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 ; }
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 2/13 dm vdo uds-threads: eliminate uds_*_semaphore interfaces
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
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'.
--- drivers/md/dm-vdo/uds-threads.c | 55 ++++++++------------------------- drivers/md/dm-vdo/uds-threads.h | 4 +-- 2 files changed, 15 insertions(+), 44 deletions(-)
drivers/md/dm-vdo/uds-threads.c +13 -42
@@ -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 ;
drivers/md/dm-vdo/uds-threads.h +2 -2
@@ -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 */
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 3/13 dm vdo uds-threads: push 'barrier' down to sparse-cache
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
The sparse-cache is the only user of the 'barrier' data structure, so just move it private to it.
--- 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(-)
drivers/md/dm-vdo/sparse-cache.c +68 -1
@@ -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) {
drivers/md/dm-vdo/uds-threads.c +0 -56
59 lines not on this page · raw message
drivers/md/dm-vdo/uds-threads.h +0 -15
@@ -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);
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 4/13 dm vdo indexer sparse-cache: cleanup threads_barrier code
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
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.
--- drivers/md/dm-vdo/sparse-cache.c | 60 ++++++++++---------------------- 1 file changed, 19 insertions(+), 41 deletions(-)
drivers/md/dm-vdo/sparse-cache.c +19 -41
@@ -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; }
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 7/13 dm vdo: fold thread-cond-var.c into thread-utils
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
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.
--- 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
drivers/md/dm-vdo/Makefile +0 -1
@@ -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 \
drivers/md/dm-vdo/thread-cond-var.c deleted +0 -46
46 lines not on this page · raw message
drivers/md/dm-vdo/thread-utils.c +11 -0
@@ -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); +}
drivers/md/dm-vdo/thread-utils.h +23 -5
@@ -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) {
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 8/13 dm vdo thread-utils: push uds_*_cond interface down to indexer
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
Only used by indexer components. Also return void from uds_init_cond(), remove uds_destroy_cond(), and fix up all callers.
--- 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(-)
drivers/md/dm-vdo/index-session.c +13 -19
@@ -230,36 +230,21 @@ static int __must_check make_empty_index_session(struct uds_index_session **indereturn 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); +}
drivers/md/dm-vdo/index.c +1 -7
@@ -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);
drivers/md/dm-vdo/indexer.h +24 -0
@@ -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 */
drivers/md/dm-vdo/thread-utils.c +0 -12
@@ -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); -}
drivers/md/dm-vdo/thread-utils.h +0 -28
@@ -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 */
drivers/md/dm-vdo/volume.c +2 -13
@@ -1627,17 +1627,8 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layoutreturn 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);
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 9/13 dm vdo thread-utils: remove all uds_*_mutex wrappers
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
Just use mutex_init, mutex_lock and mutex_unlock.
--- 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(-)
drivers/md/dm-vdo/index-session.c +47 -63
@@ -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 **indeif (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); }
drivers/md/dm-vdo/index.c +18 -24
141 lines not on this page · raw message
drivers/md/dm-vdo/thread-utils.h +0 -23
@@ -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 */
drivers/md/dm-vdo/volume-index.c +15 -25
@@ -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_nonreturn 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',
drivers/md/dm-vdo/volume.c +16 -22
@@ -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_layoutreturn 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);
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 11/13 dm vdo thread-utils: cleanup included headers
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
--- 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(-)
drivers/md/dm-vdo/logger.c +1 -0
@@ -11,6 +11,7 @@#include <linux/printk.h> #include <linux/sched.h> +#include "errors.h" #include "thread-device.h" #include "thread-utils.h"
drivers/md/dm-vdo/thread-utils.c +2 -2
@@ -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"
drivers/md/dm-vdo/thread-utils.h +0 -6
@@ -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 */
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 1/13 dm vdo: make uds_*_semaphore interface private to uds-threads.c
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
--- drivers/md/dm-vdo/uds-threads.c | 39 +++++++++++++++++++++++++++++++++ drivers/md/dm-vdo/uds-threads.h | 37 ------------------------------- 2 files changed, 39 insertions(+), 37 deletions(-)
drivers/md/dm-vdo/uds-threads.c +39 -0
@@ -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;
drivers/md/dm-vdo/uds-threads.h +0 -37
@@ -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 */
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 5/13 dm vdo: rename uds-threads.[ch] to thread-utils.[ch]
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
---
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%)drivers/md/dm-vdo/Makefile +1 -1
@@ -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 \
drivers/md/dm-vdo/config.c +1 -1
@@ -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" ;
drivers/md/dm-vdo/funnel-requestqueue.c +1 -1
@@ -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
drivers/md/dm-vdo/index-page-map.c +1 -1
@@ -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" /*
drivers/md/dm-vdo/index-session.h +1 -1
@@ -10,7 +10,7 @@#include <linux/cache.h> #include "config.h" -#include "uds-threads.h" +#include "thread-utils.h" #include "uds.h" /*
drivers/md/dm-vdo/logger.c +1 -1
@@ -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;
drivers/md/dm-vdo/status-codes.c +1 -1
@@ -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" },
drivers/md/dm-vdo/thread-cond-var.c +1 -1
@@ -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) {
drivers/md/dm-vdo/thread-utils.c renamed from drivers/md/dm-vdo/uds-threads.c +1 -1
@@ -3,7 +3,7 @@* Copyright 2023 Red Hat */ -#include "uds-threads.h" +#include "thread-utils.h" #include <linux/completion.h> #include <linux/delay.h>
drivers/md/dm-vdo/thread-utils.h renamed from drivers/md/dm-vdo/uds-threads.h +2 -3
@@ -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 */
drivers/md/dm-vdo/volume-index.c +1 -1
@@ -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
drivers/md/dm-vdo/volume-index.h +1 -1
@@ -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
drivers/md/dm-vdo/volume.c +1 -1
@@ -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.
drivers/md/dm-vdo/volume.h +1 -1
@@ -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
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 12/13 dm vdo thread-registry: rename all methods to reflect vdo-only use
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
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).
--- 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(-)
drivers/md/dm-vdo/memory-alloc.c +6 -6
@@ -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_stringvoid 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 )
drivers/md/dm-vdo/thread-device.c +4 -4
@@ -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); }
drivers/md/dm-vdo/thread-registry.c +4 -4
@@ -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 ;
drivers/md/dm-vdo/thread-registry.h +7 -7
@@ -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 */
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 13/13 dm vdo thread-device: rename all methods to reflect vdo-only use
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
Also moved vdo_init()'s call to vdo_initialize_thread_device_registry next to other registry initialization.
--- 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(-)
drivers/md/dm-vdo/dm-vdo-target.c +15 -15
@@ -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 **argif (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 );
drivers/md/dm-vdo/logger.c +1 -1
@@ -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,
drivers/md/dm-vdo/thread-device.c +4 -6
@@ -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); }
drivers/md/dm-vdo/thread-device.h +7 -7
@@ -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 */
Signature · 1 line
2.42.0
Matthew Sakai
maintainerPATCH 6/13 dm vdo indexer: rename uds.h to indexer.h
In reply to Matthew SakaiFrom: Mike Snitzer <[email protected]>
Also remove unnecessary include from funnel-queue.c.
---
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%)drivers/md/dm-vdo/chapter-index.c +1 -1
@@ -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)
drivers/md/dm-vdo/config.h +1 -1
@@ -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
drivers/md/dm-vdo/data-vio.h +1 -1
@@ -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"
drivers/md/dm-vdo/dedupe.c +1 -1
@@ -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"
drivers/md/dm-vdo/dedupe.h +1 -1
@@ -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"
drivers/md/dm-vdo/delta-index.c +1 -1
@@ -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
drivers/md/dm-vdo/encodings.h +1 -1
@@ -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"
drivers/md/dm-vdo/funnel-queue.c +0 -1
@@ -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) {
drivers/md/dm-vdo/funnel-requestqueue.h +1 -1
@@ -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,
drivers/md/dm-vdo/geometry.c +1 -1
@@ -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
drivers/md/dm-vdo/geometry.h +1 -1
@@ -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
drivers/md/dm-vdo/hash-utils.h +1 -1
@@ -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. */
drivers/md/dm-vdo/index-layout.h +1 -1
@@ -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
drivers/md/dm-vdo/index-page-map.c +1 -1
@@ -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
drivers/md/dm-vdo/index-session.h +1 -1
@@ -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,
drivers/md/dm-vdo/indexer.h renamed from drivers/md/dm-vdo/uds.h +3 -3
@@ -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 */
drivers/md/dm-vdo/sparse-cache.h +1 -1
@@ -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
drivers/md/dm-vdo/uds-sysfs.c +1 -1
@@ -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"
drivers/md/dm-vdo/vdo.h +1 -1
@@ -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 */
drivers/md/dm-vdo/volume-index.c +1 -1
@@ -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
drivers/md/dm-vdo/volume-index.h +1 -1
@@ -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
drivers/md/dm-vdo/volume.h +1 -1
@@ -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
Signature · 1 line
2.42.0