Rename the io->mutex variable to io->io_mutex

This simplifies text search for mutexes.
This commit is contained in:
Andrea Mazzoleni 2016-02-13 15:37:28 +01:00
parent 0707b1f446
commit 93f25c4bc4
2 changed files with 27 additions and 27 deletions

View file

@ -37,7 +37,7 @@ void io_init(struct snapraid_io* io, struct snapraid_state* state,
unsigned i;
size_t allocated;
thread_mutex_init(&io->mutex, 0);
thread_mutex_init(&io->io_mutex, 0);
thread_cond_init(&io->read_done, 0);
thread_cond_init(&io->read_sched, 0);
thread_cond_init(&io->write_done, 0);
@ -140,7 +140,7 @@ void io_done(struct snapraid_io* io)
free(io->writer_map);
free(io->writer_list);
thread_mutex_destroy(&io->mutex);
thread_mutex_destroy(&io->io_mutex);
thread_cond_destroy(&io->read_done);
thread_cond_destroy(&io->read_sched);
thread_cond_destroy(&io->write_done);
@ -258,7 +258,7 @@ static struct snapraid_task* io_reader_step(struct snapraid_worker* worker)
struct snapraid_io* io = worker->io;
/* the synchronization is protected by the io mutex */
thread_mutex_lock(&io->mutex);
thread_mutex_lock(&io->io_mutex);
while (1) {
unsigned next_index;
@ -266,7 +266,7 @@ static struct snapraid_task* io_reader_step(struct snapraid_worker* worker)
/* check if the worker has to exit */
/* even if there is work to do */
if (io->done) {
thread_mutex_unlock(&io->mutex);
thread_mutex_unlock(&io->io_mutex);
return 0;
}
@ -290,9 +290,9 @@ static struct snapraid_task* io_reader_step(struct snapraid_worker* worker)
/* if the just completed task is at this index */
if (done_index == waiting_index) {
/* notify the IO that a new read is complete */
thread_cond_signal_and_unlock(&io->read_done, &io->mutex);
thread_cond_signal_and_unlock(&io->read_done, &io->io_mutex);
} else {
thread_mutex_unlock(&io->mutex);
thread_mutex_unlock(&io->io_mutex);
}
/* return the new task */
@ -300,7 +300,7 @@ static struct snapraid_task* io_reader_step(struct snapraid_worker* worker)
}
/* otherwise wait for a read_sched event */
thread_cond_wait(&io->read_sched, &io->mutex);
thread_cond_wait(&io->read_sched, &io->io_mutex);
}
}
@ -315,7 +315,7 @@ static struct snapraid_task* io_writer_step(struct snapraid_worker* worker, int
int error_index;
/* the synchronization is protected by the io mutex */
thread_mutex_lock(&io->mutex);
thread_mutex_lock(&io->io_mutex);
/* counts the number of errors in the global state */
error_index = state - IO_WRITER_ERROR_BASE;
@ -345,9 +345,9 @@ static struct snapraid_task* io_writer_step(struct snapraid_worker* worker, int
/* if the just completed task is at this index */
if (done_index == waiting_index) {
/* notify the IO that a new write is complete */
thread_cond_signal_and_unlock(&io->write_done, &io->mutex);
thread_cond_signal_and_unlock(&io->write_done, &io->io_mutex);
} else {
thread_mutex_unlock(&io->mutex);
thread_mutex_unlock(&io->io_mutex);
}
/* return the new task */
@ -357,12 +357,12 @@ static struct snapraid_task* io_writer_step(struct snapraid_worker* worker, int
/* check if the worker has to exit */
/* but only if there is no work to do */
if (io->done) {
thread_mutex_unlock(&io->mutex);
thread_mutex_unlock(&io->io_mutex);
return 0;
}
/* otherwise wait for a write_sched event */
thread_cond_wait(&io->write_sched, &io->mutex);
thread_cond_wait(&io->write_sched, &io->io_mutex);
}
}
@ -388,7 +388,7 @@ block_off_t io_read_next(struct snapraid_io* io, void*** buffer)
io->reader_list[i] = i;
/* the synchronization is protected by the io mutex */
thread_mutex_lock(&io->mutex);
thread_mutex_lock(&io->io_mutex);
/* schedule the next read */
io_reader_sched(io, io->reader_index, blockcur_schedule);
@ -403,7 +403,7 @@ block_off_t io_read_next(struct snapraid_io* io, void*** buffer)
*buffer = io->buffer_map[io->reader_index];
/* signal all the workers that there is a new pending task */
thread_cond_broadcast_and_unlock(&io->read_sched, &io->mutex);
thread_cond_broadcast_and_unlock(&io->read_sched, &io->io_mutex);
return blockcur_caller;
}
@ -420,7 +420,7 @@ void io_write_next(struct snapraid_io* io, block_off_t blockcur, int skip, int*
io->writer_list[i] = i;
/* the synchronization is protected by the io mutex */
thread_mutex_lock(&io->mutex);
thread_mutex_lock(&io->io_mutex);
/* report errors */
for (i = 0; i < IO_WRITER_ERROR_MAX; ++i) {
@ -443,7 +443,7 @@ void io_write_next(struct snapraid_io* io, block_off_t blockcur, int skip, int*
io->writer_index = (io->writer_index + 1) % io->io_max;
/* signal all the workers that there is a new pending task */
thread_cond_broadcast_and_unlock(&io->write_sched, &io->mutex);
thread_cond_broadcast_and_unlock(&io->write_sched, &io->io_mutex);
}
void io_refresh(struct snapraid_io* io)
@ -451,7 +451,7 @@ void io_refresh(struct snapraid_io* io)
unsigned i;
/* the synchronization is protected by the io mutex */
thread_mutex_lock(&io->mutex);
thread_mutex_lock(&io->io_mutex);
/* for all readers, count the number of read blocks */
for (i = 0; i < io->reader_max; ++i) {
@ -489,7 +489,7 @@ void io_refresh(struct snapraid_io* io)
io->state->parity[worker->parity_handle->level].cached = cached;
}
thread_mutex_unlock(&io->mutex);
thread_mutex_unlock(&io->io_mutex);
}
static struct snapraid_task* io_task_read(struct snapraid_io* io, unsigned base, unsigned count, unsigned* pos, unsigned* waiting_map, unsigned* waiting_mac)
@ -503,7 +503,7 @@ static struct snapraid_task* io_task_read(struct snapraid_io* io, unsigned base,
*waiting_mac = 0;
/* the synchronization is protected by the io mutex */
thread_mutex_lock(&io->mutex);
thread_mutex_lock(&io->io_mutex);
while (1) {
unsigned char* let;
@ -541,7 +541,7 @@ static struct snapraid_task* io_task_read(struct snapraid_io* io, unsigned base,
task = &worker->task_map[io->reader_index];
thread_mutex_unlock(&io->mutex);
thread_mutex_unlock(&io->io_mutex);
/* mark the worker as processed */
/* setting the previous one to point at the next one */
@ -563,7 +563,7 @@ static struct snapraid_task* io_task_read(struct snapraid_io* io, unsigned base,
}
/* if no worker is ready, wait for an event */
thread_cond_wait(&io->read_done, &io->mutex);
thread_cond_wait(&io->read_done, &io->io_mutex);
/* count the cycles */
++waiting_cycle;
@ -591,7 +591,7 @@ void io_parity_write(struct snapraid_io* io, unsigned* pos, unsigned* waiting_ma
*waiting_mac = 0;
/* the synchronization is protected by the io mutex */
thread_mutex_lock(&io->mutex);
thread_mutex_lock(&io->io_mutex);
while (1) {
unsigned char* let;
@ -627,7 +627,7 @@ void io_parity_write(struct snapraid_io* io, unsigned* pos, unsigned* waiting_ma
/* if the worker has finished this index */
if (busy_index != worker->index) {
thread_mutex_unlock(&io->mutex);
thread_mutex_unlock(&io->io_mutex);
/* mark the worker as processed */
/* setting the previous one to point at the next one */
@ -648,7 +648,7 @@ void io_parity_write(struct snapraid_io* io, unsigned* pos, unsigned* waiting_ma
}
/* if no worker is ready, wait for an event */
thread_cond_wait(&io->write_done, &io->mutex);
thread_cond_wait(&io->write_done, &io->io_mutex);
/* count the cycles */
++waiting_cycle;
@ -785,7 +785,7 @@ void io_stop(struct snapraid_io* io)
{
unsigned i;
thread_mutex_lock(&io->mutex);
thread_mutex_lock(&io->io_mutex);
/* mark that we are stopping */
io->done = 1;
@ -794,7 +794,7 @@ void io_stop(struct snapraid_io* io)
thread_cond_broadcast(&io->read_sched);
thread_cond_broadcast(&io->write_sched);
thread_mutex_unlock(&io->mutex);
thread_mutex_unlock(&io->io_mutex);
/* wait for all readers to terminate */
for (i = 0; i < io->reader_max; ++i) {

View file

@ -148,7 +148,7 @@ struct snapraid_io {
* Mutex used to protect the synchronization
* between the io and the workers.
*/
pthread_mutex_t mutex;
pthread_mutex_t io_mutex;
/**
* Condition for a new read is completed.