mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Avoids to access parity disks when not needed.
This commit is contained in:
parent
5383f00b5f
commit
9b74284e35
4 changed files with 43 additions and 15 deletions
2
HISTORY
2
HISTORY
|
|
@ -25,6 +25,8 @@ SnapRAID HISTORY
|
|||
default value even if the other one is specified.
|
||||
* Moved the .lock file in the same dir of the first specified content
|
||||
file. This avoid to spin the parity disks in all commands.
|
||||
* The "diff", "list", "dup", "status" and "pool" commands don't access
|
||||
anymore the parity disks that can stay powered down.
|
||||
* New source code organization. The RAID engine is now
|
||||
an external component usable also in other projects.
|
||||
|
||||
|
|
|
|||
19
snapraid.c
19
snapraid.c
|
|
@ -211,6 +211,7 @@ void log_close(const char* log)
|
|||
#define OPT_TEST_FORCE_CONTENT_WRITE 273
|
||||
#define OPT_TEST_FORCE_CONTENT_TEXT 274
|
||||
#define OPT_TEST_SKIP_CONTENT_CHECK 275
|
||||
#define OPT_TEST_SKIP_PARITY_ACCESS 276
|
||||
|
||||
#if HAVE_GETOPT_LONG
|
||||
struct option long_options[] = {
|
||||
|
|
@ -296,6 +297,9 @@ struct option long_options[] = {
|
|||
/* Relax the checks done at the content file */
|
||||
{ "test-skip-content-check", 0, 0, OPT_TEST_SKIP_CONTENT_CHECK },
|
||||
|
||||
/* Skip the parity access */
|
||||
{ "test-skip-parity-access", 0, 0, OPT_TEST_SKIP_PARITY_ACCESS },
|
||||
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
#endif
|
||||
|
|
@ -535,6 +539,9 @@ int main(int argc, char* argv[])
|
|||
case OPT_TEST_SKIP_CONTENT_CHECK :
|
||||
opt.skip_content_check = 1;
|
||||
break;
|
||||
case OPT_TEST_SKIP_PARITY_ACCESS :
|
||||
opt.skip_parity_access = 1;
|
||||
break;
|
||||
case OPT_TEST_FORCE_MURMUR3 :
|
||||
opt.force_murmur3 = 1;
|
||||
break;
|
||||
|
|
@ -696,6 +703,18 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
switch (operation) {
|
||||
case OPERATION_DIFF :
|
||||
case OPERATION_LIST :
|
||||
case OPERATION_DUP :
|
||||
case OPERATION_POOL :
|
||||
case OPERATION_STATUS :
|
||||
case OPERATION_REWRITE :
|
||||
/* avoid to check and access parity disks if not needed */
|
||||
opt.skip_parity_access = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* open the log file */
|
||||
log_open(log);
|
||||
|
||||
|
|
|
|||
36
state.c
36
state.c
|
|
@ -452,7 +452,6 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
) {
|
||||
char device[PATH_MAX];
|
||||
char* slash;
|
||||
struct stat st;
|
||||
unsigned l;
|
||||
|
||||
switch (tag[0]) {
|
||||
|
|
@ -500,21 +499,28 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
|
||||
pathimport(state->parity_path[l], sizeof(state->parity_path[l]), buffer);
|
||||
|
||||
/* get the device of the directory containing the parity file */
|
||||
pathimport(device, sizeof(device), buffer);
|
||||
slash = strrchr(device, '/');
|
||||
if (slash)
|
||||
*slash = 0;
|
||||
else
|
||||
pathcpy(device, sizeof(device), ".");
|
||||
if (stat(device, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error accessing 'parity' dir '%s' specification in '%s' at line %u\n", device, path, line);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (state->opt.skip_parity_access) {
|
||||
struct stat st;
|
||||
|
||||
state->parity_device[l] = st.st_dev;
|
||||
/* get the device of the directory containing the parity file */
|
||||
pathimport(device, sizeof(device), buffer);
|
||||
slash = strrchr(device, '/');
|
||||
if (slash)
|
||||
*slash = 0;
|
||||
else
|
||||
pathcpy(device, sizeof(device), ".");
|
||||
if (stat(device, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error accessing 'parity' dir '%s' specification in '%s' at line %u\n", device, path, line);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
state->parity_device[l] = st.st_dev;
|
||||
} else {
|
||||
/* if parity is skipped, uses a fake device */
|
||||
state->parity_device[l] = -1LL - l;
|
||||
}
|
||||
|
||||
/* adjust the level */
|
||||
if (state->level < l + 1)
|
||||
|
|
|
|||
1
state.h
1
state.h
|
|
@ -74,6 +74,7 @@ struct snapraid_option {
|
|||
int skip_lock; /**< Skip the lock file protection. */
|
||||
int skip_self; /**< Skip the self-test. */
|
||||
int skip_content_check; /**< Relax some content file checks. */
|
||||
int skip_parity_access; /**< Skip the parity access for commands that don't need it. */
|
||||
int kill_after_sync; /**< Kill the process after sync without saving the final state. */
|
||||
int force_murmur3; /**< Force Murmur3 choice. */
|
||||
int force_spooky2; /**< Force Spooky2 choice. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue