diff options
author | Chandra Seetharaman <sekharan@us.ibm.com> | 2008-05-01 17:49:46 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-06-05 10:23:40 -0400 |
commit | a6a8d9f87eb8510a8f53672ea87703f62185d75f (patch) | |
tree | d166e14e3c035ae0e0f26329b2b3b0495046d234 /include/scsi | |
parent | 53c8ba95402be65d412a806cda3430f0e72cd107 (diff) |
[SCSI] scsi_dh: add infrastructure for SCSI Device Handlers
Some of the storage devices (that can be accessed through multiple paths),
do need some special handling for
1. Activating the passive path of the storage access.
2. Decode and handle the special sense codes returned by the devices.
3. Handle the I/Os being sent to the passive path, especially
during the device probe time.
when accessed through multiple paths.
As of today this special device handling is done at the dm-multipath
layer using dm-handlers. That works well for (1); for (2) to be handled
at dm layer, scsi sense information need to be exported from SCSI to dm-layer,
which is not very attractive; (3) cannot be done at all at the dm layer.
Device handler has been moved to SCSI mainly to handle (2) and (3) properly.
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Mike Anderson <andmike@linux.vnet.ibm.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'include/scsi')
-rw-r--r-- | include/scsi/scsi.h | 1 | ||||
-rw-r--r-- | include/scsi/scsi_device.h | 22 | ||||
-rw-r--r-- | include/scsi/scsi_dh.h | 59 |
3 files changed, 82 insertions, 0 deletions
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 32742c4563de..2b5b9356c314 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h | |||
@@ -400,6 +400,7 @@ struct scsi_lun { | |||
400 | #define SOFT_ERROR 0x2005 | 400 | #define SOFT_ERROR 0x2005 |
401 | #define ADD_TO_MLQUEUE 0x2006 | 401 | #define ADD_TO_MLQUEUE 0x2006 |
402 | #define TIMEOUT_ERROR 0x2007 | 402 | #define TIMEOUT_ERROR 0x2007 |
403 | #define SCSI_RETURN_NOT_HANDLED 0x2008 | ||
403 | 404 | ||
404 | /* | 405 | /* |
405 | * Midlevel queue return values. | 406 | * Midlevel queue return values. |
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index f6a9fe0ef09c..06b979f105b7 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h | |||
@@ -161,9 +161,29 @@ struct scsi_device { | |||
161 | 161 | ||
162 | struct execute_work ew; /* used to get process context on put */ | 162 | struct execute_work ew; /* used to get process context on put */ |
163 | 163 | ||
164 | struct scsi_dh_data *scsi_dh_data; | ||
164 | enum scsi_device_state sdev_state; | 165 | enum scsi_device_state sdev_state; |
165 | unsigned long sdev_data[0]; | 166 | unsigned long sdev_data[0]; |
166 | } __attribute__((aligned(sizeof(unsigned long)))); | 167 | } __attribute__((aligned(sizeof(unsigned long)))); |
168 | |||
169 | struct scsi_device_handler { | ||
170 | /* Used by the infrastructure */ | ||
171 | struct list_head list; /* list of scsi_device_handlers */ | ||
172 | struct notifier_block nb; | ||
173 | |||
174 | /* Filled by the hardware handler */ | ||
175 | struct module *module; | ||
176 | const char *name; | ||
177 | int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *); | ||
178 | int (*activate)(struct scsi_device *); | ||
179 | int (*prep_fn)(struct scsi_device *, struct request *); | ||
180 | }; | ||
181 | |||
182 | struct scsi_dh_data { | ||
183 | struct scsi_device_handler *scsi_dh; | ||
184 | char buf[0]; | ||
185 | }; | ||
186 | |||
167 | #define to_scsi_device(d) \ | 187 | #define to_scsi_device(d) \ |
168 | container_of(d, struct scsi_device, sdev_gendev) | 188 | container_of(d, struct scsi_device, sdev_gendev) |
169 | #define class_to_sdev(d) \ | 189 | #define class_to_sdev(d) \ |
@@ -230,7 +250,9 @@ extern struct scsi_device *__scsi_add_device(struct Scsi_Host *, | |||
230 | uint, uint, uint, void *hostdata); | 250 | uint, uint, uint, void *hostdata); |
231 | extern int scsi_add_device(struct Scsi_Host *host, uint channel, | 251 | extern int scsi_add_device(struct Scsi_Host *host, uint channel, |
232 | uint target, uint lun); | 252 | uint target, uint lun); |
253 | extern int scsi_register_device_handler(struct scsi_device_handler *scsi_dh); | ||
233 | extern void scsi_remove_device(struct scsi_device *); | 254 | extern void scsi_remove_device(struct scsi_device *); |
255 | extern int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh); | ||
234 | 256 | ||
235 | extern int scsi_device_get(struct scsi_device *); | 257 | extern int scsi_device_get(struct scsi_device *); |
236 | extern void scsi_device_put(struct scsi_device *); | 258 | extern void scsi_device_put(struct scsi_device *); |
diff --git a/include/scsi/scsi_dh.h b/include/scsi/scsi_dh.h new file mode 100644 index 000000000000..04d0d8495c83 --- /dev/null +++ b/include/scsi/scsi_dh.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | * Header file for SCSI device handler infrastruture. | ||
3 | * | ||
4 | * Modified version of patches posted by Mike Christie <michaelc@cs.wisc.edu> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | * | ||
20 | * Copyright IBM Corporation, 2007 | ||
21 | * Authors: | ||
22 | * Chandra Seetharaman <sekharan@us.ibm.com> | ||
23 | * Mike Anderson <andmike@linux.vnet.ibm.com> | ||
24 | */ | ||
25 | |||
26 | #include <scsi/scsi_device.h> | ||
27 | |||
28 | enum { | ||
29 | SCSI_DH_OK = 0, | ||
30 | /* | ||
31 | * device errors | ||
32 | */ | ||
33 | SCSI_DH_DEV_FAILED, /* generic device error */ | ||
34 | SCSI_DH_DEV_TEMP_BUSY, | ||
35 | SCSI_DH_DEVICE_MAX, /* max device blkerr definition */ | ||
36 | |||
37 | /* | ||
38 | * transport errors | ||
39 | */ | ||
40 | SCSI_DH_NOTCONN = SCSI_DH_DEVICE_MAX + 1, | ||
41 | SCSI_DH_CONN_FAILURE, | ||
42 | SCSI_DH_TRANSPORT_MAX, /* max transport blkerr definition */ | ||
43 | |||
44 | /* | ||
45 | * driver and generic errors | ||
46 | */ | ||
47 | SCSI_DH_IO = SCSI_DH_TRANSPORT_MAX + 1, /* generic error */ | ||
48 | SCSI_DH_INVALID_IO, | ||
49 | SCSI_DH_RETRY, /* retry the req, but not immediately */ | ||
50 | SCSI_DH_IMM_RETRY, /* immediately retry the req */ | ||
51 | SCSI_DH_TIMED_OUT, | ||
52 | SCSI_DH_RES_TEMP_UNAVAIL, | ||
53 | SCSI_DH_DEV_OFFLINED, | ||
54 | SCSI_DH_NOSYS, | ||
55 | SCSI_DH_DRIVER_MAX, | ||
56 | }; | ||
57 | |||
58 | extern int scsi_dh_activate(struct request_queue *); | ||
59 | extern int scsi_dh_handler_exist(const char *); | ||