2 * Engenio/LSI 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>
27 #define RDAC_NAME "rdac"
28 #define RDAC_RETRY_COUNT 5
33 * These struct definitions and the forming of the
34 * mode page were taken from the LSI RDAC 2.4 GPL'd
35 * driver, and then converted to Linux conventions.
37 #define RDAC_QUIESCENCE_TIME 20;
41 #define RDAC_PAGE_CODE_REDUNDANT_CONTROLLER 0x2c
44 * Controller modes definitions
46 #define RDAC_MODE_TRANSFER_SPECIFIED_LUNS 0x02
51 #define RDAC_FORCED_QUIESENCE 0x02
53 #define RDAC_TIMEOUT (60 * HZ)
54 #define RDAC_RETRIES 3
56 struct rdac_mode_6_hdr
{
63 struct rdac_mode_10_hdr
{
71 struct rdac_mode_common
{
72 u8 controller_serial
[16];
73 u8 alt_controller_serial
[16];
76 u8 quiescence_timeout
;
80 struct rdac_pg_legacy
{
81 struct rdac_mode_6_hdr hdr
;
84 struct rdac_mode_common common
;
85 #define MODE6_MAX_LUN 32
86 u8 lun_table
[MODE6_MAX_LUN
];
92 struct rdac_pg_expanded
{
93 struct rdac_mode_10_hdr hdr
;
97 struct rdac_mode_common common
;
105 u8 page_code
; /* 0xC9 */
108 u8 page_id
[4]; /* "vace" */
114 #define SUBSYS_ID_LEN 16
115 #define SLOT_ID_LEN 2
116 #define ARRAY_LABEL_LEN 31
120 u8 page_code
; /* 0xC4 */
123 u8 page_id
[4]; /* "subs" */
124 u8 subsys_id
[SUBSYS_ID_LEN
];
126 u8 slot_id
[SLOT_ID_LEN
];
130 struct rdac_controller
{
131 u8 subsys_id
[SUBSYS_ID_LEN
];
132 u8 slot_id
[SLOT_ID_LEN
];
135 struct list_head node
; /* list of all controllers */
137 struct rdac_pg_legacy legacy
;
138 struct rdac_pg_expanded expanded
;
141 u8 array_name
[ARRAY_LABEL_LEN
];
144 struct work_struct ms_work
;
145 struct scsi_device
*ms_sdev
;
146 struct list_head ms_head
;
151 u8 page_code
; /* 0xC8 */
154 u8 page_id
[4]; /* "edid" */
158 u8 vol_user_label_len
;
159 u8 vol_user_label
[60];
160 u8 array_uniq_id_len
;
161 u8 array_unique_id
[16];
162 u8 array_user_label_len
;
163 u8 array_user_label
[60];
169 u8 page_code
; /* 0xC2 */
172 u8 page_id
[4]; /* "swr4" */
176 u8 max_lun_supported
;
177 u8 partitions
[239]; /* Total allocation length should be 0xFF */
180 struct rdac_dh_data
{
181 struct rdac_controller
*ctlr
;
182 #define UNINITIALIZED_LUN (1 << 8)
184 #define RDAC_STATE_ACTIVE 0
185 #define RDAC_STATE_PASSIVE 1
188 #define RDAC_LUN_UNOWNED 0
189 #define RDAC_LUN_OWNED 1
190 #define RDAC_LUN_AVT 2
192 unsigned char sense
[SCSI_SENSE_BUFFERSIZE
];
194 struct c2_inquiry c2
;
195 struct c4_inquiry c4
;
196 struct c8_inquiry c8
;
197 struct c9_inquiry c9
;
201 static const char *lun_state
[] =
208 struct rdac_queue_data
{
209 struct list_head entry
;
210 struct rdac_dh_data
*h
;
211 activate_complete callback_fn
;
215 static LIST_HEAD(ctlr_list
);
216 static DEFINE_SPINLOCK(list_lock
);
217 static struct workqueue_struct
*kmpath_rdacd
;
218 static void send_mode_select(struct work_struct
*work
);
221 * module parameter to enable rdac debug logging.
222 * 2 bits for each type of logging, only two types defined for now
223 * Can be enhanced if required at later point
225 static int rdac_logging
= 1;
226 module_param(rdac_logging
, int, S_IRUGO
|S_IWUSR
);
227 MODULE_PARM_DESC(rdac_logging
, "A bit mask of rdac logging levels, "
228 "Default is 1 - failover logging enabled, "
229 "set it to 0xF to enable all the logs");
231 #define RDAC_LOG_FAILOVER 0
232 #define RDAC_LOG_SENSE 2
234 #define RDAC_LOG_BITS 2
236 #define RDAC_LOG_LEVEL(SHIFT) \
237 ((rdac_logging >> (SHIFT)) & ((1 << (RDAC_LOG_BITS)) - 1))
239 #define RDAC_LOG(SHIFT, sdev, f, arg...) \
241 if (unlikely(RDAC_LOG_LEVEL(SHIFT))) \
242 sdev_printk(KERN_INFO, sdev, RDAC_NAME ": " f "\n", ## arg); \
245 static inline struct rdac_dh_data
*get_rdac_data(struct scsi_device
*sdev
)
247 struct scsi_dh_data
*scsi_dh_data
= sdev
->scsi_dh_data
;
248 BUG_ON(scsi_dh_data
== NULL
);
249 return ((struct rdac_dh_data
*) scsi_dh_data
->buf
);
252 static struct request
*get_rdac_req(struct scsi_device
*sdev
,
253 void *buffer
, unsigned buflen
, int rw
)
256 struct request_queue
*q
= sdev
->request_queue
;
258 rq
= blk_get_request(q
, rw
, GFP_NOIO
);
261 sdev_printk(KERN_INFO
, sdev
,
262 "get_rdac_req: blk_get_request failed.\n");
266 if (buflen
&& blk_rq_map_kern(q
, rq
, buffer
, buflen
, GFP_NOIO
)) {
268 sdev_printk(KERN_INFO
, sdev
,
269 "get_rdac_req: blk_rq_map_kern failed.\n");
273 rq
->cmd_type
= REQ_TYPE_BLOCK_PC
;
274 rq
->cmd_flags
|= REQ_FAILFAST_DEV
| REQ_FAILFAST_TRANSPORT
|
276 rq
->retries
= RDAC_RETRIES
;
277 rq
->timeout
= RDAC_TIMEOUT
;
282 static struct request
*rdac_failover_get(struct scsi_device
*sdev
,
283 struct rdac_dh_data
*h
)
286 struct rdac_mode_common
*common
;
289 if (h
->ctlr
->use_ms10
) {
290 struct rdac_pg_expanded
*rdac_pg
;
292 data_size
= sizeof(struct rdac_pg_expanded
);
293 rdac_pg
= &h
->ctlr
->mode_select
.expanded
;
294 memset(rdac_pg
, 0, data_size
);
295 common
= &rdac_pg
->common
;
296 rdac_pg
->page_code
= RDAC_PAGE_CODE_REDUNDANT_CONTROLLER
+ 0x40;
297 rdac_pg
->subpage_code
= 0x1;
298 rdac_pg
->page_len
[0] = 0x01;
299 rdac_pg
->page_len
[1] = 0x28;
301 struct rdac_pg_legacy
*rdac_pg
;
303 data_size
= sizeof(struct rdac_pg_legacy
);
304 rdac_pg
= &h
->ctlr
->mode_select
.legacy
;
305 memset(rdac_pg
, 0, data_size
);
306 common
= &rdac_pg
->common
;
307 rdac_pg
->page_code
= RDAC_PAGE_CODE_REDUNDANT_CONTROLLER
;
308 rdac_pg
->page_len
= 0x68;
310 common
->rdac_mode
[1] = RDAC_MODE_TRANSFER_SPECIFIED_LUNS
;
311 common
->quiescence_timeout
= RDAC_QUIESCENCE_TIME
;
312 common
->rdac_options
= RDAC_FORCED_QUIESENCE
;
314 /* get request for block layer packet command */
315 rq
= get_rdac_req(sdev
, &h
->ctlr
->mode_select
, data_size
, WRITE
);
319 /* Prepare the command. */
320 if (h
->ctlr
->use_ms10
) {
321 rq
->cmd
[0] = MODE_SELECT_10
;
322 rq
->cmd
[7] = data_size
>> 8;
323 rq
->cmd
[8] = data_size
& 0xff;
325 rq
->cmd
[0] = MODE_SELECT
;
326 rq
->cmd
[4] = data_size
;
328 rq
->cmd_len
= COMMAND_SIZE(rq
->cmd
[0]);
330 rq
->sense
= h
->sense
;
331 memset(rq
->sense
, 0, SCSI_SENSE_BUFFERSIZE
);
337 static void release_controller(struct kref
*kref
)
339 struct rdac_controller
*ctlr
;
340 ctlr
= container_of(kref
, struct rdac_controller
, kref
);
342 flush_workqueue(kmpath_rdacd
);
343 spin_lock(&list_lock
);
344 list_del(&ctlr
->node
);
345 spin_unlock(&list_lock
);
349 static struct rdac_controller
*get_controller(u8
*subsys_id
, u8
*slot_id
,
352 struct rdac_controller
*ctlr
, *tmp
;
354 spin_lock(&list_lock
);
356 list_for_each_entry(tmp
, &ctlr_list
, node
) {
357 if ((memcmp(tmp
->subsys_id
, subsys_id
, SUBSYS_ID_LEN
) == 0) &&
358 (memcmp(tmp
->slot_id
, slot_id
, SLOT_ID_LEN
) == 0)) {
359 kref_get(&tmp
->kref
);
360 spin_unlock(&list_lock
);
364 ctlr
= kmalloc(sizeof(*ctlr
), GFP_ATOMIC
);
368 /* initialize fields of controller */
369 memcpy(ctlr
->subsys_id
, subsys_id
, SUBSYS_ID_LEN
);
370 memcpy(ctlr
->slot_id
, slot_id
, SLOT_ID_LEN
);
371 memcpy(ctlr
->array_name
, array_name
, ARRAY_LABEL_LEN
);
373 /* update the controller index */
374 if (slot_id
[1] == 0x31)
379 kref_init(&ctlr
->kref
);
382 ctlr
->ms_sdev
= NULL
;
383 spin_lock_init(&ctlr
->ms_lock
);
384 INIT_WORK(&ctlr
->ms_work
, send_mode_select
);
385 INIT_LIST_HEAD(&ctlr
->ms_head
);
386 list_add(&ctlr
->node
, &ctlr_list
);
388 spin_unlock(&list_lock
);
392 static int submit_inquiry(struct scsi_device
*sdev
, int page_code
,
393 unsigned int len
, struct rdac_dh_data
*h
)
396 struct request_queue
*q
= sdev
->request_queue
;
397 int err
= SCSI_DH_RES_TEMP_UNAVAIL
;
399 rq
= get_rdac_req(sdev
, &h
->inq
, len
, READ
);
403 /* Prepare the command. */
404 rq
->cmd
[0] = INQUIRY
;
406 rq
->cmd
[2] = page_code
;
408 rq
->cmd_len
= COMMAND_SIZE(INQUIRY
);
410 rq
->sense
= h
->sense
;
411 memset(rq
->sense
, 0, SCSI_SENSE_BUFFERSIZE
);
414 err
= blk_execute_rq(q
, NULL
, rq
, 1);
423 static int get_lun_info(struct scsi_device
*sdev
, struct rdac_dh_data
*h
,
427 struct c8_inquiry
*inqp
;
429 err
= submit_inquiry(sdev
, 0xC8, sizeof(struct c8_inquiry
), h
);
430 if (err
== SCSI_DH_OK
) {
432 if (inqp
->page_code
!= 0xc8)
433 return SCSI_DH_NOSYS
;
434 if (inqp
->page_id
[0] != 'e' || inqp
->page_id
[1] != 'd' ||
435 inqp
->page_id
[2] != 'i' || inqp
->page_id
[3] != 'd')
436 return SCSI_DH_NOSYS
;
437 h
->lun
= inqp
->lun
[7]; /* Uses only the last byte */
439 for(i
=0; i
<ARRAY_LABEL_LEN
-1; ++i
)
440 *(array_name
+i
) = inqp
->array_user_label
[(2*i
)+1];
442 *(array_name
+ARRAY_LABEL_LEN
-1) = '\0';
447 static int check_ownership(struct scsi_device
*sdev
, struct rdac_dh_data
*h
)
450 struct c9_inquiry
*inqp
;
452 h
->lun_state
= RDAC_LUN_UNOWNED
;
453 h
->state
= RDAC_STATE_ACTIVE
;
454 err
= submit_inquiry(sdev
, 0xC9, sizeof(struct c9_inquiry
), h
);
455 if (err
== SCSI_DH_OK
) {
457 if ((inqp
->avte_cvp
>> 7) == 0x1) {
458 /* LUN in AVT mode */
459 sdev_printk(KERN_NOTICE
, sdev
,
460 "%s: AVT mode detected\n",
462 h
->lun_state
= RDAC_LUN_AVT
;
463 } else if ((inqp
->avte_cvp
& 0x1) != 0) {
464 /* LUN was owned by the controller */
465 h
->lun_state
= RDAC_LUN_OWNED
;
469 if (h
->lun_state
== RDAC_LUN_UNOWNED
)
470 h
->state
= RDAC_STATE_PASSIVE
;
475 static int initialize_controller(struct scsi_device
*sdev
,
476 struct rdac_dh_data
*h
, char *array_name
)
479 struct c4_inquiry
*inqp
;
481 err
= submit_inquiry(sdev
, 0xC4, sizeof(struct c4_inquiry
), h
);
482 if (err
== SCSI_DH_OK
) {
484 h
->ctlr
= get_controller(inqp
->subsys_id
, inqp
->slot_id
,
487 err
= SCSI_DH_RES_TEMP_UNAVAIL
;
492 static int set_mode_select(struct scsi_device
*sdev
, struct rdac_dh_data
*h
)
495 struct c2_inquiry
*inqp
;
497 err
= submit_inquiry(sdev
, 0xC2, sizeof(struct c2_inquiry
), h
);
498 if (err
== SCSI_DH_OK
) {
501 * If more than MODE6_MAX_LUN luns are supported, use
504 if (inqp
->max_lun_supported
>= MODE6_MAX_LUN
)
505 h
->ctlr
->use_ms10
= 1;
507 h
->ctlr
->use_ms10
= 0;
512 static int mode_select_handle_sense(struct scsi_device
*sdev
,
513 unsigned char *sensebuf
)
515 struct scsi_sense_hdr sense_hdr
;
516 int err
= SCSI_DH_IO
, ret
;
517 struct rdac_dh_data
*h
= get_rdac_data(sdev
);
519 ret
= scsi_normalize_sense(sensebuf
, SCSI_SENSE_BUFFERSIZE
, &sense_hdr
);
523 switch (sense_hdr
.sense_key
) {
525 case ABORTED_COMMAND
:
530 if (sense_hdr
.asc
== 0x04 && sense_hdr
.ascq
== 0x01)
531 /* LUN Not Ready and is in the Process of Becoming
536 case ILLEGAL_REQUEST
:
537 if (sense_hdr
.asc
== 0x91 && sense_hdr
.ascq
== 0x36)
539 * Command Lock contention
547 RDAC_LOG(RDAC_LOG_FAILOVER
, sdev
, "array %s, ctlr %d, "
548 "MODE_SELECT returned with sense %02x/%02x/%02x",
549 (char *) h
->ctlr
->array_name
, h
->ctlr
->index
,
550 sense_hdr
.sense_key
, sense_hdr
.asc
, sense_hdr
.ascq
);
556 static void send_mode_select(struct work_struct
*work
)
558 struct rdac_controller
*ctlr
=
559 container_of(work
, struct rdac_controller
, ms_work
);
561 struct scsi_device
*sdev
= ctlr
->ms_sdev
;
562 struct rdac_dh_data
*h
= get_rdac_data(sdev
);
563 struct request_queue
*q
= sdev
->request_queue
;
564 int err
, retry_cnt
= RDAC_RETRY_COUNT
;
565 struct rdac_queue_data
*tmp
, *qdata
;
569 spin_lock(&ctlr
->ms_lock
);
570 list_splice_init(&ctlr
->ms_head
, &list
);
572 ctlr
->ms_sdev
= NULL
;
573 spin_unlock(&ctlr
->ms_lock
);
576 lun_table
= ctlr
->mode_select
.expanded
.lun_table
;
578 lun_table
= ctlr
->mode_select
.legacy
.lun_table
;
581 err
= SCSI_DH_RES_TEMP_UNAVAIL
;
582 rq
= rdac_failover_get(sdev
, h
);
586 list_for_each_entry(qdata
, &list
, entry
) {
587 lun_table
[qdata
->h
->lun
] = 0x81;
590 RDAC_LOG(RDAC_LOG_FAILOVER
, sdev
, "array %s, ctlr %d, "
591 "%s MODE_SELECT command",
592 (char *) h
->ctlr
->array_name
, h
->ctlr
->index
,
593 (retry_cnt
== RDAC_RETRY_COUNT
) ? "queueing" : "retrying");
595 err
= blk_execute_rq(q
, NULL
, rq
, 1);
597 if (err
!= SCSI_DH_OK
) {
598 err
= mode_select_handle_sense(sdev
, h
->sense
);
599 if (err
== SCSI_DH_RETRY
&& retry_cnt
--)
602 if (err
== SCSI_DH_OK
) {
603 h
->state
= RDAC_STATE_ACTIVE
;
604 RDAC_LOG(RDAC_LOG_FAILOVER
, sdev
, "array %s, ctlr %d, "
605 "MODE_SELECT completed",
606 (char *) h
->ctlr
->array_name
, h
->ctlr
->index
);
610 list_for_each_entry_safe(qdata
, tmp
, &list
, entry
) {
611 list_del(&qdata
->entry
);
612 if (err
== SCSI_DH_OK
)
613 qdata
->h
->state
= RDAC_STATE_ACTIVE
;
614 if (qdata
->callback_fn
)
615 qdata
->callback_fn(qdata
->callback_data
, err
);
621 static int queue_mode_select(struct scsi_device
*sdev
,
622 activate_complete fn
, void *data
)
624 struct rdac_queue_data
*qdata
;
625 struct rdac_controller
*ctlr
;
627 qdata
= kzalloc(sizeof(*qdata
), GFP_KERNEL
);
629 return SCSI_DH_RETRY
;
631 qdata
->h
= get_rdac_data(sdev
);
632 qdata
->callback_fn
= fn
;
633 qdata
->callback_data
= data
;
635 ctlr
= qdata
->h
->ctlr
;
636 spin_lock(&ctlr
->ms_lock
);
637 list_add_tail(&qdata
->entry
, &ctlr
->ms_head
);
638 if (!ctlr
->ms_queued
) {
640 ctlr
->ms_sdev
= sdev
;
641 queue_work(kmpath_rdacd
, &ctlr
->ms_work
);
643 spin_unlock(&ctlr
->ms_lock
);
647 static int rdac_activate(struct scsi_device
*sdev
,
648 activate_complete fn
, void *data
)
650 struct rdac_dh_data
*h
= get_rdac_data(sdev
);
651 int err
= SCSI_DH_OK
;
653 err
= check_ownership(sdev
, h
);
654 if (err
!= SCSI_DH_OK
)
657 if (h
->lun_state
== RDAC_LUN_UNOWNED
) {
658 err
= queue_mode_select(sdev
, fn
, data
);
659 if (err
== SCSI_DH_OK
)
668 static int rdac_prep_fn(struct scsi_device
*sdev
, struct request
*req
)
670 struct rdac_dh_data
*h
= get_rdac_data(sdev
);
671 int ret
= BLKPREP_OK
;
673 if (h
->state
!= RDAC_STATE_ACTIVE
) {
675 req
->cmd_flags
|= REQ_QUIET
;
681 static int rdac_check_sense(struct scsi_device
*sdev
,
682 struct scsi_sense_hdr
*sense_hdr
)
684 struct rdac_dh_data
*h
= get_rdac_data(sdev
);
686 RDAC_LOG(RDAC_LOG_SENSE
, sdev
, "array %s, ctlr %d, "
687 "I/O returned with sense %02x/%02x/%02x",
688 (char *) h
->ctlr
->array_name
, h
->ctlr
->index
,
689 sense_hdr
->sense_key
, sense_hdr
->asc
, sense_hdr
->ascq
);
691 switch (sense_hdr
->sense_key
) {
693 if (sense_hdr
->asc
== 0x04 && sense_hdr
->ascq
== 0x01)
694 /* LUN Not Ready - Logical Unit Not Ready and is in
695 * the process of becoming ready
698 return ADD_TO_MLQUEUE
;
699 if (sense_hdr
->asc
== 0x04 && sense_hdr
->ascq
== 0x81)
700 /* LUN Not Ready - Storage firmware incompatible
701 * Manual code synchonisation required.
703 * Nothing we can do here. Try to bypass the path.
706 if (sense_hdr
->asc
== 0x04 && sense_hdr
->ascq
== 0xA1)
707 /* LUN Not Ready - Quiescense in progress
709 * Just retry and wait.
711 return ADD_TO_MLQUEUE
;
712 if (sense_hdr
->asc
== 0xA1 && sense_hdr
->ascq
== 0x02)
713 /* LUN Not Ready - Quiescense in progress
714 * or has been achieved
717 return ADD_TO_MLQUEUE
;
719 case ILLEGAL_REQUEST
:
720 if (sense_hdr
->asc
== 0x94 && sense_hdr
->ascq
== 0x01) {
721 /* Invalid Request - Current Logical Unit Ownership.
722 * Controller is not the current owner of the LUN,
723 * Fail the path, so that the other path be used.
725 h
->state
= RDAC_STATE_PASSIVE
;
730 if (sense_hdr
->asc
== 0x29 && sense_hdr
->ascq
== 0x00)
732 * Power On, Reset, or Bus Device Reset, just retry.
734 return ADD_TO_MLQUEUE
;
735 if (sense_hdr
->asc
== 0x8b && sense_hdr
->ascq
== 0x02)
737 * Quiescence in progress , just retry.
739 return ADD_TO_MLQUEUE
;
742 /* success just means we do not care what scsi-ml does */
743 return SCSI_RETURN_NOT_HANDLED
;
746 static const struct scsi_dh_devlist rdac_dev_list
[] = {
760 {"STK", "OPENstorage D280"},
762 {"SUN", "LCSM100_I"},
763 {"SUN", "LCSM100_S"},
764 {"SUN", "LCSM100_E"},
765 {"SUN", "LCSM100_F"},
770 {"LSI", "INF-01-00"},
771 {"ENGENIO", "INF-01-00"},
772 {"STK", "FLEXLINE 380"},
773 {"SUN", "CSM100_R_FC"},
777 static int rdac_bus_attach(struct scsi_device
*sdev
);
778 static void rdac_bus_detach(struct scsi_device
*sdev
);
780 static struct scsi_device_handler rdac_dh
= {
782 .module
= THIS_MODULE
,
783 .devlist
= rdac_dev_list
,
784 .prep_fn
= rdac_prep_fn
,
785 .check_sense
= rdac_check_sense
,
786 .attach
= rdac_bus_attach
,
787 .detach
= rdac_bus_detach
,
788 .activate
= rdac_activate
,
791 static int rdac_bus_attach(struct scsi_device
*sdev
)
793 struct scsi_dh_data
*scsi_dh_data
;
794 struct rdac_dh_data
*h
;
797 char array_name
[ARRAY_LABEL_LEN
];
799 scsi_dh_data
= kzalloc(sizeof(struct scsi_device_handler
*)
800 + sizeof(*h
) , GFP_KERNEL
);
802 sdev_printk(KERN_ERR
, sdev
, "%s: Attach failed\n",
807 scsi_dh_data
->scsi_dh
= &rdac_dh
;
808 h
= (struct rdac_dh_data
*) scsi_dh_data
->buf
;
809 h
->lun
= UNINITIALIZED_LUN
;
810 h
->state
= RDAC_STATE_ACTIVE
;
812 err
= get_lun_info(sdev
, h
, array_name
);
813 if (err
!= SCSI_DH_OK
)
816 err
= initialize_controller(sdev
, h
, array_name
);
817 if (err
!= SCSI_DH_OK
)
820 err
= check_ownership(sdev
, h
);
821 if (err
!= SCSI_DH_OK
)
824 err
= set_mode_select(sdev
, h
);
825 if (err
!= SCSI_DH_OK
)
828 if (!try_module_get(THIS_MODULE
))
831 spin_lock_irqsave(sdev
->request_queue
->queue_lock
, flags
);
832 sdev
->scsi_dh_data
= scsi_dh_data
;
833 spin_unlock_irqrestore(sdev
->request_queue
->queue_lock
, flags
);
835 sdev_printk(KERN_NOTICE
, sdev
,
837 RDAC_NAME
, h
->lun
, lun_state
[(int)h
->lun_state
]);
842 kref_put(&h
->ctlr
->kref
, release_controller
);
846 sdev_printk(KERN_ERR
, sdev
, "%s: not attached\n",
851 static void rdac_bus_detach( struct scsi_device
*sdev
)
853 struct scsi_dh_data
*scsi_dh_data
;
854 struct rdac_dh_data
*h
;
857 spin_lock_irqsave(sdev
->request_queue
->queue_lock
, flags
);
858 scsi_dh_data
= sdev
->scsi_dh_data
;
859 sdev
->scsi_dh_data
= NULL
;
860 spin_unlock_irqrestore(sdev
->request_queue
->queue_lock
, flags
);
862 h
= (struct rdac_dh_data
*) scsi_dh_data
->buf
;
864 kref_put(&h
->ctlr
->kref
, release_controller
);
866 module_put(THIS_MODULE
);
867 sdev_printk(KERN_NOTICE
, sdev
, "%s: Detached\n", RDAC_NAME
);
872 static int __init
rdac_init(void)
876 r
= scsi_register_device_handler(&rdac_dh
);
878 printk(KERN_ERR
"Failed to register scsi device handler.");
883 * Create workqueue to handle mode selects for rdac
885 kmpath_rdacd
= create_singlethread_workqueue("kmpath_rdacd");
887 scsi_unregister_device_handler(&rdac_dh
);
888 printk(KERN_ERR
"kmpath_rdacd creation failed.\n");
894 static void __exit
rdac_exit(void)
896 destroy_workqueue(kmpath_rdacd
);
897 scsi_unregister_device_handler(&rdac_dh
);
900 module_init(rdac_init
);
901 module_exit(rdac_exit
);
903 MODULE_DESCRIPTION("Multipath LSI/Engenio RDAC driver");
904 MODULE_AUTHOR("Mike Christie, Chandra Seetharaman");
905 MODULE_LICENSE("GPL");