2008-05-02 05:49:52 +08:00
|
|
|
/*
|
2011-09-02 15:56:32 +08:00
|
|
|
* LSI/Engenio/NetApp E-Series RDAC SCSI Device Handler
|
2008-05-02 05:49:52 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Mike Christie. All rights reserved.
|
|
|
|
* Copyright (C) Chandra Seetharaman, IBM Corp. 2007
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <scsi/scsi.h>
|
|
|
|
#include <scsi/scsi_eh.h>
|
|
|
|
#include <scsi/scsi_dh.h>
|
2009-10-22 00:22:51 +08:00
|
|
|
#include <linux/workqueue.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2011-05-27 21:47:43 +08:00
|
|
|
#include <linux/module.h>
|
2008-05-02 05:49:52 +08:00
|
|
|
|
|
|
|
#define RDAC_NAME "rdac"
|
2008-11-06 12:06:37 +08:00
|
|
|
#define RDAC_RETRY_COUNT 5
|
2008-05-02 05:49:52 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* LSI mode page stuff
|
|
|
|
*
|
|
|
|
* These struct definitions and the forming of the
|
|
|
|
* mode page were taken from the LSI RDAC 2.4 GPL'd
|
|
|
|
* driver, and then converted to Linux conventions.
|
|
|
|
*/
|
2011-07-14 20:07:13 +08:00
|
|
|
#define RDAC_QUIESCENCE_TIME 20
|
2008-05-02 05:49:52 +08:00
|
|
|
/*
|
|
|
|
* Page Codes
|
|
|
|
*/
|
|
|
|
#define RDAC_PAGE_CODE_REDUNDANT_CONTROLLER 0x2c
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Controller modes definitions
|
|
|
|
*/
|
|
|
|
#define RDAC_MODE_TRANSFER_SPECIFIED_LUNS 0x02
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RDAC Options field
|
|
|
|
*/
|
|
|
|
#define RDAC_FORCED_QUIESENCE 0x02
|
|
|
|
|
|
|
|
#define RDAC_TIMEOUT (60 * HZ)
|
|
|
|
#define RDAC_RETRIES 3
|
|
|
|
|
|
|
|
struct rdac_mode_6_hdr {
|
|
|
|
u8 data_len;
|
|
|
|
u8 medium_type;
|
|
|
|
u8 device_params;
|
|
|
|
u8 block_desc_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rdac_mode_10_hdr {
|
|
|
|
u16 data_len;
|
|
|
|
u8 medium_type;
|
|
|
|
u8 device_params;
|
|
|
|
u16 reserved;
|
|
|
|
u16 block_desc_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rdac_mode_common {
|
|
|
|
u8 controller_serial[16];
|
|
|
|
u8 alt_controller_serial[16];
|
|
|
|
u8 rdac_mode[2];
|
|
|
|
u8 alt_rdac_mode[2];
|
|
|
|
u8 quiescence_timeout;
|
|
|
|
u8 rdac_options;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rdac_pg_legacy {
|
|
|
|
struct rdac_mode_6_hdr hdr;
|
|
|
|
u8 page_code;
|
|
|
|
u8 page_len;
|
|
|
|
struct rdac_mode_common common;
|
|
|
|
#define MODE6_MAX_LUN 32
|
|
|
|
u8 lun_table[MODE6_MAX_LUN];
|
|
|
|
u8 reserved2[32];
|
|
|
|
u8 reserved3;
|
|
|
|
u8 reserved4;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rdac_pg_expanded {
|
|
|
|
struct rdac_mode_10_hdr hdr;
|
|
|
|
u8 page_code;
|
|
|
|
u8 subpage_code;
|
|
|
|
u8 page_len[2];
|
|
|
|
struct rdac_mode_common common;
|
|
|
|
u8 lun_table[256];
|
|
|
|
u8 reserved3;
|
|
|
|
u8 reserved4;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct c9_inquiry {
|
|
|
|
u8 peripheral_info;
|
|
|
|
u8 page_code; /* 0xC9 */
|
|
|
|
u8 reserved1;
|
|
|
|
u8 page_len;
|
|
|
|
u8 page_id[4]; /* "vace" */
|
|
|
|
u8 avte_cvp;
|
|
|
|
u8 path_prio;
|
|
|
|
u8 reserved2[38];
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SUBSYS_ID_LEN 16
|
|
|
|
#define SLOT_ID_LEN 2
|
2009-09-04 11:42:21 +08:00
|
|
|
#define ARRAY_LABEL_LEN 31
|
2008-05-02 05:49:52 +08:00
|
|
|
|
|
|
|
struct c4_inquiry {
|
|
|
|
u8 peripheral_info;
|
|
|
|
u8 page_code; /* 0xC4 */
|
|
|
|
u8 reserved1;
|
|
|
|
u8 page_len;
|
|
|
|
u8 page_id[4]; /* "subs" */
|
|
|
|
u8 subsys_id[SUBSYS_ID_LEN];
|
|
|
|
u8 revision[4];
|
|
|
|
u8 slot_id[SLOT_ID_LEN];
|
|
|
|
u8 reserved[2];
|
|
|
|
};
|
|
|
|
|
2011-07-21 05:18:56 +08:00
|
|
|
#define UNIQUE_ID_LEN 16
|
2008-05-02 05:49:52 +08:00
|
|
|
struct c8_inquiry {
|
|
|
|
u8 peripheral_info;
|
|
|
|
u8 page_code; /* 0xC8 */
|
|
|
|
u8 reserved1;
|
|
|
|
u8 page_len;
|
|
|
|
u8 page_id[4]; /* "edid" */
|
|
|
|
u8 reserved2[3];
|
|
|
|
u8 vol_uniq_id_len;
|
|
|
|
u8 vol_uniq_id[16];
|
|
|
|
u8 vol_user_label_len;
|
|
|
|
u8 vol_user_label[60];
|
|
|
|
u8 array_uniq_id_len;
|
2011-07-21 05:18:56 +08:00
|
|
|
u8 array_unique_id[UNIQUE_ID_LEN];
|
2008-05-02 05:49:52 +08:00
|
|
|
u8 array_user_label_len;
|
|
|
|
u8 array_user_label[60];
|
|
|
|
u8 lun[8];
|
|
|
|
};
|
|
|
|
|
2011-07-21 05:18:56 +08:00
|
|
|
struct rdac_controller {
|
|
|
|
u8 array_id[UNIQUE_ID_LEN];
|
|
|
|
int use_ms10;
|
|
|
|
struct kref kref;
|
|
|
|
struct list_head node; /* list of all controllers */
|
|
|
|
union {
|
|
|
|
struct rdac_pg_legacy legacy;
|
|
|
|
struct rdac_pg_expanded expanded;
|
|
|
|
} mode_select;
|
|
|
|
u8 index;
|
|
|
|
u8 array_name[ARRAY_LABEL_LEN];
|
2011-07-28 02:22:56 +08:00
|
|
|
struct Scsi_Host *host;
|
2011-07-21 05:18:56 +08:00
|
|
|
spinlock_t ms_lock;
|
|
|
|
int ms_queued;
|
|
|
|
struct work_struct ms_work;
|
|
|
|
struct scsi_device *ms_sdev;
|
|
|
|
struct list_head ms_head;
|
2016-03-03 14:54:10 +08:00
|
|
|
struct list_head dh_list;
|
2011-07-21 05:18:56 +08:00
|
|
|
};
|
|
|
|
|
2008-05-02 05:49:52 +08:00
|
|
|
struct c2_inquiry {
|
|
|
|
u8 peripheral_info;
|
|
|
|
u8 page_code; /* 0xC2 */
|
|
|
|
u8 reserved1;
|
|
|
|
u8 page_len;
|
|
|
|
u8 page_id[4]; /* "swr4" */
|
|
|
|
u8 sw_version[3];
|
|
|
|
u8 sw_date[3];
|
|
|
|
u8 features_enabled;
|
|
|
|
u8 max_lun_supported;
|
|
|
|
u8 partitions[239]; /* Total allocation length should be 0xFF */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rdac_dh_data {
|
2016-03-03 14:54:10 +08:00
|
|
|
struct list_head node;
|
2008-05-02 05:49:52 +08:00
|
|
|
struct rdac_controller *ctlr;
|
2016-03-03 14:54:10 +08:00
|
|
|
struct scsi_device *sdev;
|
2008-05-02 05:49:52 +08:00
|
|
|
#define UNINITIALIZED_LUN (1 << 8)
|
|
|
|
unsigned lun;
|
2011-04-09 01:37:40 +08:00
|
|
|
|
|
|
|
#define RDAC_MODE 0
|
|
|
|
#define RDAC_MODE_AVT 1
|
|
|
|
#define RDAC_MODE_IOSHIP 2
|
|
|
|
unsigned char mode;
|
|
|
|
|
2008-05-02 05:49:52 +08:00
|
|
|
#define RDAC_STATE_ACTIVE 0
|
|
|
|
#define RDAC_STATE_PASSIVE 1
|
|
|
|
unsigned char state;
|
2008-07-18 07:53:15 +08:00
|
|
|
|
|
|
|
#define RDAC_LUN_UNOWNED 0
|
|
|
|
#define RDAC_LUN_OWNED 1
|
|
|
|
char lun_state;
|
2011-04-09 01:37:40 +08:00
|
|
|
|
|
|
|
#define RDAC_PREFERRED 0
|
|
|
|
#define RDAC_NON_PREFERRED 1
|
|
|
|
char preferred;
|
|
|
|
|
2008-05-02 05:49:52 +08:00
|
|
|
union {
|
|
|
|
struct c2_inquiry c2;
|
|
|
|
struct c4_inquiry c4;
|
|
|
|
struct c8_inquiry c8;
|
|
|
|
struct c9_inquiry c9;
|
|
|
|
} inq;
|
|
|
|
};
|
|
|
|
|
2011-04-09 01:37:40 +08:00
|
|
|
static const char *mode[] = {
|
|
|
|
"RDAC",
|
|
|
|
"AVT",
|
|
|
|
"IOSHIP",
|
|
|
|
};
|
2008-07-18 07:53:15 +08:00
|
|
|
static const char *lun_state[] =
|
|
|
|
{
|
|
|
|
"unowned",
|
|
|
|
"owned",
|
|
|
|
};
|
|
|
|
|
2009-10-22 00:22:51 +08:00
|
|
|
struct rdac_queue_data {
|
|
|
|
struct list_head entry;
|
|
|
|
struct rdac_dh_data *h;
|
|
|
|
activate_complete callback_fn;
|
|
|
|
void *callback_data;
|
|
|
|
};
|
|
|
|
|
2008-05-02 05:49:52 +08:00
|
|
|
static LIST_HEAD(ctlr_list);
|
|
|
|
static DEFINE_SPINLOCK(list_lock);
|
2009-10-22 00:22:51 +08:00
|
|
|
static struct workqueue_struct *kmpath_rdacd;
|
|
|
|
static void send_mode_select(struct work_struct *work);
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2009-09-04 11:42:28 +08:00
|
|
|
/*
|
|
|
|
* module parameter to enable rdac debug logging.
|
|
|
|
* 2 bits for each type of logging, only two types defined for now
|
|
|
|
* Can be enhanced if required at later point
|
|
|
|
*/
|
|
|
|
static int rdac_logging = 1;
|
|
|
|
module_param(rdac_logging, int, S_IRUGO|S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(rdac_logging, "A bit mask of rdac logging levels, "
|
|
|
|
"Default is 1 - failover logging enabled, "
|
|
|
|
"set it to 0xF to enable all the logs");
|
|
|
|
|
|
|
|
#define RDAC_LOG_FAILOVER 0
|
|
|
|
#define RDAC_LOG_SENSE 2
|
|
|
|
|
|
|
|
#define RDAC_LOG_BITS 2
|
|
|
|
|
|
|
|
#define RDAC_LOG_LEVEL(SHIFT) \
|
|
|
|
((rdac_logging >> (SHIFT)) & ((1 << (RDAC_LOG_BITS)) - 1))
|
|
|
|
|
|
|
|
#define RDAC_LOG(SHIFT, sdev, f, arg...) \
|
|
|
|
do { \
|
|
|
|
if (unlikely(RDAC_LOG_LEVEL(SHIFT))) \
|
|
|
|
sdev_printk(KERN_INFO, sdev, RDAC_NAME ": " f "\n", ## arg); \
|
|
|
|
} while (0);
|
|
|
|
|
2016-11-03 21:20:21 +08:00
|
|
|
static unsigned int rdac_failover_get(struct rdac_controller *ctlr,
|
|
|
|
struct list_head *list,
|
|
|
|
unsigned char *cdb)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
|
|
|
struct rdac_mode_common *common;
|
|
|
|
unsigned data_size;
|
2011-02-12 06:14:08 +08:00
|
|
|
struct rdac_queue_data *qdata;
|
|
|
|
u8 *lun_table;
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2017-05-20 15:58:10 +08:00
|
|
|
if (ctlr->use_ms10) {
|
2008-05-02 05:49:52 +08:00
|
|
|
struct rdac_pg_expanded *rdac_pg;
|
|
|
|
|
|
|
|
data_size = sizeof(struct rdac_pg_expanded);
|
2017-05-20 15:58:10 +08:00
|
|
|
rdac_pg = &ctlr->mode_select.expanded;
|
2008-05-02 05:49:52 +08:00
|
|
|
memset(rdac_pg, 0, data_size);
|
|
|
|
common = &rdac_pg->common;
|
|
|
|
rdac_pg->page_code = RDAC_PAGE_CODE_REDUNDANT_CONTROLLER + 0x40;
|
|
|
|
rdac_pg->subpage_code = 0x1;
|
|
|
|
rdac_pg->page_len[0] = 0x01;
|
|
|
|
rdac_pg->page_len[1] = 0x28;
|
2011-02-12 06:14:08 +08:00
|
|
|
lun_table = rdac_pg->lun_table;
|
2008-05-02 05:49:52 +08:00
|
|
|
} else {
|
|
|
|
struct rdac_pg_legacy *rdac_pg;
|
|
|
|
|
|
|
|
data_size = sizeof(struct rdac_pg_legacy);
|
2017-05-20 15:58:10 +08:00
|
|
|
rdac_pg = &ctlr->mode_select.legacy;
|
2008-05-02 05:49:52 +08:00
|
|
|
memset(rdac_pg, 0, data_size);
|
|
|
|
common = &rdac_pg->common;
|
|
|
|
rdac_pg->page_code = RDAC_PAGE_CODE_REDUNDANT_CONTROLLER;
|
|
|
|
rdac_pg->page_len = 0x68;
|
2011-02-12 06:14:08 +08:00
|
|
|
lun_table = rdac_pg->lun_table;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
common->rdac_mode[1] = RDAC_MODE_TRANSFER_SPECIFIED_LUNS;
|
|
|
|
common->quiescence_timeout = RDAC_QUIESCENCE_TIME;
|
|
|
|
common->rdac_options = RDAC_FORCED_QUIESENCE;
|
|
|
|
|
2011-02-12 06:14:08 +08:00
|
|
|
list_for_each_entry(qdata, list, entry) {
|
|
|
|
lun_table[qdata->h->lun] = 0x81;
|
|
|
|
}
|
|
|
|
|
2008-05-02 05:49:52 +08:00
|
|
|
/* Prepare the command. */
|
2017-05-20 15:58:10 +08:00
|
|
|
if (ctlr->use_ms10) {
|
2016-11-03 21:20:21 +08:00
|
|
|
cdb[0] = MODE_SELECT_10;
|
|
|
|
cdb[7] = data_size >> 8;
|
|
|
|
cdb[8] = data_size & 0xff;
|
2008-05-02 05:49:52 +08:00
|
|
|
} else {
|
2016-11-03 21:20:21 +08:00
|
|
|
cdb[0] = MODE_SELECT;
|
|
|
|
cdb[4] = data_size;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
|
2016-11-03 21:20:21 +08:00
|
|
|
return data_size;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void release_controller(struct kref *kref)
|
|
|
|
{
|
|
|
|
struct rdac_controller *ctlr;
|
|
|
|
ctlr = container_of(kref, struct rdac_controller, kref);
|
|
|
|
|
|
|
|
list_del(&ctlr->node);
|
|
|
|
kfree(ctlr);
|
|
|
|
}
|
|
|
|
|
2011-07-21 05:18:56 +08:00
|
|
|
static struct rdac_controller *get_controller(int index, char *array_name,
|
2011-07-28 02:22:56 +08:00
|
|
|
u8 *array_id, struct scsi_device *sdev)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
|
|
|
struct rdac_controller *ctlr, *tmp;
|
|
|
|
|
|
|
|
list_for_each_entry(tmp, &ctlr_list, node) {
|
2011-07-21 05:18:56 +08:00
|
|
|
if ((memcmp(tmp->array_id, array_id, UNIQUE_ID_LEN) == 0) &&
|
2011-07-28 02:22:56 +08:00
|
|
|
(tmp->index == index) &&
|
|
|
|
(tmp->host == sdev->host)) {
|
2008-05-02 05:49:52 +08:00
|
|
|
kref_get(&tmp->kref);
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ctlr = kmalloc(sizeof(*ctlr), GFP_ATOMIC);
|
|
|
|
if (!ctlr)
|
2012-02-02 23:21:54 +08:00
|
|
|
return NULL;
|
2008-05-02 05:49:52 +08:00
|
|
|
|
|
|
|
/* initialize fields of controller */
|
2011-07-21 05:18:56 +08:00
|
|
|
memcpy(ctlr->array_id, array_id, UNIQUE_ID_LEN);
|
|
|
|
ctlr->index = index;
|
2011-07-28 02:22:56 +08:00
|
|
|
ctlr->host = sdev->host;
|
2009-09-04 11:42:21 +08:00
|
|
|
memcpy(ctlr->array_name, array_name, ARRAY_LABEL_LEN);
|
|
|
|
|
2008-05-02 05:49:52 +08:00
|
|
|
kref_init(&ctlr->kref);
|
|
|
|
ctlr->use_ms10 = -1;
|
2009-10-22 00:22:51 +08:00
|
|
|
ctlr->ms_queued = 0;
|
|
|
|
ctlr->ms_sdev = NULL;
|
|
|
|
spin_lock_init(&ctlr->ms_lock);
|
|
|
|
INIT_WORK(&ctlr->ms_work, send_mode_select);
|
|
|
|
INIT_LIST_HEAD(&ctlr->ms_head);
|
2008-05-02 05:49:52 +08:00
|
|
|
list_add(&ctlr->node, &ctlr_list);
|
2016-03-03 14:54:10 +08:00
|
|
|
INIT_LIST_HEAD(&ctlr->dh_list);
|
2012-02-02 23:21:54 +08:00
|
|
|
|
2008-05-02 05:49:52 +08:00
|
|
|
return ctlr;
|
|
|
|
}
|
|
|
|
|
2009-09-04 11:42:21 +08:00
|
|
|
static int get_lun_info(struct scsi_device *sdev, struct rdac_dh_data *h,
|
2011-07-21 05:18:56 +08:00
|
|
|
char *array_name, u8 *array_id)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
2016-11-03 21:20:21 +08:00
|
|
|
int err = SCSI_DH_IO, i;
|
|
|
|
struct c8_inquiry *inqp = &h->inq.c8;
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2016-11-03 21:20:21 +08:00
|
|
|
if (!scsi_get_vpd_page(sdev, 0xC8, (unsigned char *)inqp,
|
|
|
|
sizeof(struct c8_inquiry))) {
|
2008-07-18 07:53:15 +08:00
|
|
|
if (inqp->page_code != 0xc8)
|
|
|
|
return SCSI_DH_NOSYS;
|
|
|
|
if (inqp->page_id[0] != 'e' || inqp->page_id[1] != 'd' ||
|
|
|
|
inqp->page_id[2] != 'i' || inqp->page_id[3] != 'd')
|
|
|
|
return SCSI_DH_NOSYS;
|
2008-08-13 08:26:58 +08:00
|
|
|
h->lun = inqp->lun[7]; /* Uses only the last byte */
|
2009-09-04 11:42:21 +08:00
|
|
|
|
|
|
|
for(i=0; i<ARRAY_LABEL_LEN-1; ++i)
|
|
|
|
*(array_name+i) = inqp->array_user_label[(2*i)+1];
|
|
|
|
|
|
|
|
*(array_name+ARRAY_LABEL_LEN-1) = '\0';
|
2011-07-21 05:18:56 +08:00
|
|
|
memset(array_id, 0, UNIQUE_ID_LEN);
|
|
|
|
memcpy(array_id, inqp->array_unique_id, inqp->array_uniq_id_len);
|
2016-11-03 21:20:21 +08:00
|
|
|
err = SCSI_DH_OK;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-07-18 07:53:15 +08:00
|
|
|
static int check_ownership(struct scsi_device *sdev, struct rdac_dh_data *h)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
2016-11-03 21:20:21 +08:00
|
|
|
int err = SCSI_DH_IO, access_state;
|
2016-03-03 14:54:10 +08:00
|
|
|
struct rdac_dh_data *tmp;
|
2016-11-03 21:20:21 +08:00
|
|
|
struct c9_inquiry *inqp = &h->inq.c9;
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2008-11-06 12:05:21 +08:00
|
|
|
h->state = RDAC_STATE_ACTIVE;
|
2016-11-03 21:20:21 +08:00
|
|
|
if (!scsi_get_vpd_page(sdev, 0xC9, (unsigned char *)inqp,
|
|
|
|
sizeof(struct c9_inquiry))) {
|
2011-04-09 01:38:33 +08:00
|
|
|
/* detect the operating mode */
|
|
|
|
if ((inqp->avte_cvp >> 5) & 0x1)
|
|
|
|
h->mode = RDAC_MODE_IOSHIP; /* LUN in IOSHIP mode */
|
|
|
|
else if (inqp->avte_cvp >> 7)
|
|
|
|
h->mode = RDAC_MODE_AVT; /* LUN in AVT mode */
|
|
|
|
else
|
|
|
|
h->mode = RDAC_MODE; /* LUN in RDAC mode */
|
|
|
|
|
|
|
|
/* Update ownership */
|
2016-03-03 14:54:10 +08:00
|
|
|
if (inqp->avte_cvp & 0x1) {
|
2008-07-18 07:53:15 +08:00
|
|
|
h->lun_state = RDAC_LUN_OWNED;
|
2016-03-03 14:54:10 +08:00
|
|
|
access_state = SCSI_ACCESS_STATE_OPTIMAL;
|
|
|
|
} else {
|
2011-04-09 01:38:33 +08:00
|
|
|
h->lun_state = RDAC_LUN_UNOWNED;
|
2016-03-03 14:54:10 +08:00
|
|
|
if (h->mode == RDAC_MODE) {
|
2011-04-09 01:38:33 +08:00
|
|
|
h->state = RDAC_STATE_PASSIVE;
|
2016-03-03 14:54:10 +08:00
|
|
|
access_state = SCSI_ACCESS_STATE_STANDBY;
|
|
|
|
} else
|
|
|
|
access_state = SCSI_ACCESS_STATE_ACTIVE;
|
2008-07-18 07:53:15 +08:00
|
|
|
}
|
|
|
|
|
2011-04-09 01:38:33 +08:00
|
|
|
/* Update path prio*/
|
2016-03-03 14:54:10 +08:00
|
|
|
if (inqp->path_prio & 0x1) {
|
2011-04-09 01:38:33 +08:00
|
|
|
h->preferred = RDAC_PREFERRED;
|
2016-03-03 14:54:10 +08:00
|
|
|
access_state |= SCSI_ACCESS_STATE_PREFERRED;
|
|
|
|
} else
|
2011-04-09 01:38:33 +08:00
|
|
|
h->preferred = RDAC_NON_PREFERRED;
|
2016-03-03 14:54:10 +08:00
|
|
|
rcu_read_lock();
|
|
|
|
list_for_each_entry_rcu(tmp, &h->ctlr->dh_list, node) {
|
|
|
|
/* h->sdev should always be valid */
|
|
|
|
BUG_ON(!tmp->sdev);
|
|
|
|
tmp->sdev->access_state = access_state;
|
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
2016-11-03 21:20:21 +08:00
|
|
|
err = SCSI_DH_OK;
|
2011-04-09 01:38:33 +08:00
|
|
|
}
|
2008-08-22 14:12:40 +08:00
|
|
|
|
2008-05-02 05:49:52 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-07-18 07:53:15 +08:00
|
|
|
static int initialize_controller(struct scsi_device *sdev,
|
2011-07-21 05:18:56 +08:00
|
|
|
struct rdac_dh_data *h, char *array_name, u8 *array_id)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
2016-11-03 21:20:21 +08:00
|
|
|
int err = SCSI_DH_IO, index;
|
|
|
|
struct c4_inquiry *inqp = &h->inq.c4;
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2016-11-03 21:20:21 +08:00
|
|
|
if (!scsi_get_vpd_page(sdev, 0xC4, (unsigned char *)inqp,
|
|
|
|
sizeof(struct c4_inquiry))) {
|
2011-07-21 05:18:56 +08:00
|
|
|
/* get the controller index */
|
|
|
|
if (inqp->slot_id[1] == 0x31)
|
|
|
|
index = 0;
|
|
|
|
else
|
|
|
|
index = 1;
|
2012-02-02 23:21:54 +08:00
|
|
|
|
|
|
|
spin_lock(&list_lock);
|
2011-07-28 02:22:56 +08:00
|
|
|
h->ctlr = get_controller(index, array_name, array_id, sdev);
|
2008-05-02 05:49:52 +08:00
|
|
|
if (!h->ctlr)
|
|
|
|
err = SCSI_DH_RES_TEMP_UNAVAIL;
|
2016-03-03 14:54:10 +08:00
|
|
|
else {
|
|
|
|
h->sdev = sdev;
|
2021-01-13 14:31:03 +08:00
|
|
|
list_add_rcu(&h->node, &h->ctlr->dh_list);
|
2016-03-03 14:54:10 +08:00
|
|
|
}
|
2012-02-02 23:21:54 +08:00
|
|
|
spin_unlock(&list_lock);
|
2016-11-03 21:20:21 +08:00
|
|
|
err = SCSI_DH_OK;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-07-18 07:53:15 +08:00
|
|
|
static int set_mode_select(struct scsi_device *sdev, struct rdac_dh_data *h)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
2016-11-03 21:20:21 +08:00
|
|
|
int err = SCSI_DH_IO;
|
|
|
|
struct c2_inquiry *inqp = &h->inq.c2;
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2016-11-03 21:20:21 +08:00
|
|
|
if (!scsi_get_vpd_page(sdev, 0xC2, (unsigned char *)inqp,
|
|
|
|
sizeof(struct c2_inquiry))) {
|
2008-05-02 05:49:52 +08:00
|
|
|
/*
|
|
|
|
* If more than MODE6_MAX_LUN luns are supported, use
|
|
|
|
* mode select 10
|
|
|
|
*/
|
|
|
|
if (inqp->max_lun_supported >= MODE6_MAX_LUN)
|
|
|
|
h->ctlr->use_ms10 = 1;
|
|
|
|
else
|
|
|
|
h->ctlr->use_ms10 = 0;
|
2016-11-03 21:20:21 +08:00
|
|
|
err = SCSI_DH_OK;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-07-18 07:53:15 +08:00
|
|
|
static int mode_select_handle_sense(struct scsi_device *sdev,
|
2016-11-03 21:20:21 +08:00
|
|
|
struct scsi_sense_hdr *sense_hdr)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
2016-11-03 21:20:21 +08:00
|
|
|
int err = SCSI_DH_IO;
|
2015-08-27 20:16:59 +08:00
|
|
|
struct rdac_dh_data *h = sdev->handler_data;
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2016-11-03 21:20:21 +08:00
|
|
|
if (!scsi_sense_valid(sense_hdr))
|
2008-05-02 05:49:52 +08:00
|
|
|
goto done;
|
|
|
|
|
2016-11-03 21:20:21 +08:00
|
|
|
switch (sense_hdr->sense_key) {
|
2009-03-04 14:47:54 +08:00
|
|
|
case NO_SENSE:
|
|
|
|
case ABORTED_COMMAND:
|
|
|
|
case UNIT_ATTENTION:
|
2008-05-02 05:49:52 +08:00
|
|
|
err = SCSI_DH_RETRY;
|
2009-03-04 14:47:54 +08:00
|
|
|
break;
|
|
|
|
case NOT_READY:
|
2016-11-03 21:20:21 +08:00
|
|
|
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x01)
|
2009-03-04 14:47:54 +08:00
|
|
|
/* LUN Not Ready and is in the Process of Becoming
|
|
|
|
* Ready
|
|
|
|
*/
|
|
|
|
err = SCSI_DH_RETRY;
|
|
|
|
break;
|
|
|
|
case ILLEGAL_REQUEST:
|
2016-11-03 21:20:21 +08:00
|
|
|
if (sense_hdr->asc == 0x91 && sense_hdr->ascq == 0x36)
|
2009-03-04 14:47:54 +08:00
|
|
|
/*
|
|
|
|
* Command Lock contention
|
|
|
|
*/
|
2016-01-22 22:42:41 +08:00
|
|
|
err = SCSI_DH_IMM_RETRY;
|
2009-03-04 14:47:54 +08:00
|
|
|
break;
|
|
|
|
default:
|
2009-09-04 11:42:28 +08:00
|
|
|
break;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
|
2009-09-04 11:42:28 +08:00
|
|
|
RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, "
|
|
|
|
"MODE_SELECT returned with sense %02x/%02x/%02x",
|
|
|
|
(char *) h->ctlr->array_name, h->ctlr->index,
|
2016-11-03 21:20:21 +08:00
|
|
|
sense_hdr->sense_key, sense_hdr->asc, sense_hdr->ascq);
|
2009-09-04 11:42:28 +08:00
|
|
|
|
2008-05-02 05:49:52 +08:00
|
|
|
done:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-10-22 00:22:51 +08:00
|
|
|
static void send_mode_select(struct work_struct *work)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
2009-10-22 00:22:51 +08:00
|
|
|
struct rdac_controller *ctlr =
|
|
|
|
container_of(work, struct rdac_controller, ms_work);
|
|
|
|
struct scsi_device *sdev = ctlr->ms_sdev;
|
2015-08-27 20:16:59 +08:00
|
|
|
struct rdac_dh_data *h = sdev->handler_data;
|
2016-11-03 21:20:21 +08:00
|
|
|
int err = SCSI_DH_OK, retry_cnt = RDAC_RETRY_COUNT;
|
2009-10-22 00:22:51 +08:00
|
|
|
struct rdac_queue_data *tmp, *qdata;
|
|
|
|
LIST_HEAD(list);
|
2018-03-10 06:32:11 +08:00
|
|
|
unsigned char cdb[MAX_COMMAND_SIZE];
|
2016-11-03 21:20:21 +08:00
|
|
|
struct scsi_sense_hdr sshdr;
|
|
|
|
unsigned int data_size;
|
2022-07-15 02:07:08 +08:00
|
|
|
blk_opf_t req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
|
2016-11-03 21:20:21 +08:00
|
|
|
REQ_FAILFAST_DRIVER;
|
2009-10-22 00:22:51 +08:00
|
|
|
|
|
|
|
spin_lock(&ctlr->ms_lock);
|
|
|
|
list_splice_init(&ctlr->ms_head, &list);
|
|
|
|
ctlr->ms_queued = 0;
|
|
|
|
ctlr->ms_sdev = NULL;
|
|
|
|
spin_unlock(&ctlr->ms_lock);
|
|
|
|
|
2016-11-03 21:20:21 +08:00
|
|
|
retry:
|
2019-09-04 23:52:29 +08:00
|
|
|
memset(cdb, 0, sizeof(cdb));
|
|
|
|
|
2016-11-03 21:20:21 +08:00
|
|
|
data_size = rdac_failover_get(ctlr, &list, cdb);
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2009-09-04 11:42:28 +08:00
|
|
|
RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, "
|
|
|
|
"%s MODE_SELECT command",
|
|
|
|
(char *) h->ctlr->array_name, h->ctlr->index,
|
2008-11-06 12:06:37 +08:00
|
|
|
(retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying");
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2017-02-23 23:02:37 +08:00
|
|
|
if (scsi_execute(sdev, cdb, DMA_TO_DEVICE, &h->ctlr->mode_select,
|
|
|
|
data_size, NULL, &sshdr, RDAC_TIMEOUT * HZ,
|
|
|
|
RDAC_RETRIES, req_flags, 0, NULL)) {
|
2016-11-03 21:20:21 +08:00
|
|
|
err = mode_select_handle_sense(sdev, &sshdr);
|
2008-11-06 12:06:37 +08:00
|
|
|
if (err == SCSI_DH_RETRY && retry_cnt--)
|
|
|
|
goto retry;
|
2016-01-22 22:42:41 +08:00
|
|
|
if (err == SCSI_DH_IMM_RETRY)
|
|
|
|
goto retry;
|
2008-11-06 12:06:37 +08:00
|
|
|
}
|
2009-09-04 11:42:28 +08:00
|
|
|
if (err == SCSI_DH_OK) {
|
2008-05-02 05:49:52 +08:00
|
|
|
h->state = RDAC_STATE_ACTIVE;
|
2009-09-04 11:42:28 +08:00
|
|
|
RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, "
|
|
|
|
"MODE_SELECT completed",
|
|
|
|
(char *) h->ctlr->array_name, h->ctlr->index);
|
|
|
|
}
|
2008-07-18 07:53:15 +08:00
|
|
|
|
2009-10-22 00:22:51 +08:00
|
|
|
list_for_each_entry_safe(qdata, tmp, &list, entry) {
|
|
|
|
list_del(&qdata->entry);
|
|
|
|
if (err == SCSI_DH_OK)
|
|
|
|
qdata->h->state = RDAC_STATE_ACTIVE;
|
|
|
|
if (qdata->callback_fn)
|
|
|
|
qdata->callback_fn(qdata->callback_data, err);
|
|
|
|
kfree(qdata);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int queue_mode_select(struct scsi_device *sdev,
|
|
|
|
activate_complete fn, void *data)
|
|
|
|
{
|
|
|
|
struct rdac_queue_data *qdata;
|
|
|
|
struct rdac_controller *ctlr;
|
|
|
|
|
|
|
|
qdata = kzalloc(sizeof(*qdata), GFP_KERNEL);
|
|
|
|
if (!qdata)
|
|
|
|
return SCSI_DH_RETRY;
|
|
|
|
|
2015-08-27 20:16:59 +08:00
|
|
|
qdata->h = sdev->handler_data;
|
2009-10-22 00:22:51 +08:00
|
|
|
qdata->callback_fn = fn;
|
|
|
|
qdata->callback_data = data;
|
|
|
|
|
|
|
|
ctlr = qdata->h->ctlr;
|
|
|
|
spin_lock(&ctlr->ms_lock);
|
|
|
|
list_add_tail(&qdata->entry, &ctlr->ms_head);
|
|
|
|
if (!ctlr->ms_queued) {
|
|
|
|
ctlr->ms_queued = 1;
|
|
|
|
ctlr->ms_sdev = sdev;
|
|
|
|
queue_work(kmpath_rdacd, &ctlr->ms_work);
|
|
|
|
}
|
|
|
|
spin_unlock(&ctlr->ms_lock);
|
|
|
|
return SCSI_DH_OK;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
|
2009-10-22 00:22:46 +08:00
|
|
|
static int rdac_activate(struct scsi_device *sdev,
|
|
|
|
activate_complete fn, void *data)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
2015-08-27 20:16:59 +08:00
|
|
|
struct rdac_dh_data *h = sdev->handler_data;
|
2008-05-02 05:49:52 +08:00
|
|
|
int err = SCSI_DH_OK;
|
2011-04-09 01:39:30 +08:00
|
|
|
int act = 0;
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2008-07-18 07:53:15 +08:00
|
|
|
err = check_ownership(sdev, h);
|
|
|
|
if (err != SCSI_DH_OK)
|
2008-05-02 05:49:52 +08:00
|
|
|
goto done;
|
|
|
|
|
2011-04-09 01:39:30 +08:00
|
|
|
switch (h->mode) {
|
|
|
|
case RDAC_MODE:
|
|
|
|
if (h->lun_state == RDAC_LUN_UNOWNED)
|
|
|
|
act = 1;
|
|
|
|
break;
|
|
|
|
case RDAC_MODE_IOSHIP:
|
|
|
|
if ((h->lun_state == RDAC_LUN_UNOWNED) &&
|
|
|
|
(h->preferred == RDAC_PREFERRED))
|
|
|
|
act = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (act) {
|
2009-10-22 00:22:51 +08:00
|
|
|
err = queue_mode_select(sdev, fn, data);
|
|
|
|
if (err == SCSI_DH_OK)
|
|
|
|
return 0;
|
|
|
|
}
|
2008-05-02 05:49:52 +08:00
|
|
|
done:
|
2009-10-22 00:22:46 +08:00
|
|
|
if (fn)
|
|
|
|
fn(data, err);
|
|
|
|
return 0;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
|
2018-11-09 21:42:40 +08:00
|
|
|
static blk_status_t rdac_prep_fn(struct scsi_device *sdev, struct request *req)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
2015-08-27 20:16:59 +08:00
|
|
|
struct rdac_dh_data *h = sdev->handler_data;
|
2008-05-02 05:49:52 +08:00
|
|
|
|
|
|
|
if (h->state != RDAC_STATE_ACTIVE) {
|
2016-10-20 21:12:13 +08:00
|
|
|
req->rq_flags |= RQF_QUIET;
|
2018-11-09 21:42:40 +08:00
|
|
|
return BLK_STS_IOERR;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
|
2018-11-09 21:42:40 +08:00
|
|
|
return BLK_STS_OK;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
|
2021-04-16 06:08:11 +08:00
|
|
|
static enum scsi_disposition rdac_check_sense(struct scsi_device *sdev,
|
|
|
|
struct scsi_sense_hdr *sense_hdr)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
2015-08-27 20:16:59 +08:00
|
|
|
struct rdac_dh_data *h = sdev->handler_data;
|
2009-09-04 11:42:28 +08:00
|
|
|
|
|
|
|
RDAC_LOG(RDAC_LOG_SENSE, sdev, "array %s, ctlr %d, "
|
|
|
|
"I/O returned with sense %02x/%02x/%02x",
|
|
|
|
(char *) h->ctlr->array_name, h->ctlr->index,
|
|
|
|
sense_hdr->sense_key, sense_hdr->asc, sense_hdr->ascq);
|
|
|
|
|
2008-05-02 05:49:52 +08:00
|
|
|
switch (sense_hdr->sense_key) {
|
|
|
|
case NOT_READY:
|
2009-04-20 20:44:23 +08:00
|
|
|
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x01)
|
|
|
|
/* LUN Not Ready - Logical Unit Not Ready and is in
|
|
|
|
* the process of becoming ready
|
|
|
|
* Just retry.
|
|
|
|
*/
|
|
|
|
return ADD_TO_MLQUEUE;
|
2008-05-02 05:49:52 +08:00
|
|
|
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x81)
|
|
|
|
/* LUN Not Ready - Storage firmware incompatible
|
|
|
|
* Manual code synchonisation required.
|
|
|
|
*
|
|
|
|
* Nothing we can do here. Try to bypass the path.
|
|
|
|
*/
|
|
|
|
return SUCCESS;
|
|
|
|
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0xA1)
|
|
|
|
/* LUN Not Ready - Quiescense in progress
|
|
|
|
*
|
|
|
|
* Just retry and wait.
|
|
|
|
*/
|
2008-08-13 03:11:57 +08:00
|
|
|
return ADD_TO_MLQUEUE;
|
2009-03-17 21:21:40 +08:00
|
|
|
if (sense_hdr->asc == 0xA1 && sense_hdr->ascq == 0x02)
|
|
|
|
/* LUN Not Ready - Quiescense in progress
|
|
|
|
* or has been achieved
|
|
|
|
* Just retry.
|
|
|
|
*/
|
|
|
|
return ADD_TO_MLQUEUE;
|
2008-05-02 05:49:52 +08:00
|
|
|
break;
|
|
|
|
case ILLEGAL_REQUEST:
|
|
|
|
if (sense_hdr->asc == 0x94 && sense_hdr->ascq == 0x01) {
|
|
|
|
/* Invalid Request - Current Logical Unit Ownership.
|
|
|
|
* Controller is not the current owner of the LUN,
|
|
|
|
* Fail the path, so that the other path be used.
|
|
|
|
*/
|
|
|
|
h->state = RDAC_STATE_PASSIVE;
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case UNIT_ATTENTION:
|
|
|
|
if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00)
|
|
|
|
/*
|
|
|
|
* Power On, Reset, or Bus Device Reset, just retry.
|
2009-01-26 23:59:37 +08:00
|
|
|
*/
|
|
|
|
return ADD_TO_MLQUEUE;
|
|
|
|
if (sense_hdr->asc == 0x8b && sense_hdr->ascq == 0x02)
|
|
|
|
/*
|
|
|
|
* Quiescence in progress , just retry.
|
2008-05-02 05:49:52 +08:00
|
|
|
*/
|
2008-08-13 03:11:57 +08:00
|
|
|
return ADD_TO_MLQUEUE;
|
2008-05-02 05:49:52 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* success just means we do not care what scsi-ml does */
|
|
|
|
return SCSI_RETURN_NOT_HANDLED;
|
|
|
|
}
|
|
|
|
|
2015-08-27 20:16:59 +08:00
|
|
|
static int rdac_bus_attach(struct scsi_device *sdev)
|
2008-05-02 05:49:52 +08:00
|
|
|
{
|
|
|
|
struct rdac_dh_data *h;
|
2008-07-18 07:53:15 +08:00
|
|
|
int err;
|
2009-09-04 11:42:21 +08:00
|
|
|
char array_name[ARRAY_LABEL_LEN];
|
2011-07-21 05:18:56 +08:00
|
|
|
char array_id[UNIQUE_ID_LEN];
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2014-09-14 10:59:51 +08:00
|
|
|
h = kzalloc(sizeof(*h) , GFP_KERNEL);
|
2014-09-15 02:08:21 +08:00
|
|
|
if (!h)
|
2017-09-20 15:18:51 +08:00
|
|
|
return SCSI_DH_NOMEM;
|
2008-07-18 07:52:51 +08:00
|
|
|
h->lun = UNINITIALIZED_LUN;
|
|
|
|
h->state = RDAC_STATE_ACTIVE;
|
2008-07-18 07:53:15 +08:00
|
|
|
|
2011-07-21 05:18:56 +08:00
|
|
|
err = get_lun_info(sdev, h, array_name, array_id);
|
2008-07-18 07:53:15 +08:00
|
|
|
if (err != SCSI_DH_OK)
|
|
|
|
goto failed;
|
|
|
|
|
2011-07-21 05:18:56 +08:00
|
|
|
err = initialize_controller(sdev, h, array_name, array_id);
|
2008-07-18 07:53:15 +08:00
|
|
|
if (err != SCSI_DH_OK)
|
|
|
|
goto failed;
|
|
|
|
|
2009-09-04 11:42:15 +08:00
|
|
|
err = check_ownership(sdev, h);
|
|
|
|
if (err != SCSI_DH_OK)
|
|
|
|
goto clean_ctlr;
|
|
|
|
|
|
|
|
err = set_mode_select(sdev, h);
|
|
|
|
if (err != SCSI_DH_OK)
|
|
|
|
goto clean_ctlr;
|
|
|
|
|
2008-07-18 07:53:15 +08:00
|
|
|
sdev_printk(KERN_NOTICE, sdev,
|
2011-04-09 01:37:40 +08:00
|
|
|
"%s: LUN %d (%s) (%s)\n",
|
|
|
|
RDAC_NAME, h->lun, mode[(int)h->mode],
|
|
|
|
lun_state[(int)h->lun_state]);
|
2008-05-02 05:49:52 +08:00
|
|
|
|
2015-08-27 20:16:59 +08:00
|
|
|
sdev->handler_data = h;
|
2017-09-20 15:18:51 +08:00
|
|
|
return SCSI_DH_OK;
|
2008-07-18 07:53:15 +08:00
|
|
|
|
2009-09-04 11:42:15 +08:00
|
|
|
clean_ctlr:
|
2012-02-02 23:21:54 +08:00
|
|
|
spin_lock(&list_lock);
|
2009-09-04 11:42:15 +08:00
|
|
|
kref_put(&h->ctlr->kref, release_controller);
|
2012-02-02 23:21:54 +08:00
|
|
|
spin_unlock(&list_lock);
|
2009-09-04 11:42:15 +08:00
|
|
|
|
2008-07-18 07:53:15 +08:00
|
|
|
failed:
|
2014-09-14 10:59:51 +08:00
|
|
|
kfree(h);
|
2017-09-20 15:18:51 +08:00
|
|
|
return err;
|
2008-05-02 05:49:52 +08:00
|
|
|
}
|
|
|
|
|
2008-07-18 07:52:51 +08:00
|
|
|
static void rdac_bus_detach( struct scsi_device *sdev )
|
|
|
|
{
|
2015-08-27 20:16:59 +08:00
|
|
|
struct rdac_dh_data *h = sdev->handler_data;
|
2008-07-18 07:52:51 +08:00
|
|
|
|
2012-02-02 23:21:54 +08:00
|
|
|
if (h->ctlr && h->ctlr->ms_queued)
|
|
|
|
flush_workqueue(kmpath_rdacd);
|
|
|
|
|
|
|
|
spin_lock(&list_lock);
|
2016-03-03 14:54:10 +08:00
|
|
|
if (h->ctlr) {
|
|
|
|
list_del_rcu(&h->node);
|
2008-07-18 07:52:51 +08:00
|
|
|
kref_put(&h->ctlr->kref, release_controller);
|
2016-03-03 14:54:10 +08:00
|
|
|
}
|
2012-02-02 23:21:54 +08:00
|
|
|
spin_unlock(&list_lock);
|
2015-08-27 20:16:59 +08:00
|
|
|
sdev->handler_data = NULL;
|
2021-01-13 14:31:03 +08:00
|
|
|
synchronize_rcu();
|
2014-09-14 10:59:51 +08:00
|
|
|
kfree(h);
|
2008-07-18 07:52:51 +08:00
|
|
|
}
|
|
|
|
|
2014-09-15 02:08:21 +08:00
|
|
|
static struct scsi_device_handler rdac_dh = {
|
|
|
|
.name = RDAC_NAME,
|
|
|
|
.module = THIS_MODULE,
|
|
|
|
.prep_fn = rdac_prep_fn,
|
|
|
|
.check_sense = rdac_check_sense,
|
|
|
|
.attach = rdac_bus_attach,
|
|
|
|
.detach = rdac_bus_detach,
|
|
|
|
.activate = rdac_activate,
|
|
|
|
};
|
2008-07-18 07:52:51 +08:00
|
|
|
|
2008-05-02 05:49:52 +08:00
|
|
|
static int __init rdac_init(void)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = scsi_register_device_handler(&rdac_dh);
|
2009-10-22 00:22:51 +08:00
|
|
|
if (r != 0) {
|
2008-05-02 05:49:52 +08:00
|
|
|
printk(KERN_ERR "Failed to register scsi device handler.");
|
2009-10-22 00:22:51 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create workqueue to handle mode selects for rdac
|
|
|
|
*/
|
|
|
|
kmpath_rdacd = create_singlethread_workqueue("kmpath_rdacd");
|
|
|
|
if (!kmpath_rdacd) {
|
|
|
|
scsi_unregister_device_handler(&rdac_dh);
|
|
|
|
printk(KERN_ERR "kmpath_rdacd creation failed.\n");
|
2011-11-18 08:44:27 +08:00
|
|
|
|
|
|
|
r = -EINVAL;
|
2009-10-22 00:22:51 +08:00
|
|
|
}
|
|
|
|
done:
|
2008-05-02 05:49:52 +08:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit rdac_exit(void)
|
|
|
|
{
|
2009-10-22 00:22:51 +08:00
|
|
|
destroy_workqueue(kmpath_rdacd);
|
2008-05-02 05:49:52 +08:00
|
|
|
scsi_unregister_device_handler(&rdac_dh);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(rdac_init);
|
|
|
|
module_exit(rdac_exit);
|
|
|
|
|
2011-09-02 15:56:32 +08:00
|
|
|
MODULE_DESCRIPTION("Multipath LSI/Engenio/NetApp E-Series RDAC driver");
|
2008-05-02 05:49:52 +08:00
|
|
|
MODULE_AUTHOR("Mike Christie, Chandra Seetharaman");
|
2011-02-12 07:12:44 +08:00
|
|
|
MODULE_VERSION("01.00.0000.0000");
|
2008-05-02 05:49:52 +08:00
|
|
|
MODULE_LICENSE("GPL");
|