diff --git a/HISTORY b/HISTORY index 317a98a8..e8b09603 100644 --- a/HISTORY +++ b/HISTORY @@ -10,6 +10,8 @@ SnapRAID HISTORY * More efficient 'pool' command that updates only the links that need to be updated. This ensures that no change is done, avoiding to trigger a directory rescan of other programs. + * Changed the --test-io-stats screen to print the file name in process + for each disk. 11.1 2017/05 ============ diff --git a/cmdline/dry.c b/cmdline/dry.c index 54720e8a..2fc3b18f 100644 --- a/cmdline/dry.c +++ b/cmdline/dry.c @@ -248,6 +248,8 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit if (!disk) continue; + state_usage_file(state, disk, task->file); + /* if the block is not used */ if (!block_has_file(block)) continue; diff --git a/cmdline/elem.c b/cmdline/elem.c index eb663ace..a597c07d 100644 --- a/cmdline/elem.c +++ b/cmdline/elem.c @@ -755,7 +755,8 @@ struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev disk->smartctl[0] = 0; disk->device = dev; disk->tick = 0; - disk->cached = 0; + disk->cached_blocks = 0; + disk->progress_file = 0; disk->total_blocks = 0; disk->free_blocks = 0; disk->first_free_block = 0; diff --git a/cmdline/elem.h b/cmdline/elem.h index c41cdaeb..e821e419 100644 --- a/cmdline/elem.h +++ b/cmdline/elem.h @@ -338,7 +338,8 @@ struct snapraid_disk { uint64_t tick; /**< Usage time. */ uint64_t progress_tick[PROGRESS_MAX]; /**< Last ticks of progress. */ - unsigned cached; /**< Number of IO blocks cached. */ + unsigned cached_blocks; /**< Number of IO blocks cached. */ + struct snapraid_file* progress_file; /**< File in progress. */ /** * First free searching block. @@ -468,7 +469,7 @@ struct snapraid_parity { int skip_access; /**< If at least one of the parity disk is inaccessible and it should be skipped. */ uint64_t tick; /**< Usage time. */ uint64_t progress_tick[PROGRESS_MAX]; /**< Last cpu ticks of progress. */ - unsigned cached; /**< Number of IO blocks cached. */ + unsigned cached_blocks; /**< Number of IO blocks cached. */ }; /** diff --git a/cmdline/io.c b/cmdline/io.c index 8b43703c..bafea0db 100644 --- a/cmdline/io.c +++ b/cmdline/io.c @@ -490,9 +490,9 @@ static void io_refresh_thread(struct snapraid_io* io) cached = end - begin; if (worker->parity_handle) - io->state->parity[worker->parity_handle->level].cached = cached; + io->state->parity[worker->parity_handle->level].cached_blocks = cached; else - worker->handle->disk->cached = cached; + worker->handle->disk->cached_blocks = cached; } /* for all writers, count the number of written blocks */ @@ -509,7 +509,7 @@ static void io_refresh_thread(struct snapraid_io* io) end += io->io_max; cached = end - begin; - io->state->parity[worker->parity_handle->level].cached = cached; + io->state->parity[worker->parity_handle->level].cached_blocks = cached; } thread_mutex_unlock(&io->io_mutex); diff --git a/cmdline/scrub.c b/cmdline/scrub.c index b744278f..20a7ead3 100644 --- a/cmdline/scrub.c +++ b/cmdline/scrub.c @@ -392,6 +392,8 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par if (!disk) continue; + state_usage_file(state, disk, file); + /* if the block is unsynced, errors are expected */ if (block_has_invalid_parity(block)) { /* report that the block and the file are not synced */ diff --git a/cmdline/state.c b/cmdline/state.c index 7794b59c..a1a922b0 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -161,7 +161,7 @@ void state_init(struct snapraid_state* state) state->parity[l].free_blocks = 0; state->parity[l].skip_access = 0; state->parity[l].tick = 0; - state->parity[l].cached = 0; + state->parity[l].cached_blocks = 0; state->parity[l].is_excluded_by_filter = 0; } state->tick_io = 0; @@ -4253,17 +4253,23 @@ static void state_progress_graph(struct snapraid_state* state, struct snapraid_i printf("\n"); + /* search for the slowest */ for (i = state->disklist; i != 0; i = i->next) { struct snapraid_disk* disk = i->data; - v = disk->cached; + v = disk->cached_blocks; printr(disk->name, pad); printf("%4" PRIu64 " | ", v); - printc('o', v * bar / io->io_max); + + if (disk->progress_file && disk->progress_file->sub) + printf("%s", disk->progress_file->sub); + else + printf("-"); + printf("\n"); } for (l = 0; l < state->level; ++l) { - v = state->parity[l].cached; + v = state->parity[l].cached_blocks; printr(lev_config_name(l), pad); printf("%4" PRIu64 " | ", v); printc('o', v * bar / io->io_max); @@ -4289,6 +4295,9 @@ static void state_progress_graph(struct snapraid_state* state, struct snapraid_i printf("%3" PRIu64 "%% | ", v * 100 / tick_total); printc('*', v * bar / tick_total); printf("\n"); + + /* clear the file in progress */ + disk->progress_file = 0; } for (l = 0; l < state->level; ++l) { @@ -4543,6 +4552,13 @@ void state_usage_hash(struct snapraid_state* state) state->tick_last = now; } +void state_usage_file(struct snapraid_state* state, struct snapraid_disk* disk, struct snapraid_file* file) +{ + (void)state; + + disk->progress_file = file; +} + void state_usage_disk(struct snapraid_state* state, struct snapraid_handle* handle_map, unsigned* waiting_map, unsigned waiting_mac) { uint64_t now = tick(); diff --git a/cmdline/state.h b/cmdline/state.h index 6e190e82..cbc1a556 100644 --- a/cmdline/state.h +++ b/cmdline/state.h @@ -347,6 +347,11 @@ void state_usage_sched(struct snapraid_state* state); void state_usage_raid(struct snapraid_state* state); void state_usage_hash(struct snapraid_state* state); +/** + * Set the last file used + */ +void state_usage_file(struct snapraid_state* state, struct snapraid_disk* disk, struct snapraid_file* file); + /** * Set the usage time for a set of data disks. */ diff --git a/cmdline/sync.c b/cmdline/sync.c index 929d3acd..dbcce38c 100644 --- a/cmdline/sync.c +++ b/cmdline/sync.c @@ -248,6 +248,8 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta /* until now is disk */ state_usage_disk(state, handle, &j, 1); + state_usage_file(state, disk, file); + countsize += read_size; /* now compute the hash */ @@ -851,6 +853,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari if (!disk) continue; + state_usage_file(state, disk, file); + /* get the state of the block */ block_state = block_state_get(block);