blob: 19f653930f7c27016e9c6f59ac207b64b5690aa1 [file] [log] [blame]
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07001/*
2 * Generic SCSI-3 ALUA SCSI Device Handler
3 *
Hannes Reinecke69723d12010-09-24 15:57:04 +02004 * Copyright (C) 2007-2010 Hannes Reinecke, SUSE Linux Products GmbH.
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07005 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 */
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090022#include <linux/slab.h>
Hannes Reinecke69723d12010-09-24 15:57:04 +020023#include <linux/delay.h>
Paul Gortmakeracf3368f2011-05-27 09:47:43 -040024#include <linux/module.h>
Hannes Reineckea7089772015-12-01 10:16:52 +010025#include <asm/unaligned.h>
Hannes Reinecke057ea7c2008-07-17 16:53:21 -070026#include <scsi/scsi.h>
Hannes Reinecke80bd68d2015-12-01 10:16:47 +010027#include <scsi/scsi_dbg.h>
Hannes Reinecke057ea7c2008-07-17 16:53:21 -070028#include <scsi/scsi_eh.h>
29#include <scsi/scsi_dh.h>
30
31#define ALUA_DH_NAME "alua"
Hannes Reineckee79c82c2016-02-19 09:17:20 +010032#define ALUA_DH_VER "2.0"
Hannes Reinecke057ea7c2008-07-17 16:53:21 -070033
Hannes Reinecke057ea7c2008-07-17 16:53:21 -070034#define TPGS_SUPPORT_NONE 0x00
35#define TPGS_SUPPORT_OPTIMIZED 0x01
36#define TPGS_SUPPORT_NONOPTIMIZED 0x02
37#define TPGS_SUPPORT_STANDBY 0x04
38#define TPGS_SUPPORT_UNAVAILABLE 0x08
Hannes Reinecke69723d12010-09-24 15:57:04 +020039#define TPGS_SUPPORT_LBA_DEPENDENT 0x10
Hannes Reinecke057ea7c2008-07-17 16:53:21 -070040#define TPGS_SUPPORT_OFFLINE 0x40
41#define TPGS_SUPPORT_TRANSITION 0x80
42
Rob Evers3588c5a2012-05-18 14:08:54 -040043#define RTPG_FMT_MASK 0x70
44#define RTPG_FMT_EXT_HDR 0x10
45
Hannes Reinecke057ea7c2008-07-17 16:53:21 -070046#define TPGS_MODE_UNINITIALIZED -1
47#define TPGS_MODE_NONE 0x0
48#define TPGS_MODE_IMPLICIT 0x1
49#define TPGS_MODE_EXPLICIT 0x2
50
Hannes Reineckec49c8342016-02-19 09:17:03 +010051#define ALUA_RTPG_SIZE 128
Rob Evers3588c5a2012-05-18 14:08:54 -040052#define ALUA_FAILOVER_TIMEOUT 60
Hannes Reinecke057ea7c2008-07-17 16:53:21 -070053#define ALUA_FAILOVER_RETRIES 5
Hannes Reinecke03197b62016-02-19 09:17:10 +010054#define ALUA_RTPG_DELAY_MSECS 5
Hannes Reinecke057ea7c2008-07-17 16:53:21 -070055
Hannes Reinecke6c4fc042015-12-01 10:16:51 +010056/* device handler flags */
Hannes Reinecke03197b62016-02-19 09:17:10 +010057#define ALUA_OPTIMIZE_STPG 0x01
58#define ALUA_RTPG_EXT_HDR_UNSUPP 0x02
Hannes Reinecke00642a12016-02-19 09:17:11 +010059#define ALUA_SYNC_STPG 0x04
Hannes Reinecke03197b62016-02-19 09:17:10 +010060/* State machine flags */
61#define ALUA_PG_RUN_RTPG 0x10
62#define ALUA_PG_RUN_STPG 0x20
63#define ALUA_PG_RUNNING 0x40
Moger, Babu4335d092012-03-27 20:55:49 +000064
Hannes Reineckeaa90f492016-02-19 09:17:08 +010065static uint optimize_stpg;
66module_param(optimize_stpg, uint, S_IRUGO|S_IWUSR);
67MODULE_PARM_DESC(optimize_stpg, "Allow use of a non-optimized path, rather than sending a STPG, when implicit TPGS is supported (0=No,1=Yes). Default is 0.");
68
Hannes Reinecke43394c62016-02-19 09:17:04 +010069static LIST_HEAD(port_group_list);
70static DEFINE_SPINLOCK(port_group_lock);
Hannes Reinecke03197b62016-02-19 09:17:10 +010071static struct workqueue_struct *kaluad_wq;
Hannes Reinecke00642a12016-02-19 09:17:11 +010072static struct workqueue_struct *kaluad_sync_wq;
Hannes Reinecke43394c62016-02-19 09:17:04 +010073
74struct alua_port_group {
75 struct kref kref;
Hannes Reinecke03197b62016-02-19 09:17:10 +010076 struct rcu_head rcu;
Hannes Reinecke43394c62016-02-19 09:17:04 +010077 struct list_head node;
Hannes Reinecke00472202016-02-19 09:17:05 +010078 unsigned char device_id_str[256];
79 int device_id_len;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -070080 int group_id;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -070081 int tpgs;
82 int state;
Moger, Babudcd3a752012-03-27 20:56:08 +000083 int pref;
Moger, Babu4335d092012-03-27 20:55:49 +000084 unsigned flags; /* used for optimizing STPG */
Rob Evers3588c5a2012-05-18 14:08:54 -040085 unsigned char transition_tmo;
Hannes Reinecke03197b62016-02-19 09:17:10 +010086 unsigned long expiry;
87 unsigned long interval;
88 struct delayed_work rtpg_work;
89 spinlock_t lock;
90 struct list_head rtpg_list;
91 struct scsi_device *rtpg_sdev;
Hannes Reinecke43394c62016-02-19 09:17:04 +010092};
93
94struct alua_dh_data {
95 struct alua_port_group *pg;
96 int group_id;
Hannes Reinecke03197b62016-02-19 09:17:10 +010097 spinlock_t pg_lock;
Chandra Seetharaman96e65862009-10-21 09:23:04 -070098 struct scsi_device *sdev;
Hannes Reinecke03197b62016-02-19 09:17:10 +010099 int init_error;
100 struct mutex init_mutex;
101};
102
103struct alua_queue_data {
104 struct list_head entry;
Chandra Seetharaman96e65862009-10-21 09:23:04 -0700105 activate_complete callback_fn;
106 void *callback_data;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700107};
108
109#define ALUA_POLICY_SWITCH_CURRENT 0
110#define ALUA_POLICY_SWITCH_ALL 1
111
Hannes Reinecke03197b62016-02-19 09:17:10 +0100112static void alua_rtpg_work(struct work_struct *work);
113static void alua_rtpg_queue(struct alua_port_group *pg,
114 struct scsi_device *sdev,
Hannes Reinecke2b358652016-02-19 09:17:13 +0100115 struct alua_queue_data *qdata, bool force);
116static void alua_check(struct scsi_device *sdev, bool force);
Chandra Seetharaman96e65862009-10-21 09:23:04 -0700117
Hannes Reinecke43394c62016-02-19 09:17:04 +0100118static void release_port_group(struct kref *kref)
119{
120 struct alua_port_group *pg;
121
122 pg = container_of(kref, struct alua_port_group, kref);
Hannes Reinecke03197b62016-02-19 09:17:10 +0100123 if (pg->rtpg_sdev)
124 flush_delayed_work(&pg->rtpg_work);
Hannes Reinecke43394c62016-02-19 09:17:04 +0100125 spin_lock(&port_group_lock);
126 list_del(&pg->node);
127 spin_unlock(&port_group_lock);
Hannes Reinecke03197b62016-02-19 09:17:10 +0100128 kfree_rcu(pg, rcu);
Hannes Reinecke43394c62016-02-19 09:17:04 +0100129}
130
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700131/*
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700132 * submit_rtpg - Issue a REPORT TARGET GROUP STATES command
133 * @sdev: sdev the command should be sent to
134 */
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100135static int submit_rtpg(struct scsi_device *sdev, unsigned char *buff,
136 int bufflen, struct scsi_sense_hdr *sshdr, int flags)
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700137{
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100138 u8 cdb[COMMAND_SIZE(MAINTENANCE_IN)];
139 int req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
140 REQ_FAILFAST_DRIVER;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700141
142 /* Prepare the command. */
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100143 memset(cdb, 0x0, COMMAND_SIZE(MAINTENANCE_IN));
144 cdb[0] = MAINTENANCE_IN;
Hannes Reinecked42ae5f2016-02-19 09:16:58 +0100145 if (!(flags & ALUA_RTPG_EXT_HDR_UNSUPP))
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100146 cdb[1] = MI_REPORT_TARGET_PGS | MI_EXT_HDR_PARAM_FMT;
Rob Evers8e67ce62012-05-18 14:08:55 -0400147 else
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100148 cdb[1] = MI_REPORT_TARGET_PGS;
149 put_unaligned_be32(bufflen, &cdb[6]);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700150
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100151 return scsi_execute_req_flags(sdev, cdb, DMA_FROM_DEVICE,
152 buff, bufflen, sshdr,
153 ALUA_FAILOVER_TIMEOUT * HZ,
154 ALUA_FAILOVER_RETRIES, NULL, req_flags);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700155}
156
157/*
Hannes Reineckeb2460752016-02-19 09:17:00 +0100158 * submit_stpg - Issue a SET TARGET PORT GROUP command
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700159 *
160 * Currently we're only setting the current target port group state
161 * to 'active/optimized' and let the array firmware figure out
162 * the states of the remaining groups.
163 */
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100164static int submit_stpg(struct scsi_device *sdev, int group_id,
165 struct scsi_sense_hdr *sshdr)
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700166{
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100167 u8 cdb[COMMAND_SIZE(MAINTENANCE_OUT)];
Hannes Reineckeb2460752016-02-19 09:17:00 +0100168 unsigned char stpg_data[8];
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700169 int stpg_len = 8;
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100170 int req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
171 REQ_FAILFAST_DRIVER;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700172
173 /* Prepare the data buffer */
Hannes Reineckeb2460752016-02-19 09:17:00 +0100174 memset(stpg_data, 0, stpg_len);
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100175 stpg_data[4] = SCSI_ACCESS_STATE_OPTIMAL;
Hannes Reineckeb2460752016-02-19 09:17:00 +0100176 put_unaligned_be16(group_id, &stpg_data[6]);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700177
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700178 /* Prepare the command. */
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100179 memset(cdb, 0x0, COMMAND_SIZE(MAINTENANCE_OUT));
180 cdb[0] = MAINTENANCE_OUT;
181 cdb[1] = MO_SET_TARGET_PGS;
182 put_unaligned_be32(stpg_len, &cdb[6]);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700183
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100184 return scsi_execute_req_flags(sdev, cdb, DMA_TO_DEVICE,
185 stpg_data, stpg_len,
186 sshdr, ALUA_FAILOVER_TIMEOUT * HZ,
187 ALUA_FAILOVER_RETRIES, NULL, req_flags);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700188}
189
Hannes Reinecke00472202016-02-19 09:17:05 +0100190struct alua_port_group *alua_find_get_pg(char *id_str, size_t id_size,
191 int group_id)
192{
193 struct alua_port_group *pg;
194
195 list_for_each_entry(pg, &port_group_list, node) {
196 if (pg->group_id != group_id)
197 continue;
198 if (pg->device_id_len != id_size)
199 continue;
200 if (strncmp(pg->device_id_str, id_str, id_size))
201 continue;
202 if (!kref_get_unless_zero(&pg->kref))
203 continue;
204 return pg;
205 }
206
207 return NULL;
208}
209
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700210/*
Hannes Reinecke43394c62016-02-19 09:17:04 +0100211 * alua_alloc_pg - Allocate a new port_group structure
212 * @sdev: scsi device
213 * @h: alua device_handler data
214 * @group_id: port group id
215 *
216 * Allocate a new port_group structure for a given
217 * device.
218 */
219struct alua_port_group *alua_alloc_pg(struct scsi_device *sdev,
220 int group_id, int tpgs)
221{
Hannes Reinecke00472202016-02-19 09:17:05 +0100222 struct alua_port_group *pg, *tmp_pg;
Hannes Reinecke43394c62016-02-19 09:17:04 +0100223
224 pg = kzalloc(sizeof(struct alua_port_group), GFP_KERNEL);
225 if (!pg)
Hannes Reinecke00472202016-02-19 09:17:05 +0100226 return ERR_PTR(-ENOMEM);
Hannes Reinecke43394c62016-02-19 09:17:04 +0100227
Hannes Reinecke00472202016-02-19 09:17:05 +0100228 pg->device_id_len = scsi_vpd_lun_id(sdev, pg->device_id_str,
229 sizeof(pg->device_id_str));
230 if (pg->device_id_len <= 0) {
231 /*
232 * Internal error: TPGS supported but no device
233 * identifcation found. Disable ALUA support.
234 */
235 kfree(pg);
236 sdev_printk(KERN_INFO, sdev,
237 "%s: No device descriptors found\n",
238 ALUA_DH_NAME);
239 return ERR_PTR(-ENXIO);
240 }
Hannes Reinecke43394c62016-02-19 09:17:04 +0100241 pg->group_id = group_id;
242 pg->tpgs = tpgs;
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100243 pg->state = SCSI_ACCESS_STATE_OPTIMAL;
Hannes Reineckeaa90f492016-02-19 09:17:08 +0100244 if (optimize_stpg)
245 pg->flags |= ALUA_OPTIMIZE_STPG;
Hannes Reinecke43394c62016-02-19 09:17:04 +0100246 kref_init(&pg->kref);
Hannes Reinecke03197b62016-02-19 09:17:10 +0100247 INIT_DELAYED_WORK(&pg->rtpg_work, alua_rtpg_work);
248 INIT_LIST_HEAD(&pg->rtpg_list);
249 INIT_LIST_HEAD(&pg->node);
250 spin_lock_init(&pg->lock);
Hannes Reinecke00472202016-02-19 09:17:05 +0100251
Hannes Reinecke43394c62016-02-19 09:17:04 +0100252 spin_lock(&port_group_lock);
Hannes Reinecke00472202016-02-19 09:17:05 +0100253 tmp_pg = alua_find_get_pg(pg->device_id_str, pg->device_id_len,
254 group_id);
255 if (tmp_pg) {
256 spin_unlock(&port_group_lock);
257 kfree(pg);
258 return tmp_pg;
259 }
260
Hannes Reinecke43394c62016-02-19 09:17:04 +0100261 list_add(&pg->node, &port_group_list);
262 spin_unlock(&port_group_lock);
263
264 return pg;
265}
266
267/*
Hannes Reinecked7c48fe2011-08-24 10:51:13 +0200268 * alua_check_tpgs - Evaluate TPGS setting
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700269 * @sdev: device to be checked
270 *
Hannes Reinecked7c48fe2011-08-24 10:51:13 +0200271 * Examine the TPGS setting of the sdev to find out if ALUA
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700272 * is supported.
273 */
Hannes Reineckead0ea642015-12-01 10:16:53 +0100274static int alua_check_tpgs(struct scsi_device *sdev)
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700275{
Hannes Reineckead0ea642015-12-01 10:16:53 +0100276 int tpgs = TPGS_MODE_NONE;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700277
Hannes Reineckedb5a6a62015-12-01 10:16:43 +0100278 /*
279 * ALUA support for non-disk devices is fraught with
280 * difficulties, so disable it for now.
281 */
282 if (sdev->type != TYPE_DISK) {
Hannes Reineckedb5a6a62015-12-01 10:16:43 +0100283 sdev_printk(KERN_INFO, sdev,
284 "%s: disable for non-disk devices\n",
285 ALUA_DH_NAME);
Hannes Reineckead0ea642015-12-01 10:16:53 +0100286 return tpgs;
Hannes Reineckedb5a6a62015-12-01 10:16:43 +0100287 }
288
Hannes Reineckead0ea642015-12-01 10:16:53 +0100289 tpgs = scsi_device_tpgs(sdev);
290 switch (tpgs) {
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700291 case TPGS_MODE_EXPLICIT|TPGS_MODE_IMPLICIT:
292 sdev_printk(KERN_INFO, sdev,
293 "%s: supports implicit and explicit TPGS\n",
294 ALUA_DH_NAME);
295 break;
296 case TPGS_MODE_EXPLICIT:
297 sdev_printk(KERN_INFO, sdev, "%s: supports explicit TPGS\n",
298 ALUA_DH_NAME);
299 break;
300 case TPGS_MODE_IMPLICIT:
301 sdev_printk(KERN_INFO, sdev, "%s: supports implicit TPGS\n",
302 ALUA_DH_NAME);
303 break;
Hannes Reinecke6cc05d42015-12-01 10:16:45 +0100304 case TPGS_MODE_NONE:
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700305 sdev_printk(KERN_INFO, sdev, "%s: not supported\n",
306 ALUA_DH_NAME);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700307 break;
Hannes Reinecke6cc05d42015-12-01 10:16:45 +0100308 default:
309 sdev_printk(KERN_INFO, sdev,
310 "%s: unsupported TPGS setting %d\n",
Hannes Reineckead0ea642015-12-01 10:16:53 +0100311 ALUA_DH_NAME, tpgs);
312 tpgs = TPGS_MODE_NONE;
Hannes Reinecke6cc05d42015-12-01 10:16:45 +0100313 break;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700314 }
315
Hannes Reineckead0ea642015-12-01 10:16:53 +0100316 return tpgs;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700317}
318
319/*
Hannes Reinecke9b80dce2015-12-01 10:16:44 +0100320 * alua_check_vpd - Evaluate INQUIRY vpd page 0x83
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700321 * @sdev: device to be checked
322 *
323 * Extract the relative target port and the target port group
324 * descriptor from the list of identificators.
325 */
Hannes Reineckea4253fd2016-02-19 09:17:06 +0100326static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h,
327 int tpgs)
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700328{
Hannes Reinecke83ea0e52015-12-01 10:16:58 +0100329 int rel_port = -1, group_id;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100330 struct alua_port_group *pg, *old_pg = NULL;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700331
Hannes Reinecke83ea0e52015-12-01 10:16:58 +0100332 group_id = scsi_vpd_tpg_id(sdev, &rel_port);
333 if (group_id < 0) {
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700334 /*
335 * Internal error; TPGS supported but required
336 * VPD identification descriptors not present.
337 * Disable ALUA support
338 */
339 sdev_printk(KERN_INFO, sdev,
340 "%s: No target port descriptors found\n",
341 ALUA_DH_NAME);
Hannes Reinecke9b80dce2015-12-01 10:16:44 +0100342 return SCSI_DH_DEV_UNSUPP;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700343 }
Hannes Reineckea4253fd2016-02-19 09:17:06 +0100344
Hannes Reinecke03197b62016-02-19 09:17:10 +0100345 pg = alua_alloc_pg(sdev, group_id, tpgs);
346 if (IS_ERR(pg)) {
347 if (PTR_ERR(pg) == -ENOMEM)
Hannes Reineckea4253fd2016-02-19 09:17:06 +0100348 return SCSI_DH_NOMEM;
349 return SCSI_DH_DEV_UNSUPP;
350 }
Hannes Reinecke9b80dce2015-12-01 10:16:44 +0100351 sdev_printk(KERN_INFO, sdev,
Hannes Reineckea4253fd2016-02-19 09:17:06 +0100352 "%s: device %s port group %x rel port %x\n",
Hannes Reinecke03197b62016-02-19 09:17:10 +0100353 ALUA_DH_NAME, pg->device_id_str, group_id, rel_port);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700354
Hannes Reinecke03197b62016-02-19 09:17:10 +0100355 /* Check for existing port group references */
356 spin_lock(&h->pg_lock);
357 old_pg = h->pg;
358 if (old_pg != pg) {
359 /* port group has changed. Update to new port group */
360 rcu_assign_pointer(h->pg, pg);
361 }
Hannes Reinecke851cde92016-02-19 09:17:12 +0100362 if (sdev->synchronous_alua)
363 pg->flags |= ALUA_SYNC_STPG;
Hannes Reinecke2b358652016-02-19 09:17:13 +0100364 alua_rtpg_queue(h->pg, sdev, NULL, true);
Hannes Reinecke03197b62016-02-19 09:17:10 +0100365 spin_unlock(&h->pg_lock);
366
367 if (old_pg)
368 kref_put(&old_pg->kref, release_port_group);
369
370 return SCSI_DH_OK;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700371}
372
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100373static char print_alua_state(unsigned char state)
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700374{
375 switch (state) {
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100376 case SCSI_ACCESS_STATE_OPTIMAL:
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700377 return 'A';
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100378 case SCSI_ACCESS_STATE_ACTIVE:
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700379 return 'N';
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100380 case SCSI_ACCESS_STATE_STANDBY:
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700381 return 'S';
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100382 case SCSI_ACCESS_STATE_UNAVAILABLE:
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700383 return 'U';
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100384 case SCSI_ACCESS_STATE_LBA:
Hannes Reinecke69723d12010-09-24 15:57:04 +0200385 return 'L';
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100386 case SCSI_ACCESS_STATE_OFFLINE:
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700387 return 'O';
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100388 case SCSI_ACCESS_STATE_TRANSITIONING:
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700389 return 'T';
390 default:
391 return 'X';
392 }
393}
394
395static int alua_check_sense(struct scsi_device *sdev,
396 struct scsi_sense_hdr *sense_hdr)
397{
398 switch (sense_hdr->sense_key) {
399 case NOT_READY:
Hannes Reinecke2b358652016-02-19 09:17:13 +0100400 if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0a) {
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700401 /*
402 * LUN Not Accessible - ALUA state transition
403 */
Hannes Reinecke2b358652016-02-19 09:17:13 +0100404 alua_check(sdev, false);
405 return NEEDS_RETRY;
406 }
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700407 break;
408 case UNIT_ATTENTION:
Hannes Reinecke2b358652016-02-19 09:17:13 +0100409 if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00) {
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700410 /*
Hannes Reinecke2b358652016-02-19 09:17:13 +0100411 * Power On, Reset, or Bus Device Reset.
412 * Might have obscured a state transition,
413 * so schedule a recheck.
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700414 */
Hannes Reinecke2b358652016-02-19 09:17:13 +0100415 alua_check(sdev, true);
Mike Andersonc7dbb622008-08-12 12:11:57 -0700416 return ADD_TO_MLQUEUE;
Hannes Reinecke2b358652016-02-19 09:17:13 +0100417 }
Stewart, Seanc20ee7b2013-10-15 15:52:39 +0000418 if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x04)
419 /*
420 * Device internal reset
421 */
422 return ADD_TO_MLQUEUE;
Moger, Babu410f02d2011-12-21 18:01:37 -0500423 if (sense_hdr->asc == 0x2a && sense_hdr->ascq == 0x01)
424 /*
425 * Mode Parameters Changed
426 */
427 return ADD_TO_MLQUEUE;
Hannes Reinecke2b358652016-02-19 09:17:13 +0100428 if (sense_hdr->asc == 0x2a && sense_hdr->ascq == 0x06) {
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700429 /*
430 * ALUA state changed
431 */
Hannes Reinecke2b358652016-02-19 09:17:13 +0100432 alua_check(sdev, true);
Mike Andersonc7dbb622008-08-12 12:11:57 -0700433 return ADD_TO_MLQUEUE;
Hannes Reinecke2b358652016-02-19 09:17:13 +0100434 }
435 if (sense_hdr->asc == 0x2a && sense_hdr->ascq == 0x07) {
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700436 /*
437 * Implicit ALUA state transition failed
438 */
Hannes Reinecke2b358652016-02-19 09:17:13 +0100439 alua_check(sdev, true);
Mike Andersonc7dbb622008-08-12 12:11:57 -0700440 return ADD_TO_MLQUEUE;
Hannes Reinecke2b358652016-02-19 09:17:13 +0100441 }
Moger, Babubf819732011-10-06 13:22:07 -0400442 if (sense_hdr->asc == 0x3f && sense_hdr->ascq == 0x03)
443 /*
444 * Inquiry data has changed
445 */
446 return ADD_TO_MLQUEUE;
447 if (sense_hdr->asc == 0x3f && sense_hdr->ascq == 0x0e)
Ilgu Hong4d086f62009-01-30 17:00:11 -0600448 /*
449 * REPORTED_LUNS_DATA_HAS_CHANGED is reported
450 * when switching controllers on targets like
451 * Intel Multi-Flex. We can just retry.
452 */
453 return ADD_TO_MLQUEUE;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700454 break;
455 }
456
457 return SCSI_RETURN_NOT_HANDLED;
458}
459
460/*
Hannes Reinecke9d2c3032016-02-19 09:17:15 +0100461 * alua_tur - Send a TEST UNIT READY
462 * @sdev: device to which the TEST UNIT READY command should be send
463 *
464 * Send a TEST UNIT READY to @sdev to figure out the device state
465 * Returns SCSI_DH_RETRY if the sense code is NOT READY/ALUA TRANSITIONING,
466 * SCSI_DH_OK if no error occurred, and SCSI_DH_IO otherwise.
467 */
468static int alua_tur(struct scsi_device *sdev)
469{
470 struct scsi_sense_hdr sense_hdr;
471 int retval;
472
473 retval = scsi_test_unit_ready(sdev, ALUA_FAILOVER_TIMEOUT * HZ,
474 ALUA_FAILOVER_RETRIES, &sense_hdr);
475 if (sense_hdr.sense_key == NOT_READY &&
476 sense_hdr.asc == 0x04 && sense_hdr.ascq == 0x0a)
477 return SCSI_DH_RETRY;
478 else if (retval)
479 return SCSI_DH_IO;
480 else
481 return SCSI_DH_OK;
482}
483
484/*
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700485 * alua_rtpg - Evaluate REPORT TARGET GROUP STATES
486 * @sdev: the device to be evaluated.
487 *
488 * Evaluate the Target Port Group State.
489 * Returns SCSI_DH_DEV_OFFLINED if the path is
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300490 * found to be unusable.
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700491 */
Hannes Reinecke28261402016-02-19 09:17:07 +0100492static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700493{
494 struct scsi_sense_hdr sense_hdr;
Hannes Reineckec57168a2016-02-19 09:17:14 +0100495 struct alua_port_group *tmp_pg;
Hannes Reineckec49c8342016-02-19 09:17:03 +0100496 int len, k, off, valid_states = 0, bufflen = ALUA_RTPG_SIZE;
Hannes Reineckec57168a2016-02-19 09:17:14 +0100497 unsigned char *desc, *buff;
Hannes Reinecke5597caf2015-12-01 10:16:48 +0100498 unsigned err, retval;
Rob Evers3588c5a2012-05-18 14:08:54 -0400499 unsigned int tpg_desc_tbl_off;
500 unsigned char orig_transition_tmo;
Hannes Reineckec57168a2016-02-19 09:17:14 +0100501 unsigned long flags;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700502
Hannes Reinecke03197b62016-02-19 09:17:10 +0100503 if (!pg->expiry) {
504 unsigned long transition_tmo = ALUA_FAILOVER_TIMEOUT * HZ;
505
506 if (pg->transition_tmo)
507 transition_tmo = pg->transition_tmo * HZ;
508
509 pg->expiry = round_jiffies_up(jiffies + transition_tmo);
510 }
Rob Evers3588c5a2012-05-18 14:08:54 -0400511
Hannes Reineckec49c8342016-02-19 09:17:03 +0100512 buff = kzalloc(bufflen, GFP_KERNEL);
513 if (!buff)
514 return SCSI_DH_DEV_TEMP_BUSY;
515
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700516 retry:
Hannes Reinecke43394c62016-02-19 09:17:04 +0100517 retval = submit_rtpg(sdev, buff, bufflen, &sense_hdr, pg->flags);
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100518
Hannes Reinecke5597caf2015-12-01 10:16:48 +0100519 if (retval) {
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100520 if (!scsi_sense_valid(&sense_hdr)) {
Hannes Reinecke5597caf2015-12-01 10:16:48 +0100521 sdev_printk(KERN_INFO, sdev,
522 "%s: rtpg failed, result %d\n",
523 ALUA_DH_NAME, retval);
Hannes Reineckec49c8342016-02-19 09:17:03 +0100524 kfree(buff);
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100525 if (driver_byte(retval) == DRIVER_ERROR)
Hannes Reinecke5597caf2015-12-01 10:16:48 +0100526 return SCSI_DH_DEV_TEMP_BUSY;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700527 return SCSI_DH_IO;
Hannes Reinecke5597caf2015-12-01 10:16:48 +0100528 }
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700529
Rob Evers8e67ce62012-05-18 14:08:55 -0400530 /*
531 * submit_rtpg() has failed on existing arrays
532 * when requesting extended header info, and
533 * the array doesn't support extended headers,
534 * even though it shouldn't according to T10.
535 * The retry without rtpg_ext_hdr_req set
536 * handles this.
537 */
Hannes Reinecke43394c62016-02-19 09:17:04 +0100538 if (!(pg->flags & ALUA_RTPG_EXT_HDR_UNSUPP) &&
Rob Evers8e67ce62012-05-18 14:08:55 -0400539 sense_hdr.sense_key == ILLEGAL_REQUEST &&
540 sense_hdr.asc == 0x24 && sense_hdr.ascq == 0) {
Hannes Reinecke43394c62016-02-19 09:17:04 +0100541 pg->flags |= ALUA_RTPG_EXT_HDR_UNSUPP;
Rob Evers8e67ce62012-05-18 14:08:55 -0400542 goto retry;
543 }
Hannes Reineckee2d817d2015-12-01 10:16:54 +0100544 /*
545 * Retry on ALUA state transition or if any
546 * UNIT ATTENTION occurred.
547 */
548 if (sense_hdr.sense_key == NOT_READY &&
549 sense_hdr.asc == 0x04 && sense_hdr.ascq == 0x0a)
550 err = SCSI_DH_RETRY;
551 else if (sense_hdr.sense_key == UNIT_ATTENTION)
552 err = SCSI_DH_RETRY;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100553 if (err == SCSI_DH_RETRY &&
554 pg->expiry != 0 && time_before(jiffies, pg->expiry)) {
Hannes Reinecke80bd68d2015-12-01 10:16:47 +0100555 sdev_printk(KERN_ERR, sdev, "%s: rtpg retry\n",
556 ALUA_DH_NAME);
557 scsi_print_sense_hdr(sdev, ALUA_DH_NAME, &sense_hdr);
Hannes Reinecke03197b62016-02-19 09:17:10 +0100558 return err;
Hannes Reinecke80bd68d2015-12-01 10:16:47 +0100559 }
560 sdev_printk(KERN_ERR, sdev, "%s: rtpg failed\n",
561 ALUA_DH_NAME);
562 scsi_print_sense_hdr(sdev, ALUA_DH_NAME, &sense_hdr);
Hannes Reineckec49c8342016-02-19 09:17:03 +0100563 kfree(buff);
Hannes Reinecke03197b62016-02-19 09:17:10 +0100564 pg->expiry = 0;
Hannes Reinecke80bd68d2015-12-01 10:16:47 +0100565 return SCSI_DH_IO;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700566 }
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700567
Hannes Reineckec49c8342016-02-19 09:17:03 +0100568 len = get_unaligned_be32(&buff[0]) + 4;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700569
Hannes Reineckec49c8342016-02-19 09:17:03 +0100570 if (len > bufflen) {
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700571 /* Resubmit with the correct length */
Hannes Reineckec49c8342016-02-19 09:17:03 +0100572 kfree(buff);
573 bufflen = len;
574 buff = kmalloc(bufflen, GFP_KERNEL);
575 if (!buff) {
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700576 sdev_printk(KERN_WARNING, sdev,
Harvey Harrisoncadbd4a2008-07-03 23:47:27 -0700577 "%s: kmalloc buffer failed\n",__func__);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700578 /* Temporary failure, bypass */
Hannes Reinecke03197b62016-02-19 09:17:10 +0100579 pg->expiry = 0;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700580 return SCSI_DH_DEV_TEMP_BUSY;
581 }
582 goto retry;
583 }
584
Hannes Reinecke43394c62016-02-19 09:17:04 +0100585 orig_transition_tmo = pg->transition_tmo;
Hannes Reineckec49c8342016-02-19 09:17:03 +0100586 if ((buff[4] & RTPG_FMT_MASK) == RTPG_FMT_EXT_HDR && buff[5] != 0)
Hannes Reinecke43394c62016-02-19 09:17:04 +0100587 pg->transition_tmo = buff[5];
Rob Evers3588c5a2012-05-18 14:08:54 -0400588 else
Hannes Reinecke43394c62016-02-19 09:17:04 +0100589 pg->transition_tmo = ALUA_FAILOVER_TIMEOUT;
Rob Evers3588c5a2012-05-18 14:08:54 -0400590
Hannes Reinecke28261402016-02-19 09:17:07 +0100591 if (orig_transition_tmo != pg->transition_tmo) {
Rob Evers3588c5a2012-05-18 14:08:54 -0400592 sdev_printk(KERN_INFO, sdev,
593 "%s: transition timeout set to %d seconds\n",
Hannes Reinecke43394c62016-02-19 09:17:04 +0100594 ALUA_DH_NAME, pg->transition_tmo);
Hannes Reinecke03197b62016-02-19 09:17:10 +0100595 pg->expiry = jiffies + pg->transition_tmo * HZ;
Rob Evers3588c5a2012-05-18 14:08:54 -0400596 }
597
Hannes Reineckec49c8342016-02-19 09:17:03 +0100598 if ((buff[4] & RTPG_FMT_MASK) == RTPG_FMT_EXT_HDR)
Rob Evers3588c5a2012-05-18 14:08:54 -0400599 tpg_desc_tbl_off = 8;
600 else
601 tpg_desc_tbl_off = 4;
602
Hannes Reineckec57168a2016-02-19 09:17:14 +0100603 for (k = tpg_desc_tbl_off, desc = buff + tpg_desc_tbl_off;
Rob Evers3588c5a2012-05-18 14:08:54 -0400604 k < len;
Hannes Reineckec57168a2016-02-19 09:17:14 +0100605 k += off, desc += off) {
606 u16 group_id = get_unaligned_be16(&desc[2]);
Rob Evers3588c5a2012-05-18 14:08:54 -0400607
Hannes Reineckec57168a2016-02-19 09:17:14 +0100608 spin_lock_irqsave(&port_group_lock, flags);
609 tmp_pg = alua_find_get_pg(pg->device_id_str, pg->device_id_len,
610 group_id);
611 spin_unlock_irqrestore(&port_group_lock, flags);
612 if (tmp_pg) {
613 if (spin_trylock_irqsave(&tmp_pg->lock, flags)) {
614 if ((tmp_pg == pg) ||
615 !(tmp_pg->flags & ALUA_PG_RUNNING)) {
616 tmp_pg->state = desc[0] & 0x0f;
617 tmp_pg->pref = desc[0] >> 7;
618 }
619 if (tmp_pg == pg)
620 valid_states = desc[1];
621 spin_unlock_irqrestore(&tmp_pg->lock, flags);
622 }
623 kref_put(&tmp_pg->kref, release_port_group);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700624 }
Hannes Reineckec57168a2016-02-19 09:17:14 +0100625 off = 8 + (desc[7] * 4);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700626 }
627
Hannes Reineckec57168a2016-02-19 09:17:14 +0100628 spin_lock_irqsave(&pg->lock, flags);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700629 sdev_printk(KERN_INFO, sdev,
Moger, Babudcd3a752012-03-27 20:56:08 +0000630 "%s: port group %02x state %c %s supports %c%c%c%c%c%c%c\n",
Hannes Reinecke43394c62016-02-19 09:17:04 +0100631 ALUA_DH_NAME, pg->group_id, print_alua_state(pg->state),
632 pg->pref ? "preferred" : "non-preferred",
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700633 valid_states&TPGS_SUPPORT_TRANSITION?'T':'t',
634 valid_states&TPGS_SUPPORT_OFFLINE?'O':'o',
Hannes Reinecke69723d12010-09-24 15:57:04 +0200635 valid_states&TPGS_SUPPORT_LBA_DEPENDENT?'L':'l',
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700636 valid_states&TPGS_SUPPORT_UNAVAILABLE?'U':'u',
637 valid_states&TPGS_SUPPORT_STANDBY?'S':'s',
638 valid_states&TPGS_SUPPORT_NONOPTIMIZED?'N':'n',
639 valid_states&TPGS_SUPPORT_OPTIMIZED?'A':'a');
640
Hannes Reinecke43394c62016-02-19 09:17:04 +0100641 switch (pg->state) {
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100642 case SCSI_ACCESS_STATE_TRANSITIONING:
Hannes Reinecke03197b62016-02-19 09:17:10 +0100643 if (time_before(jiffies, pg->expiry)) {
Hannes Reinecke28261402016-02-19 09:17:07 +0100644 /* State transition, retry */
Hannes Reinecke03197b62016-02-19 09:17:10 +0100645 pg->interval = 2;
646 err = SCSI_DH_RETRY;
647 } else {
648 /* Transitioning time exceeded, set port to standby */
649 err = SCSI_DH_IO;
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100650 pg->state = SCSI_ACCESS_STATE_STANDBY;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100651 pg->expiry = 0;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700652 }
Hannes Reinecke69723d12010-09-24 15:57:04 +0200653 break;
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100654 case SCSI_ACCESS_STATE_OFFLINE:
Bart Van Asschee47f8972012-08-24 09:08:41 +0000655 /* Path unusable */
Hannes Reinecke69723d12010-09-24 15:57:04 +0200656 err = SCSI_DH_DEV_OFFLINED;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100657 pg->expiry = 0;
Hannes Reinecke69723d12010-09-24 15:57:04 +0200658 break;
659 default:
660 /* Useable path if active */
661 err = SCSI_DH_OK;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100662 pg->expiry = 0;
Hannes Reinecke69723d12010-09-24 15:57:04 +0200663 break;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700664 }
Hannes Reineckec57168a2016-02-19 09:17:14 +0100665 spin_unlock_irqrestore(&pg->lock, flags);
Hannes Reineckec49c8342016-02-19 09:17:03 +0100666 kfree(buff);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700667 return err;
668}
669
670/*
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100671 * alua_stpg - Issue a SET TARGET PORT GROUP command
672 *
673 * Issue a SET TARGET PORT GROUP command and evaluate the
Hannes Reineckeb2460752016-02-19 09:17:00 +0100674 * response. Returns SCSI_DH_RETRY per default to trigger
675 * a re-evaluation of the target group state or SCSI_DH_OK
676 * if no further action needs to be taken.
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100677 */
Hannes Reinecke43394c62016-02-19 09:17:04 +0100678static unsigned alua_stpg(struct scsi_device *sdev, struct alua_port_group *pg)
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100679{
Hannes Reineckeb2460752016-02-19 09:17:00 +0100680 int retval;
681 struct scsi_sense_hdr sense_hdr;
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100682
Hannes Reinecke43394c62016-02-19 09:17:04 +0100683 if (!(pg->tpgs & TPGS_MODE_EXPLICIT)) {
Hannes Reineckeb2460752016-02-19 09:17:00 +0100684 /* Only implicit ALUA supported, retry */
685 return SCSI_DH_RETRY;
686 }
Hannes Reinecke43394c62016-02-19 09:17:04 +0100687 switch (pg->state) {
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100688 case SCSI_ACCESS_STATE_OPTIMAL:
Hannes Reineckeb2460752016-02-19 09:17:00 +0100689 return SCSI_DH_OK;
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100690 case SCSI_ACCESS_STATE_ACTIVE:
Hannes Reinecke43394c62016-02-19 09:17:04 +0100691 if ((pg->flags & ALUA_OPTIMIZE_STPG) &&
692 !pg->pref &&
693 (pg->tpgs & TPGS_MODE_IMPLICIT))
Hannes Reineckeb2460752016-02-19 09:17:00 +0100694 return SCSI_DH_OK;
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100695 break;
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100696 case SCSI_ACCESS_STATE_STANDBY:
697 case SCSI_ACCESS_STATE_UNAVAILABLE:
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100698 break;
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100699 case SCSI_ACCESS_STATE_OFFLINE:
Hannes Reineckeb2460752016-02-19 09:17:00 +0100700 return SCSI_DH_IO;
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100701 case SCSI_ACCESS_STATE_TRANSITIONING:
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100702 break;
703 default:
Hannes Reineckeb2460752016-02-19 09:17:00 +0100704 sdev_printk(KERN_INFO, sdev,
705 "%s: stpg failed, unhandled TPGS state %d",
Hannes Reinecke43394c62016-02-19 09:17:04 +0100706 ALUA_DH_NAME, pg->state);
Hannes Reineckeb2460752016-02-19 09:17:00 +0100707 return SCSI_DH_NOSYS;
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100708 }
Hannes Reinecke43394c62016-02-19 09:17:04 +0100709 retval = submit_stpg(sdev, pg->group_id, &sense_hdr);
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100710
Hannes Reineckeb2460752016-02-19 09:17:00 +0100711 if (retval) {
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100712 if (!scsi_sense_valid(&sense_hdr)) {
Hannes Reineckeb2460752016-02-19 09:17:00 +0100713 sdev_printk(KERN_INFO, sdev,
714 "%s: stpg failed, result %d",
715 ALUA_DH_NAME, retval);
Hannes Reinecke40bb61a2016-02-19 09:17:02 +0100716 if (driver_byte(retval) == DRIVER_ERROR)
Hannes Reineckeb2460752016-02-19 09:17:00 +0100717 return SCSI_DH_DEV_TEMP_BUSY;
718 } else {
Hannes Reinecke43394c62016-02-19 09:17:04 +0100719 sdev_printk(KERN_INFO, sdev, "%s: stpg failed\n",
Hannes Reineckeb2460752016-02-19 09:17:00 +0100720 ALUA_DH_NAME);
721 scsi_print_sense_hdr(sdev, ALUA_DH_NAME, &sense_hdr);
722 }
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100723 }
Hannes Reineckeb2460752016-02-19 09:17:00 +0100724 /* Retry RTPG */
725 return SCSI_DH_RETRY;
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100726}
727
Hannes Reinecke03197b62016-02-19 09:17:10 +0100728static void alua_rtpg_work(struct work_struct *work)
729{
730 struct alua_port_group *pg =
731 container_of(work, struct alua_port_group, rtpg_work.work);
732 struct scsi_device *sdev;
733 LIST_HEAD(qdata_list);
734 int err = SCSI_DH_OK;
735 struct alua_queue_data *qdata, *tmp;
736 unsigned long flags;
Hannes Reinecke00642a12016-02-19 09:17:11 +0100737 struct workqueue_struct *alua_wq = kaluad_wq;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100738
739 spin_lock_irqsave(&pg->lock, flags);
740 sdev = pg->rtpg_sdev;
741 if (!sdev) {
742 WARN_ON(pg->flags & ALUA_PG_RUN_RTPG);
743 WARN_ON(pg->flags & ALUA_PG_RUN_STPG);
744 spin_unlock_irqrestore(&pg->lock, flags);
745 return;
746 }
Hannes Reinecke00642a12016-02-19 09:17:11 +0100747 if (pg->flags & ALUA_SYNC_STPG)
748 alua_wq = kaluad_sync_wq;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100749 pg->flags |= ALUA_PG_RUNNING;
750 if (pg->flags & ALUA_PG_RUN_RTPG) {
Hannes Reinecke9d2c3032016-02-19 09:17:15 +0100751 int state = pg->state;
752
Hannes Reinecke03197b62016-02-19 09:17:10 +0100753 pg->flags &= ~ALUA_PG_RUN_RTPG;
754 spin_unlock_irqrestore(&pg->lock, flags);
Hannes Reinecke5115fc72016-03-03 07:54:08 +0100755 if (state == SCSI_ACCESS_STATE_TRANSITIONING) {
Hannes Reinecke9d2c3032016-02-19 09:17:15 +0100756 if (alua_tur(sdev) == SCSI_DH_RETRY) {
757 spin_lock_irqsave(&pg->lock, flags);
758 pg->flags &= ~ALUA_PG_RUNNING;
759 pg->flags |= ALUA_PG_RUN_RTPG;
760 spin_unlock_irqrestore(&pg->lock, flags);
761 queue_delayed_work(alua_wq, &pg->rtpg_work,
762 pg->interval * HZ);
763 return;
764 }
765 /* Send RTPG on failure or if TUR indicates SUCCESS */
766 }
Hannes Reinecke03197b62016-02-19 09:17:10 +0100767 err = alua_rtpg(sdev, pg);
768 spin_lock_irqsave(&pg->lock, flags);
Hannes Reinecke2b358652016-02-19 09:17:13 +0100769 if (err == SCSI_DH_RETRY || pg->flags & ALUA_PG_RUN_RTPG) {
Hannes Reinecke03197b62016-02-19 09:17:10 +0100770 pg->flags &= ~ALUA_PG_RUNNING;
771 pg->flags |= ALUA_PG_RUN_RTPG;
772 spin_unlock_irqrestore(&pg->lock, flags);
Hannes Reinecke00642a12016-02-19 09:17:11 +0100773 queue_delayed_work(alua_wq, &pg->rtpg_work,
Hannes Reinecke03197b62016-02-19 09:17:10 +0100774 pg->interval * HZ);
775 return;
776 }
777 if (err != SCSI_DH_OK)
778 pg->flags &= ~ALUA_PG_RUN_STPG;
779 }
780 if (pg->flags & ALUA_PG_RUN_STPG) {
781 pg->flags &= ~ALUA_PG_RUN_STPG;
782 spin_unlock_irqrestore(&pg->lock, flags);
783 err = alua_stpg(sdev, pg);
784 spin_lock_irqsave(&pg->lock, flags);
Hannes Reinecke2b358652016-02-19 09:17:13 +0100785 if (err == SCSI_DH_RETRY || pg->flags & ALUA_PG_RUN_RTPG) {
Hannes Reinecke03197b62016-02-19 09:17:10 +0100786 pg->flags |= ALUA_PG_RUN_RTPG;
787 pg->interval = 0;
788 pg->flags &= ~ALUA_PG_RUNNING;
789 spin_unlock_irqrestore(&pg->lock, flags);
Hannes Reinecke00642a12016-02-19 09:17:11 +0100790 queue_delayed_work(alua_wq, &pg->rtpg_work,
Hannes Reinecke03197b62016-02-19 09:17:10 +0100791 pg->interval * HZ);
792 return;
793 }
794 }
795
796 list_splice_init(&pg->rtpg_list, &qdata_list);
797 pg->rtpg_sdev = NULL;
798 spin_unlock_irqrestore(&pg->lock, flags);
799
800 list_for_each_entry_safe(qdata, tmp, &qdata_list, entry) {
801 list_del(&qdata->entry);
802 if (qdata->callback_fn)
803 qdata->callback_fn(qdata->callback_data, err);
804 kfree(qdata);
805 }
806 spin_lock_irqsave(&pg->lock, flags);
807 pg->flags &= ~ALUA_PG_RUNNING;
808 spin_unlock_irqrestore(&pg->lock, flags);
809 scsi_device_put(sdev);
810 kref_put(&pg->kref, release_port_group);
811}
812
813static void alua_rtpg_queue(struct alua_port_group *pg,
814 struct scsi_device *sdev,
Hannes Reinecke2b358652016-02-19 09:17:13 +0100815 struct alua_queue_data *qdata, bool force)
Hannes Reinecke03197b62016-02-19 09:17:10 +0100816{
817 int start_queue = 0;
818 unsigned long flags;
Hannes Reinecke00642a12016-02-19 09:17:11 +0100819 struct workqueue_struct *alua_wq = kaluad_wq;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100820
821 if (!pg)
822 return;
823
824 spin_lock_irqsave(&pg->lock, flags);
825 if (qdata) {
826 list_add_tail(&qdata->entry, &pg->rtpg_list);
827 pg->flags |= ALUA_PG_RUN_STPG;
Hannes Reinecke2b358652016-02-19 09:17:13 +0100828 force = true;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100829 }
830 if (pg->rtpg_sdev == NULL) {
831 pg->interval = 0;
832 pg->flags |= ALUA_PG_RUN_RTPG;
833 kref_get(&pg->kref);
834 pg->rtpg_sdev = sdev;
835 scsi_device_get(sdev);
836 start_queue = 1;
Hannes Reinecke2b358652016-02-19 09:17:13 +0100837 } else if (!(pg->flags & ALUA_PG_RUN_RTPG) && force) {
838 pg->flags |= ALUA_PG_RUN_RTPG;
839 /* Do not queue if the worker is already running */
840 if (!(pg->flags & ALUA_PG_RUNNING)) {
841 kref_get(&pg->kref);
842 start_queue = 1;
843 }
Hannes Reinecke03197b62016-02-19 09:17:10 +0100844 }
Hannes Reinecke2b358652016-02-19 09:17:13 +0100845
Hannes Reinecke00642a12016-02-19 09:17:11 +0100846 if (pg->flags & ALUA_SYNC_STPG)
847 alua_wq = kaluad_sync_wq;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100848 spin_unlock_irqrestore(&pg->lock, flags);
849
850 if (start_queue &&
Hannes Reinecke00642a12016-02-19 09:17:11 +0100851 !queue_delayed_work(alua_wq, &pg->rtpg_work,
Hannes Reinecke03197b62016-02-19 09:17:10 +0100852 msecs_to_jiffies(ALUA_RTPG_DELAY_MSECS))) {
853 scsi_device_put(sdev);
854 kref_put(&pg->kref, release_port_group);
855 }
856}
857
Hannes Reineckef2ecf132016-02-19 09:16:59 +0100858/*
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700859 * alua_initialize - Initialize ALUA state
860 * @sdev: the device to be initialized
861 *
862 * For the prep_fn to work correctly we have
863 * to initialize the ALUA state for the device.
864 */
865static int alua_initialize(struct scsi_device *sdev, struct alua_dh_data *h)
866{
Hannes Reinecke43394c62016-02-19 09:17:04 +0100867 int err = SCSI_DH_DEV_UNSUPP, tpgs;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700868
Hannes Reinecke03197b62016-02-19 09:17:10 +0100869 mutex_lock(&h->init_mutex);
Hannes Reinecke43394c62016-02-19 09:17:04 +0100870 tpgs = alua_check_tpgs(sdev);
Hannes Reineckea4253fd2016-02-19 09:17:06 +0100871 if (tpgs != TPGS_MODE_NONE)
872 err = alua_check_vpd(sdev, h, tpgs);
Hannes Reinecke03197b62016-02-19 09:17:10 +0100873 h->init_error = err;
874 mutex_unlock(&h->init_mutex);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700875 return err;
876}
Moger, Babu4335d092012-03-27 20:55:49 +0000877/*
878 * alua_set_params - set/unset the optimize flag
879 * @sdev: device on the path to be activated
880 * params - parameters in the following format
881 * "no_of_params\0param1\0param2\0param3\0...\0"
882 * For example, to set the flag pass the following parameters
883 * from multipath.conf
884 * hardware_handler "2 alua 1"
885 */
886static int alua_set_params(struct scsi_device *sdev, const char *params)
887{
Christoph Hellwigee14c672015-08-27 14:16:59 +0200888 struct alua_dh_data *h = sdev->handler_data;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100889 struct alua_port_group __rcu *pg = NULL;
Moger, Babu4335d092012-03-27 20:55:49 +0000890 unsigned int optimize = 0, argc;
891 const char *p = params;
892 int result = SCSI_DH_OK;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100893 unsigned long flags;
Moger, Babu4335d092012-03-27 20:55:49 +0000894
895 if ((sscanf(params, "%u", &argc) != 1) || (argc != 1))
896 return -EINVAL;
897
898 while (*p++)
899 ;
900 if ((sscanf(p, "%u", &optimize) != 1) || (optimize > 1))
901 return -EINVAL;
902
Hannes Reinecke03197b62016-02-19 09:17:10 +0100903 rcu_read_lock();
904 pg = rcu_dereference(h->pg);
905 if (!pg) {
906 rcu_read_unlock();
Hannes Reinecke43394c62016-02-19 09:17:04 +0100907 return -ENXIO;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100908 }
909 spin_lock_irqsave(&pg->lock, flags);
Moger, Babu4335d092012-03-27 20:55:49 +0000910 if (optimize)
Hannes Reinecke43394c62016-02-19 09:17:04 +0100911 pg->flags |= ALUA_OPTIMIZE_STPG;
Moger, Babu4335d092012-03-27 20:55:49 +0000912 else
Hannes Reinecke43394c62016-02-19 09:17:04 +0100913 pg->flags &= ~ALUA_OPTIMIZE_STPG;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100914 spin_unlock_irqrestore(&pg->lock, flags);
915 rcu_read_unlock();
Moger, Babu4335d092012-03-27 20:55:49 +0000916
917 return result;
918}
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700919
920/*
921 * alua_activate - activate a path
922 * @sdev: device on the path to be activated
923 *
924 * We're currently switching the port group to be activated only and
925 * let the array figure out the rest.
926 * There may be other arrays which require us to switch all port groups
927 * based on a certain policy. But until we actually encounter them it
928 * should be okay.
929 */
Chandra Seetharaman3ae31f62009-10-21 09:22:46 -0700930static int alua_activate(struct scsi_device *sdev,
931 activate_complete fn, void *data)
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700932{
Christoph Hellwigee14c672015-08-27 14:16:59 +0200933 struct alua_dh_data *h = sdev->handler_data;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700934 int err = SCSI_DH_OK;
Hannes Reinecke03197b62016-02-19 09:17:10 +0100935 struct alua_queue_data *qdata;
936 struct alua_port_group __rcu *pg;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700937
Hannes Reinecke03197b62016-02-19 09:17:10 +0100938 qdata = kzalloc(sizeof(*qdata), GFP_KERNEL);
939 if (!qdata) {
940 err = SCSI_DH_RES_TEMP_UNAVAIL;
Hannes Reinecke43394c62016-02-19 09:17:04 +0100941 goto out;
942 }
Hannes Reinecke03197b62016-02-19 09:17:10 +0100943 qdata->callback_fn = fn;
944 qdata->callback_data = data;
945
946 mutex_lock(&h->init_mutex);
947 rcu_read_lock();
948 pg = rcu_dereference(h->pg);
949 if (!pg || !kref_get_unless_zero(&pg->kref)) {
950 rcu_read_unlock();
951 kfree(qdata);
952 err = h->init_error;
953 mutex_unlock(&h->init_mutex);
954 goto out;
955 }
956 fn = NULL;
957 rcu_read_unlock();
958 mutex_unlock(&h->init_mutex);
959
Hannes Reinecke2b358652016-02-19 09:17:13 +0100960 alua_rtpg_queue(pg, sdev, qdata, true);
Hannes Reinecke03197b62016-02-19 09:17:10 +0100961 kref_put(&pg->kref, release_port_group);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700962out:
Hannes Reineckeb2460752016-02-19 09:17:00 +0100963 if (fn)
Chandra Seetharaman3ae31f62009-10-21 09:22:46 -0700964 fn(data, err);
965 return 0;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700966}
967
968/*
Hannes Reinecke2b358652016-02-19 09:17:13 +0100969 * alua_check - check path status
970 * @sdev: device on the path to be checked
971 *
972 * Check the device status
973 */
974static void alua_check(struct scsi_device *sdev, bool force)
975{
976 struct alua_dh_data *h = sdev->handler_data;
977 struct alua_port_group *pg;
978
979 rcu_read_lock();
980 pg = rcu_dereference(h->pg);
981 if (!pg || !kref_get_unless_zero(&pg->kref)) {
982 rcu_read_unlock();
983 return;
984 }
985 rcu_read_unlock();
986
987 alua_rtpg_queue(pg, sdev, NULL, force);
988 kref_put(&pg->kref, release_port_group);
989}
990
991/*
Hannes Reinecke057ea7c2008-07-17 16:53:21 -0700992 * alua_prep_fn - request callback
993 *
994 * Fail I/O to all paths not in state
995 * active/optimized or active/non-optimized.
996 */
997static int alua_prep_fn(struct scsi_device *sdev, struct request *req)
998{
Christoph Hellwigee14c672015-08-27 14:16:59 +0200999 struct alua_dh_data *h = sdev->handler_data;
Hannes Reinecke03197b62016-02-19 09:17:10 +01001000 struct alua_port_group __rcu *pg;
Hannes Reinecke5115fc72016-03-03 07:54:08 +01001001 unsigned char state = SCSI_ACCESS_STATE_OPTIMAL;
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07001002 int ret = BLKPREP_OK;
1003
Hannes Reinecke03197b62016-02-19 09:17:10 +01001004 rcu_read_lock();
1005 pg = rcu_dereference(h->pg);
1006 if (pg)
1007 state = pg->state;
1008 rcu_read_unlock();
Hannes Reinecke5115fc72016-03-03 07:54:08 +01001009 if (state == SCSI_ACCESS_STATE_TRANSITIONING)
Hannes Reinecke69723d12010-09-24 15:57:04 +02001010 ret = BLKPREP_DEFER;
Hannes Reinecke5115fc72016-03-03 07:54:08 +01001011 else if (state != SCSI_ACCESS_STATE_OPTIMAL &&
1012 state != SCSI_ACCESS_STATE_ACTIVE &&
1013 state != SCSI_ACCESS_STATE_LBA) {
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07001014 ret = BLKPREP_KILL;
1015 req->cmd_flags |= REQ_QUIET;
1016 }
1017 return ret;
1018
1019}
1020
Hannes Reinecked3d32892016-02-19 09:17:16 +01001021static void alua_rescan(struct scsi_device *sdev)
1022{
1023 struct alua_dh_data *h = sdev->handler_data;
1024
1025 alua_initialize(sdev, h);
1026}
1027
Christoph Hellwig1d520322014-09-14 11:08:21 -07001028/*
1029 * alua_bus_attach - Attach device handler
1030 * @sdev: device to be attached to
1031 */
Christoph Hellwigee14c672015-08-27 14:16:59 +02001032static int alua_bus_attach(struct scsi_device *sdev)
Christoph Hellwig1d520322014-09-14 11:08:21 -07001033{
1034 struct alua_dh_data *h;
Hannes Reinecke43394c62016-02-19 09:17:04 +01001035 int err, ret = -EINVAL;
Christoph Hellwig1d520322014-09-14 11:08:21 -07001036
1037 h = kzalloc(sizeof(*h) , GFP_KERNEL);
1038 if (!h)
Christoph Hellwigee14c672015-08-27 14:16:59 +02001039 return -ENOMEM;
Hannes Reinecke03197b62016-02-19 09:17:10 +01001040 spin_lock_init(&h->pg_lock);
1041 rcu_assign_pointer(h->pg, NULL);
1042 h->init_error = SCSI_DH_OK;
Christoph Hellwig1d520322014-09-14 11:08:21 -07001043 h->sdev = sdev;
1044
Hannes Reinecke03197b62016-02-19 09:17:10 +01001045 mutex_init(&h->init_mutex);
Christoph Hellwig1d520322014-09-14 11:08:21 -07001046 err = alua_initialize(sdev, h);
Hannes Reinecke43394c62016-02-19 09:17:04 +01001047 if (err == SCSI_DH_NOMEM)
1048 ret = -ENOMEM;
Christoph Hellwig1d520322014-09-14 11:08:21 -07001049 if (err != SCSI_DH_OK && err != SCSI_DH_DEV_OFFLINED)
1050 goto failed;
1051
Christoph Hellwigee14c672015-08-27 14:16:59 +02001052 sdev->handler_data = h;
1053 return 0;
Christoph Hellwig1d520322014-09-14 11:08:21 -07001054failed:
1055 kfree(h);
Hannes Reinecke43394c62016-02-19 09:17:04 +01001056 return ret;
Christoph Hellwig1d520322014-09-14 11:08:21 -07001057}
1058
1059/*
1060 * alua_bus_detach - Detach device handler
1061 * @sdev: device to be detached from
1062 */
1063static void alua_bus_detach(struct scsi_device *sdev)
1064{
Christoph Hellwigee14c672015-08-27 14:16:59 +02001065 struct alua_dh_data *h = sdev->handler_data;
Hannes Reinecke03197b62016-02-19 09:17:10 +01001066 struct alua_port_group *pg;
Christoph Hellwig1d520322014-09-14 11:08:21 -07001067
Hannes Reinecke03197b62016-02-19 09:17:10 +01001068 spin_lock(&h->pg_lock);
1069 pg = h->pg;
1070 rcu_assign_pointer(h->pg, NULL);
1071 h->sdev = NULL;
1072 spin_unlock(&h->pg_lock);
1073 if (pg)
1074 kref_put(&pg->kref, release_port_group);
1075
Christoph Hellwigee14c672015-08-27 14:16:59 +02001076 sdev->handler_data = NULL;
Christoph Hellwig1d520322014-09-14 11:08:21 -07001077 kfree(h);
1078}
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07001079
1080static struct scsi_device_handler alua_dh = {
1081 .name = ALUA_DH_NAME,
1082 .module = THIS_MODULE,
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07001083 .attach = alua_bus_attach,
1084 .detach = alua_bus_detach,
1085 .prep_fn = alua_prep_fn,
1086 .check_sense = alua_check_sense,
1087 .activate = alua_activate,
Hannes Reinecked3d32892016-02-19 09:17:16 +01001088 .rescan = alua_rescan,
Moger, Babu4335d092012-03-27 20:55:49 +00001089 .set_params = alua_set_params,
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07001090};
1091
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07001092static int __init alua_init(void)
1093{
1094 int r;
1095
Hannes Reinecke03197b62016-02-19 09:17:10 +01001096 kaluad_wq = alloc_workqueue("kaluad", WQ_MEM_RECLAIM, 0);
1097 if (!kaluad_wq) {
1098 /* Temporary failure, bypass */
1099 return SCSI_DH_DEV_TEMP_BUSY;
1100 }
Hannes Reinecke00642a12016-02-19 09:17:11 +01001101 kaluad_sync_wq = create_workqueue("kaluad_sync");
1102 if (!kaluad_sync_wq) {
1103 destroy_workqueue(kaluad_wq);
1104 return SCSI_DH_DEV_TEMP_BUSY;
1105 }
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07001106 r = scsi_register_device_handler(&alua_dh);
Hannes Reinecke03197b62016-02-19 09:17:10 +01001107 if (r != 0) {
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07001108 printk(KERN_ERR "%s: Failed to register scsi device handler",
1109 ALUA_DH_NAME);
Hannes Reinecke00642a12016-02-19 09:17:11 +01001110 destroy_workqueue(kaluad_sync_wq);
Hannes Reinecke03197b62016-02-19 09:17:10 +01001111 destroy_workqueue(kaluad_wq);
1112 }
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07001113 return r;
1114}
1115
1116static void __exit alua_exit(void)
1117{
1118 scsi_unregister_device_handler(&alua_dh);
Hannes Reinecke00642a12016-02-19 09:17:11 +01001119 destroy_workqueue(kaluad_sync_wq);
Hannes Reinecke03197b62016-02-19 09:17:10 +01001120 destroy_workqueue(kaluad_wq);
Hannes Reinecke057ea7c2008-07-17 16:53:21 -07001121}
1122
1123module_init(alua_init);
1124module_exit(alua_exit);
1125
1126MODULE_DESCRIPTION("DM Multipath ALUA support");
1127MODULE_AUTHOR("Hannes Reinecke <hare@suse.de>");
1128MODULE_LICENSE("GPL");
1129MODULE_VERSION(ALUA_DH_VER);