Print this page
NEX-3508 CLONE - Port NEX-2946 Add UNMAP/TRIM functionality to ZFS and illumos
Reviewed by: Josef Sipek <josef.sipek@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Conflicts:
usr/src/uts/common/io/scsi/targets/sd.c
usr/src/uts/common/sys/scsi/targets/sddef.h
NEX-3023 Panics and hangs when using write_same and compare_and_write
Review by: Bayard Bell <bayard.bell@nexenta.com>
Review by: Rick McNeal <rick.mcneal@nexenta.com>
Review by: Jean McCormack <jean.mccormack@nexenta.com>
Approved by: Jean McCormack <jean.mccormack@nexenta.com>
Related bug: NEX-2723 Kernel panic in xfer_completion code for write_same (0x93) and compare_and_write (0x89)
NEX-1965 Page fault at netbios_first_level_name_decode+0xbb
Support simultaneous compare_and_write operations for VAAI
Bug IDs SUP-505
SUP-1768
SUP-1928
Code Reviewers:
Sarah Jelinek
Jeffry Molanus
Albert Lee
Harold Shaw
OS-69 Open source VAAI
re #7936 rb3706 Support for COMSTAR/OEM
re #8002 rb3706 Allow setting iSCSI vendor ID via stmf_sbd.conf
re #11454 rb3750 Fix inconsistent vid/pid in stmf
8226 nza-kernel needs to be buildable by itself
Re #6790 backspace should perform delete on console
VAAI (XXX ATS support for COMSTAR, YYY Block-copy support for COMSTAR)
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/io/comstar/lu/stmf_sbd/stmf_sbd.h
+++ new/usr/src/uts/common/io/comstar/lu/stmf_sbd/stmf_sbd.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
|
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 +
21 22 /*
22 23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23 - *
24 - * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 + * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
25 25 */
26 26
27 27 #ifndef _STMF_SBD_H
28 28 #define _STMF_SBD_H
29 29
30 +#include <sys/dkio.h>
31 +
30 32 #ifdef __cplusplus
31 33 extern "C" {
32 34 #endif
33 35
34 36 typedef stmf_status_t sbd_status_t;
37 +#include "ats_copy_mgr.h"
35 38 extern char sbd_vendor_id[];
36 39 extern char sbd_product_id[];
37 40 extern char sbd_revision[];
38 41 extern char *sbd_mgmt_url;
39 42 extern uint16_t sbd_mgmt_url_alloc_size;
40 43 extern krwlock_t sbd_global_prop_lock;
41 44
42 45 /*
43 46 * Error codes
44 47 */
45 48 #define SBD_SUCCESS STMF_SUCCESS
46 49 #define SBD_FAILURE STMF_LU_FAILURE
|
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
47 50
48 51 #define SBD_ALREADY (SBD_FAILURE | STMF_FSC(1))
49 52 #define SBD_NOT_SUPPORTED (SBD_FAILURE | STMF_FSC(2))
50 53 #define SBD_META_CORRUPTED (SBD_FAILURE | STMF_FSC(3))
51 54 #define SBD_INVALID_ARG (SBD_FAILURE | STMF_FSC(4))
52 55 #define SBD_NOT_FOUND (SBD_FAILURE | STMF_FSC(5))
53 56 #define SBD_ALLOC_FAILURE (SBD_FAILURE | STMF_FSC(6))
54 57 #define SBD_FILEIO_FAILURE (SBD_FAILURE | STMF_FSC(7))
55 58 #define SBD_IO_PAST_EOF (SBD_FAILURE | STMF_FSC(8))
56 59 #define SBD_BUSY (SBD_FAILURE | STMF_FSC(9))
60 +#define SBD_COMPARE_FAILED (SBD_FAILURE | STMF_FSC(10))
57 61
58 62 #define SHARED_META_DATA_SIZE 65536
59 63 #define SBD_META_OFFSET 4096
60 64 #define SBD_MIN_LU_SIZE (1024 * 1024)
61 65
62 66 /*
63 67 * sms endianess
64 68 */
65 69 #define SMS_BIG_ENDIAN 0x00
66 70 #define SMS_LITTLE_ENDIAN 0xFF
67 71
68 72 #ifdef _BIG_ENDIAN
69 73 #define SMS_DATA_ORDER SMS_BIG_ENDIAN
70 74 #else
71 75 #define SMS_DATA_ORDER SMS_LITTLE_ENDIAN
72 76 #endif
73 77
74 78 #define SBD_MAGIC 0x53554e5342444c55
75 79
76 80 #define SBD_VER_MAJOR 1
77 81 #define SBD_VER_MINOR 1
78 82 #define SBD_VER_SUBMINOR 0
79 83
80 84 #if 0
81 85 typedef struct sbd_meta_start {
82 86 uint64_t sm_magic;
83 87 uint64_t sm_meta_size;
84 88 uint64_t sm_meta_size_used;
85 89 uint64_t sm_rsvd1; /* Defaults to zero */
86 90 uint64_t sm_rsvd2;
87 91 uint16_t sm_ver_major;
88 92 uint16_t sm_ver_minor;
89 93 uint16_t sm_ver_subminor;
90 94 uint8_t sm_flags;
91 95 uint8_t sm_chksum;
92 96 } sbd_meta_start_t;
93 97 #endif
94 98
95 99 typedef struct sm_section_hdr {
96 100 uint64_t sms_offset; /* Offset of this section */
97 101 uint32_t sms_size; /* Includes the header and padding */
98 102 uint16_t sms_id; /* Section identifier */
99 103 uint8_t sms_data_order; /* 0x00 or 0xff */
100 104 uint8_t sms_chksum;
101 105 } sm_section_hdr_t;
102 106
103 107 /*
104 108 * sbd meta section identifiers
105 109 */
106 110 #define SMS_ID_LU_INFO_1_0 0
107 111 #define SMS_ID_LU_INFO_1_1 1
108 112 #define SMS_ID_PGR_INFO 2
109 113 #define SMS_ID_UNUSED 0x1000
110 114
111 115 typedef struct sbd_lu_info_1_0 {
112 116 sm_section_hdr_t sli_sms_header;
113 117 uint64_t sli_total_store_size;
114 118 uint64_t sli_total_meta_size;
115 119 uint64_t sli_lu_data_offset;
116 120 uint64_t sli_lu_data_size;
117 121 uint32_t sli_flags;
118 122 uint16_t sli_blocksize;
119 123 uint8_t sli_data_order;
120 124 uint8_t rsvd1;
121 125 uint8_t sli_lu_devid[20];
122 126 uint32_t rsvd2;
123 127 } sbd_lu_info_1_0_t;
124 128
125 129 typedef struct sbd_lu_info_1_1 {
126 130 sm_section_hdr_t sli_sms_header;
127 131 uint32_t sli_flags;
128 132 char sli_rev[4];
129 133 char sli_vid[8];
130 134 char sli_pid[16];
131 135 uint64_t sli_lu_size; /* Read capacity size */
132 136
133 137 /*
134 138 * Essetially zfs volume name for zvols to verify that the
135 139 * metadata is coming in from the correct zvol and not from a
136 140 * clone. Has no meaning in any other case.
137 141 */
138 142 uint64_t sli_meta_fname_offset;
139 143
140 144 /*
141 145 * Data filename or the media filename when the metadata is in
142 146 * a separate file. Its not needed if the metadata is shared
143 147 * with data as the user supplied name is the data filename.
144 148 */
145 149 uint64_t sli_data_fname_offset;
146 150 uint64_t sli_serial_offset;
147 151 uint64_t sli_alias_offset;
148 152 uint8_t sli_data_blocksize_shift;
149 153 uint8_t sli_data_order;
150 154 uint8_t sli_serial_size;
151 155 uint8_t sli_rsvd1;
152 156 uint8_t sli_device_id[20];
153 157 uint64_t sli_mgmt_url_offset;
154 158 uint8_t sli_rsvd2[248];
155 159
156 160 /*
157 161 * In case there is no separate meta, sli_meta_fname_offset wont
158 162 * be valid. The same is true for zfs based metadata. The data_fname
159 163 * is the zvol.
160 164 */
161 165 uint8_t sli_buf[8];
162 166 } sbd_lu_info_1_1_t;
163 167
164 168 /*
165 169 * sli flags
166 170 */
167 171 #define SLI_SEPARATE_META 0x0001
168 172 #define SLI_WRITE_PROTECTED 0x0002
169 173 #define SLI_VID_VALID 0x0004
170 174 #define SLI_PID_VALID 0x0008
171 175 #define SLI_REV_VALID 0x0010
172 176 #define SLI_META_FNAME_VALID 0x0020
173 177 #define SLI_DATA_FNAME_VALID 0x0040
174 178 #define SLI_SERIAL_VALID 0x0080
175 179 #define SLI_ALIAS_VALID 0x0100
176 180 #define SLI_WRITEBACK_CACHE_DISABLE 0x0200
177 181 #define SLI_ZFS_META 0x0400
178 182 #define SLI_MGMT_URL_VALID 0x0800
179 183
180 184 struct sbd_it_data;
181 185
182 186 typedef struct sbd_lu {
183 187 struct sbd_lu *sl_next;
184 188 stmf_lu_t *sl_lu;
185 189 uint32_t sl_alloc_size;
186 190
187 191 /* Current LU state */
188 192 kmutex_t sl_lock;
189 193 uint32_t sl_flags;
190 194 uint8_t sl_trans_op;
191 195 uint8_t sl_state:7,
192 196 sl_state_not_acked:1;
193 197
194 198 char *sl_name; /* refers to meta or data */
195 199
196 200 /* Metadata */
197 201 kmutex_t sl_metadata_lock;
198 202 krwlock_t sl_access_state_lock;
199 203 char *sl_alias;
200 204 char *sl_meta_filename; /* If applicable */
201 205 char *sl_mgmt_url;
202 206 vnode_t *sl_meta_vp;
203 207 vtype_t sl_meta_vtype;
204 208 uint8_t sl_device_id[20]; /* 4(hdr) + 16(GUID) */
205 209 uint8_t sl_meta_blocksize_shift; /* Left shift multiplier */
206 210 uint8_t sl_data_blocksize_shift;
207 211 uint8_t sl_data_fs_nbits;
208 212 uint8_t sl_serial_no_size;
209 213 uint64_t sl_total_meta_size;
210 214 uint64_t sl_meta_size_used;
211 215 uint8_t *sl_serial_no; /* optional */
212 216 char sl_vendor_id[8];
213 217 char sl_product_id[16];
214 218 char sl_revision[4];
215 219 uint32_t sl_data_fname_alloc_size; /* for an explicit alloc */
216 220 uint16_t sl_alias_alloc_size;
217 221 uint16_t sl_mgmt_url_alloc_size;
218 222 uint8_t sl_serial_no_alloc_size;
219 223 uint8_t sl_access_state;
220 224 uint64_t sl_meta_offset;
221 225
222 226 /* zfs metadata */
223 227 krwlock_t sl_zfs_meta_lock;
224 228 char *sl_zfs_meta;
225 229 minor_t sl_zvol_minor; /* for direct zvol calls */
226 230 /* opaque handles for zvol direct calls */
227 231 void *sl_zvol_minor_hdl;
228 232 void *sl_zvol_objset_hdl;
229 233 void *sl_zvol_zil_hdl;
230 234 void *sl_zvol_rl_hdl;
231 235 void *sl_zvol_bonus_hdl;
232 236
233 237 /* Backing store */
234 238 char *sl_data_filename;
235 239 vnode_t *sl_data_vp;
236 240 vtype_t sl_data_vtype;
|
↓ open down ↓ |
170 lines elided |
↑ open up ↑ |
237 241 uint64_t sl_total_data_size;
238 242 uint64_t sl_data_readable_size; /* read() fails after this */
239 243 uint64_t sl_data_offset; /* After the metadata,if any */
240 244 uint64_t sl_lu_size; /* READ CAPACITY size */
241 245 uint64_t sl_blksize; /* used for zvols */
242 246 uint64_t sl_max_xfer_len; /* used for zvols */
243 247
244 248 struct sbd_it_data *sl_it_list;
245 249 struct sbd_pgr *sl_pgr;
246 250 uint64_t sl_rs_owner_session_id;
251 + list_t sl_ats_io_list;
247 252 } sbd_lu_t;
248 253
249 254 /*
250 255 * sl_flags
251 256 */
252 257 #define SL_LINKED 0x00000001
253 258 #define SL_META_OPENED 0x00000002
254 259 #define SL_REGISTERED 0x00000004
255 260 #define SL_META_NEEDS_FLUSH 0x00000008
256 261 #define SL_DATA_NEEDS_FLUSH 0x00000010
257 262 #define SL_VID_VALID 0x00000020
258 263 #define SL_PID_VALID 0x00000040
259 264 #define SL_REV_VALID 0x00000080
260 265 #define SL_WRITE_PROTECTED 0x00000100
261 266 #define SL_MEDIA_LOADED 0x00000200
262 267 #define SL_LU_HAS_SCSI2_RESERVATION 0x00000400
263 268 #define SL_WRITEBACK_CACHE_DISABLE 0x00000800
264 269 #define SL_SAVED_WRITE_CACHE_DISABLE 0x00001000
265 270 #define SL_MEDIUM_REMOVAL_PREVENTED 0x00002000
266 271 #define SL_NO_DATA_DKIOFLUSH 0x00004000
267 272 #define SL_SHARED_META 0x00008000
268 273 #define SL_ZFS_META 0x00010000
269 274 #define SL_WRITEBACK_CACHE_SET_UNSUPPORTED 0x00020000
270 275 #define SL_FLUSH_ON_DISABLED_WRITECACHE 0x00040000
271 276 #define SL_CALL_ZVOL 0x00080000
272 277 #define SL_UNMAP_ENABLED 0x00100000
273 278
274 279 /*
275 280 * sl_trans_op. LU is undergoing some transition and this field
276 281 * tells what kind of transition that is.
277 282 */
278 283 #define SL_OP_NONE 0
279 284 #define SL_OP_CREATE_REGISTER_LU 1
280 285 #define SL_OP_IMPORT_LU 2
281 286 #define SL_OP_DELETE_LU 3
282 287 #define SL_OP_MODIFY_LU 4
283 288 #define SL_OP_LU_PROPS 5
284 289
285 290 sbd_status_t sbd_data_read(sbd_lu_t *sl, scsi_task_t *task,
286 291 uint64_t offset, uint64_t size, uint8_t *buf);
287 292 sbd_status_t sbd_data_write(sbd_lu_t *sl, scsi_task_t *task,
288 293 uint64_t offset, uint64_t size, uint8_t *buf);
289 294 stmf_status_t sbd_task_alloc(struct scsi_task *task);
290 295 void sbd_new_task(struct scsi_task *task, struct stmf_data_buf *initial_dbuf);
291 296 void sbd_dbuf_xfer_done(struct scsi_task *task, struct stmf_data_buf *dbuf);
292 297 void sbd_send_status_done(struct scsi_task *task);
|
↓ open down ↓ |
36 lines elided |
↑ open up ↑ |
293 298 void sbd_task_free(struct scsi_task *task);
294 299 stmf_status_t sbd_abort(struct stmf_lu *lu, int abort_cmd, void *arg,
295 300 uint32_t flags);
296 301 void sbd_ctl(struct stmf_lu *lu, int cmd, void *arg);
297 302 stmf_status_t sbd_info(uint32_t cmd, stmf_lu_t *lu, void *arg, uint8_t *buf,
298 303 uint32_t *bufsizep);
299 304 sbd_status_t sbd_write_lu_info(sbd_lu_t *sl);
300 305 sbd_status_t sbd_flush_data_cache(sbd_lu_t *sl, int fsync_done);
301 306 sbd_status_t sbd_wcd_set(int wcd, sbd_lu_t *sl);
302 307 void sbd_wcd_get(int *wcd, sbd_lu_t *sl);
303 -int sbd_unmap(sbd_lu_t *, uint64_t, uint64_t);
308 +int sbd_unmap(sbd_lu_t *sl, dkioc_free_list_t *dfl);
304 309
310 +void sbd_handle_short_write_transfers(scsi_task_t *, stmf_data_buf_t *,
311 + uint32_t);
312 +void sbd_handle_short_read_transfers(scsi_task_t *, stmf_data_buf_t *,
313 + uint8_t *, uint32_t, uint32_t);
314 +
305 315 #ifdef __cplusplus
306 316 }
307 317 #endif
308 318
309 319 #endif /* _STMF_SBD_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX