mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
tunedasd: add copy_pair swap capability
Add an option to tunedasd to trigger a copy pair swap using the appropriate
ioctl for DASD devices.
-s, --copy-pair-swap COPY_PAIR
This command requires a comma separated pair of primary,secondary to be
specified. In case of success the old secondary will become the new primary
device and the old primary will become a secondary device.
Example:
tunedasd /dev/dasda -s 0.0.9700,0.0.9740
This will set the old secondary device 0.0.9740 as the new primary.
The old primary device 0.0.9700 will automatically become a secondary
device.
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
3aa7f6e298
commit
3f12bdf4c7
@@ -31,6 +31,7 @@ int disk_query_reserve_status(char* device);
|
||||
int disk_profile (char* device, char* prof_item);
|
||||
int disk_reset_prof(char *device);
|
||||
int disk_reset_chpid(char *device, char *chpid);
|
||||
int disk_copy_swap(char *device, char *copy_pair);
|
||||
|
||||
#endif /* not DISK_H */
|
||||
|
||||
|
||||
@@ -174,6 +174,14 @@ Reset all channel paths of the selected device. The channel paths
|
||||
might be suspended due to high IFCC error rates or a High Performance
|
||||
FICON failure. Use this option to resume considering all defined
|
||||
channel paths for I/O.
|
||||
.TP
|
||||
.BR "\-s" " or " "\-\-copy\-pair\-swap <copy_pair>"
|
||||
Swap the copy roles of the specified copy pair. The <copy_pair> has to
|
||||
be a comma separated pair of \fBPRIMARY,SECONDARY\fR where
|
||||
\fBPRIMARY\fR is the old primary device that will become a secondary
|
||||
automatically. The old \fBSECONDARY\fR device will become the new
|
||||
primary device. Both devices have to be online for this operation to
|
||||
succeed.
|
||||
.\"
|
||||
.\".TP
|
||||
.\".BR "\-o" " or " "\-\-online"
|
||||
@@ -197,6 +205,12 @@ channel paths for I/O.
|
||||
.br
|
||||
|
||||
tunedasd -p 45 /dev/dasdc
|
||||
|
||||
.br
|
||||
4. Scenario: Swap copy pair 0.0.9700 and 0.0.9740
|
||||
.br
|
||||
|
||||
tunedasd -s 0.0.9700,0.0.9740 /dev/dasdc
|
||||
.br
|
||||
.SH "SEE ALSO"
|
||||
.BR dasdview (8),
|
||||
|
||||
@@ -21,12 +21,11 @@
|
||||
|
||||
#include "lib/dasd_base.h"
|
||||
#include "lib/dasd_sys.h"
|
||||
#include "lib/util_libc.h"
|
||||
|
||||
#include "disk.h"
|
||||
#include "tunedasd.h"
|
||||
|
||||
#define BUS_ID_SIZE 30
|
||||
|
||||
/* id definition for profile items */
|
||||
enum prof_id {
|
||||
prof_reqs = 0,
|
||||
@@ -549,3 +548,50 @@ int disk_reset_chpid(char *device, char *chpid)
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int disk_copy_swap(char *device, char *copy_pair)
|
||||
{
|
||||
struct dasd_copypair_swap_data data = { 0 };
|
||||
char *primary, *secondary;
|
||||
int rc = 0;
|
||||
|
||||
primary = strtok(copy_pair, ",");
|
||||
secondary = strtok(NULL, ",");
|
||||
|
||||
if (!primary || !secondary) {
|
||||
error_print("%s: Error parsing Copy Pair %s", device, copy_pair);
|
||||
return -1;
|
||||
}
|
||||
|
||||
util_strlcpy(data.primary, primary, DASD_BUS_ID_SIZE);
|
||||
util_strlcpy(data.secondary, secondary, DASD_BUS_ID_SIZE);
|
||||
|
||||
printf("Swapping copy pair %s %s on device <%s>...\n", primary, secondary, device);
|
||||
rc = dasd_copy_swap(device, &data);
|
||||
|
||||
switch (rc) {
|
||||
case 0:
|
||||
printf("Done.\n");
|
||||
return 0;
|
||||
case 1:
|
||||
error_print("Swap data invalid");
|
||||
break;
|
||||
case 2:
|
||||
error_print("No active device found");
|
||||
break;
|
||||
case 3:
|
||||
error_print("Wrong primary device specified");
|
||||
break;
|
||||
case 4:
|
||||
error_print("Secondary device not found");
|
||||
break;
|
||||
case 5:
|
||||
error_print("Swap already running");
|
||||
break;
|
||||
default:
|
||||
error_print("Swap not successful rc %d", rc);
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -119,12 +119,17 @@ static struct util_opt opt_vec[] = {
|
||||
.desc = "Reset all channel paths of a device",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
},
|
||||
{
|
||||
.option = { "copy-pair-swap", required_argument, NULL, 's' },
|
||||
.argument = "COPY_PAIR",
|
||||
.desc = "Swap a specified, comma separated copy pair.",
|
||||
},
|
||||
UTIL_OPT_HELP,
|
||||
UTIL_OPT_VERSION,
|
||||
UTIL_OPT_END
|
||||
};
|
||||
|
||||
#define CMD_KEYWORD_NUM 16
|
||||
#define CMD_KEYWORD_NUM 17
|
||||
#define DEVICES_NUM 256
|
||||
|
||||
enum cmd_keyword_id {
|
||||
@@ -144,6 +149,7 @@ enum cmd_keyword_id {
|
||||
cmd_keyword_path_all,
|
||||
cmd_keyword_enable_stats,
|
||||
cmd_keyword_disable_stats,
|
||||
cmd_keyword_copy_swap,
|
||||
};
|
||||
|
||||
|
||||
@@ -167,7 +173,8 @@ static const struct {
|
||||
{ "path_reset", cmd_keyword_path },
|
||||
{ "path_reset_all", cmd_keyword_path_all },
|
||||
{ "enable-stats", cmd_keyword_enable_stats },
|
||||
{ "disable-stats", cmd_keyword_disable_stats }
|
||||
{ "disable-stats", cmd_keyword_disable_stats },
|
||||
{ "copy-swap", cmd_keyword_copy_swap },
|
||||
};
|
||||
|
||||
|
||||
@@ -180,26 +187,27 @@ enum cmd_key_state {
|
||||
|
||||
/* Determines which combination of keywords are valid */
|
||||
static enum cmd_key_state cmd_key_table[CMD_KEYWORD_NUM][CMD_KEYWORD_NUM] = {
|
||||
/* help vers get_ cach no_c rese rele sloc prof prof rese quer path path
|
||||
* ion cach e yl rve ase k ile _ite t_pr y_re _all
|
||||
* e m of serv
|
||||
/* help vers get_ cach no_c rese rele sloc prof prof rese quer path path enab disa copy
|
||||
* ion cach e yl rve ase k ile _ite t_pr y_re _all le-s ble- -swa
|
||||
* e m of serv tats stat p
|
||||
*/
|
||||
/* help */ { req, opt, opt, opt, opt, opt, opt, opt, opt, opt, opt, inv, inv, inv, inv, inv },
|
||||
/* version */ { inv, req, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* get_cache */ { opt, opt, req, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* cache */ { opt, opt, inv, req, opt, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* no_cyl */ { opt, opt, inv, req, req, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* reserve */ { opt, opt, inv, inv, inv, req, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* release */ { opt, opt, inv, inv, inv, inv, req, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* slock */ { opt, opt, inv, inv, inv, inv, inv, req, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* profile */ { opt, opt, inv, inv, inv, inv, inv, inv, req, opt, inv, inv, inv, inv, inv, inv },
|
||||
/* prof_item */ { opt, opt, inv, inv, inv, inv, inv, inv, req, req, inv, inv, inv, inv, inv, inv },
|
||||
/* reset_prof */ { opt, opt, inv, inv, inv, inv, inv, inv, inv, inv, req, inv, inv, inv, inv, inv },
|
||||
/* query_reserve */ { inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, req, inv, inv, inv, inv },
|
||||
/* path */ { inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, req, inv, inv, inv },
|
||||
/* path_all */ { inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, req, inv, inv },
|
||||
/* enable-stats */ { inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, req, inv },
|
||||
/* disable-stats */ { inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, req },
|
||||
/* help */ { req, opt, opt, opt, opt, opt, opt, opt, opt, opt, opt, inv, inv, inv, inv, inv, inv },
|
||||
/* version */ { inv, req, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* get_cache */ { opt, opt, req, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* cache */ { opt, opt, inv, req, opt, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* no_cyl */ { opt, opt, inv, req, req, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* reserve */ { opt, opt, inv, inv, inv, req, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* release */ { opt, opt, inv, inv, inv, inv, req, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* slock */ { opt, opt, inv, inv, inv, inv, inv, req, inv, inv, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* profile */ { opt, opt, inv, inv, inv, inv, inv, inv, req, opt, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* prof_item */ { opt, opt, inv, inv, inv, inv, inv, inv, req, req, inv, inv, inv, inv, inv, inv, inv },
|
||||
/* reset_prof */ { opt, opt, inv, inv, inv, inv, inv, inv, inv, inv, req, inv, inv, inv, inv, inv, inv },
|
||||
/* query_reserve */ { inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, req, inv, inv, inv, inv, inv },
|
||||
/* path */ { inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, req, inv, inv, inv, inv },
|
||||
/* path_all */ { inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, req, inv, inv, inv },
|
||||
/* enable-stats */ { inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, req, inv, inv },
|
||||
/* disable-stats */ { inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, req, inv },
|
||||
/* copy-swap */ { inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, inv, req },
|
||||
};
|
||||
|
||||
struct parameter {
|
||||
@@ -439,7 +447,9 @@ static int get_command_line(int argc, char *argv[], struct command_line *line)
|
||||
rc = store_option (&cmdline, cmd_keyword_query_reserve,
|
||||
optarg);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
rc = store_option(&cmdline, cmd_keyword_copy_swap, optarg);
|
||||
break;
|
||||
case -1:
|
||||
/* End of options string - start of devices list */
|
||||
cmdline.device_id = optind;
|
||||
@@ -508,6 +518,9 @@ static int do_command(char *device, struct command_line cmdline)
|
||||
case cmd_keyword_path_all:
|
||||
rc = disk_reset_chpid(device, NULL);
|
||||
break;
|
||||
case cmd_keyword_copy_swap:
|
||||
rc = disk_copy_swap(device, cmdline.parm[cmd_keyword_copy_swap].data);
|
||||
break;
|
||||
default:
|
||||
error_print ("Unknown command '%s' specified",
|
||||
get_keyword_name (i));
|
||||
|
||||
Reference in New Issue
Block a user