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 _META_H 27 #define _META_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #include <limits.h> 32 #include <stdio.h> 33 #include <stdlib.h> 34 #include <fcntl.h> 35 #include <errno.h> 36 #include <string.h> 37 #include <unistd.h> 38 #include <libgen.h> 39 #include <locale.h> 40 #include <time.h> 41 #include <assert.h> 42 #include <stdarg.h> 43 #include <signal.h> 44 #include <devid.h> 45 #include <sys/types.h> 46 #include <sys/stat.h> 47 #include <sys/sysmacros.h> 48 #include <sys/mkdev.h> 49 #include <sys/time.h> 50 #include <sys/dkio.h> 51 #include <sys/vtoc.h> 52 #include <sys/efi_partition.h> 53 #include <meta_basic.h> 54 #include <mdiox.h> 55 #include <metamed.h> 56 #include <sys/lvm/mdio.h> 57 #include <sys/lvm/md_mddb.h> 58 #include <sys/lvm/md_sp.h> 59 #include <sys/lvm/mdmn_commd.h> 60 61 #ifdef __cplusplus 62 extern "C" { 63 #endif 64 65 /* debug malloc include */ 66 #ifdef DEBUG_MALLOC 67 #ifdef _REENTRANT 68 die right now 69 #endif 70 #include <../lib/malloclib/malloc.h> 71 #endif 72 73 /* 74 * useful macros 75 */ 76 #ifndef min 77 #define min(x, y) (((x) < (y)) ? (x) : (y)) 78 #endif 79 #ifndef max 80 #define max(x, y) (((x) > (y)) ? (x) : (y)) 81 #endif 82 #ifndef rounddown 83 #define rounddown(x, y) (((x) / (y)) * (y)) 84 #endif 85 86 /* 87 * external names 88 */ 89 90 #define METATAB "/etc/lvm/md.tab" 91 #define METACONF "/etc/lvm/md.cf" 92 #define METACONFTMP "/etc/lvm/md.cf.new" 93 #define META_DBCONF "/etc/lvm/mddb.cf" 94 #define META_DBCONFTMP "/etc/lvm/mddb.cf.new" 95 #define META_MNSET_NODELIST "/var/run/nodelist" 96 #define METALOG "/etc/lvm/md.log" 97 #define METALOCK "/etc/lvm/lock" 98 #define METADEVPATH "/etc/lvm/devpath" 99 #define METALOGENV "MD_LOG" 100 #define METAPKGROOT "/usr" 101 #define ADMSPECIAL "/dev/md/admin" 102 103 #define MDB_STR "metadevice state database" 104 105 /* default database size (4MB) */ 106 #define MD_DBSIZE (8192) 107 108 /* default Multinode database size (16MB) */ 109 #define MD_MN_DBSIZE (32768) 110 111 /* disk label size */ 112 #define VTOC_SIZE (16) 113 114 /* maximum ctd name size (in # of digits) for printing out */ 115 #define CTD_FORMAT_LEN 6 116 117 /* Recommend timeout in seconds for RPC client creation. */ 118 #define MD_CLNT_CREATE_TOUT (60) 119 120 /* 121 * If event needs to be checked during wait of MD_CLNT_CREATE_TOUT, 122 * spin checking for event and then waiting for MD_CLNT_CREATE_SUBTIMEOUT 123 * seconds until MD_CLNT_CREATE_TOUT seconds are used. 124 */ 125 #define MD_CLNT_CREATE_SUBTIMEOUT (5) 126 127 /* 128 * metaclust verbosity levels and what they are for. Messages upto MC_LOG2 129 * will also be logged in syslog. 130 */ 131 #define MC_LOG0 0 /* special class. log messages regardless of */ 132 /* debug level */ 133 #define MC_LOG1 1 /* log standard error messages */ 134 #define MC_LOG2 2 /* log metaclust step level timing messages */ 135 #define MC_LOG3 3 /* log per set level timing messages */ 136 /* intended for use in loops walking mn sets */ 137 #define MC_LOG4 4 /* log per device level timing messages */ 138 /* intended for use in loops walking devices */ 139 #define MC_LOG5 5 /* typically for use in deep nested loops */ 140 /* or in libmeta routines */ 141 142 /* 143 * for meta_print* options 144 */ 145 typedef uint_t mdprtopts_t; 146 #define PRINT_SHORT 0x00000001 147 #define PRINT_SUBDEVS 0x00000002 148 #define PRINT_HEADER 0x00000004 149 #define PRINT_DEBUG 0x00000008 150 #define PRINT_TIMES 0x00000010 151 #define PRINT_SETSTAT 0x00000020 152 #define PRINT_SETSTAT_ONLY 0x00000040 153 #define PRINT_FAST 0x00000080 154 #define PRINT_DEVID 0x00000100 155 #define PRINT_LARGEDEVICES 0x00000200 156 #define PRINT_FN 0x00000400 157 158 /* 159 * for meta_devadm options 160 */ 161 typedef uint_t mddevopts_t; 162 #define DEV_VERBOSE 0x00000001 163 #define DEV_NOACTION 0x00000002 164 #define DEV_LOG 0x00000004 165 #define DEV_RELOAD 0x00000008 166 #define DEV_UPDATE 0x00000010 167 #define DEV_LOCAL_SET 0x00000020 /* update only MD_LOCAL_SET */ 168 169 /* 170 * return values for meta_devadm operations 171 */ 172 #define METADEVADM_SUCCESS 0 173 #define METADEVADM_ERR 1 174 #define METADEVADM_DEVIDINVALID 2 175 #define METADEVADM_DSKNAME_ERR 3 176 #define METADEVADM_DISKMOVE 4 177 178 /* 179 * meta_check* options 180 */ 181 typedef uint_t mdchkopts_t; 182 #define MDCHK_ALLOW_MDDB 0x01 /* allows repliica in md's (metainit) */ 183 #define MDCHK_ALLOW_HS 0x02 /* allows hs in multiple hsp's (hs) */ 184 #define MDCHK_ALLOW_LOG 0x04 /* allows sharing of logs (trans) */ 185 #define MDCHK_ALLOW_REPSLICE 0x08 /* allow replica slice to be used */ 186 #define MDCHK_ALLOW_NODBS 0x10 /* no db replicas allowed (metadb) */ 187 #define MDCHK_DRVINSET 0x20 /* drive is in set (metaset) */ 188 #define MDCHK_SET_LOCKED 0x40 /* The set is locked */ 189 #define MDCHK_SET_FORCE 0x80 /* This is a forced operation */ 190 191 /* 192 * meta_check_inuse options 193 */ 194 typedef uint_t mdinuseopts_t; 195 #define MDCHK_SWAP 0x01 /* check swap & overlap w/swap */ 196 #define MDCHK_DUMP 0x02 /* check dump & overlap w/dump */ 197 #define MDCHK_MOUNTED 0x04 /* check mounted & overlap w/mounted */ 198 #define MDCHK_INUSE 0xff /* check all */ 199 200 /* 201 * meta* force options 202 */ 203 typedef uint_t mdforceopts_t; 204 #define MDFORCE_NONE 0x01 /* no extra force used */ 205 #define MDFORCE_LOCAL 0x02 /* force from metadb command line */ 206 #define MDFORCE_DS 0x04 /* force from metaset library */ 207 #define MDFORCE_SET_LOCKED 0x10 /* The set is locked */ 208 209 210 /* 211 * meta* options 212 */ 213 typedef uint_t mdcmdopts_t; 214 #define MDCMD_DOIT 0x0001 /* really do operation */ 215 #define MDCMD_FORCE 0x0002 /* force operation */ 216 #define MDCMD_PRINT 0x0004 /* print success messages to stdout */ 217 #define MDCMD_RECURSE 0x0008 /* recursive operation */ 218 #define MDCMD_INIT 0x0010 /* init operation */ 219 #define MDCMD_UPDATE 0x0020 /* update sizes used w/o DOIT mostly */ 220 #define MDCMD_NOLOCK 0x0040 /* lock already held, DONT acquire */ 221 #define MDCMD_VERBOSE 0x0100 /* be verbose */ 222 #define MDCMD_USE_WHOLE_DISK 0x0200 /* repartition disk */ 223 #define MDCMD_DIRECT 0x0400 /* extents specified directly */ 224 #define MDCMD_ALLOPTION 0x0800 /* the all option is being used */ 225 #define MDCMD_MN_OPEN_CHECK 0x1000 /* Perform open check on all nodes */ 226 227 /* 228 * meta_tab* definitions 229 */ 230 #define TAB_ARG_ALLOC 5 231 #define TAB_LINE_ALLOC 10 232 233 typedef uint_t mdinittypes_t; 234 #define TAB_UNKNOWN 0x0000 235 #define TAB_MDDB 0x0001 236 #define TAB_HSP 0x0002 237 #define TAB_STRIPE 0x0004 238 #define TAB_MIRROR 0x0008 239 #define TAB_RAID 0x0010 240 #define TAB_TRANS 0x0020 241 #define TAB_SP 0x0040 242 #define TAB_MD (TAB_STRIPE | TAB_MIRROR | TAB_RAID |\ 243 TAB_TRANS | TAB_SP) 244 #define TAB_MD_HSP (TAB_MD | TAB_HSP) 245 246 typedef struct { 247 mdinittypes_t type; 248 char *context; 249 char *cname; 250 int argc; 251 char **argv; 252 size_t alloc; 253 uint_t flags; /* for application use */ 254 } md_tab_line_t; 255 256 typedef struct { 257 char *filename; 258 char *data; 259 size_t total; 260 size_t nlines; 261 md_tab_line_t *lines; 262 size_t alloc; 263 } md_tab_t; 264 265 /* 266 * disk status definitions 267 */ 268 typedef struct md_disk_status_list { 269 struct md_disk_status_list *next; 270 mddrivename_t *drivenamep; 271 md_error_t status; 272 } md_disk_status_list_t; 273 274 /* 275 * module name list used by meta_patch_root & meta_systemfile 276 */ 277 struct modname { 278 char *name; 279 struct modname *next; 280 }; 281 282 /* 283 * list to be used for printing Device Relocation Information 284 */ 285 typedef struct mddevid_t { 286 struct mddevid_t *next; 287 char *ctdname; 288 mdkey_t key; 289 } mddevid_t; 290 291 /* 292 * Multi-Node Diskset List 293 * 294 * we either store the IP address of the private interconnect or its name 295 * in the msl_node_addr member 296 */ 297 typedef struct mndiskset_membershiplist { 298 uint_t msl_node_id; 299 md_mnnode_nm_t msl_node_name; 300 md_mnnode_nm_t msl_node_addr; 301 struct mndiskset_membershiplist *next; 302 } mndiskset_membershiplist_t; 303 304 /* 305 * client pool for rpc calls to mdcommd 306 */ 307 typedef struct md_mn_client_list { 308 CLIENT *mcl_clnt; 309 struct md_mn_client_list *mcl_next; 310 } md_mn_client_list_t; 311 312 /* 313 * Resync thread manipulation commands. 314 * 315 * The resync thread can now be started, blocked, unblocked or killed. 316 * This typedef specifies the action to be taken by meta_resync.c 317 * routines. 318 */ 319 typedef enum { 320 MD_RESYNC_START = 1, 321 MD_RESYNC_BLOCK, 322 MD_RESYNC_UNBLOCK, 323 MD_RESYNC_KILL, 324 MD_RESYNC_KILL_NO_WAIT, 325 MD_RESYNC_FORCE_MNSTART 326 } md_resync_cmd_t; 327 328 329 /* 330 * rpc.metad macro definitions. 331 */ 332 #define METAD_SETUP_DR(cmd, id) \ 333 { \ 334 req.ur_cmd = cmd; \ 335 req.ur_setno = MD_LOCAL_SET; \ 336 req.ur_type = MDDB_USER; \ 337 req.ur_type2 = MDDB_UR_DR; \ 338 req.ur_recid = id; \ 339 } 340 341 #define METAD_SETUP_NR(cmd, id) \ 342 { \ 343 req.ur_cmd = cmd; \ 344 req.ur_setno = MD_LOCAL_SET; \ 345 req.ur_type = MDDB_USER; \ 346 req.ur_type2 = MDDB_UR_NR; \ 347 req.ur_recid = id; \ 348 } 349 350 #define METAD_SETUP_SR(cmd, id) \ 351 { \ 352 req.ur_cmd = cmd; \ 353 req.ur_setno = MD_LOCAL_SET; \ 354 req.ur_type = MDDB_USER; \ 355 req.ur_type2 = MDDB_UR_SR; \ 356 req.ur_recid = id; \ 357 } 358 359 #define METAD_SETUP_UR(cmd, type2, id) \ 360 { \ 361 req.ur_cmd = cmd; \ 362 req.ur_setno = MD_LOCAL_SET; \ 363 req.ur_type = MDDB_USER; \ 364 req.ur_type2 = type2; \ 365 req.ur_recid = id; \ 366 } 367 368 #define METAD_SETUP_LR(cmd, setno, id) \ 369 { \ 370 req.ur_cmd = cmd; \ 371 req.ur_setno = setno; \ 372 req.ur_type = MDDB_USER; \ 373 req.ur_type2 = MDDB_UR_LR; \ 374 req.ur_recid = id; \ 375 } 376 377 /* 378 * This typedef specifies the signature of a function that 379 * meta_client_create_retry can use to establish an rpc connection. 380 * private is used to pass data from the caller of meta_client_create_retry 381 * to clnt_create_func. 382 */ 383 typedef CLIENT *(*clnt_create_func_t)(char *hostname, 384 void *private, 385 struct timeval *time_out); 386 387 /* definition of the table for the different message types */ 388 typedef struct md_mn_msg_tbl_entry { 389 md_mn_msgclass_t mte_class; 390 void (*mte_handler) 391 (md_mn_msg_t *msg, uint_t flags, md_mn_result_t *res); 392 int (*mte_smgen) 393 (md_mn_msg_t *msg, md_mn_msg_t **msglist); 394 time_t mte_timeout; /* seconds before msg times out */ 395 uint_t mte_retry1; /* nretries in case of class busy */ 396 uint_t mte_ticks1; /* sleep nticks before retry */ 397 uint_t mte_retry2; /* nretries in case of comm fail */ 398 uint_t mte_ticks2; /* sleep nticks before retry */ 399 } md_mn_msg_tbl_entry_t; 400 401 /* 402 * Flags for the take command 403 */ 404 #define TAKE_FORCE 0x0001 405 #define TAKE_USETAG 0x0002 406 #define TAKE_USEIT 0x0004 407 #define TAKE_IMP 0x0008 408 #define TAKE_RETAKE 0x0010 409 410 /* 411 * ignore gettext for lint so we check printf args 412 */ 413 #ifdef __lint 414 #define dgettext(d, s) s 415 #define gettext(s) s 416 #endif 417 418 /* 419 * Defines for enabling/disabling SVM services in SMF. 420 */ 421 #define META_SMF_CORE 0x01 422 #define META_SMF_DISKSET 0x02 423 #define META_SMF_MN_DISKSET 0x04 424 #define META_SMF_ALL 0xFF 425 426 /* 427 * Defines to send/not_send addition of mddb sidenames to 428 * rpc.mdcommd for MN disksets. 429 */ 430 #define DB_ADDSIDENMS_NO_BCAST 0 431 #define DB_ADDSIDENMS_BCAST 1 432 433 /* 434 * Defines and structures to support rpc.mdcommd. 435 * RPC routines in rpc.metad will be used to suspend, resume 436 * and reinitialize the rpc.mdcommd running on that node. 437 * These actions are needed when the nodelist is changing. 438 */ 439 #define COMMDCTL_SUSPEND 1 440 #define COMMDCTL_RESUME 2 441 #define COMMDCTL_REINIT 3 442 443 /* 444 * Defines used when joining a node to a MN diskset. 445 * A MN diskset is stale if < 50% mddbs are available when the first node 446 * joins the set. A MN diskset is stale when 50% mddbs are available when 447 * the first node joins the set if the mediator is unable to provide an 448 * extra vote. 449 * Once a MN set is marked stale, it stays in the stale state (even if > 50% 450 * mddbs are available) until all nodes are withdrawn from the diskset. 451 * Any new nodes joining a stale MN diskset are marked stale regardless of 452 * the availability of mddbs in order to keep the diskset consistent across 453 * all nodes. 454 * 455 * If a reconfig cycle is underway, set the reconfig flag so that rpc.metad 456 * clnt_locks are not enforced. Since the reconfig cycle has locked out the 457 * meta* commands, this is safe to do. 458 */ 459 #define MNSET_IS_STALE 1 /* Is MN set stale? */ 460 #define MNSET_IN_RECONFIG 2 /* Is MN set in reconfig? */ 461 462 /* 463 * Structure used during reconfig step2 to aid in sychronization 464 * of the drives in a diskset. 465 */ 466 typedef struct md_mnsr_node { 467 md_mnset_record *mmn_mnsr; 468 md_mnnode_nm_t mmn_nodename; 469 int mmn_numdrives; 470 md_drive_desc *mmn_dd; 471 struct md_mnsr_node *mmn_next; 472 } md_mnsr_node_t; 473 474 475 /* 476 * meta events definitions ("meta_notify.h") 477 */ 478 479 /* 480 * event flags 481 * meta_notify_createq(), (EXISTERR, PERMANENT) 482 * meta_notify_getev(), (WAIT) 483 * meta_notify_getevlist() (WAIT) 484 */ 485 #define EVFLG_WAIT 0x00000001 /* block until events are pending */ 486 #define EVFLG_EXISTERR 0x00000002 /* if q exists, return an error */ 487 #define EVFLG_PERMANENT 0x00000004 /* queue persists after process exit */ 488 489 /* 490 * events are always associated with an underlying object 491 * This object is of one of the following types. 492 */ 493 typedef enum md_ev_objtype_t { 494 EVO_EMPTY = 0, 495 EVO_METADEV, 496 EVO_MIRROR, 497 EVO_STRIPE, 498 EVO_RAID5, 499 EVO_TRANS, 500 EVO_REPLICA, 501 EVO_HSP, 502 EVO_HS, 503 EVO_SET, 504 EVO_DRIVE, 505 EVO_HOST, 506 EVO_MEDIATOR, 507 EVO_UNSPECIFIED, 508 EVO_LAST 509 } ev_obj_t; 510 511 /* 512 * Specific events are sent upon state changes 513 * in the underlying devices or when sent by 514 * user applications. These events have a unique 515 * type. These types map to kernel event types (sys/md_notify.h) 516 * 517 * When updating these UPDATE THE TABLE in lib/config/config.c 518 */ 519 typedef enum md_ev_id_t { 520 EV_UNK = 0, 521 EV_EMPTY, 522 EV_CREATE, 523 EV_DELETE, 524 EV_ADD, 525 EV_REMOVE, 526 EV_REPLACE, 527 EV_GROW, 528 EV_RENAME_SRC, 529 EV_RENAME_DST, 530 EV_MEDIATOR_ADD, 531 EV_MEDIATOR_DELETE, 532 EV_HOST_ADD, 533 EV_HOST_DELETE, 534 EV_DRIVE_ADD, 535 EV_DRIVE_DELETE, 536 EV_INIT_START, 537 EV_INIT_FAILED, 538 EV_INIT_FATAL, 539 EV_INIT_SUCCESS, 540 EV_IOERR, 541 EV_ERRED, 542 EV_LASTERRED, 543 EV_OK, 544 EV_ENABLE, 545 EV_RESYNC_START, 546 EV_RESYNC_FAILED, 547 EV_RESYNC_SUCCESS, 548 EV_RESYNC_DONE, 549 EV_HOTSPARED, 550 EV_HS_FREED, 551 EV_HS_CHANGED, 552 EV_TAKEOVER, 553 EV_RELEASE, 554 EV_OPEN_FAIL, 555 EV_OFFLINE, 556 EV_ONLINE, 557 EV_GROW_PENDING, 558 EV_DETACH, 559 EV_DETACHING, 560 EV_ATTACH, 561 EV_ATTACHING, 562 EV_CHANGE, 563 EV_EXCHANGE, 564 EV_REGEN_START, 565 EV_REGEN_DONE, 566 EV_REGEN_FAILED, 567 EV_USER, 568 EV_NOTIFY_LOST, 569 EV_LAST 570 } evid_t; 571 572 #define EV_ALLOBJS (~0ULL) 573 #define EV_ALLSETS ((set_t)(~0)) 574 575 #if !defined(_KERNEL) 576 577 #define NOTIFY_MD(tag, set, dev, ev) \ 578 (void) meta_notify_sendev((tag), (set), (dev), (ev)) 579 580 #define SE_NOTIFY(se_class, se_subclass, tag, set, dev) \ 581 meta_svm_sysevent((se_class), (se_subclass), (tag), (set), (dev)) 582 583 #endif /* _KERNEL */ 584 585 typedef struct md_ev { 586 ev_obj_t obj_type; 587 set_t setno; 588 evid_t ev; 589 u_longlong_t obj; /* usually md_dev64_t or hsp id */ 590 u_longlong_t uev; /* for (EV_USER) user-defined events */ 591 } md_ev_t; 592 593 typedef struct md_evlist { 594 struct md_evlist *next; 595 md_ev_t *evp; 596 } md_evlist_t; 597 598 /* end of meta event definitions ("meta_notify.h") */ 599 600 typedef struct md_im_names { 601 int min_count; 602 char **min_names; 603 } md_im_names_t; 604 605 /* Values for replica info status */ 606 #define MD_IM_REPLICA_SCANNED (0x01) 607 #define MD_IM_REPLICA_VALID (0x02) 608 609 typedef struct md_im_replica_info { 610 struct md_im_replica_info *mir_next; 611 int mir_status; 612 int mir_flags; 613 daddr32_t mir_offset; 614 daddr32_t mir_length; 615 md_timeval32_t mir_timestamp; 616 } md_im_replica_info_t; 617 618 typedef struct md_im_drive_info { 619 struct md_im_drive_info *mid_next; /* next drive in this set */ 620 mddrivename_t *mid_dnp; 621 void *mid_devid; 622 void *mid_o_devid; 623 int mid_devid_sz; 624 int mid_o_devid_sz; 625 char mid_minor_name[MDDB_MINOR_NAME_MAX]; 626 minor_t mid_mnum; 627 int mid_available; 628 md_timeval32_t mid_setcreatetimestamp; 629 char *mid_driver_name; 630 char *mid_devname; 631 md_im_replica_info_t *mid_replicas; 632 int overlapped_disk; 633 struct md_im_drive_info *overlap; /* chain of overlap disks */ 634 } md_im_drive_info_t; 635 636 /* Values for mid_available */ 637 #define MD_IM_DISK_AVAILABLE 0x00 638 #define MD_IM_DISK_NOT_AVAILABLE 0x01 639 640 /* Values for set descriptor flags */ 641 #define MD_IM_SET_INVALID 0x10 642 #define MD_IM_SET_REPLICATED 0x20 643 644 /* Values for mis_partial */ 645 #define MD_IM_COMPLETE_DISKSET 0x04 646 #define MD_IM_PARTIAL_DISKSET 0x08 647 648 typedef struct md_im_set_desc { 649 struct md_im_set_desc *mis_next; 650 int mis_flags; 651 int mis_oldsetno; 652 md_im_drive_info_t *mis_drives; 653 int mis_active_replicas; 654 int mis_partial; 655 } md_im_set_desc_t; 656 657 /* meta_admin.c */ 658 extern int open_admin(md_error_t *ep); 659 extern int close_admin(md_error_t *ep); 660 extern int meta_dev_ismeta(md_dev64_t dev); 661 extern int meta_get_nunits(md_error_t *ep); 662 extern md_dev64_t metamakedev(minor_t mnum); 663 664 /* meta_attach.c */ 665 extern int meta_concat_generic(mdsetname_t *sp, mdname_t *namep, 666 u_longlong_t big_or_little, md_error_t *ep); 667 extern int meta_concat_parent(mdsetname_t *sp, mdname_t *childnp, 668 md_error_t *ep); 669 670 /* meta_check.c */ 671 extern int meta_check_inuse(mdsetname_t *sp, mdname_t *np, 672 mdinuseopts_t inuse_flag, md_error_t *ep); 673 extern int meta_check_driveinset(mdsetname_t *sp, 674 mddrivename_t *dnp, md_error_t *ep); 675 extern int meta_check_drivemounted(mdsetname_t *sp, 676 mddrivename_t *dnp, md_error_t *ep); 677 extern int meta_check_driveswapped(mdsetname_t *sp, 678 mddrivename_t *dnp, md_error_t *ep); 679 extern int meta_check_samedrive(mdname_t *np1, mdname_t *np2, 680 md_error_t *ep); 681 extern int meta_check_overlap(char *uname, mdname_t *np1, 682 diskaddr_t slblk1, diskaddr_t nblks1, mdname_t *np2, 683 diskaddr_t slblk2, diskaddr_t nblks2, 684 md_error_t *ep); 685 extern int meta_check_inmeta(mdsetname_t *sp, mdname_t *np, 686 mdchkopts_t options, diskaddr_t slblk, 687 diskaddr_t nblks, 688 md_error_t *ep); 689 extern int meta_check_inset(mdsetname_t *sp, mdname_t *np, 690 md_error_t *ep); 691 extern int meta_check_root(md_error_t *ep); 692 693 694 /* meta_db.c */ 695 extern char *meta_devid_encode_str(ddi_devid_t devid, 696 char *minor_name); 697 extern void meta_devid_encode_str_free(char *devidstr); 698 extern int meta_devid_decode_str(char *devidstr, 699 ddi_devid_t *devidp, char **minor_namep); 700 extern int meta_check_inreplica(mdsetname_t *sp, mdname_t *np, 701 diskaddr_t slblk, diskaddr_t nblks, md_error_t *ep); 702 extern int meta_check_replica(mdsetname_t *sp, mdname_t *np, 703 mdchkopts_t options, diskaddr_t slblk, 704 diskaddr_t nblks, md_error_t *ep); 705 extern int meta_db_addsidenms(mdsetname_t *sp, mdname_t *np, 706 daddr_t blkno, int bcast, md_error_t *ep); 707 extern int meta_db_delsidenm(mdsetname_t *sp, side_t sideno, 708 mdname_t *np, daddr_t blkno, md_error_t *ep); 709 extern int meta_db_patch(char *sname, char *cname, int patch, 710 md_error_t *ep); 711 extern int meta_db_attach(mdsetname_t *sp, mdnamelist_t *db_nlp, 712 mdchkopts_t options, md_timeval32_t *timeval, 713 int dbcnt, int dbsize, char *sysfilename, 714 md_error_t *ep); 715 extern int meta_db_detach(mdsetname_t *sp, mdnamelist_t *db_nlp, 716 mdforceopts_t force, char *sysfilename, 717 md_error_t *ep); 718 extern void metafreereplicalist(md_replicalist_t *rlp); 719 extern int metareplicalist(mdsetname_t *sp, int flags, 720 md_replicalist_t **rlpp, md_error_t *ep); 721 extern void meta_sync_db_locations(mdsetname_t *sp, 722 md_error_t *ep); 723 extern int meta_setup_db_locations(md_error_t *ep); 724 extern daddr_t meta_db_minreplica(mdsetname_t *sp, md_error_t *ep); 725 extern int meta_get_replica_names(mdsetname_t *, 726 mdnamelist_t **, int options, md_error_t *); 727 extern void meta_mkdummymaster(mdsetname_t *sp, int fd, 728 daddr_t firstblk); 729 extern md_timeval32_t meta_get_lb_inittime(mdsetname_t *sp, md_error_t *ep); 730 731 /* meta_db_balance.c */ 732 extern int meta_db_balance(mdsetname_t *sp, md_drive_desc *opdd, 733 md_drive_desc *curdd, daddr_t dbsize, 734 md_error_t *ep); 735 736 /* metadevstamp.c */ 737 extern int getdevstamp(mddrivename_t *dnp, time_t *stamp, 738 md_error_t *ep); 739 extern int setdevstamp(mddrivename_t *dnp, time_t *stamp, 740 md_error_t *ep); 741 742 /* meta_error.c */ 743 extern int metaioctl(int cmd, void *data, md_error_t *ep, 744 char *name); 745 extern void md_logpfx(FILE *fp); 746 /* PRINTFLIKE2 */ 747 extern char *mde_sperror(md_error_t *mdep, const char *fmt, ...); 748 /* PRINTFLIKE2 */ 749 extern void mde_perror(md_error_t *mdep, const char *fmt, ...); 750 /* PRINTFLIKE1 */ 751 extern void md_perror(const char *fmt, ...); 752 /* PRINTFLIKE1 */ 753 extern void md_eprintf(const char *fmt, ...); 754 extern void meta_mc_log(int level, const char *fmt, ...); 755 756 /* meta_getdevs.c */ 757 extern minor_t meta_getminor(md_dev64_t dev64); 758 extern major_t meta_getmajor(md_dev64_t dev64); 759 extern md_dev64_t meta_expldev(md_dev64_t dev); 760 extern dev32_t meta_cmpldev(md_dev64_t dev64); 761 762 extern int meta_getdevs(mdsetname_t *sp, mdname_t *namep, 763 mdnamelist_t **nlpp, md_error_t *ep); 764 extern int meta_getalldevs(mdsetname_t *sp, mdnamelist_t **nlpp, 765 int check_db, md_error_t *ep); 766 extern int meta_getvtoc(int fd, char *devname, 767 struct vtoc *vtocbufp, int *partno, 768 md_error_t *ep); 769 extern int meta_setvtoc(int fd, char *devname, 770 struct vtoc *vtocbufp, md_error_t *ep); 771 extern int meta_setmdvtoc(int fd, char *devname, 772 mdvtoc_t *mdvtocbufp, md_error_t *ep); 773 extern int meta_get_names(char *drivername, mdsetname_t *sp, 774 mdnamelist_t **nlpp, mdprtopts_t options, 775 md_error_t *ep); 776 extern int meta_deviceid_to_nmlist(char *search_path, 777 ddi_devid_t devid, char *minor_name, 778 devid_nmlist_t **retlist); 779 780 /* meta_hotspares.c */ 781 extern int meta_get_hsp_names(mdsetname_t *sp, 782 mdhspnamelist_t **hspnlpp, int options, 783 md_error_t *ep); 784 extern void meta_free_hsp(md_hsp_t *hspp); 785 extern void meta_invalidate_hsp(mdhspname_t *hspnp); 786 extern md_hsp_t *meta_get_hsp(mdsetname_t *sp, mdhspname_t *hspnp, 787 md_error_t *ep); 788 extern md_hsp_t *meta_get_hsp_common(mdsetname_t *sp, 789 mdhspname_t *hspnp, int fast, md_error_t *ep); 790 extern int meta_check_inhsp(mdsetname_t *sp, mdname_t *np, 791 diskaddr_t slblk, diskaddr_t nblks, md_error_t *ep); 792 extern int meta_check_hotspare(mdsetname_t *sp, mdname_t *np, 793 md_error_t *ep); 794 extern char *hs_state_to_name(md_hs_t *hsp, 795 md_timeval32_t *tvp); 796 extern int meta_hsp_print(mdsetname_t *sp, mdhspname_t *hspnp, 797 mdnamelist_t **nlpp, char *fname, FILE *fp, 798 mdprtopts_t options, md_error_t *ep); 799 extern int metachkhsp(mdsetname_t *sp, mdhspname_t *hspnp, 800 md_error_t *ep); 801 extern int meta_hs_add(mdsetname_t *sp, mdhspname_t *hspnp, 802 mdnamelist_t *nlp, mdcmdopts_t options, 803 md_error_t *ep); 804 extern int meta_hs_delete(mdsetname_t *sp, mdhspname_t *hspnp, 805 mdnamelist_t *nlp, mdcmdopts_t options, 806 md_error_t *ep); 807 extern int meta_hs_replace(mdsetname_t *sp, mdhspname_t *hspnp, 808 mdname_t *oldnp, mdname_t *newnp, 809 mdcmdopts_t options, md_error_t *ep); 810 extern int meta_hs_enable(mdsetname_t *sp, mdnamelist_t *nlp, 811 mdcmdopts_t options, md_error_t *ep); 812 extern int meta_check_hsp(mdsetname_t *sp, md_hsp_t *hspp, 813 mdcmdopts_t options, md_error_t *ep); 814 extern int meta_create_hsp(mdsetname_t *sp, md_hsp_t *hspp, 815 mdcmdopts_t options, md_error_t *ep); 816 extern int meta_init_hsp(mdsetname_t **spp, 817 int argc, char *argv[], mdcmdopts_t options, 818 md_error_t *ep); 819 extern int meta_hsp_reset(mdsetname_t *sp, mdhspname_t *hspnp, 820 mdcmdopts_t options, md_error_t *ep); 821 822 /* meta_init.c */ 823 extern int parse_interlace(char *uname, char *name, 824 diskaddr_t *interlacep, md_error_t *ep); 825 extern int meta_cook_syntax(md_error_t *ep, 826 md_void_errno_t errcode, char *uname, 827 int argc, char *argv[]); 828 extern int meta_setup_geom(md_unit_t *md, mdname_t *np, 829 mdgeom_t *geomp, uint_t write_reinstruct, 830 uint_t read_reinstruct, uint_t round_cyl, 831 md_error_t *ep); 832 extern int meta_adjust_geom(md_unit_t *md, mdname_t *np, 833 uint_t write_reinstruct, uint_t read_reinstruct, 834 uint_t round_cyl, md_error_t *ep); 835 extern int meta_init_name(mdsetname_t **spp, int argc, 836 char *argv[], char *cname, mdcmdopts_t options, 837 md_error_t *ep); 838 extern int meta_check_devicesize(diskaddr_t total_blocks); 839 extern int meta_init_make_device(mdsetname_t **spp, char *uname, 840 md_error_t *ep); 841 extern mdinittypes_t meta_get_init_type(int argc, char *argv[]); 842 843 /* meta_mdcf.c */ 844 extern int meta_update_md_cf(mdsetname_t *sp, md_error_t *ep); 845 846 /* meta_med.c */ 847 extern int meddstealerror(md_error_t *ep, med_err_t *medep); 848 extern int clnt_med_null(char *hostname, md_error_t *ep); 849 extern int clnt_med_upd_data(md_h_t *mdhp, mdsetname_t *sp, 850 med_data_t *meddp, md_error_t *ep); 851 extern int clnt_med_get_data(md_h_t *mdhp, mdsetname_t *sp, 852 med_data_t *meddp, md_error_t *ep); 853 extern int clnt_med_get_rec(md_h_t *mdhp, mdsetname_t *sp, 854 med_rec_t *medrp, md_error_t *ep); 855 extern int clnt_med_upd_rec(md_h_t *mdhp, mdsetname_t *sp, 856 med_rec_t *medrp, md_error_t *ep); 857 extern int clnt_med_hostname(char *hostname, char **ret_hostname, 858 md_error_t *ep); 859 860 extern int meta_med_hnm2ip(md_hi_arr_t *mp, md_error_t *ep); 861 extern int meta_h2hi(md_h_arr_t *mdhp, md_hi_arr_t *mdhip, 862 md_error_t *ep); 863 extern int meta_hi2h(md_hi_arr_t *mdhip, md_h_arr_t *mdhp, 864 md_error_t *ep); 865 extern int setup_med_cfg(mdsetname_t *sp, mddb_config_t *cp, 866 int force, md_error_t *ep); 867 868 /* meta_mem.c */ 869 #ifdef _DEBUG_MALLOC_INC 870 extern void *_Malloc(char *file, int line, size_t s); 871 extern void *_Zalloc(char *file, int line, size_t s); 872 extern void *_Realloc(char *file, int line, void *p, size_t s); 873 extern void *_Calloc(char *file, int line, size_t n, size_t s); 874 extern char *_Strdup(char *file, int line, char *p); 875 extern void _Free(char *file, int line, void *p); 876 #define Malloc(s) _Malloc(__FILE__, __LINE__, (s)) 877 #define Zalloc(s) _Zalloc(__FILE__, __LINE__, (s)) 878 #define Realloc(p, s) _Realloc(__FILE__, __LINE__, (p), (s)) 879 #define Calloc(n, s) _Calloc(__FILE__, __LINE__, (n), (s)) 880 #define Strdup(p) _Strdup(__FILE__, __LINE__, (p)) 881 #define Free(p) _Free(__FILE__, __LINE__, (p)) 882 #else /* ! _DEBUG_MALLOC_INC */ 883 extern void *Malloc(size_t s); 884 extern void *Zalloc(size_t s); 885 extern void *Realloc(void *p, size_t s); 886 extern void *Calloc(size_t n, size_t s); 887 extern char *Strdup(char *p); 888 extern void Free(void *p); 889 #endif /* ! _DEBUG_MALLOC_INC */ 890 891 /* meta_metad.c */ 892 extern int clnt_adddrvs(char *hostname, mdsetname_t *sp, 893 md_drive_desc *dd, md_timeval32_t timestamp, 894 ulong_t genid, md_error_t *ep); 895 extern int clnt_addhosts(char *hostname, mdsetname_t *sp, 896 int node_c, char **node_v, md_error_t *ep); 897 extern int clnt_update_namespace(char *hostname, mdsetname_t *sp, 898 side_t side, mddrivename_t *dnp, char *newname, 899 md_error_t *ep); 900 extern int clnt_add_drv_sidenms(char *hostname, char *this_host, 901 mdsetname_t *sp, md_set_desc *sd, int node_c, 902 char **node_v, md_error_t *ep); 903 extern int clnt_createset(char *hostname, mdsetname_t *sp, 904 md_node_nm_arr_t nodes, md_timeval32_t timestamp, 905 ulong_t genid, md_error_t *ep); 906 extern int clnt_mncreateset(char *hostname, mdsetname_t *sp, 907 md_mnnode_desc *nodelist, md_timeval32_t timestamp, 908 ulong_t genid, md_node_nm_t master_nodenm, 909 int master_nodeid, md_error_t *ep); 910 extern int clnt_joinset(char *hostname, mdsetname_t *sp, 911 int flags, md_error_t *ep); 912 extern int clnt_withdrawset(char *hostname, mdsetname_t *sp, 913 md_error_t *ep); 914 extern int clnt_deldrvs_by_devid(char *hostname, mdsetname_t *sp, 915 md_drive_desc *dd, md_error_t *ep); 916 extern int clnt_deldrvs(char *hostname, mdsetname_t *sp, 917 md_drive_desc *dd, md_error_t *ep); 918 extern int clnt_delhosts(char *hostname, mdsetname_t *sp, 919 int node_c, char **node_v, md_error_t *ep); 920 extern int clnt_delset(char *hostname, mdsetname_t *sp, 921 md_error_t *ep); 922 extern int clnt_del_drv_sidenms(char *hostname, mdsetname_t *sp, 923 md_error_t *ep); 924 extern int clnt_devinfo(char *hostname, mdsetname_t *sp, 925 mddrivename_t *dp, md_dev64_t *ret_dev, 926 time_t *ret_timestamp, md_error_t *ep); 927 extern int clnt_devid(char *hostname, mdsetname_t *sp, 928 mddrivename_t *dp, char **ret_encdevid, 929 md_error_t *ep); 930 extern int clnt_devinfo_by_devid(char *hostname, mdsetname_t *sp, 931 char *devidstr, md_dev64_t *retdev, 932 char *orig_devname, char **ret_devname, 933 char **ret_driver, md_error_t *ep); 934 extern int clnt_drvused(char *hostname, mdsetname_t *sp, 935 mddrivename_t *dp, md_error_t *ep); 936 extern void free_sr(md_set_record *sr); 937 extern int clnt_getset(char *hostname, char *setname, set_t setno, 938 md_set_record **sr, md_error_t *ep); 939 extern int clnt_mngetset(char *hostname, char *setname, 940 set_t setno, md_mnset_record **mnsr, 941 md_error_t *ep); 942 extern int clnt_hostname(char *hostname, char **ret_hostname, 943 md_error_t *ep); 944 extern int clnt_nullproc(char *hostname, md_error_t *ep); 945 extern int clnt_ownset(char *hostname, mdsetname_t *sp, 946 int *ret_bool, md_error_t *ep); 947 extern int clnt_setnameok(char *hostname, mdsetname_t *sp, 948 int *ret_bool, md_error_t *ep); 949 extern int clnt_setnumbusy(char *hostname, set_t setno, 950 int *ret_bool, md_error_t *ep); 951 extern int clnt_upd_dr_dbinfo(char *hostname, mdsetname_t *sp, 952 md_drive_desc *dd, md_error_t *ep); 953 extern int clnt_stimeout(char *hostname, mdsetname_t *sp, 954 mhd_mhiargs_t *mhiargsp, md_error_t *ep); 955 extern int clnt_gtimeout(char *hostname, mdsetname_t *sp, 956 mhd_mhiargs_t *ret_mhiargs, md_error_t *ep); 957 extern int clnt_upd_dr_flags(char *hostname, mdsetname_t *sp, 958 md_drive_desc *dd, uint_t new_flags, 959 md_error_t *ep); 960 extern int clnt_enable_sr_flags(char *hostname, mdsetname_t *sp, 961 uint_t new_flags, md_error_t *ep); 962 extern int clnt_disable_sr_flags(char *hostname, mdsetname_t *sp, 963 uint_t new_flags, md_error_t *ep); 964 extern int clnt_upd_sr_flags(char *hostname, mdsetname_t *sp, 965 uint_t new_flags, md_error_t *ep); 966 extern int clnt_upd_nr_flags(char *hostname, mdsetname_t *sp, 967 md_mnnode_desc *nd, uint_t flag_action, 968 uint_t flags, md_error_t *ep); 969 extern int clnt_unlock_set(char *hostname, md_setkey_t *cl_sk, 970 md_error_t *ep); 971 extern int clnt_lock_set(char *hostname, mdsetname_t *sp, 972 md_error_t *ep); 973 extern int clnt_updmeds(char *hostname, mdsetname_t *sp, 974 md_h_arr_t *meddp, md_error_t *ep); 975 extern int clnt_resnarf_set(char *hostname, set_t setno, 976 md_error_t *ep); 977 extern md_setkey_t *cl_get_setkey(set_t setno, char *setname); 978 extern void cl_set_setkey(md_setkey_t *cl_sk); 979 extern void meta_conv_drvname_new2old(o_mddrivename_t *, 980 mddrivename_t *); 981 extern void meta_conv_drvname_old2new(o_mddrivename_t *, 982 mddrivename_t *); 983 extern void meta_conv_drvdesc_new2old(o_md_drive_desc *, 984 md_drive_desc *); 985 extern void meta_conv_drvdesc_old2new(o_md_drive_desc *, 986 md_drive_desc *); 987 extern void alloc_olddrvdesc(o_md_drive_desc **, md_drive_desc *); 988 extern void alloc_newdrvdesc(o_md_drive_desc *, md_drive_desc **); 989 extern void free_olddrvdesc(o_md_drive_desc *); 990 extern void free_newdrvdesc(md_drive_desc *); 991 extern char *meta_get_devid(char *); 992 extern int clnt_mnsetmaster(char *hostname, mdsetname_t *sp, 993 md_node_nm_t master_nodenm, int master_nodeid, 994 md_error_t *ep); 995 extern int clnt_clr_mnsetlock(char *hostname, md_error_t *ep); 996 extern int clnt_mdcommdctl(char *hostname, int flag_action, 997 mdsetname_t *sp, md_mn_msgclass_t class, 998 uint_t flags, md_error_t *ep); 999 extern int clnt_mn_is_stale(char *hostname, mdsetname_t *sp, 1000 int *ret_bool, md_error_t *ep); 1001 extern int clnt_getdrivedesc(char *hostname, mdsetname_t *sp, 1002 md_drive_desc **dd, md_error_t *ep); 1003 extern void free_rem_dd(md_drive_desc *dd); 1004 extern int clnt_upd_dr_reconfig(char *hostname, mdsetname_t *sp, 1005 md_drive_desc *dd, md_error_t *ep); 1006 extern int clnt_reset_mirror_owner(char *hostname, mdsetname_t *sp, 1007 int node_c, int *node_id, md_error_t *ep); 1008 extern int clnt_mn_susp_res_io(char *hostname, set_t setno, 1009 int flag, md_error_t *ep); 1010 extern int clnt_mn_mirror_resync_all(char *hostname, set_t setno, 1011 md_error_t *ep); 1012 extern int clnt_mn_sp_update_abr(char *hostname, set_t setno, 1013 md_error_t *ep); 1014 1015 /* meta_metad_subr.c */ 1016 extern mddb_userreq_t *get_db_rec(md_ur_get_cmd_t cmd, set_t setno, 1017 mddb_type_t type, uint_t type2, mddb_recid_t *idp, 1018 md_error_t *ep); 1019 extern void *get_ur_rec(set_t setno, md_ur_get_cmd_t cmd, 1020 uint_t type2, mddb_recid_t *idp, md_error_t *ep); 1021 extern void sr_validate(void); 1022 extern void sr_del_drv(md_set_record *sr, mddb_recid_t recid); 1023 extern int set_snarf(md_error_t *ep); 1024 extern void sr_cache_add(md_set_record *sr); 1025 extern void sr_cache_del(mddb_recid_t recid); 1026 extern void dr_cache_add(md_set_record *sr, md_drive_record *dr); 1027 extern void dr_cache_del(md_set_record *sr, mddb_recid_t recid); 1028 extern void mnnr_cache_add(md_mnset_record *sr, 1029 md_mnnode_record *nr); 1030 extern void mnnr_cache_del(md_mnset_record *sr, mddb_recid_t recid); 1031 extern int metad_isautotakebyname(char *setname); 1032 extern int metad_isautotakebynum(set_t setno); 1033 extern md_set_record *metad_getsetbyname(char *setname, md_error_t *ep); 1034 extern md_set_record *metad_getsetbynum(set_t setno, md_error_t *ep); 1035 extern void commitset(md_set_record *sr, int inc_genid, 1036 md_error_t *ep); 1037 extern md_set_record *setdup(md_set_record *sr); 1038 extern md_mnset_record *mnsetdup(md_mnset_record *mnsr); 1039 extern md_drive_record *drdup(md_drive_record *dr); 1040 extern md_mnnode_record *nrdup(md_mnnode_record *nr); 1041 extern md_drive_desc *dd_list_dup(md_drive_desc *dd); 1042 extern void sr_cache_flush(int flushnames); 1043 extern void sr_cache_flush_setno(set_t setno); 1044 extern void s_delset(char *setname, md_error_t *ep); 1045 extern void s_delrec(mddb_recid_t recid, md_error_t *ep); 1046 extern int s_ownset(set_t setno, md_error_t *ep); 1047 extern int resnarf_set(set_t setno, md_error_t *ep); 1048 1049 /* meta_mh.c */ 1050 extern mhd_mhiargs_t defmhiargs; 1051 extern int meta_take_own(char *sname, mddrivenamelist_t *dnlp, 1052 mhd_mhiargs_t *mhiargsp, int partial_set, 1053 md_error_t *ep); 1054 extern int tk_own_bydd(mdsetname_t *sp, md_drive_desc *dd, 1055 mhd_mhiargs_t *mhiargsp, int partial_set, 1056 md_error_t *ep); 1057 extern int meta_rel_own(char *sname, mddrivenamelist_t *dnlp, 1058 int partial_set, md_error_t *ep); 1059 extern int rel_own_bydd(mdsetname_t *sp, md_drive_desc *dd, 1060 int partial_set, md_error_t *ep); 1061 extern int meta_status_own(char *sname, 1062 md_disk_status_list_t *dslp, int partial_set, 1063 md_error_t *ep); 1064 extern md_disk_status_list_t *meta_drive_to_disk_status_list( 1065 mddrivenamelist_t *dnlp); 1066 extern void meta_free_disk_status_list(md_disk_status_list_t *dslp); 1067 extern void meta_free_drive_info_list(mhd_drive_info_list_t *listp); 1068 extern int meta_list_drives(char *hostname, char *path, 1069 mhd_did_flags_t flags, 1070 mhd_drive_info_list_t *listp, md_error_t *ep); 1071 extern int meta_get_drive_names(mdsetname_t *sp, 1072 mddrivenamelist_t **dnlpp, int options, 1073 md_error_t *ep); 1074 1075 /* meta_mirror.c */ 1076 extern int meta_get_mirror_names(mdsetname_t *sp, 1077 mdnamelist_t **nlpp, int options, md_error_t *ep); 1078 extern void meta_free_mirror(md_mirror_t *mirrorp); 1079 extern md_mirror_t *meta_get_mirror(mdsetname_t *sp, mdname_t *mirnp, 1080 md_error_t *ep); 1081 extern int meta_check_inmirror(mdsetname_t *sp, mdname_t *np, 1082 diskaddr_t slblk, diskaddr_t nblks, md_error_t *ep); 1083 extern int meta_check_submirror(mdsetname_t *sp, mdname_t *np, 1084 mdname_t *mirnp, int force, md_error_t *ep); 1085 extern char *rd_opt_to_name(mm_rd_opt_t opt); 1086 extern int name_to_rd_opt(char *uname, char *name, 1087 mm_rd_opt_t *optp, md_error_t *ep); 1088 extern char *wr_opt_to_name(mm_wr_opt_t opt); 1089 extern int name_to_wr_opt(char *uname, char *name, 1090 mm_wr_opt_t *optp, md_error_t *ep); 1091 extern int name_to_pass_num(char *uname, char *name, 1092 mm_pass_num_t *passp, md_error_t *ep); 1093 extern char *sm_state_to_name(md_submirror_t *mdsp, 1094 md_status_t mirror_status, md_timeval32_t *tvp, 1095 uint_t tstate); 1096 extern int sm_state_to_action(mdsetname_t *sp, 1097 md_submirror_t *mdsp, md_status_t mirror_status, 1098 md_mirror_t *mirrorp, char **actionp, 1099 md_error_t *ep); 1100 extern int meta_print_mirror_options(mm_rd_opt_t read_options, 1101 mm_wr_opt_t write_option, mm_pass_num_t pass_num, 1102 uint_t tstate, char *fname, 1103 mdsetname_t *sp, FILE *fp, md_error_t *ep); 1104 extern int meta_mirror_print(mdsetname_t *sp, mdname_t *mirnp, 1105 mdnamelist_t **nlpp, char *fname, FILE *fp, 1106 mdprtopts_t options, md_error_t *ep); 1107 extern int meta_mirror_online(mdsetname_t *sp, mdname_t *mirnp, 1108 mdname_t *submirnp, mdcmdopts_t options, 1109 md_error_t *ep); 1110 extern int meta_mirror_offline(mdsetname_t *sp, mdname_t *mirnp, 1111 mdname_t *submirnp, mdcmdopts_t options, 1112 md_error_t *ep); 1113 extern int meta_mirror_attach(mdsetname_t *sp, mdname_t *mirnp, 1114 mdname_t *submirnp, mdcmdopts_t options, 1115 md_error_t *ep); 1116 extern int meta_mirror_detach(mdsetname_t *sp, mdname_t *mirnp, 1117 mdname_t *submirnp, mdcmdopts_t options, 1118 md_error_t *ep); 1119 extern int meta_mirror_get_params(mdsetname_t *sp, 1120 mdname_t *mirnp, mm_params_t *paramsp, 1121 md_error_t *ep); 1122 extern int meta_mirror_set_params(mdsetname_t *sp, 1123 mdname_t *mirnp, mm_params_t *paramsp, 1124 md_error_t *ep); 1125 extern int meta_mirror_replace(mdsetname_t *sp, mdname_t *mirnp, 1126 mdname_t *oldnp, mdname_t *newnp, 1127 mdcmdopts_t options, md_error_t *ep); 1128 extern int meta_mirror_enable(mdsetname_t *sp, mdname_t *mirnp, 1129 mdname_t *compnp, mdcmdopts_t options, 1130 md_error_t *ep); 1131 extern int meta_check_mirror(mdsetname_t *sp, 1132 md_mirror_t *mirrorp, mdcmdopts_t options, 1133 md_error_t *ep); 1134 extern int meta_create_mirror(mdsetname_t *sp, 1135 md_mirror_t *mirrorp, mdcmdopts_t options, 1136 md_error_t *ep); 1137 extern int meta_init_mirror(mdsetname_t **spp, 1138 int argc, char *argv[], mdcmdopts_t options, 1139 md_error_t *ep); 1140 extern int meta_mirror_reset(mdsetname_t *sp, mdname_t *mirnp, 1141 mdcmdopts_t options, md_error_t *ep); 1142 extern int meta_mirror_anycomp_is_err(mdsetname_t *, 1143 mdnamelist_t *); 1144 1145 /* meta_mirror_resync.c */ 1146 extern int meta_mirror_resync(mdsetname_t *sp, mdname_t *mirnp, 1147 daddr_t size, md_error_t *ep, md_resync_cmd_t cmd); 1148 extern int meta_mirror_resync_all(mdsetname_t *sp, daddr_t size, 1149 md_error_t *ep); 1150 extern void *meta_mn_mirror_resync_all(void *arg); 1151 extern void meta_mirror_resync_kill_all(void); 1152 extern void meta_mirror_resync_block_all(void); 1153 extern void meta_mirror_resync_unblock_all(void); 1154 extern void meta_mirror_resync_unblock(mdsetname_t *sp); 1155 extern void meta_mirror_resync_kill(mdsetname_t *sp); 1156 1157 /* meta_mount.c */ 1158 extern char *meta_get_mountp(mdsetname_t *, mdname_t *, 1159 md_error_t *); 1160 1161 /* meta_name.c */ 1162 extern char *meta_name_getname(mdsetname_t **spp, char *uname, 1163 meta_device_type_t uname_type, md_error_t *ep); 1164 extern char *meta_canonicalize(mdsetname_t *sp, char *uname); 1165 extern char *meta_canonicalize_check_set(mdsetname_t **sp, 1166 char *uname, md_error_t *ep); 1167 extern int meta_is_all(char *uname); 1168 extern int is_existing_metadevice(mdsetname_t *sp, char *uname); 1169 extern int is_existing_hsp(mdsetname_t *sp, char *uname); 1170 extern int is_existing_meta_hsp(mdsetname_t *sp, char *uname); 1171 extern int is_metaname(char *uname); 1172 extern int meta_is_none(char *uname); 1173 extern int is_hspname(char *uname); 1174 extern int parse_ctd(char *uname, uint_t *slice); 1175 extern void parse_device(mdsetname_t *, char *, char **, char **); 1176 extern md_set_desc *sr2setdesc(md_set_record *sr); 1177 extern mdsetname_t *metasetname(char *sname, md_error_t *ep); 1178 extern mdsetname_t *metasetnosetname(set_t setno, md_error_t *ep); 1179 extern mdsetname_t *metafakesetname(set_t setno, char *sname); 1180 extern md_set_desc *metaget_setdesc(mdsetname_t *sp, md_error_t *ep); 1181 extern void metaflushsetname(mdsetname_t *sp); 1182 extern void metaflushdrivenames(void); 1183 extern int metaislocalset(mdsetname_t *sp); 1184 extern int metaissameset(mdsetname_t *sp1, mdsetname_t *sp2); 1185 extern void metaflushsidenames(mddrivename_t *dnp); 1186 extern char *metadiskname(char *name); 1187 extern mddrivename_t *metadrivename(mdsetname_t **spp, char *uname, 1188 md_error_t *ep); 1189 extern mddrivename_t *metadrivenamebydevid(mdsetname_t **spp, char *devid, 1190 char *uname, md_error_t *ep); 1191 extern mdname_t *metaslicename(mddrivename_t *dnp, uint_t sliceno, 1192 md_error_t *ep); 1193 extern void metafreedrivename(mddrivename_t *dnp); 1194 extern void metafreedrivenamelist(mddrivenamelist_t *dnlp); 1195 extern int metadrivenamelist(mdsetname_t **spp, 1196 mddrivenamelist_t **dnlpp, 1197 int argc, char *argv[], md_error_t *ep); 1198 extern mddrivename_t *metadrivenamelist_append(mddrivenamelist_t **dnlpp, 1199 mddrivename_t *dnp); 1200 extern mddrivenamelist_t **meta_drivenamelist_append_wrapper( 1201 mddrivenamelist_t **dnlpp, 1202 mddrivename_t *dnp); 1203 extern int meta_getdev(mdsetname_t *sp, mdname_t *np, 1204 md_error_t *ep); 1205 extern mdname_t *metaname_fast(mdsetname_t **spp, char *uname, 1206 meta_device_type_t uname_type, md_error_t *ep); 1207 extern mdname_t *metaname(mdsetname_t **spp, char *uname, 1208 meta_device_type_t uname_type, md_error_t *ep); 1209 extern mdname_t *metamnumname(mdsetname_t **spp, minor_t mnum, 1210 int fast, md_error_t *ep); 1211 extern char *get_mdname(mdsetname_t *sp, minor_t mnum); 1212 extern int metaismeta(mdname_t *np); 1213 extern int metachkmeta(mdname_t *np, md_error_t *ep); 1214 extern int metachkdisk(mdname_t *np, md_error_t *ep); 1215 extern int metachkcomp(mdname_t *np, md_error_t *ep); 1216 extern void metafreenamelist(mdnamelist_t *nlp); 1217 extern int metanamelist(mdsetname_t **spp, mdnamelist_t **nlpp, 1218 int argc, char *argv[], meta_device_type_t type, 1219 md_error_t *ep); 1220 extern mdname_t *metanamelist_append(mdnamelist_t **nlpp, 1221 mdname_t *np); 1222 extern mdnamelist_t **meta_namelist_append_wrapper(mdnamelist_t **nlpp, 1223 mdname_t *np); 1224 extern mdhspname_t *metahspname(mdsetname_t **spp, 1225 char *uname, md_error_t *ep); 1226 extern mdhspname_t *metahsphspname(mdsetname_t **spp, 1227 hsp_t hsp, md_error_t *ep); 1228 extern char *get_hspname(mdsetname_t *sp, hsp_t mnum); 1229 extern void metafreehspnamelist(mdhspnamelist_t *hspnlp); 1230 extern int metahspnamelist(mdsetname_t **spp, 1231 mdhspnamelist_t **hspnlpp, 1232 int argc, char *argv[], md_error_t *ep); 1233 extern mdhspname_t *metahspnamelist_append(mdhspnamelist_t **hspnlp, 1234 mdhspname_t *hspnp); 1235 extern mdname_t *metadevname(mdsetname_t **spp, 1236 md_dev64_t dev, md_error_t *ep); 1237 extern char *get_devname(set_t setno, md_dev64_t dev); 1238 extern mdname_t *metakeyname(mdsetname_t **spp, 1239 mdkey_t key, int fast, md_error_t *ep); 1240 extern void metaflushmetanames(void); 1241 extern void metaflushnames(int flush_sr_cache); 1242 extern int meta_get_hotspare_names(mdsetname_t *sp, 1243 mdnamelist_t **nlpp, int options, md_error_t *ep); 1244 extern void meta_create_non_dup_list(mdname_t *mdnp, 1245 mddevid_t **ldevidpp); 1246 extern mddrivename_t *meta_getdnp_bydevid(mdsetname_t *sp, side_t sideno, 1247 ddi_devid_t devidp, mdkey_t key, md_error_t *ep); 1248 1249 1250 /* meta_nameinfo.c */ 1251 extern mdsetname_t *metagetset(mdname_t *np, int bypass_daemon, 1252 md_error_t *ep); 1253 extern void metafreevtoc(mdvtoc_t *vtocp); 1254 extern int meta_match_enclosure(mdname_t *, mdcinfo_t *, 1255 md_error_t *); 1256 extern mdvtoc_t *metagetvtoc(mdname_t *np, int nocache, uint_t *partnop, 1257 md_error_t *ep); 1258 extern int metasetvtoc(mdname_t *np, md_error_t *ep); 1259 extern void metaflushctlrcache(void); 1260 extern mdgeom_t *metagetgeom(mdname_t *np, md_error_t *ep); 1261 extern mdcinfo_t *metagetcinfo(mdname_t *np, md_error_t *ep); 1262 extern int metagetpartno(mdname_t *np, md_error_t *ep); 1263 extern diskaddr_t metagetsize(mdname_t *np, md_error_t *ep); 1264 extern diskaddr_t metagetlabel(mdname_t *np, md_error_t *ep); 1265 extern diskaddr_t metagetstart(mdsetname_t *sp, mdname_t *np, 1266 md_error_t *ep); 1267 extern int metahasmddb(mdsetname_t *sp, mdname_t *np, 1268 md_error_t *ep); 1269 extern char *metagetdevicesname(mdname_t *np, md_error_t *ep); 1270 extern char *metagetmiscname(mdname_t *np, md_error_t *ep); 1271 extern md_unit_t *meta_get_mdunit(mdsetname_t *sp, mdname_t *np, 1272 md_error_t *ep); 1273 extern void meta_free_unit(mddrivename_t *dnp); 1274 extern void meta_invalidate_name(mdname_t *np); 1275 extern md_common_t *meta_get_unit(mdsetname_t *sp, mdname_t *np, 1276 md_error_t *ep); 1277 extern int meta_isopen(mdsetname_t *sp, mdname_t *np, 1278 md_error_t *ep, mdcmdopts_t options); 1279 1280 /* meta_namespace.c */ 1281 extern char *meta_getnmbykey(set_t setno, side_t sideno, 1282 mdkey_t key, md_error_t *ep); 1283 extern char *meta_getnmentbykey(set_t setno, side_t sideno, 1284 mdkey_t key, char **drvnm, minor_t *mnum, 1285 md_dev64_t *dev, md_error_t *ep); 1286 extern char *meta_getnmentbydev(set_t setno, side_t sideno, 1287 md_dev64_t dev, char **drvnm, minor_t *mnum, 1288 mdkey_t *key, md_error_t *ep); 1289 extern char *meta_gethspnmentbyid(set_t setno, side_t sideno, 1290 hsp_t hspid, md_error_t *ep); 1291 extern hsp_t meta_gethspnmentbyname(set_t setno, side_t sideno, 1292 char *hspname, md_error_t *ep); 1293 extern char *meta_getdidminorbykey(set_t setno, side_t sideno, 1294 mdkey_t key, md_error_t *ep); 1295 extern ddi_devid_t meta_getdidbykey(set_t setno, side_t sideno, 1296 mdkey_t key, md_error_t *ep); 1297 extern int meta_setdid(set_t setno, side_t sideno, mdkey_t key, 1298 md_error_t *ep); 1299 extern int add_name(mdsetname_t *sp, side_t sideno, mdkey_t key, 1300 char *dname, minor_t mnum, char *bname, 1301 char *minorname, ddi_devid_t devid, md_error_t *ep); 1302 extern int del_name(mdsetname_t *sp, side_t sideno, mdkey_t key, 1303 md_error_t *ep); 1304 extern int add_key_name(mdsetname_t *sp, mdname_t *np, 1305 mdnamelist_t **nlpp, md_error_t *ep); 1306 extern int del_key_name(mdsetname_t *sp, mdname_t *np, 1307 md_error_t *ep); 1308 extern int del_key_names(mdsetname_t *sp, mdnamelist_t *nlp, 1309 md_error_t *ep); 1310 extern mdkey_t add_self_name(mdsetname_t *, char *, 1311 md_mkdev_params_t *, md_error_t *); 1312 extern int del_self_name(mdsetname_t *, mdkey_t, 1313 md_error_t *); 1314 1315 /* meta_patch.c */ 1316 extern int meta_patch_vfstab(char *cmpname, mdname_t *fsnp, 1317 char *vname, char *old_bdevname, int doit, 1318 int verbose, char **tname, md_error_t *ep); 1319 extern int meta_patch_fsdev(char *fsname, mdname_t *fsnp, 1320 char *vname, md_error_t *ep); 1321 extern int meta_patch_swapdev(mdname_t *fsnp, 1322 char *vname, char *old_bdevname, md_error_t *ep); 1323 extern int meta_patch_mddb(char *sname, char *cname, int patch, 1324 md_error_t *ep); 1325 1326 /* meta_patch_root.c */ 1327 extern int meta_patch_rootdev(mdname_t *np, char *sname, 1328 char *vname, char *cname, char *dbname, int doit, 1329 int verbose, md_error_t *ep); 1330 1331 /* meta_print.c */ 1332 extern int meta_print_name(mdsetname_t *sp, mdname_t *namep, 1333 mdnamelist_t **nlpp, char *fname, FILE *fp, 1334 mdprtopts_t options, mdnamelist_t **lognlpp, 1335 md_error_t *ep); 1336 extern int meta_print_all(mdsetname_t *sp, char *fname, 1337 mdnamelist_t **nlpp, FILE *fp, 1338 mdprtopts_t options, int *meta_print_trans_msgp, 1339 md_error_t *ep); 1340 extern char *meta_print_time(md_timeval32_t *timep); 1341 extern char *meta_print_hrtime(hrtime_t secs); 1342 extern int meta_prbits(FILE *fp, const char *fmt, ...); 1343 extern char *meta_number_to_string(diskaddr_t number, 1344 u_longlong_t blk_sz); 1345 extern int meta_get_tstate(md_dev64_t dev64, uint_t *tstatep, 1346 md_error_t *ep); 1347 extern int meta_print_devid(mdsetname_t *sp, FILE *fp, 1348 mddevid_t *mddevidp, md_error_t *ep); 1349 1350 /* meta_raid.c */ 1351 extern int meta_get_raid_names(mdsetname_t *sp, 1352 mdnamelist_t **nlpp, int options, md_error_t *ep); 1353 extern void meta_free_raid(md_raid_t *raidp); 1354 extern md_raid_t *meta_get_raid_common(mdsetname_t *sp, mdname_t *raidnp, 1355 int fast, md_error_t *ep); 1356 extern md_raid_t *meta_get_raid(mdsetname_t *sp, mdname_t *raidnp, 1357 md_error_t *ep); 1358 extern int meta_check_inraid(mdsetname_t *sp, mdname_t *np, 1359 diskaddr_t slblk, diskaddr_t nblks, md_error_t *ep); 1360 extern int meta_check_column(mdsetname_t *sp, mdname_t *np, 1361 md_error_t *ep); 1362 extern char *raid_state_to_name(md_raid_t *raidp, 1363 md_timeval32_t *tvp, uint_t tstate); 1364 extern char *raid_state_to_action(md_raid_t *raidp); 1365 extern char *raid_col_state_to_name(md_raidcol_t *colp, 1366 md_timeval32_t *tvp, uint_t tstate); 1367 extern int meta_print_raid_options(mdhspname_t *hspnamep, 1368 char *fname, FILE *fp, md_error_t *ep); 1369 extern int meta_raid_print(mdsetname_t *sp, mdname_t *raidnp, 1370 mdnamelist_t **nlpp, char *fname, FILE *fp, 1371 mdprtopts_t options, md_error_t *ep); 1372 extern int meta_raid_attach(mdsetname_t *sp, mdname_t *raidnp, 1373 mdnamelist_t *nlp, mdcmdopts_t options, 1374 md_error_t *ep); 1375 extern int meta_raid_get_params(mdsetname_t *sp, mdname_t *raidnp, 1376 mr_params_t *paramsp, md_error_t *ep); 1377 extern int meta_raid_set_params(mdsetname_t *sp, mdname_t *raidnp, 1378 mr_params_t *paramsp, md_error_t *ep); 1379 extern int meta_raid_replace(mdsetname_t *sp, mdname_t *raidnp, 1380 mdname_t *oldnp, mdname_t *newnp, 1381 mdcmdopts_t options, md_error_t *ep); 1382 extern int meta_raid_enable(mdsetname_t *sp, mdname_t *raidnp, 1383 mdname_t *compnp, mdcmdopts_t options, 1384 md_error_t *ep); 1385 extern diskaddr_t meta_default_raid_interlace(void); 1386 extern int meta_raid_check_interlace(diskaddr_t interlace, 1387 char *uname, md_error_t *ep); 1388 extern int meta_check_raid(mdsetname_t *sp, md_raid_t *raidp, 1389 mdcmdopts_t options, md_error_t *ep); 1390 extern int meta_create_raid(mdsetname_t *sp, md_raid_t *raidp, 1391 mdcmdopts_t options, md_error_t *ep); 1392 extern int meta_init_raid(mdsetname_t **spp, 1393 int argc, char *argv[], mdcmdopts_t options, 1394 md_error_t *ep); 1395 extern int meta_raid_reset(mdsetname_t *sp, mdname_t *np, 1396 mdcmdopts_t options, md_error_t *ep); 1397 extern int meta_raid_anycomp_is_err(mdsetname_t *, mdnamelist_t *); 1398 1399 /* meta_raid_resync.c */ 1400 extern int meta_raid_resync(mdsetname_t *sp, mdname_t *raidnp, 1401 daddr_t size, md_error_t *ep); 1402 extern int meta_raid_resync_all(mdsetname_t *sp, daddr_t size, 1403 md_error_t *ep); 1404 1405 extern int meta_raid_regen_byname(mdsetname_t *sp, 1406 mdname_t *raidnp, diskaddr_t size, md_error_t *ep); 1407 1408 /* meta_repartition.c */ 1409 extern int meta_replicaslice(mddrivename_t *dnp, 1410 uint_t *slicep, md_error_t *ep); 1411 1412 /* meta_replace.c */ 1413 extern int meta_replace_byname(mdsetname_t *sp, mdname_t *namep, 1414 mdname_t *oldnp, mdname_t *newnp, 1415 mdcmdopts_t options, md_error_t *ep); 1416 extern int meta_enable_byname(mdsetname_t *sp, mdname_t *namep, 1417 mdname_t *compnp, mdcmdopts_t options, 1418 md_error_t *ep); 1419 1420 /* meta_reset.c */ 1421 extern int meta_reset(mdsetname_t *sp, mdname_t *np, 1422 mdcmdopts_t options, md_error_t *ep); 1423 extern int meta_reset_all(mdsetname_t *sp, mdcmdopts_t options, 1424 md_error_t *ep); 1425 extern int meta_reset_by_name(mdsetname_t *sp, mdname_t *np, 1426 mdcmdopts_t options, md_error_t *ep); 1427 1428 /* meta_resync.c */ 1429 extern int meta_resync_byname(mdsetname_t *sp, mdname_t *np, 1430 daddr_t size, md_error_t *ep, md_resync_cmd_t cmd); 1431 extern int meta_resync_all(mdsetname_t *sp, daddr_t size, 1432 md_error_t *ep); 1433 1434 /* meta_set.c */ 1435 extern set_t get_max_sets(md_error_t *ep); 1436 extern int get_max_meds(md_error_t *ep); 1437 extern side_t getmyside(mdsetname_t *sp, md_error_t *ep); 1438 extern md_set_record *getsetbyname(char *setname, md_error_t *ep); 1439 extern md_set_record *getsetbynum(set_t setno, md_error_t *ep); 1440 extern int meta_check_drive_inuse(mdsetname_t *sp, 1441 mddrivename_t *dnp, int check_db, md_error_t *ep); 1442 extern int meta_check_ownership(mdsetname_t *sp, md_error_t *ep); 1443 extern int meta_check_ownership_on_host(mdsetname_t *sp, 1444 char *hostname, md_error_t *ep); 1445 extern int meta_is_member(char *node_name, md_mn_nodeid_t node_id, 1446 mndiskset_membershiplist_t *nl); 1447 extern int meta_getnextside_devinfo(mdsetname_t *sp, char *bname, 1448 side_t *sideno, char **ret_bname, char **ret_dname, 1449 minor_t *ret_mnum, md_error_t *ep); 1450 extern int meta_getside_devinfo(mdsetname_t *sp, char *bname, 1451 side_t sideno, char **ret_bname, char **ret_dname, 1452 minor_t *ret_mnum, md_error_t *ep); 1453 extern int meta_is_drive_in_anyset(mddrivename_t *dnp, 1454 mdsetname_t **spp, int bypass_daemon, 1455 md_error_t *ep); 1456 extern int meta_is_drive_in_thisset(mdsetname_t *sp, 1457 mddrivename_t *dnp, int bypass_daemon, 1458 md_error_t *ep); 1459 extern int meta_is_devid_in_anyset(void *devid, 1460 mdsetname_t **spp, md_error_t *ep); 1461 extern int meta_is_devid_in_thisset(mdsetname_t *sp, 1462 void *devid, md_error_t *ep); 1463 extern int meta_set_balance(mdsetname_t *sp, md_error_t *ep); 1464 extern int meta_set_destroy(mdsetname_t *sp, int lock_set, 1465 md_error_t *ep); 1466 extern int meta_set_purge(mdsetname_t *sp, int bypass_cluster, 1467 int forceflg, md_error_t *ep); 1468 extern int meta_set_query(mdsetname_t *sp, mddb_dtag_lst_t **dtlpp, 1469 md_error_t *ep); 1470 extern mddrivename_t *metadrivename_withdrkey(mdsetname_t *sp, 1471 side_t sideno, mdkey_t key, int flags, 1472 md_error_t *ep); 1473 extern void metafreedrivedesc(md_drive_desc **dd); 1474 extern md_drive_desc *metaget_drivedesc(mdsetname_t *sp, int flags, 1475 md_error_t *ep); 1476 extern md_drive_desc *metaget_drivedesc_fromnamelist(mdsetname_t *sp, 1477 mdnamelist_t *nlp, md_error_t *ep); 1478 extern md_drive_desc *metaget_drivedesc_sideno(mdsetname_t *sp, 1479 side_t sideno, int flags, md_error_t *ep); 1480 extern int metaget_setownership(mdsetname_t *sp, md_error_t *ep); 1481 extern char *mynode(void); 1482 extern int strinlst(char *str, int cnt, char **lst); 1483 extern int meta_get_reserved_names(mdsetname_t *sp, 1484 mdnamelist_t **nlpp, int options, md_error_t *ep); 1485 extern int meta_set_join(mdsetname_t *sp, md_error_t *ep); 1486 extern int meta_set_withdraw(mdsetname_t *sp, md_error_t *ep); 1487 extern int meta_reconfig_choose_master(); 1488 extern int meta_mnsync_user_records(mdsetname_t *sp, 1489 md_error_t *ep); 1490 extern int meta_mnsync_diskset_mddbs(mdsetname_t *sp, 1491 md_error_t *ep); 1492 extern int meta_mnjoin_all(mdsetname_t *sp, md_error_t *ep); 1493 extern int meta_getandsetmaster(mdsetname_t *sp, 1494 md_mnset_record *mnsr, md_set_desc *sd, 1495 md_error_t *ep); 1496 extern int meta_devid_use(md_error_t *ep); 1497 1498 /* meta_set_drv.c */ 1499 extern int meta_make_sidenmlist(mdsetname_t *, 1500 mddrivename_t *, int imp_flag, 1501 md_im_drive_info_t *midp, md_error_t *); 1502 extern int meta_set_adddrives(mdsetname_t *sp, 1503 mddrivenamelist_t *dnlp, daddr_t dbsize, 1504 int force_label, md_error_t *ep); 1505 extern int meta_set_deletedrives(mdsetname_t *sp, 1506 mddrivenamelist_t *dnlp, int forceflg, 1507 md_error_t *ep); 1508 1509 /* meta_set_hst.c */ 1510 extern int meta_set_checkname(char *setname, md_error_t *ep); 1511 extern int meta_set_addhosts(mdsetname_t *sp, int multi_node, 1512 int node_c, char **node_v, int auto_take, 1513 md_error_t *ep); 1514 extern int meta_set_deletehosts(mdsetname_t *sp, int node_c, 1515 char **node_v, int forceflg, md_error_t *ep); 1516 extern int meta_set_auto_take(mdsetname_t *sp, int take_val, 1517 md_error_t *ep); 1518 1519 /* meta_set_med.c */ 1520 extern int meta_set_addmeds(mdsetname_t *sp, int node_c, 1521 char **node_v, md_error_t *ep); 1522 extern int meta_set_deletemeds(mdsetname_t *sp, int node_c, 1523 char **node_v, int forceflg, md_error_t *ep); 1524 1525 /* meta_set_tkr.c */ 1526 extern int meta_set_take(mdsetname_t *sp, mhd_mhiargs_t *mhiargsp, 1527 int flags, int usetag, md_error_t *ep); 1528 extern int meta_set_release(mdsetname_t *sp, md_error_t *ep); 1529 extern int meta_update_mb(mdsetname_t *sp, md_drive_desc *dd, 1530 md_error_t *ep); 1531 1532 /* meta_setup.c */ 1533 extern char *myname; 1534 extern FILE *metalogfp; 1535 extern int metasyslog; 1536 extern uint_t verbosity; 1537 extern hrtime_t start_time; 1538 extern sigset_t allsigs; 1539 #define ANYSIG allsigs 1540 extern char *meta_lock_name(set_t setno); 1541 extern int meta_unlock(mdsetname_t *sp, md_error_t *ep); 1542 extern int meta_lock(mdsetname_t *sp, int print_status, 1543 md_error_t *ep); 1544 extern int meta_lock_nowait(mdsetname_t *sp, md_error_t *ep); 1545 extern int meta_lock_status(mdsetname_t *sp, md_error_t *ep); 1546 extern int md_daemonize(mdsetname_t *sp, md_error_t *ep); 1547 extern void md_exit(mdsetname_t *sp, int eval); 1548 extern void md_post_sig(int sig); 1549 extern int md_got_sig(void); 1550 extern int md_which_sig(void); 1551 extern void md_rb_sig_handling_on(void); 1552 extern void md_rb_sig_handling_off(int sig_seen, int sig); 1553 extern void setup_mc_log(uint_t level); 1554 extern int md_init(int argc, char *argv[], 1555 int dosyslog, int doadmin, md_error_t *ep); 1556 extern int md_init_nosig(int argc, char *argv[], 1557 int dosyslog, int doadmin, md_error_t *ep); 1558 1559 extern int md_init_daemon(char *name, md_error_t *ep); 1560 1561 /* meta_smf.c */ 1562 extern int meta_smf_enable(uint_t flags, md_error_t *ep); 1563 extern int meta_smf_disable(uint_t flags, md_error_t *ep); 1564 extern int meta_smf_isonline(uint_t flags, md_error_t *ep); 1565 extern int meta_smf_getmask(); 1566 1567 /* meta_sp.c */ 1568 extern int meta_get_sp_names(mdsetname_t *sp, mdnamelist_t **nlpp, 1569 int options, md_error_t *ep); 1570 extern int meta_check_insp(mdsetname_t *sp, mdname_t *np, 1571 diskaddr_t slblk, diskaddr_t nblks, md_error_t *ep); 1572 extern int meta_sp_print(mdsetname_t *sp, mdname_t *np, 1573 mdnamelist_t **nlpp, char *fname, FILE *fp, 1574 mdprtopts_t options, md_error_t *ep); 1575 extern md_sp_t *meta_get_sp_common(mdsetname_t *sp, mdname_t *np, 1576 int fast, md_error_t *ep); 1577 extern md_sp_t *meta_get_sp(mdsetname_t *sp, mdname_t *np, 1578 md_error_t *ep); 1579 extern int meta_init_sp(mdsetname_t **spp, int argc, char *argv[], 1580 mdcmdopts_t options, md_error_t *ep); 1581 extern void meta_free_sp(md_sp_t *spp); 1582 extern int meta_sp_issp(mdsetname_t *sp, mdname_t *np, 1583 md_error_t *ep); 1584 extern int meta_sp_reset(mdsetname_t *sp, mdname_t *np, 1585 mdcmdopts_t options, md_error_t *ep); 1586 extern int meta_sp_reset_component(mdsetname_t *sp, char *name, 1587 mdcmdopts_t options, md_error_t *ep); 1588 extern int meta_sp_attach(mdsetname_t *sp, mdname_t *np, 1589 char *addsize, mdcmdopts_t options, 1590 sp_ext_length_t alignment, md_error_t *ep); 1591 extern int meta_recover_sp(mdsetname_t *sp, mdname_t *np, int argc, 1592 char *argv[], mdcmdopts_t options, md_error_t *ep); 1593 extern boolean_t meta_sp_can_create_sps(mdsetname_t *mdsetnamep, 1594 mdname_t *mdnamep, int number_of_sps, 1595 blkcnt_t sp_size); 1596 extern boolean_t meta_sp_can_create_sps_on_drive(mdsetname_t *mdsetnamep, 1597 mddrivename_t *mddrivenamep, int number_of_sps, 1598 blkcnt_t sp_size); 1599 extern blkcnt_t meta_sp_get_free_space(mdsetname_t *mdsetnamep, 1600 mdname_t *mdnamep); 1601 extern blkcnt_t meta_sp_get_free_space_on_drive(mdsetname_t *mdsetnamep, 1602 mddrivename_t *mddrivenamep); 1603 extern int meta_sp_get_number_of_possible_sps( 1604 mdsetname_t *mdsetnamep, mdname_t *mdnamep, 1605 blkcnt_t sp_size); 1606 extern int meta_sp_get_number_of_possible_sps_on_drive( 1607 mdsetname_t *mdsetnamep, 1608 mddrivename_t *mddrivenamep, blkcnt_t sp_size); 1609 extern blkcnt_t meta_sp_get_possible_sp_size(mdsetname_t *mdsetnamep, 1610 mdname_t *mdnamep, int number_of_sps); 1611 extern blkcnt_t meta_sp_get_possible_sp_size_on_drive( 1612 mdsetname_t *mdsetnamep, 1613 mddrivename_t *mddrivenamep, int number_of_sps); 1614 extern int meta_sp_setstatus(mdsetname_t *sp, minor_t *minors, 1615 int num_units, sp_status_t status, md_error_t *ep); 1616 extern int meta_sp_parsesize(char *s, sp_ext_length_t *szp); 1617 extern int meta_sp_update_abr(mdsetname_t *sp, md_error_t *ep); 1618 extern void *meta_mn_sp_update_abr(void *arg); 1619 1620 /* meta_stat.c */ 1621 extern int meta_stat(const char *, struct stat *); 1622 extern void metaflushstatcache(void); 1623 1624 /* meta_stripe.c */ 1625 extern int meta_stripe_replace(mdsetname_t *sp, mdname_t *stripenp, 1626 mdname_t *oldnp, mdname_t *newnp, 1627 mdcmdopts_t options, md_error_t *ep); 1628 extern int meta_get_stripe_names(mdsetname_t *sp, 1629 mdnamelist_t **nlpp, int options, md_error_t *ep); 1630 extern void meta_free_stripe(md_stripe_t *stripep); 1631 extern md_stripe_t *meta_get_stripe_common(mdsetname_t *sp, 1632 mdname_t *stripenp, int fast, md_error_t *ep); 1633 extern md_stripe_t *meta_get_stripe(mdsetname_t *sp, mdname_t *stripenp, 1634 md_error_t *ep); 1635 extern int meta_check_instripe(mdsetname_t *sp, mdname_t *np, 1636 diskaddr_t slblk, diskaddr_t nblks, md_error_t *ep); 1637 extern int meta_check_component(mdsetname_t *sp, mdname_t *np, 1638 int force, md_error_t *ep); 1639 extern char *comp_state_to_name(md_comp_t *mdcp, 1640 md_timeval32_t *tvp, uint_t tstate); 1641 extern int meta_print_stripe_options(mdhspname_t *hspnamep, 1642 char *fname, FILE *fp, md_error_t *ep); 1643 extern int meta_stripe_print(mdsetname_t *sp, mdname_t *stripenp, 1644 mdnamelist_t **nlpp, char *fname, FILE *fp, 1645 mdprtopts_t options, md_error_t *ep); 1646 extern int meta_find_erred_comp(mdsetname_t *sp, 1647 mdname_t *stripenp, mdname_t **compnpp, 1648 comp_state_t *compstate, md_error_t *ep); 1649 extern int meta_stripe_attach(mdsetname_t *sp, mdname_t *stripenp, 1650 mdnamelist_t *nlp, diskaddr_t interlace, 1651 mdcmdopts_t options, md_error_t *ep); 1652 extern int meta_stripe_get_params(mdsetname_t *sp, 1653 mdname_t *stripenp, ms_params_t *paramsp, 1654 md_error_t *ep); 1655 extern int meta_stripe_set_params(mdsetname_t *sp, 1656 mdname_t *stripenp, ms_params_t *paramsp, 1657 md_error_t *ep); 1658 extern diskaddr_t meta_default_stripe_interlace(void); 1659 extern int meta_stripe_check_interlace(diskaddr_t interlace, 1660 char *uname, md_error_t *ep); 1661 extern int meta_check_stripe(mdsetname_t *sp, 1662 md_stripe_t *stripep, mdcmdopts_t options, 1663 md_error_t *ep); 1664 extern int meta_create_stripe(mdsetname_t *sp, 1665 md_stripe_t *stripep, mdcmdopts_t options, 1666 md_error_t *ep); 1667 extern int meta_init_stripe(mdsetname_t **spp, 1668 int argc, char *argv[], mdcmdopts_t options, 1669 md_error_t *ep); 1670 extern int meta_stripe_reset(mdsetname_t *sp, mdname_t *stripenp, 1671 mdcmdopts_t options, md_error_t *ep); 1672 extern int meta_stripe_anycomp_is_err(mdsetname_t *, 1673 mdnamelist_t *); 1674 1675 /* meta_systemfile.c */ 1676 extern int meta_systemfile_copy(char *sname, int doroot, 1677 int domddb, int doit, int verbose, char **tname, 1678 FILE **tfp, md_error_t *ep); 1679 extern int meta_systemfile_append_mdroot(mdname_t *rootnp, 1680 char *sname, char *tname, FILE *tfp, int ismeta, 1681 int doit, int verbose, md_error_t *ep); 1682 extern int meta_systemfile_append_mddb(char *cname, char *sname, 1683 char *tname, FILE *tfp, int doit, int verbose, 1684 int check, md_error_t *ep); 1685 1686 /* meta_tab.c */ 1687 extern void meta_tab_dump(md_tab_t *tabp, FILE *fp); 1688 extern void meta_tab_free(md_tab_t *tabp); 1689 extern md_tab_t *meta_tab_parse(char *filename, md_error_t *ep); 1690 extern md_tab_line_t *meta_tab_find(mdsetname_t *sp, md_tab_t *tabp, 1691 char *name, mdinittypes_t type); 1692 1693 /* meta_trans.c */ 1694 extern int meta_trans_replace(mdsetname_t *sp, mdname_t *transnp, 1695 mdname_t *oldnp, mdname_t *newnp, 1696 mdcmdopts_t options, md_error_t *ep); 1697 extern int meta_get_trans_names(mdsetname_t *sp, 1698 mdnamelist_t **nlpp, int options, md_error_t *ep); 1699 extern void meta_free_trans(md_trans_t *transp); 1700 extern md_trans_t *meta_get_trans(mdsetname_t *sp, mdname_t *transnp, 1701 md_error_t *ep); 1702 extern md_trans_t *meta_get_trans_common(mdsetname_t *sp, 1703 mdname_t *transnp, int fast, md_error_t *ep); 1704 extern int meta_check_intrans(mdsetname_t *sp, mdname_t *np, 1705 mdchkopts_t options, diskaddr_t slblk, 1706 diskaddr_t nblks, md_error_t *ep); 1707 extern int meta_check_master(mdsetname_t *sp, mdname_t *np, 1708 int force, md_error_t *ep); 1709 extern int meta_check_log(mdsetname_t *sp, mdname_t *np, 1710 md_error_t *ep); 1711 extern char *mt_l_error_to_name(md_trans_t *transp, 1712 md_timeval32_t *tvp, uint_t tstate); 1713 extern char *mt_flags_to_name(md_trans_t *transp, 1714 md_timeval32_t *tvp, uint_t tstate); 1715 extern char *mt_flags_to_action(md_trans_t *transp); 1716 extern char *mt_l_error_to_action( 1717 mdsetname_t *sp, 1718 mdnamelist_t *transnlp, 1719 mdname_t *lognamep, 1720 md_error_t *ep); 1721 extern int meta_trans_print(mdsetname_t *sp, mdname_t *transnp, 1722 mdnamelist_t **nlistpp, char *fname, FILE *fp, 1723 mdprtopts_t options, int *meta_print_trans_msgp, 1724 mdnamelist_t **lognlpp, md_error_t *ep); 1725 extern int meta_logs_print(mdsetname_t *sp, mdnamelist_t *lognlp, 1726 mdnamelist_t **nlistpp, char *fname, FILE *fp, 1727 mdprtopts_t options, md_error_t *ep); 1728 extern int meta_trans_attach(mdsetname_t *sp, mdname_t *transnp, 1729 mdname_t *lognp, mdcmdopts_t options, 1730 md_error_t *ep); 1731 extern int meta_trans_detach(mdsetname_t *sp, mdname_t *transnp, 1732 mdcmdopts_t options, int *delayed, md_error_t *ep); 1733 extern int meta_check_trans(mdsetname_t *sp, md_trans_t *transp, 1734 mdcmdopts_t options, md_error_t *ep); 1735 extern int meta_create_trans(mdsetname_t *sp, md_trans_t *transp, 1736 mdcmdopts_t options, char *uname, md_error_t *ep); 1737 extern int meta_init_trans(mdsetname_t **spp, 1738 int argc, char *argv[], mdcmdopts_t options, 1739 md_error_t *ep); 1740 extern int meta_trans_reset(mdsetname_t *sp, mdname_t *transnp, 1741 mdcmdopts_t options, md_error_t *ep); 1742 1743 /* meta_userflags.c */ 1744 extern int meta_getuserflags(mdsetname_t *sp, mdname_t *np, 1745 uint_t *userflags, md_error_t *ep); 1746 extern int meta_setuserflags(mdsetname_t *sp, mdname_t *np, 1747 uint_t userflags, md_error_t *ep); 1748 1749 /* metarpcopen.c */ 1750 extern CLIENT *meta_client_create_retry(char *hostname, 1751 clnt_create_func_t func, void *data, 1752 time_t tout, md_error_t *ep); 1753 extern CLIENT *meta_client_create(char *host, rpcprog_t prognum, 1754 rpcvers_t version, char *nettype); 1755 extern CLIENT *metarpcopen(char *hostname, long time_out, 1756 md_error_t *ep); 1757 extern void metarpcclose(CLIENT *clntp); 1758 extern void metarpccloseall(void); 1759 extern int cl_sto(CLIENT *clntp, char *hostname, long time_out, 1760 md_error_t *ep); 1761 1762 /* metasplitname.c */ 1763 extern int splitname(char *devname, md_splitname *splitname); 1764 extern char *splicename(md_splitname *splitname); 1765 1766 /* meta_notify.c */ 1767 extern int meta_notify_createq(char *qname, ulong_t flags, 1768 md_error_t *ep); 1769 extern int meta_notify_deleteq(char *qname, md_error_t *ep); 1770 extern int meta_notify_validq(char *qname, md_error_t *ep); 1771 extern int meta_notify_listq(char ***qnames, md_error_t *ep); 1772 extern int meta_notify_flushq(char *qname, md_error_t *ep); 1773 1774 extern int meta_notify_getev(char *qname, ulong_t flags, 1775 md_ev_t *evp, md_error_t *ep); 1776 extern int meta_notify_getevlist(char *qname, ulong_t flags, 1777 md_evlist_t **evlpp, md_error_t *ep); 1778 extern int meta_notify_putev(md_ev_t *evp, md_error_t *ep); 1779 extern int meta_notify_putevlist(md_evlist_t *evlistp, 1780 md_error_t *ep); 1781 extern void meta_notify_freeevlist(md_evlist_t *evlp); 1782 1783 extern int meta_notify_sendev(ev_obj_t tag, set_t set, 1784 md_dev64_t dev, evid_t event); 1785 1786 extern int meta_exchange(mdsetname_t *, mdname_t *, mdname_t *, 1787 mdcmdopts_t, md_error_t *); 1788 extern int meta_rename(mdsetname_t *, mdname_t *, mdname_t *, 1789 mdcmdopts_t, md_error_t *); 1790 /* meta_se_notify.c */ 1791 extern void meta_svm_sysevent(char *se_class, char *se_subclass, 1792 uint32_t tag, set_t setno, md_dev64_t devid); 1793 1794 /* metgetroot.c */ 1795 extern void *meta_get_current_root(md_error_t *ep); 1796 extern mdname_t *meta_get_current_root_dev(mdsetname_t *sp, 1797 md_error_t *ep); 1798 1799 /* meta_time.c */ 1800 extern int meta_gettimeofday(md_timeval32_t *tv); 1801 1802 /* meta_devadm.c */ 1803 extern int meta_fixdevid(mdsetname_t *sp, mddevopts_t options, 1804 char *diskname, md_error_t *ep); 1805 extern int meta_upd_ctdnames(mdsetname_t **sp, set_t setno, 1806 side_t sideno, mddrivename_t *dnp, char **newname, 1807 md_error_t *ep); 1808 extern int pathname_reload(mdsetname_t **sp, set_t setno, 1809 md_error_t *ep); 1810 extern int meta_update_devtree(minor_t mnum); 1811 1812 /* meta_mn_comm.c */ 1813 extern int mdmn_send_message(set_t setno, md_mn_msgtype_t type, 1814 uint_t flags, char *data, int size, 1815 md_mn_result_t **resp, md_error_t *ep); 1816 extern int mdmn_send_message_with_msgid(set_t setno, 1817 md_mn_msgtype_t type, uint_t flags, char *data, 1818 int size, md_mn_result_t **resp, 1819 md_mn_msgid_t *msgid, md_error_t *ep); 1820 extern int mdmn_create_msgid(md_mn_msgid_t *id); 1821 extern int mdmn_reinit_set(set_t setno, long timeout); 1822 extern int mdmn_resume(set_t setno, md_mn_msgclass_t class, 1823 uint_t flags, long timeout); 1824 extern int mdmn_suspend(set_t setno, md_mn_msgclass_t class, 1825 long timeout); 1826 extern int mdmn_msgtype_lock(md_mn_msgtype_t msgtype, 1827 uint_t locktype); 1828 extern void mdmn_abort(void); 1829 extern md_mn_result_t *copy_result(md_mn_result_t *res); 1830 extern void free_result(md_mn_result_t *res); 1831 extern md_mn_msg_t *copy_msg(md_mn_msg_t *src, md_mn_msg_t *dest); 1832 1833 /* meta_import.c */ 1834 extern int read_master_block(md_error_t *ep, int fd, void *bp, 1835 int bsize); 1836 extern int read_database_block(md_error_t *, int, mddb_mb_t *, int, 1837 void *, int); 1838 extern daddr_t getphysblk(mddb_block_t, mddb_mb_t *); 1839 1840 extern md_im_drive_info_t *pick_good_disk(md_im_set_desc_t *misp); 1841 1842 extern void meta_unrslv_replicated_mb(mdsetname_t *sp, 1843 md_drive_desc *dd, mddrivenamelist_t *dnlp, 1844 md_error_t *ep); 1845 extern void meta_unrslv_replicated_nm(mdsetname_t *sp, 1846 md_drive_desc *dd, mddrivenamelist_t *dnlp, 1847 md_error_t *ep); 1848 extern void * replicated_list_lookup(uint_t devid_len, 1849 void *old_devid); 1850 extern int build_replicated_disks_list(md_error_t *ep, 1851 mddrivenamelist_t *dnlp); 1852 1853 /* 1854 * pnm_rec is used to store the mapping from keys in the NM namespace 1855 * to actual physical devices. The current name of a physical device, used 1856 * by a set that can be imported, can be retrieved by matching the did_key 1857 * (deviceID entry) in the DID_SHR_NM namespace to the min_devid_key in the 1858 * DID_NM namespace(the did_key to the min_key). Then matching the min_key 1859 * in the DID_NM namespace to the n_key in the NM namespace. 1860 * 1861 * n_name is defined to be an array, so that only one malloc is needed for the 1862 * entire datastructure. 1863 */ 1864 typedef struct pnm_rec { 1865 mdkey_t n_key; /* The n_key/min_key value */ 1866 struct pnm_rec *next; 1867 ushort_t n_namlen; 1868 char n_name[1]; /* The name of the physical device */ 1869 } pnm_rec_t; 1870 1871 /* Indentation value for metaimport output */ 1872 #define META_INDENT 4 1873 1874 /* Flags for metaimport reporting */ 1875 #define META_IMP_REPORT 0x0001 1876 #define META_IMP_VERBOSE 0x0002 1877 #define META_IMP_PASS1 0x1000 1878 1879 extern int meta_list_disks(md_error_t *, md_im_names_t *); 1880 extern mddrivenamelist_t *meta_prune_cnames(md_error_t *, 1881 md_im_names_t *, int); 1882 extern int meta_get_and_report_set_info( 1883 mddrivenamelist_t *, md_im_set_desc_t **, 1884 int, uint_t, int *, int, 1885 md_im_drive_info_t *, md_error_t *); 1886 extern void free_pnm_rec_list(pnm_rec_t **); 1887 extern int meta_imp_set(md_im_set_desc_t *, 1888 char *, int, bool_t, md_error_t *); 1889 extern int meta_imp_drvused(mdsetname_t *sp, 1890 mddrivename_t *dnp, md_error_t *ep); 1891 extern int meta_replica_quorum(md_im_set_desc_t *misp); 1892 extern int meta_imp_set_adddrives(mdsetname_t *sp, 1893 mddrivenamelist_t *dnlp, 1894 md_im_set_desc_t *misp, md_error_t *ep); 1895 extern void meta_free_im_set_desc(md_im_set_desc_t *misp); 1896 extern int clnt_imp_adddrvs(char *hostname, 1897 mdsetname_t *sp, md_drive_desc *dd, 1898 md_timeval32_t timestamp, 1899 ulong_t genid, md_error_t *ep); 1900 1901 /* Flags for direction in copy_msg_1 */ 1902 #define MD_MN_COPY_TO_ONDISK 0x0001 1903 #define MD_MN_COPY_TO_INCORE 0x0002 1904 1905 extern void copy_msg_1(md_mn_msg_t *incorep, 1906 md_mn_msg_od_t *ondiskp, int direction); 1907 extern void free_msg(md_mn_msg_t *msg); 1908 1909 extern md_mn_msgclass_t mdmn_get_message_class(md_mn_msgtype_t msgtype); 1910 extern void (*mdmn_get_handler(md_mn_msgtype_t msgtype)) 1911 (md_mn_msg_t *msg, uint_t flags, 1912 md_mn_result_t *res); 1913 extern int (*mdmn_get_submessage_generator(md_mn_msgtype_t type)) 1914 (md_mn_msg_t *msg, md_mn_msg_t **msglist); 1915 extern time_t mdmn_get_timeout(md_mn_msgtype_t msgtype); 1916 1917 extern int meta_read_nodelist(int *nodecnt, 1918 mndiskset_membershiplist_t **nl, md_error_t *ep); 1919 extern int meta_write_nodelist(int nodecnt, char **nids, 1920 md_error_t *ep); 1921 extern void meta_free_nodelist(mndiskset_membershiplist_t *nl); 1922 1923 /* meta_mn_subr.c */ 1924 /* defines for flags argument for meta_mn_send_command() */ 1925 #define MD_DISP_STDERR 0x0000 1926 #define MD_IGNORE_STDERR 0x0001 1927 #define MD_DRYRUN 0x0002 1928 #define MD_RETRY_BUSY 0x0004 1929 #define MD_NOLOG 0x0008 1930 #define MD_PANIC_WHEN_INCONSISTENT 0x0010 1931 1932 /* define for initall_context argument for meta_mn_send_command() */ 1933 #define NO_CONTEXT_STRING NULL 1934 1935 extern int meta_is_mn_set(mdsetname_t *sp, md_error_t *ep); 1936 extern int meta_is_mn_name(mdsetname_t **sp, char *name, 1937 md_error_t *ep); 1938 extern void meta_ping_mnset(set_t setno); 1939 extern int meta_mn_send_command(mdsetname_t *sp, int argc, 1940 char *argv[], int flags, char *initall_context, 1941 md_error_t *ep); 1942 extern int meta_mn_send_suspend_writes(minor_t mnum, 1943 md_error_t *ep); 1944 extern int meta_mn_send_setsync(mdsetname_t *sp, 1945 mdname_t *mirnp, daddr_t size, md_error_t *ep); 1946 extern int meta_mn_send_metaclear_command(mdsetname_t *sp, 1947 char *name, mdcmdopts_t options, int pflag, 1948 md_error_t *ep); 1949 extern int meta_mn_send_resync_starting(mdname_t *mirnp, 1950 md_error_t *ep); 1951 extern int meta_mn_change_owner(md_set_mmown_params_t **opp, 1952 set_t setno, uint_t mnum, uint_t owner, 1953 uint_t flags); 1954 extern int meta_mn_singlenode(void); 1955 extern int meta_mn_send_get_tstate(md_dev64_t dev, uint_t *tstatep, 1956 md_error_t *ep); 1957 /* meta_set_prv.c */ 1958 extern int setup_db_bydd(mdsetname_t *sp, md_drive_desc *dd, 1959 int force, md_error_t *ep); 1960 extern int snarf_set(mdsetname_t *sp, bool_t stale_bool, 1961 md_error_t *ep); 1962 extern int halt_set(mdsetname_t *sp, md_error_t *ep); 1963 1964 /* meta_statconcise.c */ 1965 extern void print_concise_entry(int indent, char *name, 1966 diskaddr_t size, char mtype); 1967 extern char *meta_get_raid_col_state(rcs_state_t); 1968 extern char *meta_get_stripe_state(comp_state_t); 1969 extern char *meta_get_hs_state(hotspare_states_t); 1970 extern int report_metastat_info(mddb_mb_t *, mddb_lb_t *, 1971 mddb_rb_t *, pnm_rec_t **, mdname_t *, int, 1972 md_timeval32_t *, md_error_t *); 1973 1974 #ifdef __cplusplus 1975 } 1976 #endif 1977 1978 #endif /* _META_H */ 1979