From 2b1e356099408426cd553d971049889ee999dfa7 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 28 Feb 2026 09:18:20 +0100 Subject: [PATCH] Always use the mutex when scanning disks --- cmdline/elem.c | 16 ++-------------- cmdline/elem.h | 6 ------ cmdline/io.c | 7 ------- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/cmdline/elem.c b/cmdline/elem.c index 6922e813..92f61c77 100644 --- a/cmdline/elem.c +++ b/cmdline/elem.c @@ -766,7 +766,6 @@ struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev #if HAVE_THREAD thread_mutex_init(&disk->fs_mutex); - disk->fs_mutex_enabled = 0; /* lock will be enabled at threads start */ #endif disk->smartctl[0] = 0; @@ -825,20 +824,10 @@ void disk_free(struct snapraid_disk* disk) free(disk); } -void disk_start_thread(struct snapraid_disk* disk) -{ -#if HAVE_THREAD - disk->fs_mutex_enabled = 1; -#else - (void)disk; -#endif -} - static inline void fs_lock(struct snapraid_disk* disk) { #if HAVE_THREAD - if (disk->fs_mutex_enabled) - thread_mutex_lock(&disk->fs_mutex); + thread_mutex_lock(&disk->fs_mutex); #else (void)disk; #endif @@ -847,8 +836,7 @@ static inline void fs_lock(struct snapraid_disk* disk) static inline void fs_unlock(struct snapraid_disk* disk) { #if HAVE_THREAD - if (disk->fs_mutex_enabled) - thread_mutex_unlock(&disk->fs_mutex); + thread_mutex_unlock(&disk->fs_mutex); #else (void)disk; #endif diff --git a/cmdline/elem.h b/cmdline/elem.h index e947e596..0b51f747 100644 --- a/cmdline/elem.h +++ b/cmdline/elem.h @@ -379,7 +379,6 @@ struct snapraid_disk { * change during multithread processing. */ thread_mutex_t fs_mutex; - int fs_mutex_enabled; /*< If the lock has to be used. */ /** * Mutex for protecting the scan process. @@ -997,11 +996,6 @@ struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev */ void disk_free(struct snapraid_disk* disk); -/** - * Enable multithread support for the disk. - */ -void disk_start_thread(struct snapraid_disk* disk); - /** * Get the size of the disk in blocks. */ diff --git a/cmdline/io.c b/cmdline/io.c index f1c1e489..65fe1269 100644 --- a/cmdline/io.c +++ b/cmdline/io.c @@ -812,13 +812,6 @@ static void io_start_thread(struct snapraid_io* io, bit_vect_t* block_enabled) { unsigned i; - tommy_node* j; - - /* enable the filesystem mutex in all disks */ - for (j = io->state->disklist; j != 0; j = j->next) { - struct snapraid_disk* disk = j->data; - disk_start_thread(disk); - } io->block_start = blockstart; io->block_max = blockmax;