2 * LSI/Engenio/NetApp E-Series RDAC SCSI Device Handler
4 * Copyright (C) 2005 Mike Christie. All rights reserved.
5 * Copyright (C) Chandra Seetharaman, IBM Corp. 2007
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.
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.
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.
22 #include <scsi/scsi.h>
23 #include <scsi/scsi_eh.h>
24 #include <scsi/scsi_dh.h>
25 #include <linux/workqueue.h>
26 #include <linux/slab.h>
28 #define RDAC_NAME "rdac"
29 #define RDAC_RETRY_COUNT 5
34 * These struct definitions and the forming of the
35 * mode page were taken from the LSI RDAC 2.4 GPL'd
36 * driver, and then converted to Linux conventions.
38 #define RDAC_QUIESCENCE_TIME 20
42 #define RDAC_PAGE_CODE_REDUNDANT_CONTROLLER 0x2c
45 * Controller modes definitions
47 #define RDAC_MODE_TRANSFER_SPECIFIED_LUNS 0x02
52 #define RDAC_FORCED_QUIESENCE 0x02
54 #define RDAC_TIMEOUT (60 * HZ)
55 #define RDAC_RETRIES 3
57 struct rdac_mode_6_hdr {
64 struct rdac_mode_10_hdr {
72 struct rdac_mode_common {
73 u8 controller_serial[16];
74 u8 alt_controller_serial[16];
77 u8 quiescence_timeout;
81 struct rdac_pg_legacy {
82 struct rdac_mode_6_hdr hdr;
85 struct rdac_mode_common common;
86 #define MODE6_MAX_LUN 32
87 u8 lun_table[MODE6_MAX_LUN];
93 struct rdac_pg_expanded {
94 struct rdac_mode_10_hdr hdr;
98 struct rdac_mode_common common;
106 u8 page_code; /* 0xC9 */
109 u8 page_id[4]; /* "vace" */
115 #define SUBSYS_ID_LEN 16
116 #define SLOT_ID_LEN 2
117 #define ARRAY_LABEL_LEN 31
121 u8 page_code; /* 0xC4 */
124 u8 page_id[4]; /* "subs" */
125 u8 subsys_id[SUBSYS_ID_LEN];
127 u8 slot_id[SLOT_ID_LEN];
131 #define UNIQUE_ID_LEN 16
134 u8 page_code; /* 0xC8 */
137 u8 page_id[4]; /* "edid" */
141 u8 vol_user_label_len;
142 u8 vol_user_label[60];
143 u8 array_uniq_id_len;
144 u8 array_unique_id[UNIQUE_ID_LEN];
145 u8 array_user_label_len;
146 u8 array_user_label[60];
150 struct rdac_controller {
151 u8 array_id[UNIQUE_ID_LEN];
154 struct list_head node; /* list of all controllers */
156 struct rdac_pg_legacy legacy;
157 struct rdac_pg_expanded expanded;
160 u8 array_name[ARRAY_LABEL_LEN];
161 struct Scsi_Host *host;
164 struct work_struct ms_work;
165 struct scsi_device *ms_sdev;
166 struct list_head ms_head;
171 u8 page_code; /* 0xC2 */
174 u8 page_id[4]; /* "swr4" */
178 u8 max_lun_supported;
179 u8 partitions[239]; /* Total allocation length should be 0xFF */
182 struct rdac_dh_data {
183 struct rdac_controller *ctlr;
184 #define UNINITIALIZED_LUN (1 << 8)
188 #define RDAC_MODE_AVT 1
189 #define RDAC_MODE_IOSHIP 2
192 #define RDAC_STATE_ACTIVE 0
193 #define RDAC_STATE_PASSIVE 1
196 #define RDAC_LUN_UNOWNED 0
197 #define RDAC_LUN_OWNED 1
200 #define RDAC_PREFERRED 0
201 #define RDAC_NON_PREFERRED 1
204 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
206 struct c2_inquiry c2;
207 struct c4_inquiry c4;
208 struct c8_inquiry c8;
209 struct c9_inquiry c9;
213 static const char *mode[] = {
218 static const char *lun_state[] =
224 struct rdac_queue_data {
225 struct list_head entry;
226 struct rdac_dh_data *h;
227 activate_complete callback_fn;
231 static LIST_HEAD(ctlr_list);
232 static DEFINE_SPINLOCK(list_lock);
233 static struct workqueue_struct *kmpath_rdacd;
234 static void send_mode_select(struct work_struct *work);
237 * module parameter to enable rdac debug logging.
238 * 2 bits for each type of logging, only two types defined for now
239 * Can be enhanced if required at later point
241 static int rdac_logging = 1;
242 module_param(rdac_logging, int, S_IRUGO|S_IWUSR);
243 MODULE_PARM_DESC(rdac_logging, "A bit mask of rdac logging levels, "
244 "Default is 1 - failover logging enabled, "
245 "set it to 0xF to enable all the logs");
247 #define RDAC_LOG_FAILOVER 0
248 #define RDAC_LOG_SENSE 2
250 #define RDAC_LOG_BITS 2
252 #define RDAC_LOG_LEVEL(SHIFT) \
253 ((rdac_logging >> (SHIFT)) & ((1 << (RDAC_LOG_BITS)) - 1))
255 #define RDAC_LOG(SHIFT, sdev, f, arg...) \
257 if (unlikely(RDAC_LOG_LEVEL(SHIFT))) \
258 sdev_printk(KERN_INFO, sdev, RDAC_NAME ": " f "\n", ## arg); \
261 static inline struct rdac_dh_data *get_rdac_data(struct scsi_device *sdev)
263 struct scsi_dh_data *scsi_dh_data = sdev->scsi_dh_data;
264 BUG_ON(scsi_dh_data == NULL);
265 return ((struct rdac_dh_data *) scsi_dh_data->buf);
268 static struct request *get_rdac_req(struct scsi_device *sdev,
269 void *buffer, unsigned buflen, int rw)
272 struct request_queue *q = sdev->request_queue;
274 rq = blk_get_request(q, rw, GFP_NOIO);
277 sdev_printk(KERN_INFO, sdev,
278 "get_rdac_req: blk_get_request failed.\n");
282 if (buflen && blk_rq_map_kern(q, rq, buffer, buflen, GFP_NOIO)) {
284 sdev_printk(KERN_INFO, sdev,
285 "get_rdac_req: blk_rq_map_kern failed.\n");
289 rq->cmd_type = REQ_TYPE_BLOCK_PC;
290 rq->cmd_flags |= REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
292 rq->retries = RDAC_RETRIES;
293 rq->timeout = RDAC_TIMEOUT;
298 static struct request *rdac_failover_get(struct scsi_device *sdev,
299 struct rdac_dh_data *h, struct list_head *list)
302 struct rdac_mode_common *common;
304 struct rdac_queue_data *qdata;
307 if (h->ctlr->use_ms10) {
308 struct rdac_pg_expanded *rdac_pg;
310 data_size = sizeof(struct rdac_pg_expanded);
311 rdac_pg = &h->ctlr->mode_select.expanded;
312 memset(rdac_pg, 0, data_size);
313 common = &rdac_pg->common;
314 rdac_pg->page_code = RDAC_PAGE_CODE_REDUNDANT_CONTROLLER + 0x40;
315 rdac_pg->subpage_code = 0x1;
316 rdac_pg->page_len[0] = 0x01;
317 rdac_pg->page_len[1] = 0x28;
318 lun_table = rdac_pg->lun_table;
320 struct rdac_pg_legacy *rdac_pg;
322 data_size = sizeof(struct rdac_pg_legacy);
323 rdac_pg = &h->ctlr->mode_select.legacy;
324 memset(rdac_pg, 0, data_size);
325 common = &rdac_pg->common;
326 rdac_pg->page_code = RDAC_PAGE_CODE_REDUNDANT_CONTROLLER;
327 rdac_pg->page_len = 0x68;
328 lun_table = rdac_pg->lun_table;
330 common->rdac_mode[1] = RDAC_MODE_TRANSFER_SPECIFIED_LUNS;
331 common->quiescence_timeout = RDAC_QUIESCENCE_TIME;
332 common->rdac_options = RDAC_FORCED_QUIESENCE;
334 list_for_each_entry(qdata, list, entry) {
335 lun_table[qdata->h->lun] = 0x81;
338 /* get request for block layer packet command */
339 rq = get_rdac_req(sdev, &h->ctlr->mode_select, data_size, WRITE);
343 /* Prepare the command. */
344 if (h->ctlr->use_ms10) {
345 rq->cmd[0] = MODE_SELECT_10;
346 rq->cmd[7] = data_size >> 8;
347 rq->cmd[8] = data_size & 0xff;
349 rq->cmd[0] = MODE_SELECT;
350 rq->cmd[4] = data_size;
352 rq->cmd_len = COMMAND_SIZE(rq->cmd[0]);
354 rq->sense = h->sense;
355 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
361 static void release_controller(struct kref *kref)
363 struct rdac_controller *ctlr;
364 ctlr = container_of(kref, struct rdac_controller, kref);
366 flush_workqueue(kmpath_rdacd);
367 spin_lock(&list_lock);
368 list_del(&ctlr->node);
369 spin_unlock(&list_lock);
373 static struct rdac_controller *get_controller(int index, char *array_name,
374 u8 *array_id, struct scsi_device *sdev)
376 struct rdac_controller *ctlr, *tmp;
378 spin_lock(&list_lock);
380 list_for_each_entry(tmp, &ctlr_list, node) {
381 if ((memcmp(tmp->array_id, array_id, UNIQUE_ID_LEN) == 0) &&
382 (tmp->index == index) &&
383 (tmp->host == sdev->host)) {
384 kref_get(&tmp->kref);
385 spin_unlock(&list_lock);
389 ctlr = kmalloc(sizeof(*ctlr), GFP_ATOMIC);
393 /* initialize fields of controller */
394 memcpy(ctlr->array_id, array_id, UNIQUE_ID_LEN);
396 ctlr->host = sdev->host;
397 memcpy(ctlr->array_name, array_name, ARRAY_LABEL_LEN);
399 kref_init(&ctlr->kref);
402 ctlr->ms_sdev = NULL;
403 spin_lock_init(&ctlr->ms_lock);
404 INIT_WORK(&ctlr->ms_work, send_mode_select);
405 INIT_LIST_HEAD(&ctlr->ms_head);
406 list_add(&ctlr->node, &ctlr_list);
408 spin_unlock(&list_lock);
412 static int submit_inquiry(struct scsi_device *sdev, int page_code,
413 unsigned int len, struct rdac_dh_data *h)
416 struct request_queue *q = sdev->request_queue;
417 int err = SCSI_DH_RES_TEMP_UNAVAIL;
419 rq = get_rdac_req(sdev, &h->inq, len, READ);
423 /* Prepare the command. */
424 rq->cmd[0] = INQUIRY;
426 rq->cmd[2] = page_code;
428 rq->cmd_len = COMMAND_SIZE(INQUIRY);
430 rq->sense = h->sense;
431 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
434 err = blk_execute_rq(q, NULL, rq, 1);
443 static int get_lun_info(struct scsi_device *sdev, struct rdac_dh_data *h,
444 char *array_name, u8 *array_id)
447 struct c8_inquiry *inqp;
449 err = submit_inquiry(sdev, 0xC8, sizeof(struct c8_inquiry), h);
450 if (err == SCSI_DH_OK) {
452 if (inqp->page_code != 0xc8)
453 return SCSI_DH_NOSYS;
454 if (inqp->page_id[0] != 'e' || inqp->page_id[1] != 'd' ||
455 inqp->page_id[2] != 'i' || inqp->page_id[3] != 'd')
456 return SCSI_DH_NOSYS;
457 h->lun = inqp->lun[7]; /* Uses only the last byte */
459 for(i=0; i<ARRAY_LABEL_LEN-1; ++i)
460 *(array_name+i) = inqp->array_user_label[(2*i)+1];
462 *(array_name+ARRAY_LABEL_LEN-1) = '\0';
463 memset(array_id, 0, UNIQUE_ID_LEN);
464 memcpy(array_id, inqp->array_unique_id, inqp->array_uniq_id_len);
469 static int check_ownership(struct scsi_device *sdev, struct rdac_dh_data *h)
472 struct c9_inquiry *inqp;
474 h->state = RDAC_STATE_ACTIVE;
475 err = submit_inquiry(sdev, 0xC9, sizeof(struct c9_inquiry), h);
476 if (err == SCSI_DH_OK) {
478 /* detect the operating mode */
479 if ((inqp->avte_cvp >> 5) & 0x1)
480 h->mode = RDAC_MODE_IOSHIP; /* LUN in IOSHIP mode */
481 else if (inqp->avte_cvp >> 7)
482 h->mode = RDAC_MODE_AVT; /* LUN in AVT mode */
484 h->mode = RDAC_MODE; /* LUN in RDAC mode */
486 /* Update ownership */
487 if (inqp->avte_cvp & 0x1)
488 h->lun_state = RDAC_LUN_OWNED;
490 h->lun_state = RDAC_LUN_UNOWNED;
491 if (h->mode == RDAC_MODE)
492 h->state = RDAC_STATE_PASSIVE;
495 /* Update path prio*/
496 if (inqp->path_prio & 0x1)
497 h->preferred = RDAC_PREFERRED;
499 h->preferred = RDAC_NON_PREFERRED;
505 static int initialize_controller(struct scsi_device *sdev,
506 struct rdac_dh_data *h, char *array_name, u8 *array_id)
509 struct c4_inquiry *inqp;
511 err = submit_inquiry(sdev, 0xC4, sizeof(struct c4_inquiry), h);
512 if (err == SCSI_DH_OK) {
514 /* get the controller index */
515 if (inqp->slot_id[1] == 0x31)
519 h->ctlr = get_controller(index, array_name, array_id, sdev);
521 err = SCSI_DH_RES_TEMP_UNAVAIL;
526 static int set_mode_select(struct scsi_device *sdev, struct rdac_dh_data *h)
529 struct c2_inquiry *inqp;
531 err = submit_inquiry(sdev, 0xC2, sizeof(struct c2_inquiry), h);
532 if (err == SCSI_DH_OK) {
535 * If more than MODE6_MAX_LUN luns are supported, use
538 if (inqp->max_lun_supported >= MODE6_MAX_LUN)
539 h->ctlr->use_ms10 = 1;
541 h->ctlr->use_ms10 = 0;
546 static int mode_select_handle_sense(struct scsi_device *sdev,
547 unsigned char *sensebuf)
549 struct scsi_sense_hdr sense_hdr;
550 int err = SCSI_DH_IO, ret;
551 struct rdac_dh_data *h = get_rdac_data(sdev);
553 ret = scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE, &sense_hdr);
557 switch (sense_hdr.sense_key) {
559 case ABORTED_COMMAND:
564 if (sense_hdr.asc == 0x04 && sense_hdr.ascq == 0x01)
565 /* LUN Not Ready and is in the Process of Becoming
570 case ILLEGAL_REQUEST:
571 if (sense_hdr.asc == 0x91 && sense_hdr.ascq == 0x36)
573 * Command Lock contention
581 RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, "
582 "MODE_SELECT returned with sense %02x/%02x/%02x",
583 (char *) h->ctlr->array_name, h->ctlr->index,
584 sense_hdr.sense_key, sense_hdr.asc, sense_hdr.ascq);
590 static void send_mode_select(struct work_struct *work)
592 struct rdac_controller *ctlr =
593 container_of(work, struct rdac_controller, ms_work);
595 struct scsi_device *sdev = ctlr->ms_sdev;
596 struct rdac_dh_data *h = get_rdac_data(sdev);
597 struct request_queue *q = sdev->request_queue;
598 int err, retry_cnt = RDAC_RETRY_COUNT;
599 struct rdac_queue_data *tmp, *qdata;
602 spin_lock(&ctlr->ms_lock);
603 list_splice_init(&ctlr->ms_head, &list);
605 ctlr->ms_sdev = NULL;
606 spin_unlock(&ctlr->ms_lock);
609 err = SCSI_DH_RES_TEMP_UNAVAIL;
610 rq = rdac_failover_get(sdev, h, &list);
614 RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, "
615 "%s MODE_SELECT command",
616 (char *) h->ctlr->array_name, h->ctlr->index,
617 (retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying");
619 err = blk_execute_rq(q, NULL, rq, 1);
621 if (err != SCSI_DH_OK) {
622 err = mode_select_handle_sense(sdev, h->sense);
623 if (err == SCSI_DH_RETRY && retry_cnt--)
626 if (err == SCSI_DH_OK) {
627 h->state = RDAC_STATE_ACTIVE;
628 RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, "
629 "MODE_SELECT completed",
630 (char *) h->ctlr->array_name, h->ctlr->index);
634 list_for_each_entry_safe(qdata, tmp, &list, entry) {
635 list_del(&qdata->entry);
636 if (err == SCSI_DH_OK)
637 qdata->h->state = RDAC_STATE_ACTIVE;
638 if (qdata->callback_fn)
639 qdata->callback_fn(qdata->callback_data, err);
645 static int queue_mode_select(struct scsi_device *sdev,
646 activate_complete fn, void *data)
648 struct rdac_queue_data *qdata;
649 struct rdac_controller *ctlr;
651 qdata = kzalloc(sizeof(*qdata), GFP_KERNEL);
653 return SCSI_DH_RETRY;
655 qdata->h = get_rdac_data(sdev);
656 qdata->callback_fn = fn;
657 qdata->callback_data = data;
659 ctlr = qdata->h->ctlr;
660 spin_lock(&ctlr->ms_lock);
661 list_add_tail(&qdata->entry, &ctlr->ms_head);
662 if (!ctlr->ms_queued) {
664 ctlr->ms_sdev = sdev;
665 queue_work(kmpath_rdacd, &ctlr->ms_work);
667 spin_unlock(&ctlr->ms_lock);
671 static int rdac_activate(struct scsi_device *sdev,
672 activate_complete fn, void *data)
674 struct rdac_dh_data *h = get_rdac_data(sdev);
675 int err = SCSI_DH_OK;
678 err = check_ownership(sdev, h);
679 if (err != SCSI_DH_OK)
684 if (h->lun_state == RDAC_LUN_UNOWNED)
687 case RDAC_MODE_IOSHIP:
688 if ((h->lun_state == RDAC_LUN_UNOWNED) &&
689 (h->preferred == RDAC_PREFERRED))
697 err = queue_mode_select(sdev, fn, data);
698 if (err == SCSI_DH_OK)
707 static int rdac_prep_fn(struct scsi_device *sdev, struct request *req)
709 struct rdac_dh_data *h = get_rdac_data(sdev);
710 int ret = BLKPREP_OK;
712 if (h->state != RDAC_STATE_ACTIVE) {
714 req->cmd_flags |= REQ_QUIET;
720 static int rdac_check_sense(struct scsi_device *sdev,
721 struct scsi_sense_hdr *sense_hdr)
723 struct rdac_dh_data *h = get_rdac_data(sdev);
725 RDAC_LOG(RDAC_LOG_SENSE, sdev, "array %s, ctlr %d, "
726 "I/O returned with sense %02x/%02x/%02x",
727 (char *) h->ctlr->array_name, h->ctlr->index,
728 sense_hdr->sense_key, sense_hdr->asc, sense_hdr->ascq);
730 switch (sense_hdr->sense_key) {
732 if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x01)
733 /* LUN Not Ready - Logical Unit Not Ready and is in
734 * the process of becoming ready
737 return ADD_TO_MLQUEUE;
738 if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x81)
739 /* LUN Not Ready - Storage firmware incompatible
740 * Manual code synchonisation required.
742 * Nothing we can do here. Try to bypass the path.
745 if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0xA1)
746 /* LUN Not Ready - Quiescense in progress
748 * Just retry and wait.
750 return ADD_TO_MLQUEUE;
751 if (sense_hdr->asc == 0xA1 && sense_hdr->ascq == 0x02)
752 /* LUN Not Ready - Quiescense in progress
753 * or has been achieved
756 return ADD_TO_MLQUEUE;
758 case ILLEGAL_REQUEST:
759 if (sense_hdr->asc == 0x94 && sense_hdr->ascq == 0x01) {
760 /* Invalid Request - Current Logical Unit Ownership.
761 * Controller is not the current owner of the LUN,
762 * Fail the path, so that the other path be used.
764 h->state = RDAC_STATE_PASSIVE;
769 if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00)
771 * Power On, Reset, or Bus Device Reset, just retry.
773 return ADD_TO_MLQUEUE;
774 if (sense_hdr->asc == 0x8b && sense_hdr->ascq == 0x02)
776 * Quiescence in progress , just retry.
778 return ADD_TO_MLQUEUE;
781 /* success just means we do not care what scsi-ml does */
782 return SCSI_RETURN_NOT_HANDLED;
785 static const struct scsi_dh_devlist rdac_dev_list[] = {
800 {"STK", "OPENstorage D280"},
802 {"SUN", "LCSM100_I"},
803 {"SUN", "LCSM100_S"},
804 {"SUN", "LCSM100_E"},
805 {"SUN", "LCSM100_F"},
812 {"LSI", "INF-01-00"},
813 {"ENGENIO", "INF-01-00"},
814 {"STK", "FLEXLINE 380"},
815 {"SUN", "CSM100_R_FC"},
816 {"SUN", "STK6580_6780"},
818 {"SUN", "ArrayStorage"},
822 static int rdac_bus_attach(struct scsi_device *sdev);
823 static void rdac_bus_detach(struct scsi_device *sdev);
825 static struct scsi_device_handler rdac_dh = {
827 .module = THIS_MODULE,
828 .devlist = rdac_dev_list,
829 .prep_fn = rdac_prep_fn,
830 .check_sense = rdac_check_sense,
831 .attach = rdac_bus_attach,
832 .detach = rdac_bus_detach,
833 .activate = rdac_activate,
836 static int rdac_bus_attach(struct scsi_device *sdev)
838 struct scsi_dh_data *scsi_dh_data;
839 struct rdac_dh_data *h;
842 char array_name[ARRAY_LABEL_LEN];
843 char array_id[UNIQUE_ID_LEN];
845 scsi_dh_data = kzalloc(sizeof(*scsi_dh_data)
846 + sizeof(*h) , GFP_KERNEL);
848 sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n",
853 scsi_dh_data->scsi_dh = &rdac_dh;
854 h = (struct rdac_dh_data *) scsi_dh_data->buf;
855 h->lun = UNINITIALIZED_LUN;
856 h->state = RDAC_STATE_ACTIVE;
858 err = get_lun_info(sdev, h, array_name, array_id);
859 if (err != SCSI_DH_OK)
862 err = initialize_controller(sdev, h, array_name, array_id);
863 if (err != SCSI_DH_OK)
866 err = check_ownership(sdev, h);
867 if (err != SCSI_DH_OK)
870 err = set_mode_select(sdev, h);
871 if (err != SCSI_DH_OK)
874 if (!try_module_get(THIS_MODULE))
877 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
878 sdev->scsi_dh_data = scsi_dh_data;
879 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
881 sdev_printk(KERN_NOTICE, sdev,
882 "%s: LUN %d (%s) (%s)\n",
883 RDAC_NAME, h->lun, mode[(int)h->mode],
884 lun_state[(int)h->lun_state]);
889 kref_put(&h->ctlr->kref, release_controller);
893 sdev_printk(KERN_ERR, sdev, "%s: not attached\n",
898 static void rdac_bus_detach( struct scsi_device *sdev )
900 struct scsi_dh_data *scsi_dh_data;
901 struct rdac_dh_data *h;
904 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
905 scsi_dh_data = sdev->scsi_dh_data;
906 sdev->scsi_dh_data = NULL;
907 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
909 h = (struct rdac_dh_data *) scsi_dh_data->buf;
911 kref_put(&h->ctlr->kref, release_controller);
913 module_put(THIS_MODULE);
914 sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", RDAC_NAME);
919 static int __init rdac_init(void)
923 r = scsi_register_device_handler(&rdac_dh);
925 printk(KERN_ERR "Failed to register scsi device handler.");
930 * Create workqueue to handle mode selects for rdac
932 kmpath_rdacd = create_singlethread_workqueue("kmpath_rdacd");
934 scsi_unregister_device_handler(&rdac_dh);
935 printk(KERN_ERR "kmpath_rdacd creation failed.\n");
941 static void __exit rdac_exit(void)
943 destroy_workqueue(kmpath_rdacd);
944 scsi_unregister_device_handler(&rdac_dh);
947 module_init(rdac_init);
948 module_exit(rdac_exit);
950 MODULE_DESCRIPTION("Multipath LSI/Engenio/NetApp E-Series RDAC driver");
951 MODULE_AUTHOR("Mike Christie, Chandra Seetharaman");
952 MODULE_VERSION("01.00.0000.0000");
953 MODULE_LICENSE("GPL");