aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoger, Babu <Babu.Moger@netapp.com>2012-03-27 16:55:49 -0400
committerJames Bottomley <JBottomley@Parallels.com>2012-04-23 14:28:07 -0400
commit4335d092a1f28e17c5bafa6170bbf9599ca29c6a (patch)
treeb72bf29f5c241ef53a342dd9c926edd0b1b3074a
parent8643b32f275466f0b706e829150b7db49c11419c (diff)
[SCSI] scsi_dh_alua: Inroduce the set_params interface scsi_dh_alua handler
Handler expects only one parameter to set the flag ALUA_OPTIMIZE_STPG. This flag is used to optimize the STPG behaviour. There is no change in behaviour by default. For example, to set the flag pass the following parameters from multipath.conf hardware_handler "2 alua 1" Signed-off-by: Babu Moger <babu.moger@netapp.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/device_handler/scsi_dh_alua.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index 04c5cea47a22..506206ae5755 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -55,11 +55,15 @@
55#define ALUA_FAILOVER_TIMEOUT (60 * HZ) 55#define ALUA_FAILOVER_TIMEOUT (60 * HZ)
56#define ALUA_FAILOVER_RETRIES 5 56#define ALUA_FAILOVER_RETRIES 5
57 57
58/* flags passed from user level */
59#define ALUA_OPTIMIZE_STPG 1
60
58struct alua_dh_data { 61struct alua_dh_data {
59 int group_id; 62 int group_id;
60 int rel_port; 63 int rel_port;
61 int tpgs; 64 int tpgs;
62 int state; 65 int state;
66 unsigned flags; /* used for optimizing STPG */
63 unsigned char inq[ALUA_INQUIRY_SIZE]; 67 unsigned char inq[ALUA_INQUIRY_SIZE];
64 unsigned char *buff; 68 unsigned char *buff;
65 int bufflen; 69 int bufflen;
@@ -621,6 +625,37 @@ static int alua_initialize(struct scsi_device *sdev, struct alua_dh_data *h)
621out: 625out:
622 return err; 626 return err;
623} 627}
628/*
629 * alua_set_params - set/unset the optimize flag
630 * @sdev: device on the path to be activated
631 * params - parameters in the following format
632 * "no_of_params\0param1\0param2\0param3\0...\0"
633 * For example, to set the flag pass the following parameters
634 * from multipath.conf
635 * hardware_handler "2 alua 1"
636 */
637static int alua_set_params(struct scsi_device *sdev, const char *params)
638{
639 struct alua_dh_data *h = get_alua_data(sdev);
640 unsigned int optimize = 0, argc;
641 const char *p = params;
642 int result = SCSI_DH_OK;
643
644 if ((sscanf(params, "%u", &argc) != 1) || (argc != 1))
645 return -EINVAL;
646
647 while (*p++)
648 ;
649 if ((sscanf(p, "%u", &optimize) != 1) || (optimize > 1))
650 return -EINVAL;
651
652 if (optimize)
653 h->flags |= ALUA_OPTIMIZE_STPG;
654 else
655 h->flags &= ~ALUA_OPTIMIZE_STPG;
656
657 return result;
658}
624 659
625/* 660/*
626 * alua_activate - activate a path 661 * alua_activate - activate a path
@@ -698,6 +733,7 @@ static struct scsi_device_handler alua_dh = {
698 .prep_fn = alua_prep_fn, 733 .prep_fn = alua_prep_fn,
699 .check_sense = alua_check_sense, 734 .check_sense = alua_check_sense,
700 .activate = alua_activate, 735 .activate = alua_activate,
736 .set_params = alua_set_params,
701 .match = alua_match, 737 .match = alua_match,
702}; 738};
703 739