diff options
Diffstat (limited to 'include/scsi/osd_initiator.h')
-rw-r--r-- | include/scsi/osd_initiator.h | 82 |
1 files changed, 70 insertions, 12 deletions
diff --git a/include/scsi/osd_initiator.h b/include/scsi/osd_initiator.h index 02bd9f716357..a8f370126632 100644 --- a/include/scsi/osd_initiator.h +++ b/include/scsi/osd_initiator.h | |||
@@ -48,7 +48,6 @@ enum osd_std_version { | |||
48 | */ | 48 | */ |
49 | struct osd_dev { | 49 | struct osd_dev { |
50 | struct scsi_device *scsi_device; | 50 | struct scsi_device *scsi_device; |
51 | struct file *file; | ||
52 | unsigned def_timeout; | 51 | unsigned def_timeout; |
53 | 52 | ||
54 | #ifdef OSD_VER1_SUPPORT | 53 | #ifdef OSD_VER1_SUPPORT |
@@ -56,10 +55,24 @@ struct osd_dev { | |||
56 | #endif | 55 | #endif |
57 | }; | 56 | }; |
58 | 57 | ||
59 | /* Retrieve/return osd_dev(s) for use by Kernel clients */ | 58 | /* Unique Identification of an OSD device */ |
60 | struct osd_dev *osduld_path_lookup(const char *dev_name); /*Use IS_ERR/ERR_PTR*/ | 59 | struct osd_dev_info { |
60 | unsigned systemid_len; | ||
61 | u8 systemid[OSD_SYSTEMID_LEN]; | ||
62 | unsigned osdname_len; | ||
63 | u8 *osdname; | ||
64 | }; | ||
65 | |||
66 | /* Retrieve/return osd_dev(s) for use by Kernel clients | ||
67 | * Use IS_ERR/ERR_PTR on returned "osd_dev *". | ||
68 | */ | ||
69 | struct osd_dev *osduld_path_lookup(const char *dev_name); | ||
70 | struct osd_dev *osduld_info_lookup(const struct osd_dev_info *odi); | ||
61 | void osduld_put_device(struct osd_dev *od); | 71 | void osduld_put_device(struct osd_dev *od); |
62 | 72 | ||
73 | const struct osd_dev_info *osduld_device_info(struct osd_dev *od); | ||
74 | bool osduld_device_same(struct osd_dev *od, const struct osd_dev_info *odi); | ||
75 | |||
63 | /* Add/remove test ioctls from external modules */ | 76 | /* Add/remove test ioctls from external modules */ |
64 | typedef int (do_test_fn)(struct osd_dev *od, unsigned cmd, unsigned long arg); | 77 | typedef int (do_test_fn)(struct osd_dev *od, unsigned cmd, unsigned long arg); |
65 | int osduld_register_test(unsigned ioctl, do_test_fn *do_test); | 78 | int osduld_register_test(unsigned ioctl, do_test_fn *do_test); |
@@ -69,8 +82,24 @@ void osduld_unregister_test(unsigned ioctl); | |||
69 | void osd_dev_init(struct osd_dev *od, struct scsi_device *scsi_device); | 82 | void osd_dev_init(struct osd_dev *od, struct scsi_device *scsi_device); |
70 | void osd_dev_fini(struct osd_dev *od); | 83 | void osd_dev_fini(struct osd_dev *od); |
71 | 84 | ||
72 | /* some hi level device operations */ | 85 | /** |
73 | int osd_auto_detect_ver(struct osd_dev *od, void *caps); /* GFP_KERNEL */ | 86 | * osd_auto_detect_ver - Detect the OSD version, return Unique Identification |
87 | * | ||
88 | * @od: OSD target lun handle | ||
89 | * @caps: Capabilities authorizing OSD root read attributes access | ||
90 | * @odi: Retrieved information uniquely identifying the osd target lun | ||
91 | * Note: odi->osdname must be kfreed by caller. | ||
92 | * | ||
93 | * Auto detects the OSD version of the OSD target and sets the @od | ||
94 | * accordingly. Meanwhile also returns the "system id" and "osd name" root | ||
95 | * attributes which uniquely identify the OSD target. This member is usually | ||
96 | * called by the ULD. ULD users should call osduld_device_info(). | ||
97 | * This rutine allocates osd requests and memory at GFP_KERNEL level and might | ||
98 | * sleep. | ||
99 | */ | ||
100 | int osd_auto_detect_ver(struct osd_dev *od, | ||
101 | void *caps, struct osd_dev_info *odi); | ||
102 | |||
74 | static inline struct request_queue *osd_request_queue(struct osd_dev *od) | 103 | static inline struct request_queue *osd_request_queue(struct osd_dev *od) |
75 | { | 104 | { |
76 | return od->scsi_device->request_queue; | 105 | return od->scsi_device->request_queue; |
@@ -84,6 +113,15 @@ static inline void osd_dev_set_ver(struct osd_dev *od, enum osd_std_version v) | |||
84 | #endif | 113 | #endif |
85 | } | 114 | } |
86 | 115 | ||
116 | static inline bool osd_dev_is_ver1(struct osd_dev *od) | ||
117 | { | ||
118 | #ifdef OSD_VER1_SUPPORT | ||
119 | return od->version == OSD_VER1; | ||
120 | #else | ||
121 | return false; | ||
122 | #endif | ||
123 | } | ||
124 | |||
87 | struct osd_request; | 125 | struct osd_request; |
88 | typedef void (osd_req_done_fn)(struct osd_request *or, void *private); | 126 | typedef void (osd_req_done_fn)(struct osd_request *or, void *private); |
89 | 127 | ||
@@ -104,6 +142,7 @@ struct osd_request { | |||
104 | struct _osd_io_info { | 142 | struct _osd_io_info { |
105 | struct bio *bio; | 143 | struct bio *bio; |
106 | u64 total_bytes; | 144 | u64 total_bytes; |
145 | u64 residual; | ||
107 | struct request *req; | 146 | struct request *req; |
108 | struct _osd_req_data_segment *last_seg; | 147 | struct _osd_req_data_segment *last_seg; |
109 | u8 *pad_buff; | 148 | u8 *pad_buff; |
@@ -112,22 +151,19 @@ struct osd_request { | |||
112 | gfp_t alloc_flags; | 151 | gfp_t alloc_flags; |
113 | unsigned timeout; | 152 | unsigned timeout; |
114 | unsigned retries; | 153 | unsigned retries; |
154 | unsigned sense_len; | ||
115 | u8 sense[OSD_MAX_SENSE_LEN]; | 155 | u8 sense[OSD_MAX_SENSE_LEN]; |
116 | enum osd_attributes_mode attributes_mode; | 156 | enum osd_attributes_mode attributes_mode; |
117 | 157 | ||
118 | osd_req_done_fn *async_done; | 158 | osd_req_done_fn *async_done; |
119 | void *async_private; | 159 | void *async_private; |
120 | int async_error; | 160 | int async_error; |
161 | int req_errors; | ||
121 | }; | 162 | }; |
122 | 163 | ||
123 | /* OSD Version control */ | ||
124 | static inline bool osd_req_is_ver1(struct osd_request *or) | 164 | static inline bool osd_req_is_ver1(struct osd_request *or) |
125 | { | 165 | { |
126 | #ifdef OSD_VER1_SUPPORT | 166 | return osd_dev_is_ver1(or->osd_dev); |
127 | return or->osd_dev->version == OSD_VER1; | ||
128 | #else | ||
129 | return false; | ||
130 | #endif | ||
131 | } | 167 | } |
132 | 168 | ||
133 | /* | 169 | /* |
@@ -234,7 +270,7 @@ int osd_execute_request_async(struct osd_request *or, | |||
234 | * @bad_attr_list - List of failing attributes (optional) | 270 | * @bad_attr_list - List of failing attributes (optional) |
235 | * @max_attr - Size of @bad_attr_list. | 271 | * @max_attr - Size of @bad_attr_list. |
236 | * | 272 | * |
237 | * After execution, sense + return code can be analyzed using this function. The | 273 | * After execution, osd_request results are analyzed using this function. The |
238 | * return code is the final disposition on the error. So it is possible that a | 274 | * return code is the final disposition on the error. So it is possible that a |
239 | * CHECK_CONDITION was returned from target but this will return NO_ERROR, for | 275 | * CHECK_CONDITION was returned from target but this will return NO_ERROR, for |
240 | * example on recovered errors. All parameters are optional if caller does | 276 | * example on recovered errors. All parameters are optional if caller does |
@@ -243,7 +279,29 @@ int osd_execute_request_async(struct osd_request *or, | |||
243 | * of the SCSI_OSD_DPRINT_SENSE Kconfig value. Set @silent if you know the | 279 | * of the SCSI_OSD_DPRINT_SENSE Kconfig value. Set @silent if you know the |
244 | * command would routinely fail, to not spam the dmsg file. | 280 | * command would routinely fail, to not spam the dmsg file. |
245 | */ | 281 | */ |
282 | |||
283 | /** | ||
284 | * osd_err_priority - osd categorized return codes in ascending severity. | ||
285 | * | ||
286 | * The categories are borrowed from the pnfs_osd_errno enum. | ||
287 | * See comments for translated Linux codes returned by osd_req_decode_sense. | ||
288 | */ | ||
289 | enum osd_err_priority { | ||
290 | OSD_ERR_PRI_NO_ERROR = 0, | ||
291 | /* Recoverable, caller should clear_highpage() all pages */ | ||
292 | OSD_ERR_PRI_CLEAR_PAGES = 1, /* -EFAULT */ | ||
293 | OSD_ERR_PRI_RESOURCE = 2, /* -ENOMEM */ | ||
294 | OSD_ERR_PRI_BAD_CRED = 3, /* -EINVAL */ | ||
295 | OSD_ERR_PRI_NO_ACCESS = 4, /* -EACCES */ | ||
296 | OSD_ERR_PRI_UNREACHABLE = 5, /* any other */ | ||
297 | OSD_ERR_PRI_NOT_FOUND = 6, /* -ENOENT */ | ||
298 | OSD_ERR_PRI_NO_SPACE = 7, /* -ENOSPC */ | ||
299 | OSD_ERR_PRI_EIO = 8, /* -EIO */ | ||
300 | }; | ||
301 | |||
246 | struct osd_sense_info { | 302 | struct osd_sense_info { |
303 | enum osd_err_priority osd_err_pri; | ||
304 | |||
247 | int key; /* one of enum scsi_sense_keys */ | 305 | int key; /* one of enum scsi_sense_keys */ |
248 | int additional_code ; /* enum osd_additional_sense_codes */ | 306 | int additional_code ; /* enum osd_additional_sense_codes */ |
249 | union { /* Sense specific information */ | 307 | union { /* Sense specific information */ |