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>
27 #include <linux/module.h>
29 #define RDAC_NAME "rdac"
30 #define RDAC_RETRY_COUNT 5
35 * These struct definitions and the forming of the
36 * mode page were taken from the LSI RDAC 2.4 GPL'd
37 * driver, and then converted to Linux conventions.
39 #define RDAC_QUIESCENCE_TIME 20
43 #define RDAC_PAGE_CODE_REDUNDANT_CONTROLLER 0x2c
46 * Controller modes definitions
48 #define RDAC_MODE_TRANSFER_SPECIFIED_LUNS 0x02
53 #define RDAC_FORCED_QUIESENCE 0x02
55 #define RDAC_TIMEOUT (60 * HZ)
56 #define RDAC_RETRIES 3
58 struct rdac_mode_6_hdr
{
65 struct rdac_mode_10_hdr
{
73 struct rdac_mode_common
{
74 u8 controller_serial
[16];
75 u8 alt_controller_serial
[16];
78 u8 quiescence_timeout
;
82 struct rdac_pg_legacy
{
83 struct rdac_mode_6_hdr hdr
;
86 struct rdac_mode_common common
;
87 #define MODE6_MAX_LUN 32
88 u8 lun_table
[MODE6_MAX_LUN
];
94 struct rdac_pg_expanded
{
95 struct rdac_mode_10_hdr hdr
;
99 struct rdac_mode_common common
;
107 u8 page_code
; /* 0xC9 */
110 u8 page_id
[4]; /* "vace" */
116 #define SUBSYS_ID_LEN 16
117 #define SLOT_ID_LEN 2
118 #define ARRAY_LABEL_LEN 31
122 u8 page_code
; /* 0xC4 */
125 u8 page_id
[4]; /* "subs" */
126 u8 subsys_id
[SUBSYS_ID_LEN
];
128 u8 slot_id
[SLOT_ID_LEN
];
132 #define UNIQUE_ID_LEN 16
135 u8 page_code
; /* 0xC8 */
138 u8 page_id
[4]; /* "edid" */
142 u8 vol_user_label_len
;
143 u8 vol_user_label
[60];
144 u8 array_uniq_id_len
;
145 u8 array_unique_id
[UNIQUE_ID_LEN
];
146 u8 array_user_label_len
;
147 u8 array_user_label
[60];
151 struct rdac_controller
{
152 u8 array_id
[UNIQUE_ID_LEN
];
155 struct list_head node
; /* list of all controllers */
157 struct rdac_pg_legacy legacy
;
158 struct rdac_pg_expanded expanded
;
161 u8 array_name
[ARRAY_LABEL_LEN
];
162 struct Scsi_Host
*host
;
165 struct work_struct ms_work
;
166 struct scsi_device
*ms_sdev
;
167 struct list_head ms_head
;
168 struct list_head dh_list
;
173 u8 page_code
; /* 0xC2 */
176 u8 page_id
[4]; /* "swr4" */
180 u8 max_lun_supported
;
181 u8 partitions
[239]; /* Total allocation length should be 0xFF */
184 struct rdac_dh_data
{
185 struct list_head node
;
186 struct rdac_controller
*ctlr
;
187 struct scsi_device
*sdev
;
188 #define UNINITIALIZED_LUN (1 << 8)
192 #define RDAC_MODE_AVT 1
193 #define RDAC_MODE_IOSHIP 2
196 #define RDAC_STATE_ACTIVE 0
197 #define RDAC_STATE_PASSIVE 1
200 #define RDAC_LUN_UNOWNED 0
201 #define RDAC_LUN_OWNED 1
204 #define RDAC_PREFERRED 0
205 #define RDAC_NON_PREFERRED 1
208 unsigned char sense
[SCSI_SENSE_BUFFERSIZE
];
210 struct c2_inquiry c2
;
211 struct c4_inquiry c4
;
212 struct c8_inquiry c8
;
213 struct c9_inquiry c9
;
217 static const char *mode
[] = {
222 static const char *lun_state
[] =
228 struct rdac_queue_data
{
229 struct list_head entry
;
230 struct rdac_dh_data
*h
;
231 activate_complete callback_fn
;
235 static LIST_HEAD(ctlr_list
);
236 static DEFINE_SPINLOCK(list_lock
);
237 static struct workqueue_struct
*kmpath_rdacd
;
238 static void send_mode_select(struct work_struct
*work
);
241 * module parameter to enable rdac debug logging.
242 * 2 bits for each type of logging, only two types defined for now
243 * Can be enhanced if required at later point
245 static int rdac_logging
= 1;
246 module_param(rdac_logging
, int, S_IRUGO
|S_IWUSR
);
247 MODULE_PARM_DESC(rdac_logging
, "A bit mask of rdac logging levels, "
248 "Default is 1 - failover logging enabled, "
249 "set it to 0xF to enable all the logs");
251 #define RDAC_LOG_FAILOVER 0
252 #define RDAC_LOG_SENSE 2
254 #define RDAC_LOG_BITS 2
256 #define RDAC_LOG_LEVEL(SHIFT) \
257 ((rdac_logging >> (SHIFT)) & ((1 << (RDAC_LOG_BITS)) - 1))
259 #define RDAC_LOG(SHIFT, sdev, f, arg...) \
261 if (unlikely(RDAC_LOG_LEVEL(SHIFT))) \
262 sdev_printk(KERN_INFO, sdev, RDAC_NAME ": " f "\n", ## arg); \
265 static struct request
*get_rdac_req(struct scsi_device
*sdev
,
266 void *buffer
, unsigned buflen
, int rw
)
269 struct request_queue
*q
= sdev
->request_queue
;
271 rq
= blk_get_request(q
, rw
, GFP_NOIO
);
274 sdev_printk(KERN_INFO
, sdev
,
275 "get_rdac_req: blk_get_request failed.\n");
278 blk_rq_set_block_pc(rq
);
280 if (buflen
&& blk_rq_map_kern(q
, rq
, buffer
, buflen
, GFP_NOIO
)) {
282 sdev_printk(KERN_INFO
, sdev
,
283 "get_rdac_req: blk_rq_map_kern failed.\n");
287 rq
->cmd_flags
|= REQ_FAILFAST_DEV
| REQ_FAILFAST_TRANSPORT
|
289 rq
->retries
= RDAC_RETRIES
;
290 rq
->timeout
= RDAC_TIMEOUT
;
295 static struct request
*rdac_failover_get(struct scsi_device
*sdev
,
296 struct rdac_dh_data
*h
, struct list_head
*list
)
299 struct rdac_mode_common
*common
;
301 struct rdac_queue_data
*qdata
;
304 if (h
->ctlr
->use_ms10
) {
305 struct rdac_pg_expanded
*rdac_pg
;
307 data_size
= sizeof(struct rdac_pg_expanded
);
308 rdac_pg
= &h
->ctlr
->mode_select
.expanded
;
309 memset(rdac_pg
, 0, data_size
);
310 common
= &rdac_pg
->common
;
311 rdac_pg
->page_code
= RDAC_PAGE_CODE_REDUNDANT_CONTROLLER
+ 0x40;
312 rdac_pg
->subpage_code
= 0x1;
313 rdac_pg
->page_len
[0] = 0x01;
314 rdac_pg
->page_len
[1] = 0x28;
315 lun_table
= rdac_pg
->lun_table
;
317 struct rdac_pg_legacy
*rdac_pg
;
319 data_size
= sizeof(struct rdac_pg_legacy
);
320 rdac_pg
= &h
->ctlr
->mode_select
.legacy
;
321 memset(rdac_pg
, 0, data_size
);
322 common
= &rdac_pg
->common
;
323 rdac_pg
->page_code
= RDAC_PAGE_CODE_REDUNDANT_CONTROLLER
;
324 rdac_pg
->page_len
= 0x68;
325 lun_table
= rdac_pg
->lun_table
;
327 common
->rdac_mode
[1] = RDAC_MODE_TRANSFER_SPECIFIED_LUNS
;
328 common
->quiescence_timeout
= RDAC_QUIESCENCE_TIME
;
329 common
->rdac_options
= RDAC_FORCED_QUIESENCE
;
331 list_for_each_entry(qdata
, list
, entry
) {
332 lun_table
[qdata
->h
->lun
] = 0x81;
335 /* get request for block layer packet command */
336 rq
= get_rdac_req(sdev
, &h
->ctlr
->mode_select
, data_size
, WRITE
);
340 /* Prepare the command. */
341 if (h
->ctlr
->use_ms10
) {
342 rq
->cmd
[0] = MODE_SELECT_10
;
343 rq
->cmd
[7] = data_size
>> 8;
344 rq
->cmd
[8] = data_size
& 0xff;
346 rq
->cmd
[0] = MODE_SELECT
;
347 rq
->cmd
[4] = data_size
;
349 rq
->cmd_len
= COMMAND_SIZE(rq
->cmd
[0]);
351 rq
->sense
= h
->sense
;
352 memset(rq
->sense
, 0, SCSI_SENSE_BUFFERSIZE
);
358 static void release_controller(struct kref
*kref
)
360 struct rdac_controller
*ctlr
;
361 ctlr
= container_of(kref
, struct rdac_controller
, kref
);
363 list_del(&ctlr
->node
);
367 static struct rdac_controller
*get_controller(int index
, char *array_name
,
368 u8
*array_id
, struct scsi_device
*sdev
)
370 struct rdac_controller
*ctlr
, *tmp
;
372 list_for_each_entry(tmp
, &ctlr_list
, node
) {
373 if ((memcmp(tmp
->array_id
, array_id
, UNIQUE_ID_LEN
) == 0) &&
374 (tmp
->index
== index
) &&
375 (tmp
->host
== sdev
->host
)) {
376 kref_get(&tmp
->kref
);
380 ctlr
= kmalloc(sizeof(*ctlr
), GFP_ATOMIC
);
384 /* initialize fields of controller */
385 memcpy(ctlr
->array_id
, array_id
, UNIQUE_ID_LEN
);
387 ctlr
->host
= sdev
->host
;
388 memcpy(ctlr
->array_name
, array_name
, ARRAY_LABEL_LEN
);
390 kref_init(&ctlr
->kref
);
393 ctlr
->ms_sdev
= NULL
;
394 spin_lock_init(&ctlr
->ms_lock
);
395 INIT_WORK(&ctlr
->ms_work
, send_mode_select
);
396 INIT_LIST_HEAD(&ctlr
->ms_head
);
397 list_add(&ctlr
->node
, &ctlr_list
);
398 INIT_LIST_HEAD(&ctlr
->dh_list
);
403 static int submit_inquiry(struct scsi_device
*sdev
, int page_code
,
404 unsigned int len
, struct rdac_dh_data
*h
)
407 struct request_queue
*q
= sdev
->request_queue
;
408 int err
= SCSI_DH_RES_TEMP_UNAVAIL
;
410 rq
= get_rdac_req(sdev
, &h
->inq
, len
, READ
);
414 /* Prepare the command. */
415 rq
->cmd
[0] = INQUIRY
;
417 rq
->cmd
[2] = page_code
;
419 rq
->cmd_len
= COMMAND_SIZE(INQUIRY
);
421 rq
->sense
= h
->sense
;
422 memset(rq
->sense
, 0, SCSI_SENSE_BUFFERSIZE
);
425 err
= blk_execute_rq(q
, NULL
, rq
, 1);
434 static int get_lun_info(struct scsi_device
*sdev
, struct rdac_dh_data
*h
,
435 char *array_name
, u8
*array_id
)
438 struct c8_inquiry
*inqp
;
440 err
= submit_inquiry(sdev
, 0xC8, sizeof(struct c8_inquiry
), h
);
441 if (err
== SCSI_DH_OK
) {
443 if (inqp
->page_code
!= 0xc8)
444 return SCSI_DH_NOSYS
;
445 if (inqp
->page_id
[0] != 'e' || inqp
->page_id
[1] != 'd' ||
446 inqp
->page_id
[2] != 'i' || inqp
->page_id
[3] != 'd')
447 return SCSI_DH_NOSYS
;
448 h
->lun
= inqp
->lun
[7]; /* Uses only the last byte */
450 for(i
=0; i
<ARRAY_LABEL_LEN
-1; ++i
)
451 *(array_name
+i
) = inqp
->array_user_label
[(2*i
)+1];
453 *(array_name
+ARRAY_LABEL_LEN
-1) = '\0';
454 memset(array_id
, 0, UNIQUE_ID_LEN
);
455 memcpy(array_id
, inqp
->array_unique_id
, inqp
->array_uniq_id_len
);
460 static int check_ownership(struct scsi_device
*sdev
, struct rdac_dh_data
*h
)
462 int err
, access_state
;
463 struct rdac_dh_data
*tmp
;
464 struct c9_inquiry
*inqp
;
466 h
->state
= RDAC_STATE_ACTIVE
;
467 err
= submit_inquiry(sdev
, 0xC9, sizeof(struct c9_inquiry
), h
);
468 if (err
== SCSI_DH_OK
) {
470 /* detect the operating mode */
471 if ((inqp
->avte_cvp
>> 5) & 0x1)
472 h
->mode
= RDAC_MODE_IOSHIP
; /* LUN in IOSHIP mode */
473 else if (inqp
->avte_cvp
>> 7)
474 h
->mode
= RDAC_MODE_AVT
; /* LUN in AVT mode */
476 h
->mode
= RDAC_MODE
; /* LUN in RDAC mode */
478 /* Update ownership */
479 if (inqp
->avte_cvp
& 0x1) {
480 h
->lun_state
= RDAC_LUN_OWNED
;
481 access_state
= SCSI_ACCESS_STATE_OPTIMAL
;
483 h
->lun_state
= RDAC_LUN_UNOWNED
;
484 if (h
->mode
== RDAC_MODE
) {
485 h
->state
= RDAC_STATE_PASSIVE
;
486 access_state
= SCSI_ACCESS_STATE_STANDBY
;
488 access_state
= SCSI_ACCESS_STATE_ACTIVE
;
491 /* Update path prio*/
492 if (inqp
->path_prio
& 0x1) {
493 h
->preferred
= RDAC_PREFERRED
;
494 access_state
|= SCSI_ACCESS_STATE_PREFERRED
;
496 h
->preferred
= RDAC_NON_PREFERRED
;
498 list_for_each_entry_rcu(tmp
, &h
->ctlr
->dh_list
, node
) {
499 /* h->sdev should always be valid */
501 tmp
->sdev
->access_state
= access_state
;
509 static int initialize_controller(struct scsi_device
*sdev
,
510 struct rdac_dh_data
*h
, char *array_name
, u8
*array_id
)
513 struct c4_inquiry
*inqp
;
515 err
= submit_inquiry(sdev
, 0xC4, sizeof(struct c4_inquiry
), h
);
516 if (err
== SCSI_DH_OK
) {
518 /* get the controller index */
519 if (inqp
->slot_id
[1] == 0x31)
524 spin_lock(&list_lock
);
525 h
->ctlr
= get_controller(index
, array_name
, array_id
, sdev
);
527 err
= SCSI_DH_RES_TEMP_UNAVAIL
;
529 list_add_rcu(&h
->node
, &h
->ctlr
->dh_list
);
532 spin_unlock(&list_lock
);
537 static int set_mode_select(struct scsi_device
*sdev
, struct rdac_dh_data
*h
)
540 struct c2_inquiry
*inqp
;
542 err
= submit_inquiry(sdev
, 0xC2, sizeof(struct c2_inquiry
), h
);
543 if (err
== SCSI_DH_OK
) {
546 * If more than MODE6_MAX_LUN luns are supported, use
549 if (inqp
->max_lun_supported
>= MODE6_MAX_LUN
)
550 h
->ctlr
->use_ms10
= 1;
552 h
->ctlr
->use_ms10
= 0;
557 static int mode_select_handle_sense(struct scsi_device
*sdev
,
558 unsigned char *sensebuf
)
560 struct scsi_sense_hdr sense_hdr
;
561 int err
= SCSI_DH_IO
, ret
;
562 struct rdac_dh_data
*h
= sdev
->handler_data
;
564 ret
= scsi_normalize_sense(sensebuf
, SCSI_SENSE_BUFFERSIZE
, &sense_hdr
);
568 switch (sense_hdr
.sense_key
) {
570 case ABORTED_COMMAND
:
575 if (sense_hdr
.asc
== 0x04 && sense_hdr
.ascq
== 0x01)
576 /* LUN Not Ready and is in the Process of Becoming
581 case ILLEGAL_REQUEST
:
582 if (sense_hdr
.asc
== 0x91 && sense_hdr
.ascq
== 0x36)
584 * Command Lock contention
586 err
= SCSI_DH_IMM_RETRY
;
592 RDAC_LOG(RDAC_LOG_FAILOVER
, sdev
, "array %s, ctlr %d, "
593 "MODE_SELECT returned with sense %02x/%02x/%02x",
594 (char *) h
->ctlr
->array_name
, h
->ctlr
->index
,
595 sense_hdr
.sense_key
, sense_hdr
.asc
, sense_hdr
.ascq
);
601 static void send_mode_select(struct work_struct
*work
)
603 struct rdac_controller
*ctlr
=
604 container_of(work
, struct rdac_controller
, ms_work
);
606 struct scsi_device
*sdev
= ctlr
->ms_sdev
;
607 struct rdac_dh_data
*h
= sdev
->handler_data
;
608 struct request_queue
*q
= sdev
->request_queue
;
609 int err
, retry_cnt
= RDAC_RETRY_COUNT
;
610 struct rdac_queue_data
*tmp
, *qdata
;
613 spin_lock(&ctlr
->ms_lock
);
614 list_splice_init(&ctlr
->ms_head
, &list
);
616 ctlr
->ms_sdev
= NULL
;
617 spin_unlock(&ctlr
->ms_lock
);
620 err
= SCSI_DH_RES_TEMP_UNAVAIL
;
621 rq
= rdac_failover_get(sdev
, h
, &list
);
625 RDAC_LOG(RDAC_LOG_FAILOVER
, sdev
, "array %s, ctlr %d, "
626 "%s MODE_SELECT command",
627 (char *) h
->ctlr
->array_name
, h
->ctlr
->index
,
628 (retry_cnt
== RDAC_RETRY_COUNT
) ? "queueing" : "retrying");
630 err
= blk_execute_rq(q
, NULL
, rq
, 1);
632 if (err
!= SCSI_DH_OK
) {
633 err
= mode_select_handle_sense(sdev
, h
->sense
);
634 if (err
== SCSI_DH_RETRY
&& retry_cnt
--)
636 if (err
== SCSI_DH_IMM_RETRY
)
639 if (err
== SCSI_DH_OK
) {
640 h
->state
= RDAC_STATE_ACTIVE
;
641 RDAC_LOG(RDAC_LOG_FAILOVER
, sdev
, "array %s, ctlr %d, "
642 "MODE_SELECT completed",
643 (char *) h
->ctlr
->array_name
, h
->ctlr
->index
);
647 list_for_each_entry_safe(qdata
, tmp
, &list
, entry
) {
648 list_del(&qdata
->entry
);
649 if (err
== SCSI_DH_OK
)
650 qdata
->h
->state
= RDAC_STATE_ACTIVE
;
651 if (qdata
->callback_fn
)
652 qdata
->callback_fn(qdata
->callback_data
, err
);
658 static int queue_mode_select(struct scsi_device
*sdev
,
659 activate_complete fn
, void *data
)
661 struct rdac_queue_data
*qdata
;
662 struct rdac_controller
*ctlr
;
664 qdata
= kzalloc(sizeof(*qdata
), GFP_KERNEL
);
666 return SCSI_DH_RETRY
;
668 qdata
->h
= sdev
->handler_data
;
669 qdata
->callback_fn
= fn
;
670 qdata
->callback_data
= data
;
672 ctlr
= qdata
->h
->ctlr
;
673 spin_lock(&ctlr
->ms_lock
);
674 list_add_tail(&qdata
->entry
, &ctlr
->ms_head
);
675 if (!ctlr
->ms_queued
) {
677 ctlr
->ms_sdev
= sdev
;
678 queue_work(kmpath_rdacd
, &ctlr
->ms_work
);
680 spin_unlock(&ctlr
->ms_lock
);
684 static int rdac_activate(struct scsi_device
*sdev
,
685 activate_complete fn
, void *data
)
687 struct rdac_dh_data
*h
= sdev
->handler_data
;
688 int err
= SCSI_DH_OK
;
691 err
= check_ownership(sdev
, h
);
692 if (err
!= SCSI_DH_OK
)
697 if (h
->lun_state
== RDAC_LUN_UNOWNED
)
700 case RDAC_MODE_IOSHIP
:
701 if ((h
->lun_state
== RDAC_LUN_UNOWNED
) &&
702 (h
->preferred
== RDAC_PREFERRED
))
710 err
= queue_mode_select(sdev
, fn
, data
);
711 if (err
== SCSI_DH_OK
)
720 static int rdac_prep_fn(struct scsi_device
*sdev
, struct request
*req
)
722 struct rdac_dh_data
*h
= sdev
->handler_data
;
723 int ret
= BLKPREP_OK
;
725 if (h
->state
!= RDAC_STATE_ACTIVE
) {
727 req
->cmd_flags
|= REQ_QUIET
;
733 static int rdac_check_sense(struct scsi_device
*sdev
,
734 struct scsi_sense_hdr
*sense_hdr
)
736 struct rdac_dh_data
*h
= sdev
->handler_data
;
738 RDAC_LOG(RDAC_LOG_SENSE
, sdev
, "array %s, ctlr %d, "
739 "I/O returned with sense %02x/%02x/%02x",
740 (char *) h
->ctlr
->array_name
, h
->ctlr
->index
,
741 sense_hdr
->sense_key
, sense_hdr
->asc
, sense_hdr
->ascq
);
743 switch (sense_hdr
->sense_key
) {
745 if (sense_hdr
->asc
== 0x04 && sense_hdr
->ascq
== 0x01)
746 /* LUN Not Ready - Logical Unit Not Ready and is in
747 * the process of becoming ready
750 return ADD_TO_MLQUEUE
;
751 if (sense_hdr
->asc
== 0x04 && sense_hdr
->ascq
== 0x81)
752 /* LUN Not Ready - Storage firmware incompatible
753 * Manual code synchonisation required.
755 * Nothing we can do here. Try to bypass the path.
758 if (sense_hdr
->asc
== 0x04 && sense_hdr
->ascq
== 0xA1)
759 /* LUN Not Ready - Quiescense in progress
761 * Just retry and wait.
763 return ADD_TO_MLQUEUE
;
764 if (sense_hdr
->asc
== 0xA1 && sense_hdr
->ascq
== 0x02)
765 /* LUN Not Ready - Quiescense in progress
766 * or has been achieved
769 return ADD_TO_MLQUEUE
;
771 case ILLEGAL_REQUEST
:
772 if (sense_hdr
->asc
== 0x94 && sense_hdr
->ascq
== 0x01) {
773 /* Invalid Request - Current Logical Unit Ownership.
774 * Controller is not the current owner of the LUN,
775 * Fail the path, so that the other path be used.
777 h
->state
= RDAC_STATE_PASSIVE
;
782 if (sense_hdr
->asc
== 0x29 && sense_hdr
->ascq
== 0x00)
784 * Power On, Reset, or Bus Device Reset, just retry.
786 return ADD_TO_MLQUEUE
;
787 if (sense_hdr
->asc
== 0x8b && sense_hdr
->ascq
== 0x02)
789 * Quiescence in progress , just retry.
791 return ADD_TO_MLQUEUE
;
794 /* success just means we do not care what scsi-ml does */
795 return SCSI_RETURN_NOT_HANDLED
;
798 static int rdac_bus_attach(struct scsi_device
*sdev
)
800 struct rdac_dh_data
*h
;
802 char array_name
[ARRAY_LABEL_LEN
];
803 char array_id
[UNIQUE_ID_LEN
];
805 h
= kzalloc(sizeof(*h
) , GFP_KERNEL
);
808 h
->lun
= UNINITIALIZED_LUN
;
809 h
->state
= RDAC_STATE_ACTIVE
;
811 err
= get_lun_info(sdev
, h
, array_name
, array_id
);
812 if (err
!= SCSI_DH_OK
)
815 err
= initialize_controller(sdev
, h
, array_name
, array_id
);
816 if (err
!= SCSI_DH_OK
)
819 err
= check_ownership(sdev
, h
);
820 if (err
!= SCSI_DH_OK
)
823 err
= set_mode_select(sdev
, h
);
824 if (err
!= SCSI_DH_OK
)
827 sdev_printk(KERN_NOTICE
, sdev
,
828 "%s: LUN %d (%s) (%s)\n",
829 RDAC_NAME
, h
->lun
, mode
[(int)h
->mode
],
830 lun_state
[(int)h
->lun_state
]);
832 sdev
->handler_data
= h
;
836 spin_lock(&list_lock
);
837 kref_put(&h
->ctlr
->kref
, release_controller
);
838 spin_unlock(&list_lock
);
845 static void rdac_bus_detach( struct scsi_device
*sdev
)
847 struct rdac_dh_data
*h
= sdev
->handler_data
;
849 if (h
->ctlr
&& h
->ctlr
->ms_queued
)
850 flush_workqueue(kmpath_rdacd
);
852 spin_lock(&list_lock
);
854 list_del_rcu(&h
->node
);
856 kref_put(&h
->ctlr
->kref
, release_controller
);
858 spin_unlock(&list_lock
);
859 sdev
->handler_data
= NULL
;
863 static struct scsi_device_handler rdac_dh
= {
865 .module
= THIS_MODULE
,
866 .prep_fn
= rdac_prep_fn
,
867 .check_sense
= rdac_check_sense
,
868 .attach
= rdac_bus_attach
,
869 .detach
= rdac_bus_detach
,
870 .activate
= rdac_activate
,
873 static int __init
rdac_init(void)
877 r
= scsi_register_device_handler(&rdac_dh
);
879 printk(KERN_ERR
"Failed to register scsi device handler.");
884 * Create workqueue to handle mode selects for rdac
886 kmpath_rdacd
= create_singlethread_workqueue("kmpath_rdacd");
888 scsi_unregister_device_handler(&rdac_dh
);
889 printk(KERN_ERR
"kmpath_rdacd creation failed.\n");
897 static void __exit
rdac_exit(void)
899 destroy_workqueue(kmpath_rdacd
);
900 scsi_unregister_device_handler(&rdac_dh
);
903 module_init(rdac_init
);
904 module_exit(rdac_exit
);
906 MODULE_DESCRIPTION("Multipath LSI/Engenio/NetApp E-Series RDAC driver");
907 MODULE_AUTHOR("Mike Christie, Chandra Seetharaman");
908 MODULE_VERSION("01.00.0000.0000");
909 MODULE_LICENSE("GPL");