Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm vdo: remove vdo_perform_once

Remove obsolete function vdo_perform_once. Instead, initialize
necessary module state when loading the module.

Signed-off-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>

authored by

Matthew Sakai and committed by
Mike Snitzer
7eb30fe1 d0464d82

+10 -54
+2
drivers/md/dm-vdo/dm-vdo-target.c
··· 34 34 #include "string-utils.h" 35 35 #include "thread-device.h" 36 36 #include "thread-registry.h" 37 + #include "thread-utils.h" 37 38 #include "types.h" 38 39 #include "vdo.h" 39 40 #include "vio.h" ··· 2873 2872 2874 2873 /* Memory tracking must be initialized first for accurate accounting. */ 2875 2874 vdo_memory_init(); 2875 + vdo_initialize_threads_mutex(); 2876 2876 vdo_initialize_thread_device_registry(); 2877 2877 vdo_initialize_device_registry_once(); 2878 2878 vdo_log_info("loaded version %s", CURRENT_VERSION);
+6 -24
drivers/md/dm-vdo/status-codes.c
··· 40 40 { "VDO_INVALID_ADMIN_STATE", "Invalid operation for current state" }, 41 41 }; 42 42 43 - static atomic_t vdo_status_codes_registered = ATOMIC_INIT(0); 44 - static int status_code_registration_result; 45 - 46 - static void do_status_code_registration(void) 43 + /** 44 + * vdo_register_status_codes() - Register the VDO status codes. 45 + * Return: A success or error code. 46 + */ 47 + int vdo_register_status_codes(void) 47 48 { 48 49 int result; 49 50 ··· 54 53 result = uds_register_error_block("VDO Status", VDO_STATUS_CODE_BASE, 55 54 VDO_STATUS_CODE_BLOCK_END, vdo_status_list, 56 55 sizeof(vdo_status_list)); 57 - /* 58 - * The following test handles cases where libvdo is statically linked against both the test 59 - * modules and the test driver (because multiple instances of this module call their own 60 - * copy of this function once each, resulting in multiple calls to register_error_block 61 - * which is shared in libuds). 62 - */ 63 - if (result == UDS_DUPLICATE_NAME) 64 - result = UDS_SUCCESS; 65 - 66 - status_code_registration_result = (result == UDS_SUCCESS) ? VDO_SUCCESS : result; 67 - } 68 - 69 - /** 70 - * vdo_register_status_codes() - Register the VDO status codes if needed. 71 - * Return: A success or error code. 72 - */ 73 - int vdo_register_status_codes(void) 74 - { 75 - vdo_perform_once(&vdo_status_codes_registered, do_status_code_registration); 76 - return status_code_registration_result; 56 + return (result == UDS_SUCCESS) ? VDO_SUCCESS : result; 77 57 } 78 58 79 59 /**
+1 -27
drivers/md/dm-vdo/thread-utils.c
··· 17 17 18 18 static struct hlist_head thread_list; 19 19 static struct mutex thread_mutex; 20 - static atomic_t thread_once = ATOMIC_INIT(0); 21 20 22 21 struct thread { 23 22 void (*thread_function)(void *thread_data); ··· 26 27 struct completion thread_done; 27 28 }; 28 29 29 - #define ONCE_NOT_DONE 0 30 - #define ONCE_IN_PROGRESS 1 31 - #define ONCE_COMPLETE 2 32 - 33 - /* Run a function once only, and record that fact in the atomic value. */ 34 - void vdo_perform_once(atomic_t *once, void (*function)(void)) 35 - { 36 - for (;;) { 37 - switch (atomic_cmpxchg(once, ONCE_NOT_DONE, ONCE_IN_PROGRESS)) { 38 - case ONCE_NOT_DONE: 39 - function(); 40 - atomic_set_release(once, ONCE_COMPLETE); 41 - return; 42 - case ONCE_IN_PROGRESS: 43 - cond_resched(); 44 - break; 45 - case ONCE_COMPLETE: 46 - return; 47 - default: 48 - return; 49 - } 50 - } 51 - } 52 - 53 - static void thread_init(void) 30 + void vdo_initialize_threads_mutex(void) 54 31 { 55 32 mutex_init(&thread_mutex); 56 33 } ··· 37 62 struct thread *thread = arg; 38 63 39 64 thread->thread_task = current; 40 - vdo_perform_once(&thread_once, thread_init); 41 65 mutex_lock(&thread_mutex); 42 66 hlist_add_head(&thread->thread_links, &thread_list); 43 67 mutex_unlock(&thread_mutex);
+1 -3
drivers/md/dm-vdo/thread-utils.h
··· 12 12 13 13 struct thread; 14 14 15 - 15 + void vdo_initialize_threads_mutex(void); 16 16 int __must_check vdo_create_thread(void (*thread_function)(void *), void *thread_data, 17 17 const char *name, struct thread **new_thread); 18 18 void vdo_join_threads(struct thread *thread); 19 - 20 - void vdo_perform_once(atomic_t *once_state, void (*function) (void)); 21 19 22 20 #endif /* UDS_THREADS_H */