/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_MD_MDDB_H
#define _SYS_MD_MDDB_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#if 0 /* DRP FOR DEBUGGING */
#define MDDB_FAKE
#endif
/* Private flags */
/* only be done once */
/* returned from NEW_DEV */
/*
* returned from: mddb_getnextrec
* mddb_getrecsize
* mddb_commitrec
* mddb_commitrecs
* mddb_deleterec
*/
/* to perform requested operation */
/* 16MB */
/* 256MB */
/*
* Used during reconfig cycle to determine quickly if there is
* new master for the set.
*/
/* Definitions of flag in Locator Block Device ID data area - mddb_did_info */
/* Definitions of flag in Locator Block - mddb_lb */
/*
* Set struct used by all parts of the driver, to store anchor pointers.
*
* Lock associated with field in this structure:
*
* Some of fields are accessible by both the single threaded ioctl thread
* and internal threads such as resync, hotsparing...etc. In this case
* additional protection is needed. For example, s_db is protected by
* s_dbmx additionally and s_un, s_ui are protected by md_unit_array_rw.lock
* s_nm, s_nmid, s_did_nm and s_did_nmid and s_dtp are protected by nm_lock
* Rest of other fileds are protected by md_mx. Two fields s_un_next and
* s_un_avail are introduced by the friendly name project and are ONLY
* accessible via a single threaded ioctl thread which already is protected
* by the ioctl lock and there is no need to add extra protection to them.
* However, in the future if they become accessible by other internal threads
* then an additional protection such as md_mx lock is highly recommended.
*
*/
typedef struct md_set {
} md_set_t;
/*
* MDDB_REV_MNMB:
* If a MN diskset, master block revision is set to MDDB_REV_MNMB.
* Even though the master block structure is no different
* for a MN set, setting the revision field to a different
* number keeps any pre-MN_diskset code from accessing
* this diskset. It also allows for an early determination
* of a MN diskset when reading in from disk so that the
* proper size locator block and locator names structure
* can be read in thus saving time on diskset startup.
* Since no change in master block structure, the MDDB_REV_MINOR
* portion of the revision was incremented.
*
* MDDB_REV_MNLB:
* If a MN diskset, the locator block structure is a different size in
* order to accomodate up to MD_MNMAXSIDES nodes in a diskset
* with any nodeid (sideno) allowed.
* The revision is set to MDDB_REV_MNLB which is a change of the
* MDDB_REV_MAJOR portion of the revision.
*
* MDDB_REV_MNLN:
* If a MN diskset, the locator names is a different size in
* order to accomodate up to MD_MNMAXSIDES nodes in a diskset
* with any nodeid (sideno) allowed.
* The revision is set to MDDB_REV_MNLN which is a change of the
* MDDB_REV_MAJOR portion of the revision.
*
* The record blocks have two binary properties. A record block can
* represent either a 32 or 64 bit unit. A record block can also represent
* a traditionally named unit or a friendly named unit. Thus, there are
* minor revisions of record block.
*
* Traditional Friendly
* Name Name
* ----------- --------
* 32 bit MDDB_REV_RB MDDB_REV_RBFN
* 64 bit MDDB_REV_RB64 MDDB_REV_RB64FN
*/
/*
*/
case MDDB_REV_RB: \
case MDDB_REV_RB64: \
unv &= ~MD_FN_META_DEV; \
break; \
case MDDB_REV_RBFN: \
case MDDB_REV_RB64FN: \
unv |= MD_FN_META_DEV; \
break; \
}
typedef int mddb_block_t;
#pragma pack(4)
#endif
typedef struct md_mnname_suffix {
typedef struct mddb_ln {
int ln_magic;
/* Don't change array sizes without changing RNDUP_BLKCNT */
} mddb_ln_t;
/*
* Locator name structure for MN diskset. Same as for traditional
* and local diskset except that more sides are supported and the
* side number can be any number since the side number is stored
* in the ln_mnsuffixes structure instead of being used as an index
* into that array. This means that the whole array may need to be
* searched in order to find the correct information given a side number.
*/
typedef struct mddb_mnln {
int ln_magic;
/* Don't change array sizes without changing MDDB_MNLNCNT */
} mddb_mnln_t;
((delta) * \
sizeof (md_name_suffix))
/ MDDB_BSIZE)
typedef struct mddb_dt {
} mddb_dt_t;
typedef union identifier {
} identifier_t;
typedef struct mddb_locator {
int l_flags;
typedef struct mddb_sidelocator {
typedef struct mddb_mnsidelocator {
typedef struct mddb_drvnm {
} mddb_drvnm_t;
/*
* Locator Block Device ID Information
* Several device id's may share one disk block in an effort to
* conserve used replica space.
*/
typedef struct mddb_did_info {
typedef struct mddb_did_blk {
#pragma pack()
#endif
/*
* Device ID Disk Blocks.
* Incore linked list of disk blocks containing device IDs.
* The list is built when reading in the mddb_did_blk structure and
* when reading in the actual disk blocks containing device ids.
* This list is used to easily write out all disk blocks containing
* device ids.
*/
typedef struct mddb_did_db {
/*
* Device ID Free List.
* Incore linked list of free space in disk blocks containing device IDs.
* Used to manage placement of device IDs in disk blocks.
* All disk blocks on free list are also in linked list of disk block
* containing device IDs (mddb_did_db_t).
*/
typedef struct mddb_did_free {
/*
* Device ID Incore Area
* Contains pointer to Device ID Disk Block list and
* Device ID Free List.
* Also contains incore array of pointers to device IDs. Pointers
* point into the device ID Disk Block list and are used as a
* shortcut to find incore device IDs.
*/
typedef struct mddb_did_ic {
/*
* Locator Block (LB):
* - Are fixed size, but the size is different
* - All LB's start at logical block 0.
* - After a replica quorum is found, there is
* is only one incore copy of the LB.
* - LB's are only written when replicas are added, deleted, or errored.
* - LB's provide information about other replica's and their state.
*/
#pragma pack(4)
#endif
typedef struct mddb_lb {
/* Don't change array sizes without changing RNDUP_BLKCNT */
} mddb_lb_t;
#pragma pack()
#endif
/*
* Locator block structure for MN diskset. Same as for traditional
* and local diskset except that more sides are supported and the
* side number can be any number since the side number is stored
* in the lb_mnsidelocators structure instead of being used as an index
* into that array. This means that the whole array may need to be
* searched in order to find the correct information given a side number.
*/
typedef struct mddb_mnlb {
/* Don't change array sizes without changing MDDB_MNLBCNT */
} mddb_mnlb_t;
sizeof (mddb_sidelocator_t))
/ MDDB_BSIZE)
typedef struct mddb_map {
} mddb_map_t;
/*
* Master block(s) (MB)
* - Are written by userland; Never by the driver!
* - Each replica has there own master blocks,
* the master block(s) are not shared.
* - MB's are not in the logical block address space of the database.
* - MB's are a fixed size record (MDDB_BSIZE)
* - MB's provide the logical to physical block translation,
* for their replica.
*/
typedef struct mddb_mb {
#ifdef _LP64
#else
#endif /* _LP64 */
} mddb_mb_t;
/*
* In-core version of mddb_mb. It is known that the mddb_mb is 512 bytes on
* disk, really, and so this structure is 512 + sizeof(struct mddb_mb_ic *)
*/
typedef struct mddb_mb_ic {
} mddb_mb_ic_t;
/*
* there can be no address in record block. The checksum must
* stay the same where ever the record is in memory. Many
* things depend on this. Also the timestamp is the time the the
* record was committed not the time it was written to a particular
* device.
*
* Old definition of mddb_rb, for 32-bit apps and libraries
*/
typedef struct mddb_rb {
void *rb_userdata;
} mddb_rb_t;
/* This is, and always will be, the on-disk version of mddb_rb */
typedef struct mddb_rb32 {
} mddb_rb32_t;
/*
* directory entries
*/
typedef struct mddb_optinfo {
int o_li;
int o_flags;
/* Old definition of mddb_de, for 32-bit apps and libraries */
typedef struct mddb_de {
} mddb_de_t;
/*
* In core version of mddb_de, includes pointer for mddb_rb32_t user data
* mddb_rb32_t is used incore
*/
typedef struct mddb_de_ic {
void *de_rb_userdata;
void *de_rb_userdata_ic;
} mddb_de_ic_t;
typedef struct mddb_db {
#ifdef _KERNEL
#else
#endif
} mddb_db_t;
/*
* This is, and always will be, the on-disk version of mddb_de
* When mddb_de32 is read in it is converted into mddb_de_ic
*/
typedef struct mddb_de32 {
} mddb_de32_t;
/*
* This is, and always will be, the on-disk version of mddb_db
* When mddb_db32 is read in it is converted into mddb_db
* To minimize impact on mddb format mddb_db fileds remain intact
*/
typedef struct mddb_db32 {
} mddb_db32_t;
{ \
int i; \
for (i = 0; i < from->de32_blkcount; i++) \
}
{ \
int i; \
for (i = 0; i < from->de_blkcount; i++) \
}
/*
* information about a replica of the data base
*/
typedef struct mddb_ri {
int ri_transplant;
} mddb_ri_t;
typedef struct mddb_bf {
} mddb_bf_t;
/*
* Information for sets of databases (which include replicas)
*/
((i) & MDDB_RECIDMASK))
/*
* We need to keep s_ident and s_inittime 32 bit. They are used in mddb_lb
*/
typedef struct mddb_set {
/* May be cast to mddb_mnlb_t */
/* if accessing sidenames in */
/* MN diskset */
/* May be cast to mddb_mnln_t */
/* if accessing sidenames in */
/* MN diskset */
int s_optwantlck;
int s_optwaiterr;
int s_opthungerr;
int s_opthavequeuinglck;
int s_optwantqueuinglck;
int s_bufwakeup;
void *s_databuffer;
int s_singlelockgotten;
int s_singlelockwanted;
} mddb_set_t;
#ifndef MDDB_FAKE
#ifdef _KERNEL
/* md_mddb.c */
extern void mddb_locatorblock2splitname(mddb_ln_t *,
int, side_t, md_splitname *);
extern int mddb_configure(mddb_cfgcmd_t,
struct mddb_config *);
extern int mddb_getoptloc(mddb_optloc_t *);
extern void *mddb_getrecaddr(mddb_recid_t);
off_t);
extern int mddb_getrecprivate(mddb_recid_t);
extern int mddb_getrectype2(mddb_recid_t);
extern int mddb_getrecsize(mddb_recid_t);
extern int mddb_commitrec(mddb_recid_t);
extern int mddb_commitrecs(mddb_recid_t *);
extern int mddb_deleterec(mddb_recid_t);
extern void mddb_init(void);
extern void mddb_unload(void);
int mode);
int mode);
int mode);
int mode);
#ifdef DEBUG
extern void mddb_check(void);
#endif /* DEBUG */
#endif /* _KERNEL */
#else
#define md_lb_did_convert(a, b, c) (0)
#define mddb_configure(a, b) (0)
#define mddb_getrecprivate(a) (0)
#define mddb_setrecprivate(a, b) (0)
#define mddb_getrectype1(a) (0)
#define mddb_getrectype2(a) (0)
#define mddb_getrecsize(a) (0)
#define mddb_commitrec(a) (0)
#define mddb_commitrecs(a) (0)
#define mddb_deleterec(a) (0)
#define mddb_unload() (0)
#endif
#define MDDB_SLEEPOK 0
/* Flags passed to selectreplicas - not a bit mask */
#define MDDB_RETRYSCAN 0
/* and ondisk mddb by writing incore */
/* values to disk. Don't write */
/* change log records. */
/* Flags passed to writestart and writecopy */
/* - change log records */
/* - optimized resync records */
#define MDDB_NOPROBE 0
/*
* MN diskset definitions used to determine if a slave can write
* directly to the mddb. ONLY_MASTER only allows the master node
* to write to the mddb. ANY_NODE allows any node to write
* to the mddb.
*/
#define MDDB_WR_ONLY_MASTER 0
#ifdef __cplusplus
}
#endif
#endif /* _SYS_MD_MDDB_H */