1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS__MDIO_H 27 #define _SYS__MDIO_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #include <sys/debug.h> 32 #include <sys/ioctl.h> 33 #include <sys/types.h> 34 #include <sys/int_types.h> 35 #include <sys/dditypes.h> 36 #ifdef _KERNEL 37 #include <sys/lvm/md_mdiox.h> 38 #else /* !_KERNEL */ 39 #include <mdiox.h> 40 #endif 41 #include <sys/ddipropdefs.h> 42 #include <sys/hwconf.h> 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 /* 49 * driver version number 50 */ 51 #define MD_DVERSION 0x00040003 /* major.minor */ 52 #define MD_SET_SHIFT (NBITSMINOR32 - MD_BITSSET) 53 #define MD_MAXUNITS (1 << MD_SET_SHIFT) 54 #define MD_UNIT_MASK (MD_MAXUNITS - 1) 55 56 #define MD_MIN2UNIT(m) ((m) & MD_UNIT_MASK) 57 #define MD_MIN2SET(m) ((m) >> MD_SET_SHIFT) 58 #define MD_SID(u) ((u)->c.un_self_id) 59 #define MD_RECID(u) ((u)->c.un_record_id) 60 #define MD_STATUS(u) ((u)->c.un_status) 61 #define MD_PARENT(u) ((u)->c.un_parent) 62 #define MD_CAPAB(u) ((u)->c.un_capabilities) 63 #define MD_UN2SET(u) MD_MIN2SET(MD_SID(u)) 64 #define MD_UL2SET(l) MD_MIN2SET(MAXMIN32 & ((l)->un_dev)) 65 66 #define MD_MKMIN(s, u) ((((s) & MD_SETMASK) << MD_SET_SHIFT) | \ 67 ((u) & MD_UNIT_MASK)) 68 69 #define HSP_BITSID 31 70 #define HSP_SET_SHIFT (HSP_BITSID - MD_BITSSET) 71 #define HSP_SET_MASK (MD_SETMASK << HSP_SET_SHIFT) 72 #define HSP_SET(hspid) (((hspid) & HSP_SET_MASK) >> HSP_SET_SHIFT) 73 #define HSP_ID(hspid) ((hspid) & ~HSP_SET_MASK) 74 #define MAKE_HSP_ID(setno, id) (((setno) << HSP_SET_SHIFT) | (id)) 75 76 /* 77 * The following macros were added to support friendly names for hot spare 78 * pools. Before the addition of friendly names the hsp_self_id was merely 79 * the conbination of the set number and the hot spare pool number. With 80 * friendly names a NM record is created to hold the hot spare pool name. 81 * The hsp_self_id now becomes the set number shifted left plus the NM 82 * record key plus 1000. The number 1000 is used to collision between 83 * traditional hsp_self_ids and friendly name self ids. In traditional hot 84 * spare pool the hot spare pool number could never be grater than 999. 85 * 86 * HSP_ID_IS_FN(hspid) returns TRUE if the hot spare pool ID is the ID of 87 * a friendly named hsp. Will return FALSE otherwise. 88 * hspid may contain the set bits, since HSP_ID_IS_FN 89 * will call HSP_ID as part of doing its work. 90 * 91 * KEY_TO_HSP_ID(setno, reckey) constructs a hot spare pool ID (hsp_t) from 92 * a set number and a NM record key. The result is 93 * suitable for storing in the hsp_self_id member of a 94 * hot_spare_pool struct. 95 * 96 * HSP_ID_TO_KEY(hspid) returns the NM key that is encoded in the hot spare 97 * pool ID. MD_KEYBAD will be returned if hspid does 98 * not represent a friendly named hsp. hspid may 99 * contain the set bits, since HSP_ID_TO_KEY will call 100 * HSP_ID as part of doing its work. 101 * 102 * HSP_KEY_OK(reckey) Insures that the NM record key is not so large as 103 * to interfere with the set number bits in a hot 104 * spare pool self id. This macro will probably only 105 * be used in meta_hs_add. 106 */ 107 #define HSP_FN_BASE (1000) 108 #define HSP_ID_IS_FN(hspid) (HSP_ID(hspid) > HSP_FN_BASE) 109 #define KEY_TO_HSP_ID(setno, key) ((setno << HSP_SET_SHIFT) | \ 110 (key + HSP_FN_BASE)) 111 #define HSP_ID_TO_KEY(hspid) ((HSP_ID_IS_FN(hspid)) ? \ 112 (HSP_ID(hspid) - HSP_FN_BASE) : MD_KEYBAD) 113 #define HSP_KEY_OK(key) (((key + HSP_FN_BASE) & HSP_SET_MASK) == 0) 114 115 /* 116 * for did stat ioctl 117 */ 118 #define MD_FIND_INVDID 0x01 119 #define MD_GET_INVDID 0x02 120 121 /* 122 * for setting the un_revision, hsp_revision and hs_revision 123 */ 124 #define MD_64BIT_META_DEV 0x01 125 #define MD_FN_META_DEV 0x02 /* Friendly named metadevice */ 126 127 /* 128 * for trans EOF error messages 129 */ 130 #define MD_EOF_TRANS_MSG "Trans logging has been replaced by UFS" \ 131 " Logging.\nSee mount_ufs(1M). Operation failed.\n" 132 133 #define MD_SHORT_EOF_TRANS_MSG "#Trans logging has been replaced by UFS" \ 134 " Logging.\n#See mount_ufs(1M). Operation failed.\n" 135 136 #define MD_EOF_TRANS_WARNING "Existing Trans devices are not logging; they" \ 137 "\npass data directly to the underlying device.\n" 138 139 #define MD_SHORT_EOF_TRANS_WARNING "#Existing Trans devices are not " \ 140 "logging; they\n#pass data directly to the underlying device.\n" 141 142 /* 143 * miscname stuff 144 */ 145 146 #define MD_DRIVERNAMELEN 16 147 #define MD_SETDRIVERNAME(to, from, setno) \ 148 if ((from) != NULL) \ 149 (void) strcpy((to)->md_driver.md_drivername, (from)); \ 150 (to)->md_driver.md_setno = (setno); 151 152 153 #define MD_GETDRIVERNAME(to, from) \ 154 (void) strcpy((to), (from)->md_driver.md_drivername); 155 156 #define MD_PNTDRIVERNAME(from) \ 157 ((from)->md_driver.md_drivername) 158 159 /* 160 * ioctl parameter structures 161 */ 162 163 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 164 #pragma pack(4) 165 #endif 166 typedef struct md_i_driverinfo { 167 MD_DRIVER 168 md_error_t mde; 169 minor_t mnum; 170 } md_i_driverinfo_t; 171 172 typedef struct md_i_getnext { 173 MD_DRIVER 174 md_error_t mde; 175 minor_or_hsp_t id; 176 } md_i_getnext_t; 177 178 typedef struct md_i_getnum { 179 MD_DRIVER 180 md_error_t mde; 181 int start; 182 int size; 183 uint64_t minors; /* Pointer to minor #'s */ 184 } md_i_getnum_t; 185 186 typedef struct md_i_get { 187 MD_DRIVER 188 md_error_t mde; 189 minor_or_hsp_t id; 190 int size; 191 uint64_t mdp; /* Contains pointer */ 192 } md_i_get_t; 193 194 typedef struct md_i_reset { 195 MD_DRIVER 196 md_error_t mde; 197 minor_t mnum; /* Unit to clear */ 198 int force; 199 } md_i_reset_t; 200 201 /* soft partition reset parameters */ 202 typedef struct md_sp_reset { 203 MD_DRIVER 204 md_error_t mde; /* Error return */ 205 minor_t mnum; /* Unit to clear */ 206 int force; /* Force reset */ 207 md_parent_t new_parent; /* New parent for child component */ 208 } md_sp_reset_t; 209 210 /* soft partition status change parameters */ 211 typedef struct md_sp_statusset { 212 MD_DRIVER 213 md_error_t mde; /* Error return */ 214 int num_units; /* Number of units */ 215 int new_status; /* New status */ 216 int size; /* Array size */ 217 uint64_t minors; /* Pointer to array of minor numbers */ 218 } md_sp_statusset_t; 219 220 typedef struct md_sp_update_wm { 221 MD_DRIVER 222 md_error_t mde; /* Error return */ 223 minor_t mnum; /* Unit to update */ 224 uint_t count; /* Number of watermarks */ 225 uint64_t wmp; /* Pointer to array of watermarks */ 226 uint64_t osp; /* Pointer to array of offsets */ 227 } md_sp_update_wm_t; 228 229 typedef struct md_sp_read_wm { 230 MD_DRIVER 231 md_error_t mde; /* Error return */ 232 md_dev64_t rdev; /* Device from which to read */ 233 uint64_t wmp; /* Pointer to wm buffer */ 234 xsp_offset_t offset; /* Offset of wm */ 235 } md_sp_read_wm_t; 236 237 typedef struct md_set_userflags { 238 MD_DRIVER 239 md_error_t mde; 240 minor_t mnum; 241 uint_t userflags; 242 } md_set_userflags_t; 243 244 typedef struct md_stripe_params { 245 MD_DRIVER 246 md_error_t mde; /* Error return */ 247 minor_t mnum; 248 ms_params_t params; 249 } md_stripe_params_t; 250 251 typedef struct md_raid_params { 252 MD_DRIVER 253 md_error_t mde; /* Error return */ 254 minor_t mnum; 255 mr_params_t params; 256 } md_raid_params_t; 257 258 typedef struct md_mirror_params { 259 MD_DRIVER 260 md_error_t mde; /* Error return */ 261 minor_t mnum; 262 mm_params_t params; 263 } md_mirror_params_t; 264 265 typedef struct md_grow_params { 266 MD_DRIVER 267 md_error_t mde; /* Error return */ 268 minor_t mnum; /* Unit to grow */ 269 int options; /* create a 64 or 32 bit device */ 270 uint64_t mdp; /* Optional - pointer to new unit struct */ 271 int size; /* Optional - size of new unit struct */ 272 int nrows; /* Optional - original number of rows */ 273 int npar; /* Optional - number of parents to lock */ 274 uint64_t par; /* Optional - pointer to parent units */ 275 } md_grow_params_t; 276 277 /* if the didstat struct changes you will need to change the following macro */ 278 typedef struct md_i_didstat { 279 md_error_t mde; /* Error return */ 280 set_t setno; /* which set to use */ 281 side_t side; /* which side to use */ 282 int mode; /* find or get ? */ 283 int cnt; /* return number of invalid devid's found */ 284 int maxsz; /* return max size of invalid device id */ 285 uint64_t ctdp; /* pointer to structure to fill with ctds */ 286 } md_i_didstat_t; 287 288 typedef struct mdnm_params { 289 md_error_t mde; /* Error return */ 290 char drvnm[MD_MAXDRVNM]; /* drvnm for get/set/rem nm */ 291 major_t major; /* major #, (alternative) for get nm */ 292 minor_t mnum; /* minor #, for get/set/rem nm */ 293 uint_t devname_len; /* Length of device name, for set nm */ 294 uint64_t devname; /* Address of device name for set/get */ 295 set_t setno; /* Which namespace set to use */ 296 side_t side; /* -1 == current side, >0 specified */ 297 mdkey_t key; /* 0 == alloc one, else use this key */ 298 mdkey_t retkey; /* return key here! */ 299 ushort_t devid_size; /* 0 == ret size, else use this one */ 300 uint64_t devid; /* pointer to devid, supplied by user */ 301 uint_t pathname_len; /* length of pathname */ 302 uint64_t pathname; /* address of pathname for update */ 303 md_dev64_t devt; /* devt for updating namespace */ 304 ushort_t minorname_len; /* length of minor name */ 305 uint64_t minorname; /* address of minor name */ 306 uint_t ref_count; /* returned n_count */ 307 } mdnm_params_t; 308 309 typedef struct mdhspnm_params { 310 md_error_t mde; /* Error return */ 311 char drvnm[MD_MAXDRVNM]; /* drvnm for get/set/rem nm */ 312 uint_t hspname_len; /* Length of device name, for set nm */ 313 uint64_t hspname; /* Address of device name for set/get */ 314 set_t setno; /* Which namespace set to use */ 315 side_t side; /* -1 == current side, >0 specified */ 316 hsp_t hspid; /* 0 == alloc one, else use this key */ 317 hsp_t ret_hspid; /* return key here! */ 318 uint_t ref_count; /* returned n_count */ 319 } mdhspnm_params_t; 320 321 typedef struct md_getdevs_params { 322 MD_DRIVER 323 md_error_t mde; 324 minor_t mnum; 325 int cnt; 326 uint64_t devs; /* Pointer to devs */ 327 } md_getdevs_params_t; 328 329 330 typedef struct md_i_get_tstate { 331 minor_or_hsp_t id; 332 uint_t tstate; /* Transient state */ 333 md_error_t mde; 334 } md_i_get_tstate_t; 335 336 typedef struct md_set_state_params { 337 MD_DRIVER 338 md_error_t mde; 339 minor_t mnum; 340 uint_t sm; 341 uint_t comp; 342 uint_t state; 343 mddb_recid_t hs_id; 344 } md_set_state_params_t; 345 346 typedef struct md_alloc_hotsp_params { 347 MD_DRIVER 348 md_error_t mde; 349 minor_t mnum; 350 uint_t sm; 351 uint_t comp; 352 mddb_recid_t hs_id; 353 } md_alloc_hotsp_params_t; 354 355 typedef struct md_suspend_wr_params { 356 MD_DRIVER 357 md_error_t mde; 358 minor_t mnum; 359 } md_suspend_wr_params_t; 360 361 typedef struct md_mn_req_owner { 362 minor_t mnum; /* Mirror metadevice */ 363 uint_t flags; /* Flags (see below) */ 364 md_mn_nodeid_t owner; /* New owner of Mirror */ 365 } md_mn_req_owner_t; 366 367 #define MD_MN_MM_PREVENT_CHANGE 0x0001 /* Disallow further ownership change */ 368 #define MD_MN_MM_ALLOW_CHANGE 0x0002 /* Allow ownership change */ 369 #define MD_MN_MM_SPAWN_THREAD 0x0004 370 #define MD_MN_MM_CHOOSE_OWNER 0x0008 /* Choose a resync owner */ 371 372 #define MD_MN_MM_RESULT 0x80000000 /* Result contained in LSB */ 373 #define MD_MN_MM_RESULT_MASK 0xFFFF /* Mask for result code */ 374 #define MD_MN_MM_RES_OK 0 /* Success */ 375 #define MD_MN_MM_RES_FAIL 1 /* Failure */ 376 377 typedef struct md_set_mmown_params { 378 MD_DRIVER 379 md_error_t mde; 380 md_mn_req_owner_t d; /* New owner */ 381 } md_set_mmown_params_t; 382 383 typedef struct md_mn_own_status { 384 MD_DRIVER 385 md_error_t mde; 386 minor_t mnum; 387 uint_t flags; /* See above *_MM_RESULT flags */ 388 } md_mn_own_status_t; 389 390 typedef struct md_mn_poke_hotspares { 391 MD_DRIVER 392 md_error_t mde; 393 } md_mn_poke_hotspares_t; 394 395 typedef struct md_mn_rs_params { 396 MD_DRIVER 397 md_error_t mde; 398 int msg_type; /* Type of message */ 399 minor_t mnum; /* Mirror metadevice */ 400 uint_t rs_type; /* Type of resync */ 401 diskaddr_t rs_start; /* 1st block of resync range */ 402 diskaddr_t rs_size; /* size of resync range */ 403 diskaddr_t rs_done; /* amount of resync done so far */ 404 diskaddr_t rs_2_do; /* amount still to be done */ 405 md_mn_nodeid_t rs_originator; /* Originator of resync message */ 406 char rs_flags; /* flags */ 407 char rs_first_time; /* set if first resync-next message */ 408 sm_state_t rs_sm_state[NMIRROR]; /* Submirror state */ 409 sm_flags_t rs_sm_flags[NMIRROR]; /* Submirror flags */ 410 } md_mn_rs_params_t; 411 412 /* flag values for rs_flags */ 413 #define MD_MN_RS_ERR 0x01 /* Resync err */ 414 #define MD_MN_RS_CLEAR_OPT_NOT_DONE 0x02 /* Optimized resync done */ 415 #define MD_MN_RS_FIRST_RESYNC_NEXT 0x04 /* First RESYNC_NEXT message */ 416 417 typedef struct md_mn_setcap_params { 418 MD_DRIVER 419 md_error_t mde; 420 minor_t mnum; 421 uint_t sc_set; /* Capability settings */ 422 } md_mn_setcap_params_t; 423 424 typedef struct md_mkdev_params { 425 MD_DRIVER 426 md_error_t mde; /* Error return */ 427 unit_t un; 428 } md_mkdev_params_t; 429 430 /* 431 * Flags to coordinate sending device id between kernel and user space. 432 * To get devid from kernel: 433 * User calls ioctl with l_devid_flags set to GETSZ flag to get size of 434 * devid which is returned in the l_devid_sz field if the SZ flag is set. 435 * Then user allocs that size and sends same ioctl with SPACE flag set 436 * and l_devid_sz set to alloc'd size. Kernel either sets the NOSPACE 437 * flag (if alloc'd space is not big enough) or sets the VALID flag and 438 * fills in the devid. 439 * 440 * To send devid to kernel: 441 * User alloc's space for devid, fills in devid, sets (SPACE|VALID|SZ) flags 442 * and sets size of devid into l_devid_sz field. 443 * 444 * If MDDB_DEVID_SPACE is set, MDDB_DEVID_GETSZ is ignored. 445 * If no flags are set, devid information is ignored. 446 */ 447 #define MDDB_DEVID_SPACE 0x0001 /* l_devid_sz bytes of space alloc'd */ 448 #define MDDB_DEVID_VALID 0x0002 /* kernel has filled in devid */ 449 #define MDDB_DEVID_NOSPACE 0x0004 /* not enough alloc'd space for devid */ 450 #define MDDB_DEVID_GETSZ 0x0008 /* fill in l_devid_sz with devid size */ 451 #define MDDB_DEVID_SZ 0x0010 /* l_devid_sz filled in with devid sz */ 452 453 454 455 /* 456 * Maximum number of replicas (or number of locator blocks) in set. 457 */ 458 #define MDDB_NLB 50 459 460 /* 461 * maximum size of allowable bootlist property string - only used to 462 * read in and write out boolist property strings to conf files. 463 */ 464 #define MDDB_BOOTLIST_MAX_LEN MAX_HWC_LINESIZE 465 466 /* 467 * Percentage of free space left in replica during conversion of non-devid 468 * style replica to devid style replica. 469 */ 470 #define MDDB_DEVID_CONV_PERC 5 471 472 typedef struct mddb_cfg_loc { 473 dev32_t l_dev; 474 daddr32_t l_blkno; 475 int l_flags; 476 char l_driver[MD_MAXDRVNM]; 477 minor_t l_mnum; 478 int l_devid_flags; 479 uint64_t l_devid; /* pointer to devid */ 480 int l_devid_sz; 481 uint64_t l_old_devid; 482 int l_old_devid_sz; 483 char l_minor_name[MDDB_MINOR_NAME_MAX]; 484 char l_devname[MAXPATHLEN]; /* device name */ 485 } mddb_cfg_loc_t; 486 487 typedef struct mddb_dtag { 488 md_timeval32_t dt_tv; 489 int dt_id; 490 set_t dt_setno; 491 char dt_sn[MDDB_SN_LEN]; 492 char dt_hn[MD_MAX_NODENAME_PLUS_1]; 493 } mddb_dtag_t; 494 495 typedef struct mddb_dtag_lst { 496 struct mddb_dtag_lst *dtl_nx; 497 mddb_dtag_t dtl_dt; 498 } mddb_dtag_lst_t; 499 500 typedef struct mddb_dtag_get_parm { 501 set_t dtgp_setno; 502 mddb_dtag_t dtgp_dt; 503 md_error_t dtgp_mde; 504 } mddb_dtag_get_parm_t; 505 506 typedef struct mddb_dtag_use_parm { 507 int dtup_id; 508 set_t dtup_setno; 509 md_error_t dtup_mde; 510 } mddb_dtag_use_parm_t; 511 512 typedef struct mddb_accept_parm { 513 set_t accp_setno; 514 md_error_t accp_mde; 515 } mddb_accept_parm_t; 516 517 typedef struct mddb_med_parm { 518 set_t med_setno; 519 md_hi_arr_t med; 520 md_error_t med_mde; /* error return */ 521 } mddb_med_parm_t; 522 523 typedef struct mddb_med_upd_parm { 524 set_t med_setno; 525 md_error_t med_mde; /* error return */ 526 } mddb_med_upd_parm_t; 527 528 #define MED_TE_NM_LEN 64 529 530 typedef struct mddb_med_t_ent { 531 char med_te_nm[MED_TE_NM_LEN]; 532 md_dev64_t med_te_dev; /* fixed size dev_t */ 533 } mddb_med_t_ent_t; 534 535 typedef struct mddb_med_t_parm { 536 md_error_t med_tp_mde; /* error return */ 537 int med_tp_nents; /* number of entries */ 538 int med_tp_setup; /* setup flag */ 539 mddb_med_t_ent_t med_tp_ents[1]; /* Var. sized array */ 540 } mddb_med_t_parm_t; 541 542 #define MDDB_SETMASTER_MAGIC 0x53544d41 /* Ascii for STMA */ 543 typedef struct mddb_setmaster_config { 544 md_error_t c_mde; 545 set_t c_setno; 546 int c_magic; /* used to verify ioctl */ 547 int c_current_host_master; 548 } mddb_setmaster_config_t; 549 550 /* 551 * Structure used to set/reset/get flags in set structure. 552 */ 553 #define MDDB_SETFLAGS_MAGIC 0x5354464c /* ascii for STFL */ 554 typedef struct mddb_setflags_config { 555 md_error_t sf_mde; 556 set_t sf_setno; 557 int sf_magic; /* used to verify ioctl */ 558 int sf_flags; /* Control flags set/reset/get */ 559 int sf_setflags; /* Flag values */ 560 } mddb_setflags_config_t; 561 562 typedef struct mddb_set_node_params { 563 md_error_t sn_mde; 564 set_t sn_setno; 565 md_mn_nodeid_t sn_nodeid; 566 } mddb_set_node_params_t; 567 568 typedef struct mddb_block_parm { 569 md_error_t c_mde; 570 set_t c_setno; 571 int c_blk_flags; 572 } mddb_block_parm_t; 573 574 typedef struct mddb_parse_parm { 575 md_error_t c_mde; 576 set_t c_setno; 577 int c_parse_flags; 578 int c_lb_flags[MDDB_NLB]; 579 } mddb_parse_parm_t; 580 581 typedef struct mddb_optrec_parm { 582 md_error_t c_mde; 583 set_t c_setno; 584 md_replica_recerr_t c_recerr[2]; 585 } mddb_optrec_parm_t; 586 587 typedef struct mddb_config { 588 md_error_t c_mde; /* error return */ 589 int c_id; /* used with getnext locator */ 590 md_splitname c_devname; /* contains name or keys */ 591 int c_dbcnt; /* number of dbs */ 592 int c_dbmax; /* maximum number of dbs */ 593 int c_flags; 594 int c_dbend; /* size of database */ 595 set_t c_setno; /* set number of replica */ 596 int c_multi_node; /* set if multi_node set */ 597 side_t c_sideno; /* side number of replica */ 598 md_timeval32_t c_timestamp; /* creation of set */ 599 /* setname */ 600 char c_setname[MD_MAX_SETNAME_PLUS_1]; 601 md_hi_arr_t c_med; /* Mediator host information */ 602 int c_spare[14]; /* unused must be zero */ 603 md_dev64_t c_devt; /* devt to get/set */ 604 mddb_cfg_loc_t c_locator; /* device specific info */ 605 } mddb_config_t; 606 607 #define c_subcmd c_spare[0] 608 /* 609 * Subcommands. 610 */ 611 #define MDDB_CONFIG_ABS 1 /* treat c_id as abs index */ 612 613 typedef struct mddb_optloc { 614 int recid; /* really mddb_recid_t */ 615 int li[2]; 616 } mddb_optloc_t; 617 618 typedef struct md_gs_stat_parm { 619 set_t gs_setno; 620 uint_t gs_status; 621 md_error_t gs_mde; 622 } md_gs_stat_parm_t; 623 624 typedef struct { 625 int setno; 626 int owns_set; 627 } mddb_ownset_t; 628 629 typedef enum md_rename_operation_t { 630 MDRNOP_UNK = 0, MDRNOP_RENAME, MDRNOP_EXCHANGE 631 } md_renop_t; 632 633 typedef struct md_rename { 634 md_error_t mde; 635 md_renop_t op; 636 int revision; 637 uint_t flags; 638 struct { 639 minor_t mnum; 640 key_t key; 641 } from, to; 642 } md_rename_t; 643 644 typedef struct md_regen_param { 645 MD_DRIVER 646 md_error_t mde; 647 minor_t mnum; /* Unit to regenerate parity for */ 648 } md_regen_param_t; 649 650 /* Base ioctl's defined here */ 651 #define MDIOC ('V' << 8) 652 #define ISMDIOC(c) (((c) >> 8) == 'V') 653 654 #define MD_IOCSET (MDIOC|0) /* set config (metainit) */ 655 #define MD_IOCRESET (MDIOC|1) /* reset config (metaclear) */ 656 #define MD_IOCGET (MDIOC|2) /* get config (metastat) */ 657 #define MD_IOCGROW (MDIOC|3) /* grow config (dyn concat) */ 658 #define MD_IOCCHANGE (MDIOC|4) /* change config (metaparam) */ 659 #define MD_IOCSET_NM (MDIOC|5) /* set device name */ 660 #define MD_IOCGET_NM (MDIOC|6) /* get device name */ 661 #define MD_IOCREM_NM (MDIOC|7) /* remove device name */ 662 #define MD_IOCGET_DRVNM (MDIOC|8) /* get driver name */ 663 #define MD_IOCGET_NEXT (MDIOC|9) /* get next unit id */ 664 #define MD_IOCGET_DEVS (MDIOC|10) /* get device list */ 665 #define MD_DB_NEWDEV (MDIOC|11) /* add a db replica */ 666 #define MD_DB_USEDEV (MDIOC|12) /* patch in a db location */ 667 #define MD_DB_GETDEV (MDIOC|13) /* get a db replica */ 668 #define MD_DB_DELDEV (MDIOC|14) /* remove a db replica */ 669 #define MD_DB_ENDDEV (MDIOC|15) /* get db replica and size */ 670 #define MD_DB_GETDRVNM (MDIOC|16) /* get db replica driver name */ 671 #define MD_HALT (MDIOC|17) /* halt driver (metahalt) */ 672 #define MD_GRAB_SET (MDIOC|18) 673 #define MD_RELEASE_SET (MDIOC|20) /* release a set */ 674 #define MD_IOCSETSYNC (MDIOC|21) 675 #define MD_IOCGETSYNC (MDIOC|22) 676 #define MD_IOCOFFLINE (MDIOC|23) 677 #define MD_IOCONLINE (MDIOC|24) 678 #define MD_IOCATTACH (MDIOC|25) 679 #define MD_IOCDETACH (MDIOC|26) 680 #define MD_IOCREPLACE (MDIOC|27) 681 #define MD_DB_USERREQ (MDIOC|28) 682 #define MD_DB_GETOPTLOC (MDIOC|29) /* get locators for opt resync rec. */ 683 #define MD_DB_OWNSET (MDIOC|30) /* Does caller own the set */ 684 #define MD_IOCGETNSET (MDIOC|31) /* Get the config'd number sets */ 685 #define MD_IOCNXTKEY_NM (MDIOC|32) /* get next key from namespace */ 686 #define MD_DB_NEWSIDE (MDIOC|33) /* add another side to the db replica */ 687 #define MD_DB_DELSIDE (MDIOC|34) /* delete a side from the db replica */ 688 #define MD_IOCGVERSION (MDIOC|35) /* get the driver version */ 689 #define MD_IOCSET_FLAGS (MDIOC|36) /* set the userflags of a metadevice */ 690 #define MD_IOCGETNUNITS (MDIOC|37) /* Get the config'd number units */ 691 #define MD_IOCNOTIFY (MDIOC|38) /* notification */ 692 #define MD_IOCRENAME (MDIOC|39) /* (Ex)Change/Rename unit identities */ 693 #define MD_IOCISOPEN (MDIOC|40) /* Is metadevice open? */ 694 #define MD_IOCSETREGEN (MDIOC|41) /* regen ioctl for raid */ 695 #define MD_MED_GET_LST (MDIOC|42) /* Get the mediator list */ 696 #define MD_MED_SET_LST (MDIOC|43) /* Set the mediator list */ 697 #define MD_MED_UPD_MED (MDIOC|44) /* Have the kernel push mediator data */ 698 #define MD_MED_GET_NMED (MDIOC|45) /* Get the max number of mediators */ 699 #define MD_MED_GET_TLEN (MDIOC|46) /* Get the mediator transport tbl len */ 700 #define MD_MED_GET_T (MDIOC|47) /* Get the mediator transport tbl */ 701 #define MD_MED_SET_T (MDIOC|48) /* Set the mediator transport tbl */ 702 #define MD_MED_GET_TAG (MDIOC|49) /* Get the list of data tags */ 703 #define MD_MED_USE_TAG (MDIOC|50) /* Use one of the data tags */ 704 #define MD_MED_ACCEPT (MDIOC|51) /* Accept 1/2 n 1/2 */ 705 #define MD_GET_SETSTAT (MDIOC|52) /* Get the s_status for a set */ 706 #define MD_SET_SETSTAT (MDIOC|53) /* Set the s_status for a set */ 707 #define MD_IOCPROBE_DEV (MDIOC|54) /* Force pseudo opens for metadevices */ 708 #define MD_IOCGET_DID (MDIOC|55) /* Get device id */ 709 #define MD_IOCUPD_NM (MDIOC|56) /* Update namespace */ 710 #define MD_DB_SETDID (MDIOC|57) /* Set device id for a locator block */ 711 #define MD_IOCUPD_LOCNM (MDIOC|58) /* update locator namespace */ 712 #define MD_SETNMDID (MDIOC|59) /* update namespace devid */ 713 #define MD_IOCDID_STAT (MDIOC|60) /* get invalid device id's */ 714 #define MD_UPGRADE_STAT (MDIOC|61) /* get upgrade status information */ 715 #define MD_IOCGET_NUM (MDIOC|62) /* get number of devs and devs */ 716 #define MD_IOCGET_TSTATE (MDIOC|63) /* get ui_tstate for metastat */ 717 #define MD_SETMASTER (MDIOC|64) 718 #define MD_MN_SET_DOORH (MDIOC|65) /* MN: set the doorhandle */ 719 #define MD_MN_OPEN_TEST (MDIOC|66) /* MN: check / (un)lock a md */ 720 #define MD_MN_SET_MM_OWNER (MDIOC|67) /* Set mirror owner */ 721 #define MD_MN_SET_NODEID (MDIOC|68) /* Set this node's id */ 722 #define MD_MN_SET_STATE (MDIOC|69) /* Set mirror state */ 723 #define MD_MN_SUSPEND_WRITES (MDIOC|70) /* Blocks writes */ 724 #define MD_MN_GET_MM_OWNER (MDIOC|71) /* Get mirror owner */ 725 #define MD_IOCGUNIQMSGID (MDIOC|72) /* create a unique message ID */ 726 #define MD_MN_MM_OWNER_STATUS (MDIOC|73) /* Return status of SET_MM_OWNER */ 727 #define MD_MN_ALLOCATE_HOTSPARE (MDIOC|74) /* Allocate hotspare */ 728 #define MD_MN_SUBMIRROR_STATE (MDIOC|75) /* Submirror state change */ 729 #define MD_MN_RESYNC (MDIOC|76) /* Resync ioctl */ 730 #define MD_MN_SUSPEND_SET (MDIOC|77) /* suspend IO's for a MN diskset */ 731 #define MD_MN_RESUME_SET (MDIOC|78) /* resume IO's for a MN diskset */ 732 #define MD_MN_MDDB_PARSE (MDIOC|79) /* Re-parse portion of MNset mddb */ 733 #define MD_MN_MDDB_BLOCK (MDIOC|80) /* Block parse or record changes */ 734 #define MD_MN_MDDB_OPTRECFIX (MDIOC|81) /* Fix optimized record failure */ 735 #define MD_MN_SET_CAP (MDIOC|82) /* set capability, eg ABR, DMR */ 736 #define MD_MN_CHK_WRT_MDDB (MDIOC|83) /* New master checks/writes mddb */ 737 #define MD_MN_SET_SETFLAGS (MDIOC|84) /* Set/reset set flags */ 738 #define MD_MN_GET_SETFLAGS (MDIOC|85) /* Gets set flags */ 739 #define MD_IOCGET_DIDMIN (MDIOC|94) /* get the minor name for a devid */ 740 #define MD_IOCIMP_LOAD (MDIOC|95) /* load the import replicas */ 741 #define MD_IOCSET_DID (MDIOC|96) /* set the devid of a disk */ 742 #define MD_MN_GET_MIRROR_STATE (MDIOC|97) /* Get the mirror state MN only */ 743 #define MD_MN_DB_USERREQ (MDIOC|98) /* MN MT-version of USERREQ */ 744 #define MD_IOCMAKE_DEV (MDIOC|99) /* create device node for unit */ 745 #define MD_MN_SET_COMMD_RUNNING (MDIOC|100) /* Commd running or exiting */ 746 #define MD_MN_COMMD_ERR (MDIOC|101) /* get a message out */ 747 #define MD_MN_SETSYNC (MDIOC|102) /* multi-threaded MD_IOCSETSYNC */ 748 #define MD_MN_POKE_HOTSPARES (MDIOC|103) /* poke hotspares */ 749 #define MD_DB_LBINITTIME (MDIOC|104) /* get the lb_inittime */ 750 #define MD_IOCGET_HSP_NM (MDIOC|105) /* get hsp entry from namespace */ 751 #define MD_IOCREM_DEV (MDIOC|106) /* remove device node for unit */ 752 753 #define MDIOC_MISC (MDIOC|128) /* misc module base */ 754 /* Used in DEBUG_TEST code */ 755 #define MD_MN_CHECK_DOOR1 (MDIOC|126) /* MN: test door to master */ 756 #define MD_MN_CHECK_DOOR2 (MDIOC|127) /* MN: test door master-broadcast */ 757 758 #define NODBNEEDED(c) ((c) == MD_IOCNOTIFY) 759 760 typedef struct md_resync_ioctl { 761 MD_DRIVER 762 md_error_t mde; 763 minor_t ri_mnum; /* mirror to sync */ 764 diskaddr_t ri_copysize; /* The size of the copy buffer */ 765 int ri_zerofill; /* Zerofill on lec read error */ 766 int ri_percent_done; /* percent done current phase */ 767 int ri_percent_dirty; 768 md_riflags_t ri_flags; 769 } md_resync_ioctl_t; 770 771 typedef struct md_rrsize { 772 MD_DRIVER 773 md_error_t mde; /* error return */ 774 minor_t mnum; /* unit # to get */ 775 ulong_t rr_num; /* Number of resync regions */ 776 ulong_t rr_blksize; /* Blocksize of regions */ 777 } md_rrsize_t; 778 779 typedef enum replace_cmd { 780 REPLACE_COMP, ENABLE_COMP, FORCE_REPLACE_COMP, FORCE_ENABLE_COMP 781 } replace_cmd_t; 782 783 typedef struct replace_params { 784 MD_DRIVER 785 md_error_t mde; 786 replace_cmd_t cmd; /* what to do */ 787 minor_t mnum; /* mirror to act upon */ 788 md_dev64_t old_dev; /* enable/replace use this */ 789 md_dev64_t new_dev; /* replace only uses this */ 790 mdkey_t new_key; /* replace only uses this */ 791 diskaddr_t start_blk; /* start block of new device */ 792 int has_label; /* has label flag of new device */ 793 diskaddr_t number_blks; /* # of blocks of new device */ 794 uint_t options; /* misc options, see MDIOCTL_* below */ 795 } replace_params_t; 796 797 typedef struct md_i_off_on { 798 MD_DRIVER 799 md_error_t mde; 800 minor_t mnum; 801 md_dev64_t submirror; 802 int force_offline; 803 } md_i_off_on_t; 804 805 typedef struct md_att_struct { 806 MD_DRIVER 807 md_error_t mde; /* Normal error */ 808 minor_t mnum; 809 mdkey_t key; /* namespace key of sm */ 810 md_dev64_t submirror; /* The device to attach */ 811 uint_t options; /* passed in from the command */ 812 } md_att_struct_t; 813 814 /* possible values for options above */ 815 #define MDIOCTL_DRYRUN 0x0001 /* Only check if operation possible */ 816 #define MDIOCTL_NO_RESYNC_RAID 0x0002 /* if cluster replace we don't */ 817 /* want to resync */ 818 819 typedef struct md_detach_params { 820 MD_DRIVER 821 md_error_t mde; 822 minor_t mnum; /* mirror to act upon */ 823 md_dev64_t submirror; 824 int force_detach; 825 } md_detach_params_t; 826 827 /* 828 * Structure for accessing the DB from user land. 829 */ 830 typedef struct mddb_userreq { 831 md_error_t ur_mde; 832 mddb_usercmd_t ur_cmd; 833 set_t ur_setno; 834 mddb_type_t ur_type; 835 uint_t ur_type2; 836 mddb_recid_t ur_recid; 837 mddb_recstatus_t ur_recstat; 838 int ur_size; 839 uint64_t ur_data; /* Pointer to user data */ 840 } mddb_userreq_t; 841 842 /* 843 * Ioctl structure for MD_IOCISOPEN 844 */ 845 typedef struct md_isopen { 846 md_error_t mde; 847 md_dev64_t dev; 848 int isopen; 849 } md_isopen_t; 850 851 /* 852 * Ioctl structure for MD_MN_OPEN_TEST 853 * md_clu_open stands for md check/lock/unlock 854 * Can't use MD_IOCISOPEN, because it's a contracted inteface. 855 */ 856 typedef struct md_clu_open { 857 md_error_t clu_mde; 858 md_dev64_t clu_dev; 859 enum { MD_MN_LCU_CHECK = 0, 860 MD_MN_LCU_LOCK, 861 MD_MN_LCU_UNLOCK } clu_cmd; 862 int clu_isopen; 863 } md_clu_open_t; 864 865 /* 866 * Structure to push the message out from commd 867 * MAXPATHLEN macro is being overloaded to represent 868 * the line size of 1024 characters. i.e. no path 869 * is being passed. 870 */ 871 typedef struct md_mn_commd_err { 872 int size; 873 uint64_t md_message; /* pointer to array of chars */ 874 } md_mn_commd_err_t; 875 876 /* 877 * Ioctl structure for MD_IOCPROBE_DEV 878 */ 879 880 #define TESTNAME_LEN 32 881 882 #define PROBE_SEMA(p) p->probe_sema 883 #define PROBE_MX(p) p->probe_mx 884 885 /* 886 * To categorize user/kernel structures md_probedev is split into two, 887 * one used by user and the other by kernel, thereby hiding the semaphore 888 * /mutex pointer members from user, which should be the appropriate one. 889 */ 890 891 typedef struct md_probedev { 892 MD_DRIVER 893 md_error_t mde; /* return error status */ 894 int nmdevs; /* number of metadevices */ 895 char test_name[TESTNAME_LEN]; 896 uint64_t mnum_list; /* pointer to array of minor numbers */ 897 } md_probedev_t; 898 899 typedef struct md_probedev_impl { 900 ksema_t *probe_sema; 901 kmutex_t *probe_mx; 902 md_probedev_t probe; 903 } md_probedev_impl_t; 904 905 /* 906 * Ioctl structure for MD_MN_GET_MIRROR_STATE 907 */ 908 typedef struct md_mn_get_mir_state { 909 MD_DRIVER 910 minor_t mnum; /* Unit to obtain submirror info from */ 911 } md_mn_get_mir_state_t; 912 913 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 914 #pragma pack() 915 #endif 916 /* 917 * Per set flags, stored in md_set[n].s_status 918 */ 919 #define MD_SET_HALTED 0x00000001 /* Set is shut down */ 920 #define MD_SET_SNARFED 0x00000002 /* incores built for set db recs */ 921 #define MD_SET_SNARFING 0x00000004 /* incores being built for set */ 922 #define MD_SET_STALE 0x00000008 /* set database not correct */ 923 #define MD_SET_NM_LOADED 0x00000010 /* set namespace is loaded */ 924 #define MD_SET_TAGDATA 0x00000020 /* tagged data detected */ 925 #define MD_SET_ACCOK 0x00000040 /* Accept data is possible */ 926 #define MD_SET_TOOFEW 0x00000080 /* not enough replicas */ 927 #define MD_SET_USETAG 0x00000100 /* A tag is selected, use it */ 928 #define MD_SET_ACCEPT 0x00000200 /* User chose accept 50/50 mode */ 929 #define MD_SET_OWNERSHIP 0x00000400 /* Set is owned */ 930 #define MD_SET_BADTAG 0x00000800 /* DT is not valid */ 931 #define MD_SET_CLRTAG 0x00001000 /* Clear the tags */ 932 #define MD_SET_KEEPTAG 0x00002000 /* Keep the tag */ 933 #define MD_SET_PUSHLB 0x00004000 /* Indicate a LB push is needed */ 934 #define MD_SET_MNSET 0x00008000 /* Set is a multinode diskset */ 935 #define MD_SET_DIDCLUP 0x00010000 /* Set has cleaned up devids */ 936 #define MD_SET_MNPARSE_BLK 0x00020000 /* Do not send parse msgs */ 937 #define MD_SET_MN_NEWMAS_RC 0x00040000 /* Is new master during reconfig */ 938 #define MD_SET_MN_START_RC 0x00080000 /* Start step executed for set */ 939 #define MD_SET_IMPORT 0x00100000 /* Indicate set is importing */ 940 #define MD_SET_MN_MIR_STATE_RC 0x00200000 /* Mirror state gotten for set */ 941 #define MD_SET_HOLD 0x00400000 /* Hold set during release */ 942 #define MD_SET_REPLICATED_IMPORT 0x00800000 /* Set importing RC disk */ 943 944 #define MD_MNSET_SETNO(setno) (md_set[setno].s_status & MD_SET_MNSET) 945 946 /* 947 * See meta_prbits() in SUNWmd/lib/libmeta/meta_print.c for a description of 948 * the way this is used 949 */ 950 #define MD_SET_STAT_BITS "\020\001HALTED\002SNARFED\003SNARFING\004STALE" \ 951 "\005NM_LOADED\006TAGDATA\007ACCOK\010TOOFEW" \ 952 "\011USETAG\012ACCEPT\013OWNERSHIP\014BADTAG" \ 953 "\015CLRTAG\016KEEPTAG\017PUSHLB\020MNSET" \ 954 "\021DIDCLUP\022MNPARSE_BLK\023MN_NEWMAS_RC" \ 955 "\024MN_START_RC\025IMPORT\026MIR_STATE_RC" \ 956 "\027HOLD\030REPLICATED_IMPORT" 957 958 959 #ifdef __cplusplus 960 } 961 #endif 962 963 #endif /* _SYS__MDIO_H */ 964