mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-25 18:40:19 -04:00
Speed up reading of content file disabling mutexes
This commit is contained in:
parent
34ee2bf2a6
commit
b8b1d38781
4 changed files with 21 additions and 2 deletions
2
TODO
2
TODO
|
|
@ -5,6 +5,8 @@ This is the list of TODO items for SnapRAID.
|
|||
|
||||
- Next
|
||||
|
||||
* Use a memory mapped file to read the content file
|
||||
|
||||
* Integration with MergeFS ?
|
||||
|
||||
* Evaluate use of syscall getdents64() instead of readdir(): https://linux.die.net/man/2/getdents64
|
||||
|
|
|
|||
|
|
@ -765,6 +765,7 @@ struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev
|
|||
pathslash(disk->dir, sizeof(disk->dir));
|
||||
|
||||
#if HAVE_THREAD
|
||||
disk->single_thread = 0;
|
||||
thread_mutex_init(&disk->fs_mutex);
|
||||
#endif
|
||||
|
||||
|
|
@ -856,7 +857,8 @@ void extra_free(struct snapraid_extra* extra)
|
|||
static inline void fs_lock(struct snapraid_disk* disk)
|
||||
{
|
||||
#if HAVE_THREAD
|
||||
thread_mutex_lock(&disk->fs_mutex);
|
||||
if (!disk->single_thread)
|
||||
thread_mutex_lock(&disk->fs_mutex);
|
||||
#else
|
||||
(void)disk;
|
||||
#endif
|
||||
|
|
@ -865,7 +867,8 @@ static inline void fs_lock(struct snapraid_disk* disk)
|
|||
static inline void fs_unlock(struct snapraid_disk* disk)
|
||||
{
|
||||
#if HAVE_THREAD
|
||||
thread_mutex_unlock(&disk->fs_mutex);
|
||||
if (!disk->single_thread)
|
||||
thread_mutex_unlock(&disk->fs_mutex);
|
||||
#else
|
||||
(void)disk;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -388,6 +388,8 @@ struct snapraid_disk {
|
|||
int skip_access; /**< If the disk is inaccessible and it should be skipped. */
|
||||
|
||||
#if HAVE_THREAD
|
||||
int single_thread; /**< Running in single thread, and then not needing the mutex */
|
||||
|
||||
/**
|
||||
* Mutex for protecting the filesystem structure.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2133,6 +2133,12 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
|
|||
tommy_array_init(&disk_mapping);
|
||||
tommy_hashdyn_init(&bucket_hash);
|
||||
|
||||
/* mark all disks as single threads */
|
||||
for (tommy_node* i = state->disklist; i != 0; i = i->next) {
|
||||
struct snapraid_disk* disk = i->data;
|
||||
disk->single_thread = 1;
|
||||
}
|
||||
|
||||
ret = sread(f, buffer, 12);
|
||||
if (ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
@ -3231,6 +3237,12 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
|
|||
}
|
||||
}
|
||||
|
||||
/* mark all disks as multi threads */
|
||||
for (tommy_node* i = state->disklist; i != 0; i = i->next) {
|
||||
struct snapraid_disk* disk = i->data;
|
||||
disk->single_thread = 0;
|
||||
}
|
||||
|
||||
tommy_array_done(&disk_mapping);
|
||||
|
||||
if (serror(f)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue