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