Allow -d, --disk in 'up' and 'down'

This commit is contained in:
Andrea Mazzoleni 2016-01-23 15:31:30 +01:00
parent affc60e256
commit 6f004d13ce
8 changed files with 48 additions and 34 deletions

View file

@ -15,6 +15,8 @@ SnapRAID HISTORY
having verified all the hashes. This allows recovering of moved
files in case a silent error is found during the hash verification
check.
* Allows to use the -d, --filter-disk option in the 'up' and
'down' commands.
* Allows to run the 'smart' command without a configuration file.
In such case it operates on all the disks of the machine.
* In the configuration file 'data' is now a synonymous of 'disk'.

View file

@ -266,7 +266,7 @@ endif
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status -l ">>test.log"
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status -l test-%D-%T.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) up
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) down
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) down -d parity -d disk1
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) devices
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) smart --no-warnings
$(FAILENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) smart --test-fake-device --test-expect-failure

View file

@ -938,7 +938,7 @@ static int devtest(tommy_list* low, int operation)
return 0;
}
void state_device(struct snapraid_state* state, int operation)
void state_device(struct snapraid_state* state, int operation, tommy_list* filterlist_disk)
{
tommy_node* i;
unsigned j;
@ -959,6 +959,9 @@ void state_device(struct snapraid_state* state, int operation)
struct snapraid_disk* disk = i->data;
devinfo_t* entry;
if (filterlist_disk != 0 && filter_path(filterlist_disk, 0, disk->name, 0) != 0)
continue;
entry = calloc_nofail(1, sizeof(devinfo_t));
entry->device = disk->device;
@ -973,6 +976,9 @@ void state_device(struct snapraid_state* state, int operation)
for (j = 0; j < state->level; ++j) {
devinfo_t* entry;
if (filterlist_disk != 0 && filter_path(filterlist_disk, 0, lev_config_name(j), 0) != 0)
continue;
entry = calloc_nofail(1, sizeof(devinfo_t));
entry->device = state->parity[j].device;

View file

@ -923,18 +923,21 @@ int main(int argc, char* argv[])
case OPERATION_DRY :
break;
default :
if (!tommy_list_empty(&filterlist_file)) {
/* LCOV_EXCL_START */
log_fatal("You cannot use -f, --filter with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (!tommy_list_empty(&filterlist_disk)) {
/* LCOV_EXCL_START */
log_fatal("You cannot use -d, --filter-disk with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* follow */
case OPERATION_SPINUP :
case OPERATION_SPINDOWN :
if (!tommy_list_empty(&filterlist_file)) {
/* LCOV_EXCL_START */
log_fatal("You cannot use -f, --filter with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (filter_missing != 0) {
/* LCOV_EXCL_START */
log_fatal("You cannot use -m, --filter-missing with the '%s' command\n", command);
@ -1242,13 +1245,13 @@ int main(int argc, char* argv[])
memory();
} else if (operation == OPERATION_SPINUP) {
state_device(&state, DEVICE_UP);
state_device(&state, DEVICE_UP, &filterlist_disk);
} else if (operation == OPERATION_SPINDOWN) {
state_device(&state, DEVICE_DOWN);
state_device(&state, DEVICE_DOWN, &filterlist_disk);
} else if (operation == OPERATION_DEVICES) {
state_device(&state, DEVICE_LIST);
state_device(&state, DEVICE_LIST, 0);
} else if (operation == OPERATION_SMART) {
state_device(&state, DEVICE_SMART);
state_device(&state, DEVICE_SMART, 0);
} else if (operation == OPERATION_STATUS) {
state_read(&state);

View file

@ -231,7 +231,7 @@ void state_touch(struct snapraid_state* state);
/**
* Devices operations.
*/
void state_device(struct snapraid_state* state, int operation);
void state_device(struct snapraid_state* state, int operation, tommy_list* filterlist_disk);
/**
* Sync the parity data.

View file

@ -731,6 +731,8 @@ Nothing is modified.
.SS up
Spins up all the disks of the array.
.PP
You can spin\-up only some specific disks using the \-d, \-\-filter\-disk option.
.PP
Nothing is modified.
.SS down
Spins down all the disks of the array.
@ -738,6 +740,8 @@ Spins down all the disks of the array.
This command uses the \[dq]smartctl\[dq] tool, and it\'s equivalent to run
\[dq]smartctl \-s standby,now\[dq] on all the devices.
.PP
You can spin\-down only some specific disks using the \-d, \-\-filter\-disk option.
.PP
Nothing is modified.
.SS diff
Lists all the files modified from the last \[dq]sync\[dq] that need to have
@ -967,18 +971,15 @@ Note that it cannot be used with \[dq]sync\[dq] and \[dq]scrub\[dq], because the
process the whole array.
.TP
.B \-d, \-\-filter\-disk NAME
Filters the files to process in \[dq]check\[dq] and \[dq]fix\[dq].
Only the files present in the specified disk are processed.
Filters the disks to process in \[dq]check\[dq], \[dq]fix\[dq], \[dq]up\[dq] and \[dq]down\[dq].
You must specify a disk name as named in the configuration
file.
In \[dq]check\[dq], you can make it faster, specifying also \-a, \-\-audit\-only
option, to avoid to access other disks to check parity data.
If you combine more \-\-filter, \-\-filter\-disk and \-\-filter\-missing options,
only files matching all the set of filters are selected.
You can also specify parity disks with the names: \[dq]parity\[dq], \[dq]2\-parity\[dq],
\[dq]3\-parity\[dq], ... to limit the operations a specific parity disk.
If you combine more \-\-filter, \-\-filter\-disk and \-\-filter\-missing options,
only files matching all the set of filters are selected.
This option can be used many times.
This option can be used only with \[dq]check\[dq] and \[dq]fix\[dq].
This option can be used only with \[dq]check\[dq], \[dq]fix\[dq], \[dq]up\[dq] and \[dq]down\[dq].
Note that it cannot be used with \[dq]sync\[dq] and \[dq]scrub\[dq], because they always
process the whole array.
.TP

View file

@ -435,6 +435,8 @@ Commands
up
Spins up all the disks of the array.
You can spin-up only some specific disks using the -d, --filter-disk option.
Nothing is modified.
down
@ -443,6 +445,8 @@ Commands
This command uses the "smartctl" tool, and it's equivalent to run
"smartctl -s standby,now" on all the devices.
You can spin-down only some specific disks using the -d, --filter-disk option.
Nothing is modified.
diff
@ -686,18 +690,15 @@ Options
process the whole array.
-d, --filter-disk NAME
Filters the files to process in "check" and "fix".
Only the files present in the specified disk are processed.
Filters the disks to process in "check", "fix", "up" and "down".
You must specify a disk name as named in the configuration
file.
In "check", you can make it faster, specifying also -a, --audit-only
option, to avoid to access other disks to check parity data.
If you combine more --filter, --filter-disk and --filter-missing options,
only files matching all the set of filters are selected.
You can also specify parity disks with the names: "parity", "2-parity",
"3-parity", ... to limit the operations a specific parity disk.
If you combine more --filter, --filter-disk and --filter-missing options,
only files matching all the set of filters are selected.
This option can be used many times.
This option can be used only with "check" and "fix".
This option can be used only with "check", "fix", "up" and "down".
Note that it cannot be used with "sync" and "scrub", because they always
process the whole array.

View file

@ -465,6 +465,8 @@ Nothing is modified.
Spins up all the disks of the array.
You can spin-up only some specific disks using the -d, --filter-disk option.
Nothing is modified.
5.4 down
@ -475,6 +477,8 @@ Spins down all the disks of the array.
This command uses the "smartctl" tool, and it's equivalent to run
"smartctl -s standby,now" on all the devices.
You can spin-down only some specific disks using the -d, --filter-disk option.
Nothing is modified.
5.5 diff
@ -747,18 +751,15 @@ SnapRAID provides the following options:
process the whole array.
-d, --filter-disk NAME
Filters the files to process in "check" and "fix".
Only the files present in the specified disk are processed.
Filters the disks to process in "check", "fix", "up" and "down".
You must specify a disk name as named in the configuration
file.
In "check", you can make it faster, specifying also -a, --audit-only
option, to avoid to access other disks to check parity data.
If you combine more --filter, --filter-disk and --filter-missing options,
only files matching all the set of filters are selected.
You can also specify parity disks with the names: "parity", "2-parity",
"3-parity", ... to limit the operations a specific parity disk.
If you combine more --filter, --filter-disk and --filter-missing options,
only files matching all the set of filters are selected.
This option can be used many times.
This option can be used only with "check" and "fix".
This option can be used only with "check", "fix", "up" and "down".
Note that it cannot be used with "sync" and "scrub", because they always
process the whole array.