md_raid.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_MD_RAID_H
#define _SYS_MD_RAID_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* following bits are used in status word in the common section
* of unit structure: un_status
*/
#define RAID_UNMAGIC 0xBADBABE0
#define RAID_PSMAGIC 0xBADBABE1
#define RAID_CSMAGIC 0xBADBABE2
#define RAID_PWMAGIC 0xBADBABE3
#define RAID_BUFMAGIC 0xBADBABE4
/*
* These are the major constants for the definition of a raid device
*/
/*
* Note: magic is needed only to set rpw_magic, not rpw_magic_ext!
*/
rpw64->rpw_devstart = \
rpw64->rpw_pwstart = \
} else { \
raid_pwhdr32_od_t *rpw32 = \
(raid_pwhdr32_od_t *)(void *)(buf); \
rpw32->rpw_devstart = \
rpw32->rpw_pwstart = \
} \
}
}
typedef struct mr_scoreboard {
int sb_column;
int sb_flags;
void *sb_cs;
typedef struct mr_pw_reserve {
int pw_column;
int pw_free;
#pragma pack(4)
#endif
typedef struct mr_column {
} mr_column_t;
/*
* mr_column32_od is for old 32 bit format only
*/
typedef struct mr_column32_od {
/*
* Incore only elements structures
*/
typedef struct mr_column_ic {
typedef struct mr_unit_ic {
struct md_raidcs *_t_un_linlck_chn;
} mr_unit_ic_t;
typedef struct mr_unit {
mdc_unit_t c;
int un_raid_res;
long long un_pwid;
/*
* This union has to begin at an 8 byte aligned address.
* If not, this structure has different sizes in 32 / 64 bit
* environments, since in a 64 bit environment the compiler
* adds paddings before a long long, if it doesn't start at an 8byte
* aligned address.
* Be careful if you add or remove structure elements before it!
*/
union {
struct {
int _t_un_resync_index;
} _resync;
struct {
} _init;
} _t_un;
/*
* This union has to begin at an 8 byte aligned address.
* Be careful if you add or remove structure elements before it!
*/
union {
} un_mr_ic;
} mr_unit_t;
/*
* For old 32 bit format use only
*/
typedef struct mr_unit32_od {
struct timeval32 un_timestamp;
long long un_pwid;
union {
struct {
int _t_un_resync_index;
} _resync;
struct {
} _init;
} _t_un;
/*
* This spot is 8 byte aligned!!!
* Don't change this arrangement.
*/
union {
struct {
} _mric;
struct {
} _lckmx;
} _unic;
short xx_un_linlck_cv;
int xx_un_mx[2];
short xx_un_cv;
typedef struct raid_pwhdr {
int rpw_columnnum;
long long rpw_id;
char rpw_filler[12];
} raid_pwhdr_t;
/*
* For old 32 bit pre-write area
*/
typedef struct raid_pwhdr32_od {
int rpw_columnnum;
long long rpw_id;
#pragma pack()
#endif
#ifdef _KERNEL
/*
* the buffer header is only bp_mapin if it is needed. It is needed on
* all writes and on some reads. ps_mapin is non zero if the buffer is
* maped in. ps_mapin_mx protect ps_mapin. The protocol for usage is
*
* 1) check for non-zero and continue if non-zero
* 2) aquire the ps_mapin_mx
* 3) recheck for non-zero and continue if non-zero
* 4) bp_mapin
* 5) set ps_mapin to non-zero
* 6) drop ps_mapin_mx
*
* the reason for this is to avoid the mutex when possible.
*/
typedef struct md_raidps { /* raid parent save */
int ps_flags;
int ps_error;
int ps_frags;
int ps_pwfrags;
int ps_mapin; /* buffer maped in if non zero */
} md_raidps_t;
/* flags for parent save area */
#define MD_RPS_ERROR 0x0001
#define MD_RPS_READ 0x0020
#define MD_RPS_WRITE 0x0040
#define MD_RPS_DONE 0x0080
#define MD_RPS_INUSE 0x0100
#define MD_RPS_IODONE 0x0200
#define MD_RPS_HSREQ 0x0400
/*
* used in cs_state to describe the type of io operation in progress
*/
enum raid_io_stage {
RAID_NONE = 0x0,
RAID_READ_DONE = 0x1,
RAID_WRITE_DONE = 0x2,
RAID_PREWRITE_DONE = 0x4,
RAID_WRITE_PONLY_DONE = 0x8,
RAID_WRITE_DONLY_DONE = 0x10,
RAID_LINE_PWDONE = 0x20
};
typedef struct md_raidcbuf {
int cbuf_column;
int cbuf_sum;
int cbuf_pwslot;
int cbuf_pwcnt; /* 0x30 */
int cbuf_flags;
#define CBUF_PW_INVALIDATE (0x00000001)
#define CBUF_WRITE (0x00000002)
typedef struct md_raidcs {
int cs_flags;
void (*cs_call)();
void (*cs_error_call)();
void (*cs_retry_call)();
struct md_raidcs *cs_linlck_next;
struct md_raidcs *cs_linlck_prev;
long long cs_pwid;
int cs_dcolumn;
int cs_dpwslot;
int cs_pcolumn;
int cs_ppwslot;
int cs_loop;
int cs_frags;
int cs_strategy_flag;
void *cs_strategy_private;
int cs_error;
int cs_resync_check;
int cs_rstate;
/* Add new structure members HERE!! */
/* DO NOT add struture members here; cs_dbuf is dynamically sized */
} md_raidcs_t;
/* value definitions for cs_resync_check */
#define RCL_DATA_MASK 0x000000ff
#define RCL_PARITY_MASK 0x0000ff00
/* value definitions for cs_flags */
#define MD_RCS_MPBUF 0x000008
#define MD_RCS_RECOVERY 0x020000
/* value definitions for cs_pflags or cs_dflags */
#define MD_RCS_ISUP 0x0002
/* value definitions for gcs_flags */
#define MD_RGCS_ALLOCBUF 0x0001
/* returned value from raid_replay() */
#define RAID_RPLY_SUCCESS 0x0000
#define RAID_RPLY_ALLOCFAIL 0x0001
#define RAID_RPLY_COMPREPLAY 0x0002
#define RAID_RPLY_READONLY 0x0004
#define RAID_RPLY_EIO 0x0008
typedef struct raid_rplybuf {
typedef struct raid_rplylst {
struct raid_rplylst *rpl_next;
long long rpl_id;
int rpl_column1;
int rpl_column2;
/* Externals from raid.c */
extern int raid_build_incore(void *, int);
/* Externals from raid_ioctl.c */
/* rename named service functions */
/* redefinitions of the union shared by resync and init */
#define MD_RFLAG_NEEDBUF (0x0001)
#define MD_RFLAG_CLEAR (0x0002)
#define MD_RFLAG_KEEP (0x0004)
#define MD_RFLAG_NEEDPW (0x0008)
extern intptr_t raid_hotspares();
int oflags);
int resync_thread);
int colindex);
int colindex);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_MD_RAID_H */