From 3b6dfd9ffecb883c4d1a0f2edb5ec8a8720cb35a Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 16 Sep 2013 18:52:10 +0200 Subject: [PATCH 1/2] Fixes the -G option and adds test for it. --- Makefile.am | 2 ++ dup.c | 2 +- snapraid.c | 30 +++++++++++++++--------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9153c6d8..cd34c2ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -116,7 +116,9 @@ endif echo --- Create some files, sync raid6 and check $(TESTENV) ./mktest$(EXEEXT) generate 1 3 $(CHECKCOUNT) $(CHECKSIZE) $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf diff > test.log + $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf diff -G > test.log $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf dup + $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf dup -G $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -c $(srcdir)/test-raid6.conf --test-force-order-physical sync $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -c $(srcdir)/test-raid6.conf status if HAVE_SYMLINK diff --git a/dup.c b/dup.c index 19425bfd..d7d6adc5 100644 --- a/dup.c +++ b/dup.c @@ -95,7 +95,7 @@ void state_dup(struct snapraid_state* state) count = 0; size = 0; - + /* for each disk */ for(i=state->disklist;i!=0;i=i->next) { tommy_node* j; diff --git a/snapraid.c b/snapraid.c index 6d21be4f..fccea839 100644 --- a/snapraid.c +++ b/snapraid.c @@ -508,6 +508,21 @@ int main(int argc, char* argv[]) raid_init(); crc32c_init(); + /* open the log file */ + if (log == 0) + log = "2"; + if (strcmp(log, "1") == 0) { + stdlog = stdout; + } else if (strcmp(log, "2") == 0) { + stdlog = stderr; + } else { + stdlog = fopen(log, "wt"); + if (!stdlog) { + fprintf(stderr, "Error opening the log file '%s'. %s.\n", log, strerror(errno)); + exit(EXIT_FAILURE); + } + } + if (!opt.skip_self) selftest(opt.gui); @@ -534,21 +549,6 @@ int main(int argc, char* argv[]) (void)lock; #endif - /* open the log file */ - if (log == 0) - log = "2"; - if (strcmp(log, "1") == 0) { - stdlog = stdout; - } else if (strcmp(log, "2") == 0) { - stdlog = stderr; - } else { - stdlog = fopen(log, "wt"); - if (!stdlog) { - fprintf(stderr, "Error opening the log file '%s'. %s.\n", log, strerror(errno)); - exit(EXIT_FAILURE); - } - } - if (operation == OPERATION_DIFF) { state_read(&state); From 194846f01b0f40554707f86d2b24a87d0bedb5d1 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 16 Sep 2013 19:49:42 +0200 Subject: [PATCH 2/2] Uses q-parity instead qarity in messages. --- check.c | 12 ++++++------ dry.c | 2 +- scrub.c | 4 ++-- state.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/check.c b/check.c index c94e87dc..6a512170 100644 --- a/check.c +++ b/check.c @@ -172,7 +172,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u return 0; } - fprintf(stdlog, "error:%u:qarity: Data error\n", pos); + fprintf(stdlog, "error:%u:q-parity: Data error\n", pos); ++error; } @@ -191,7 +191,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u return 0; } - fprintf(stdlog, "error:%u:parity/qarity: Data error\n", pos); + fprintf(stdlog, "error:%u:parity/q-parity: Data error\n", pos); ++error; } @@ -222,7 +222,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u return 0; } - fprintf(stdlog, "error:%u:parity/qarity: Data error\n", pos); + fprintf(stdlog, "error:%u:parity/q-parity: Data error\n", pos); ++error; } @@ -766,7 +766,7 @@ static int state_check_process(struct snapraid_state* state, int check, int fix, if (ret == -1) { buffer_qarity = 0; /* no qarity to use */ - fprintf(stdlog, "error:%u:qarity: Read error\n", i); + fprintf(stdlog, "error:%u:q-parity: Read error\n", i); ++error; } } else { @@ -828,7 +828,7 @@ static int state_check_process(struct snapraid_state* state, int check, int fix, if (buffer_qarity != 0 && memcmp(buffer_qarity, buffer[diskmax + 1], state->block_size) != 0) { buffer_qarity = 0; - fprintf(stdlog, "error:%u:qarity: Data error\n", i); + fprintf(stdlog, "error:%u:q-parity: Data error\n", i); ++error; } } @@ -907,7 +907,7 @@ static int state_check_process(struct snapraid_state* state, int check, int fix, goto bail; } - fprintf(stdlog, "fixed:%u:qarity: Fixed data error\n", i); + fprintf(stdlog, "fixed:%u:q-parity: Fixed data error\n", i); ++recovered_error; } } diff --git a/dry.c b/dry.c index d00a52e1..19c86cda 100644 --- a/dry.c +++ b/dry.c @@ -111,7 +111,7 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit if (qarity) { ret = parity_read(qarity, i, buffer_aligned, state->block_size, stdlog); if (ret == -1) { - fprintf(stdlog, "error:%u:qarity: Read error\n", i); + fprintf(stdlog, "error:%u:q-parity: Read error\n", i); ++error; } } diff --git a/scrub.c b/scrub.c index b15cc4cc..a4b44541 100644 --- a/scrub.c +++ b/scrub.c @@ -307,7 +307,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par ret = parity_read(qarity, i, buffer_qarity, state->block_size, stdlog); if (ret == -1) { buffer_qarity = 0; - fprintf(stdlog, "error:%u:qarity: Read error\n", i); + fprintf(stdlog, "error:%u:q-parity: Read error\n", i); ++error; error_on_this_block = 1; } @@ -331,7 +331,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par } if (state->level >= 2) { if (buffer_qarity && memcmp(buffer[diskmax + 1], buffer_qarity, state->block_size) != 0) { - fprintf(stdlog, "error:%u:qarity: Data error\n", i); + fprintf(stdlog, "error:%u:q-parity: Data error\n", i); ++error; /* it's a silent error only if we are dealing with synched blocks */ diff --git a/state.c b/state.c index 0b03d6d4..dd3274ce 100644 --- a/state.c +++ b/state.c @@ -388,7 +388,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co else pathcpy(device, sizeof(device), "."); if (stat(device, &st) != 0) { - fprintf(stderr, "Error accessing 'qarity' dir '%s' specification in '%s' at line %u\n", device, path, line); + fprintf(stderr, "Error accessing 'q-parity' dir '%s' specification in '%s' at line %u\n", device, path, line); exit(EXIT_FAILURE); } @@ -657,7 +657,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co fprintf(stdlog, "mode:raid5\n"); fprintf(stdlog, "parity:%s\n", state->parity); if (state->qarity[0] != 0) - fprintf(stdlog, "qarity:%s\n", state->qarity); + fprintf(stdlog, "q-parity:%s\n", state->qarity); if (state->pool[0] != 0) fprintf(stdlog, "pool:%s\n", state->pool); fflush(stdlog);