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