Print this page
NEX-14754 sd: get rid of ssd cruft
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Revert "Revert "6602 lofi should support labeled devices""
This reverts commit 21386c8bd8477810b291eee22e08f1382e70cdf3.
Revert "6602 lofi should support labeled devices"
This reverts commit 406fc5100dac8d225a315a6def6be8d628f34e24.
OS-92 NexentaStor 4.0.1-PASSIV-12022013: Cannot mount root after install
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/cmlb.h
+++ new/usr/src/uts/common/sys/cmlb.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 - * Copyright 2016 Toomas Soome <tsoome@me.com>
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 +/*
28 + * Copyright 2016 Toomas Soome <tsoome@me.com>
29 + * Copyright 2017 Nexenta Systems, Inc.
30 + */
31 +
27 32 #ifndef _SYS_CMLB_H
28 33 #define _SYS_CMLB_H
29 34
30 35 #ifdef __cplusplus
31 36 extern "C" {
32 37 #endif
33 38
34 39 #include <sys/dktp/fdisk.h>
40 +#include <sys/sunddi.h>
35 41
36 42 /*
37 43 * structure used for getting phygeom and virtgeom from target driver
38 44 */
39 45 typedef struct cmlb_geom {
40 46 unsigned int g_ncyl;
41 47 unsigned short g_acyl;
42 48 unsigned short g_nhead;
43 49 unsigned short g_nsect;
44 50 unsigned short g_secsize;
45 51 diskaddr_t g_capacity;
46 52 unsigned short g_intrlv;
47 53 unsigned short g_rpm;
48 54 } cmlb_geom_t;
49 55
50 56
51 57 typedef struct tg_attribute {
52 58 int media_is_writable;
53 59 int media_is_solid_state;
54 60 int media_is_rotational;
55 61 } tg_attribute_t;
56 62
57 63
58 64
59 65 /* bit definitions for alter_behavior passed to cmlb_attach */
60 66
61 67 #define CMLB_CREATE_ALTSLICE_VTOC_16_DTYPE_DIRECT 0x00000001
62 68 #define CMLB_FAKE_GEOM_LABEL_IOCTLS_VTOC8 0x00000002
63 69 #define CMLB_OFF_BY_ONE 0x00000004
64 70 #define CMLB_FAKE_LABEL_ONE_PARTITION 0x00000008
65 71 #define CMLB_INTERNAL_MINOR_NODES 0x00000010
66 72 #define CMLB_CREATE_P0_MINOR_NODE 0x00000020
67 73
68 74 /* bit definitions of flag passed to cmlb_validate */
69 75 #define CMLB_SILENT 0x00000001
70 76
71 77 /* version for tg_ops */
72 78 #define TG_DK_OPS_VERSION_0 0
73 79 #define TG_DK_OPS_VERSION_1 1
74 80
75 81 /* definitions for cmd passed to tg_rdwr */
76 82 #define TG_READ 0
77 83 #define TG_WRITE 1
78 84
79 85 /* definitions for cmd passed to tg_getinfo */
80 86 #define TG_GETPHYGEOM 1
81 87 #define TG_GETVIRTGEOM 2
82 88 #define TG_GETCAPACITY 3
83 89 #define TG_GETBLOCKSIZE 4
84 90 #define TG_GETATTR 5
85 91
86 92 #if defined(_SUNOS_VTOC_8)
87 93
88 94 #define CMLBUNIT_DFT_SHIFT 3
89 95 /* This will support p0 node on sparc */
90 96 #define CMLBUNIT_FORCE_P0_SHIFT (CMLBUNIT_DFT_SHIFT + 1)
91 97
92 98 #elif defined(_SUNOS_VTOC_16)
93 99
94 100 #define CMLBUNIT_DFT_SHIFT 6
95 101 #define CMLBUNIT_FORCE_P0_SHIFT (CMLBUNIT_DFT_SHIFT)
96 102
97 103 #else /* defined(_SUNOS_VTOC_16) */
98 104
99 105 #error "No VTOC format defined."
100 106
101 107 #endif /* defined(_SUNOS_VTOC_8) */
102 108
103 109 /*
104 110 * Ops vector including utility functions into target driver that cmlb uses.
105 111 */
106 112 typedef struct cmlb_tg_ops {
107 113 int tg_version;
108 114
109 115 /*
110 116 * tg_rdwr:
111 117 * perform read/write on target device associated with devi.
112 118 *
113 119 * Arguments:
114 120 *
115 121 * devi: pointer to device's dev_info structure.
116 122 *
117 123 * cmd: operation to perform.
118 124 * Possible values: TG_READ, TG_WRITE
119 125 *
120 126 * bufp: pointer to allocated buffer for transfer
121 127 *
122 128 * start_block: starting block number to read/write (based on
123 129 * system blocksize, DEV_BSIZE)
124 130 *
125 131 * reqlength: requested transfer length (in bytes)
126 132 *
127 133 * tg_cookie cookie from target driver to be passed back to
128 134 * target driver when we call back to it through
129 135 * tg_ops.
130 136 *
131 137 * Note: It is the responsibility of caller to make sure
132 138 * length of buffer pointed to by bufp is at least equal to
133 139 * requested transfer length
134 140 *
135 141 * Return values:
136 142 * 0 success
137 143 * ENOMEM can not allocate memory
138 144 * EACCESS reservation conflict
139 145 * EIO I/O error
140 146 * EFAULT copyin/copyout error
141 147 * ENXIO internal error/ invalid devi
142 148 * EINVAL invalid command value.
143 149 */
144 150 int (*tg_rdwr)(dev_info_t *devi, uchar_t cmd, void *bufp,
145 151 diskaddr_t start_block, size_t reqlength, void *tg_cookie);
146 152
147 153 /*
148 154 * tg_getinfo:
149 155 * Report the information requested on device/media and
150 156 * store the requested info in area pointed to by arg.
151 157 *
152 158 * Arguments:
153 159 * devi: pointer to device's dev_info structure.
154 160 *
155 161 * cmd: operation to perform
156 162 *
157 163 * arg: arg for the operation for result.
158 164 *
159 165 * tg_cookie cookie from target driver to be passed back to
160 166 * target driver when we call back to it through
161 167 * tg_ops.
162 168 *
163 169 * Possible commands and the interpretation of arg:
164 170 *
165 171 * cmd:
166 172 * TG_GETPHYGEOM
167 173 * Obtain raw physical geometry from target,
168 174 * and store in structure pointed to by arg,
169 175 * a cmlb_geom_t structure.
170 176 *
171 177 * TG_GETVIRTGEOM:
172 178 * Obtain HBA geometry for the target and
173 179 * store in struct pointed to by arg,
174 180 * a cmlb_geom_t structure.
175 181 *
176 182 * TG_GETCAPACITY:
177 183 * Report the capacity of the target (in system
178 184 * blocksize (DEV_BSIZE) and store in the
179 185 * space pointed to by arg, a diskaddr_t.
180 186 *
181 187 * TG_GETBLOCKSIZE:
182 188 * Report the block size of the target
183 189 * in the space pointed to by arg, a uint32_t.
184 190 *
185 191 * TG_GETATTR:
186 192 * Report the information requested on
187 193 * device/media and store in area pointed to by
188 194 * arg, a tg_attribute_t structure.
189 195 * Return values:
190 196 *
191 197 * Return values:
192 198 * 0 success
193 199 *
194 200 * EACCESS reservation conflict
195 201 *
196 202 * ENXIO internal error/invalid devi
197 203 *
198 204 * EINVAL When command is TG_GETPHYGEOM or
199 205 * TG_GETVIRTGEOM, or TG_GETATTR, this return code
200 206 * indicates the operation is not applicable to
201 207 * target.
202 208 * In case of TG_GETCAP, this return code
203 209 * indicates no media in the drive.
204 210 *
205 211 * EIO An error occurred during obtaining info
206 212 * from device/media.
207 213 *
208 214 * ENOTSUP In case of TG_GETCAP, target does not
209 215 * support getting capacity info.
210 216 *
211 217 * ENOTTY Unknown command.
212 218 *
213 219 *
214 220 */
215 221 int (*tg_getinfo)(dev_info_t *devi, int cmd, void *arg,
216 222 void *tg_cookie);
217 223
218 224 } cmlb_tg_ops_t;
219 225
220 226
221 227 typedef struct __cmlb_handle *cmlb_handle_t;
222 228
223 229 /*
224 230 *
225 231 * Functions exported from cmlb
226 232 *
227 233 * Note: Most these functions can callback to target driver through the
228 234 * tg_ops functions. Target driver should consider this for synchronization.
229 235 * Any functions that may adjust minor nodes should be called when
230 236 * the target driver ensures it is safe to do so.
231 237 */
232 238
233 239 /*
234 240 * cmlb_alloc_handle:
235 241 *
236 242 * Allocates a handle.
237 243 *
238 244 * Arguments:
239 245 * cmlbhandlep pointer to handle
240 246 *
241 247 * Notes:
242 248 * Allocates a handle and stores the allocated handle in the area
243 249 * pointed to by cmlbhandlep
244 250 *
245 251 * Context:
246 252 * Kernel thread only (can sleep).
247 253 */
248 254 void
249 255 cmlb_alloc_handle(cmlb_handle_t *cmlbhandlep);
250 256
251 257
252 258 /*
253 259 * cmlb_attach:
254 260 *
255 261 * Attach handle to device, create minor nodes for device.
256 262 *
257 263 *
258 264 * Arguments:
259 265 * devi pointer to device's dev_info structure.
260 266 * tgopsp pointer to array of functions cmlb can use to callback
261 267 * to target driver.
262 268 *
263 269 * device_type Peripheral device type as defined in
264 270 * scsi/generic/inquiry.h
265 271 *
266 272 * is_removable whether or not device is removable.
267 273 *
268 274 * is_hotpluggable whether or not device is hotpluggable.
269 275 *
270 276 * node_type minor node type (as used by ddi_create_minor_node)
271 277 *
272 278 * alter_behavior
273 279 * bit flags:
274 280 *
275 281 * CMLB_CREATE_ALTSLICE_VTOC_16_DTYPE_DIRECT: create
276 282 * an alternate slice for the default label, if
277 283 * device type is DTYPE_DIRECT an architectures default
278 284 * label type is VTOC16.
279 285 * Otherwise alternate slice will no be created.
280 286 *
281 287 *
282 288 * CMLB_FAKE_GEOM_LABEL_IOCTLS_VTOC8: report a default
283 289 * geometry and label for DKIOCGGEOM and DKIOCGVTOC
284 290 * on architecture with VTOC 8 label types.
285 291 *
286 292 * CMLB_OFF_BY_ONE: do the workaround for legacy off-by-
287 293 * one bug in obtaining capacity (used for sd).
288 294 *
289 295 *
290 296 * cmlbhandle cmlb handle associated with device
291 297 *
292 298 * tg_cookie cookie from target driver to be passed back to target
293 299 * driver when we call back to it through tg_ops.
294 300 *
295 301 * cmlb does not interpret the values. It is currently
296 302 * used for sd to indicate whether retries are allowed
297 303 * on commands or not. e.g when cmlb entries are called
298 304 * from interrupt context on removable media, sd rather
299 305 * not have retries done.
300 306 *
301 307 *
302 308 *
303 309 * Notes:
304 310 * Assumes a default label based on capacity for non-removable devices.
305 311 * If capacity > 1TB, EFI is assumed otherwise VTOC (default VTOC
306 312 * for the architecture).
307 313 * For removable devices, default label type is assumed to be VTOC
308 314 * type. Create minor nodes based on a default label type.
309 315 * Label on the media is not validated.
310 316 * minor number consists of:
311 317 * if _SUNOS_VTOC_8 is defined
312 318 * lowest 3 bits is taken as partition number
313 319 * the rest is instance number
314 320 * if _SUNOS_VTOC_16 is defined
315 321 * lowest 6 bits is taken as partition number
316 322 * the rest is instance number
317 323 *
318 324 *
319 325 * Return values:
320 326 * 0 Success
321 327 * ENXIO creating minor nodes failed.
|
↓ open down ↓ |
277 lines elided |
↑ open up ↑ |
322 328 * EINVAL invalid arg, unsupported tg_ops version
323 329 *
324 330 */
325 331 int
326 332 cmlb_attach(dev_info_t *devi, cmlb_tg_ops_t *tgopsp, int device_type,
327 333 boolean_t is_removable, boolean_t is_hotpluggable, char *node_type,
328 334 int alter_behavior, cmlb_handle_t cmlbhandle, void *tg_cookie);
329 335
330 336
331 337 /*
338 + * cmlb_workaround_off_by_one:
339 + *
340 + * Enables the workaround for the ancient off-by-one bug in sd.
341 + * See comment preceding cmlb_attach().
342 + *
343 + * Arguments
344 + * cmlbhandle cmlb handle associated with device.
345 + *
346 + *
347 + * Notes:
348 + * This should only be called by sd_unit_attach(), and only before
349 + * validating the label for the first time.
350 + *
351 + * Return values:
352 + * None.
353 + */
354 +void
355 +cmlb_workaround_off_by_one(cmlb_handle_t cmlbhandle);
356 +
357 +/*
332 358 * cmlb_validate:
333 359 *
334 360 * Validates label.
335 361 *
336 362 * Arguments
337 363 * cmlbhandle cmlb handle associated with device.
338 364 *
339 365 * int flags
340 366 * currently used for verbosity control.
341 367 * CMLB_SILENT is the only current definition for it
342 368 * tg_cookie cookie from target driver to be passed back to target
343 369 * driver when we call back to it through tg_ops.
344 370 * Notes:
345 371 * If new label type is different from the current, adjust minor nodes
346 372 * accordingly.
347 373 *
348 374 * Return values:
349 375 * 0 success
350 376 * Note: having fdisk but no solaris partition is assumed
351 377 * success.
352 378 *
353 379 * ENOMEM memory allocation failed
354 380 * EIO i/o errors during read or get capacity
355 381 * EACCESS reservation conflicts
356 382 * EINVAL label was corrupt, or no default label was assumed
357 383 * ENXIO invalid handle
358 384 *
359 385 */
360 386 int
361 387 cmlb_validate(cmlb_handle_t cmlbhandle, int flags, void *tg_cookie);
362 388
363 389 /*
364 390 * cmlb_invalidate:
365 391 * Invalidate in core label data
366 392 *
367 393 * Arguments:
368 394 * cmlbhandle cmlb handle associated with device.
369 395 * tg_cookie cookie from target driver to be passed back to target
370 396 * driver when we call back to it through tg_ops.
371 397 */
372 398 void
373 399 cmlb_invalidate(cmlb_handle_t cmlbhandle, void *tg_cookie);
374 400
375 401
376 402
377 403 /*
378 404 * cmlb_is_valid
379 405 * Get status on whether the incore label/geom data is valid
380 406 *
381 407 * Arguments:
382 408 * cmlbhandle cmlb handle associated with device.
383 409 *
384 410 * Return values:
385 411 * TRUE if valid
386 412 * FALSE otherwise.
387 413 *
388 414 */
389 415 boolean_t
390 416 cmlb_is_valid(cmlb_handle_t cmlbhandle);
391 417
392 418 /*
393 419 * cmlb_partinfo:
394 420 * Get partition info for specified partition number.
395 421 *
396 422 * Arguments:
397 423 * cmlbhandle cmlb handle associated with device.
398 424 * part partition number
399 425 * driver when we call back to it through tg_ops.
400 426 * nblocksp pointer to number of blocks
401 427 * startblockp pointer to starting block
402 428 * partnamep pointer to name of partition
403 429 * tagp pointer to tag info
404 430 * tg_cookie cookie from target driver to be passed back to target
405 431 *
406 432 * Notes:
407 433 * If in-core label is not valid, this functions tries to revalidate
408 434 * the label. If label is valid, it stores the total number of blocks
409 435 * in this partition in the area pointed to by nblocksp, starting
410 436 * block number in area pointed to by startblockp, pointer to partition
411 437 * name in area pointed to by partnamep, and tag value in area
412 438 * pointed by tagp.
413 439 * For EFI labels, tag value will be set to 0.
414 440 *
415 441 * For all nblocksp, startblockp and partnamep, tagp, a value of NULL
416 442 * indicates the corresponding info is not requested.
417 443 *
418 444 *
419 445 * Return values:
420 446 * 0 success
421 447 * EINVAL no valid label or requested partition number is invalid.
422 448 *
423 449 */
424 450 int
425 451 cmlb_partinfo(cmlb_handle_t cmlbhandle, int part, diskaddr_t *nblocksp,
426 452 diskaddr_t *startblockp, char **partnamep, uint16_t *tagp, void *tg_cookie);
427 453
428 454 /*
429 455 * cmlb_efi_label_capacity:
430 456 * Get capacity stored in EFI disk label.
431 457 *
432 458 * Arguments:
433 459 * cmlbhandle cmlb handle associated with device.
434 460 * capacity pointer to capacity stored in EFI disk label.
435 461 * tg_cookie cookie from target driver to be passed back to target
436 462 * driver when we call back to it through tg_ops.
437 463 *
438 464 *
439 465 * Notes:
440 466 * If in-core label is not valid, this functions tries to revalidate
441 467 * the label. If label is valid and is an EFI label, it stores the capacity
442 468 * in disk label in the area pointed to by capacity.
443 469 *
444 470 *
445 471 * Return values:
446 472 * 0 success
447 473 * EINVAL no valid EFI label or capacity is NULL.
448 474 *
449 475 */
450 476 int
451 477 cmlb_efi_label_capacity(cmlb_handle_t cmlbhandle, diskaddr_t *capacity,
452 478 void *tg_cookie);
453 479
454 480 /*
455 481 * cmlb_ioctl:
456 482 * Ioctls for label handling will be handled by this function.
457 483 * These are:
458 484 * DKIOCGGEOM
459 485 * DKIOCSGEOM
460 486 * DKIOCGAPART
461 487 * DKIOCSAPART
462 488 * DKIOCGVTOC
463 489 * DKIOCGETEFI
464 490 * DKIOCPARTITION
465 491 * DKIOCSVTOC
466 492 * DKIOCSETEFI
467 493 * DKIOCGMBOOT
468 494 * DKIOCSMBOOT
469 495 * DKIOCG_PHYGEOM
470 496 * DKIOCG_VIRTGEOM
471 497 * DKIOCPARTINFO
472 498 *
473 499 *
474 500 * Arguments:
475 501 * cmlbhandle handle associated with device.
476 502 * cmd ioctl operation to be performed
477 503 * arg user argument, contains data to be set or reference
478 504 * parameter for get
479 505 * flag bit flag, indicating open settings, 32/64 bit type
480 506 * cred_p user credential pointer (not currently used)
481 507 * rval_p not currently used
482 508 * tg_cookie cookie from target driver to be passed back to target
483 509 * driver when we call back to it through tg_ops.
484 510 *
485 511 *
486 512 *
487 513 * Return values:
488 514 * 0
489 515 * EINVAL
490 516 * ENOTTY
491 517 * ENXIO
492 518 * EIO
493 519 * EFAULT
494 520 * ENOTSUP
495 521 * EPERM
496 522 */
497 523 int
498 524 cmlb_ioctl(cmlb_handle_t cmlbhandle, dev_t dev, int cmd,
499 525 intptr_t arg, int flag, cred_t *cred_p, int *rval_p, void *tg_cookie);
500 526
501 527 /*
502 528 * cmlb_prop_op:
503 529 * provide common label prop_op(9E) implementation that understands the
504 530 * size(9p) properties.
505 531 *
506 532 * Arguments:
507 533 * cmlbhandle cmlb handle associated with device.
508 534 * dev See prop_op(9E)
509 535 * dip "
510 536 * prop_op "
511 537 * mod_flags "
512 538 * name "
513 539 * valuep "
514 540 * lengthp "
515 541 * part partition number
516 542 * tg_cookie cookie from target driver to be passed back to target
517 543 */
518 544 int
519 545 cmlb_prop_op(cmlb_handle_t cmlbhandle,
520 546 dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
521 547 char *name, caddr_t valuep, int *lengthp, int part, void *tg_cookie);
522 548
523 549 /*
524 550 * cmlb_get_devid_block:
525 551 * get the block number where device id is stored.
526 552 *
527 553 * Arguments:
528 554 * cmlbhandle cmlb handle associated with device.
529 555 * devidblockp pointer to block number.
530 556 * tg_cookie cookie from target driver to be passed back to target
531 557 * driver when we call back to it through tg_ops.
532 558 *
533 559 * Notes:
534 560 * It stores the block number of device id in the area pointed to
535 561 * by devidblockp.
536 562 *
537 563 * Return values:
538 564 * 0 success
539 565 * EINVAL device id does not apply to current label type.
540 566 */
541 567 int
542 568 cmlb_get_devid_block(cmlb_handle_t cmlbhandle, diskaddr_t *devidblockp,
543 569 void *tg_cookie);
544 570
545 571
546 572 /*
547 573 * cmlb_close:
548 574 *
549 575 * Close the device, revert to a default label minor node for the device,
550 576 * if it is removable.
551 577 *
552 578 * Arguments:
553 579 * cmlbhandle cmlb handle associated with device.
554 580 *
555 581 * tg_cookie cookie from target driver to be passed back to target
556 582 * driver when we call back to it through tg_ops.
557 583 * Return values:
558 584 * 0 Success
559 585 * ENXIO Re-creating minor node failed.
560 586 */
561 587 int
562 588 cmlb_close(cmlb_handle_t cmlbhandle, void *tg_cookie);
563 589
564 590 /*
565 591 * cmlb_detach:
566 592 *
567 593 * Invalidate in-core labeling data and remove all minor nodes for
568 594 * the device associate with handle.
569 595 *
570 596 * Arguments:
571 597 * cmlbhandle cmlb handle associated with device.
572 598 * tg_cookie cookie from target driver to be passed back to target
573 599 * driver when we call back to it through tg_ops.
574 600 *
575 601 */
576 602 void
577 603 cmlb_detach(cmlb_handle_t cmlbhandle, void *tg_cookie);
578 604
579 605 /*
580 606 * cmlb_free_handle
581 607 *
582 608 * Frees handle.
583 609 *
584 610 * Arguments:
585 611 * cmlbhandlep pointer to handle
586 612 *
587 613 */
588 614 void
589 615 cmlb_free_handle(cmlb_handle_t *cmlbhandlep);
590 616
591 617 #ifdef __cplusplus
592 618 }
593 619 #endif
594 620
595 621 #endif /* _SYS_CMLB_H */
|
↓ open down ↓ |
254 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX