md_mirror.h revision 20bfb7bbfd42ba8121fb6ca123254c43402579ca
/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_MD_MIRROR_H
#define _SYS_MD_MIRROR_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
*/
/*
* Default resync block size for MN resync messages
*/
#define MD_DEF_RESYNC_BLK_SZ 8192
/*
* macro to test if the current block is within the current resync region
*/
/*
* Default resync update interval (in minutes).
*/
#define MD_DEF_MIRROR_RESYNC_INTVL 5
/*
* Defines for flags argument in function set_sm_comp_state()
*/
/*
* Defines for flags argument in function check_comp_4_hotspares()
*/
/*
* Defines for argument in function send_mn_resync_done_message()
*/
#define RESYNC_ERR 0x1
#define CLEAR_OPT_NOT_DONE 0x2
/*
* Defines for argument in function resync_read_blk_range()
*/
#define MD_FIRST_RESYNC_NEXT 0x1
#define MD_SEND_MESS_XMIT 0x2
#define MD_RESYNC_FLAG_ERR 0x4
/*
* Define for argument in function wait_for_overlaps()
*/
#define MD_OVERLAP_NO_REPEAT 0 /* ps must not already be on chain */
/*
* Define for max retries of mirror_owner
*/
#define MD_OWNER_RETRIES 10
/*
* mm_submirror32_od and mm_unit32_od are used only for 32 bit old format
*/
#pragma pack(4)
#endif
typedef struct mm_submirror32_od { /* submirrors */
int sm_hsp_id; /* used for mirroring plain devices */
typedef struct mm_submirror { /* submirrors */
int sm_hsp_id; /* used for mirroring plain devices */
typedef struct mm_unit32_od {
mdc_unit32_od_t c; /* common stuff */
int un_last_read; /* last submirror index read */
int un_ovrlap_chn_flg;
/*
* following used to keep dirty bitmaps
*/
/*
* following stuff is private to resync process
*/
int un_rs_copysize;
int un_rs_dests; /* destinations */
int un_rs_dropped_lock;
/*
* Incore elements in this old structure are no longer referenced by
* current 64 bit kernel. Comment them out for maintenance purpose.
*
* mm_submirror_ic_t un_smic[NMIRROR];
* kmutex_t un_ovrlap_chn_mx;
* kcondvar_t un_ovrlap_chn_cv;
* struct md_mps *un_ovrlap_chn;
* kmutex_t un_resync_mx;
* kcondvar_t un_resync_cv;
* short *un_outstanding_writes;
* uchar_t *un_goingclean_bm;
* uchar_t *un_goingdirty_bm;
* uchar_t *un_dirty_bm;
* uchar_t *un_resync_bm;
* char *un_rs_buffer;
*/
#pragma pack()
#endif
/* Types of resync in progress (used for un_rs_type) */
#define MD_RS_NONE 0 /* No resync */
/*
* un_rs_type is split into the following bitfields:
*
* 0-3 Resync type (as above)
* 4-7 Submirror index [0..3]
* 8-31 Component index
*/
#define RS_TYPE_MASK 0xF
#define RS_SMI_MASK 0xF0
#define RS_CI_MASK 0x1FFF00
#define RS_TYPE(x) ((x) & RS_TYPE_MASK)
#define SET_RS_TYPE(x, v) { \
(x) &= ~RS_TYPE_MASK; \
(x) |= ((v) & RS_TYPE_MASK); \
}
#define SET_RS_TYPE_NONE(x) { \
(x) &= ~RS_TYPE_MASK; \
}
#define SET_RS_SMI(x, v) { \
(x) &= ~RS_SMI_MASK; \
(x) |= (((v) << 4) & RS_SMI_MASK); \
}
#define SET_RS_CI(x, v) { \
(x) &= ~RS_CI_MASK; \
(x) |= (((v) << 8) & RS_CI_MASK); \
}
typedef struct mm_submirror_ic {
diskaddr_t, u_longlong_t *);
int (*sm_get_component_count)(md_dev64_t, void *);
typedef struct md_mps {
int ps_frags;
struct md_mps *ps_ovrlap_next;
struct md_mps *ps_ovrlap_prev;
void (*ps_call)();
} md_mps_t;
#define MD_MPS_ON_OVERLAP 0x0001
#define MD_MPS_ERROR 0x0002
#define MD_MPS_WRITE_AFTER_READ 0x0004
#define MD_MPS_WOW 0x0008
#define MD_MPS_DONTFREE 0x0010
#define MD_MPS_DONE 0x0020
#define MD_MPS_RESYNC_READ 0x1000
{ \
else \
}
typedef struct md_mcs {
/* Add new structure members HERE!! */
/* DO NOT add structure members here; cs_buf is dynamically sized */
} md_mcs_t;
typedef struct mm_mirror_ic {
short *un_outstanding_writes; /* outstanding write array */
char *un_rs_buffer;
int un_suspend_wr_flag;
int un_dmr_last_read; /* last DMR submirror read */
int un_abr_count; /* count of sp's with abr set */
typedef struct mm_unit {
mdc_unit_t c; /* common stuff */
int un_last_read; /* last submirror index read */
int un_ovrlap_chn_flg;
/*
* following used to keep dirty bitmaps
*/
/*
* following stuff is private to resync process
*/
int un_rs_copysize;
int un_rs_dests; /* destinations */
int un_rs_dropped_lock;
/*
* Incore only elements
*/
/*
* resync thread control
*/
void *un_rs_msg; /* Intra-node resync message */
} mm_unit_t;
#define MM_RF_GATECLOSED 0x0001
#define MM_RF_COMMIT_NEEDED 0x0002
#define MM_RF_COMMITING 0x0004
#define MM_RF_STALL_CLEAN (MM_RF_COMMITING | \
#define MD_MN_MIRROR_UNOWNED 0
#define MD_MN_NO_MIRROR_OWNER(un) \
typedef struct err_comp {
int ec_smi;
int ec_ci;
} err_comp_t;
extern int md_min_rr_size;
extern int md_def_num_rr;
/* Optimized resync records controllers */
#define MD_MIN_RR_SIZE (md_min_rr_size)
#define MD_DEF_NUM_RR (md_def_num_rr)
/* default resync buffer size */
#define MD_DEF_RESYNC_BUF_SIZE (1024)
/* Structure for optimized resync records */
typedef struct optim_resync {
/* Type 2 for mirror records */
#define MIRROR_REC 1
#define RESYNC_REC 2
#ifdef _KERNEL
#define NO_SUBMIRRORS (0)
#define ALL_SUBMIRRORS (0xFFF)
/* For use with mirror_other_sources() */
#define WHOLE_SM (-1)
(i) = ((b) / ((un))->un_rrd_blksize); \
if ((i) > ((un))->un_rrd_num) \
{ panic("md: BLK_TO_RR"); } \
}
(b) = ((i) * ((un))->un_rrd_blksize)
/*
* Write-On-Write handling.
* flags for md_mirror_wow_flg
* structure for quing copy-writes
* macros for relative locating of header and buffer
*/
typedef struct wowhdr {
int wow_offset;
} wowhdr_t;
/*
* Structure used to to save information about DMR reads. Used to save
* the count of all DMR reads and the timestamp of the last one executed.
* We declare a global with this structure and it can be read by a debugger to
* verify that the DMR ioctl has been executed and the number of times that it
* has been executed.
*/
typedef struct dmr_stats {
struct timeval dmr_timestamp;
} dmr_stats_t;
/* Externals from mirror.c */
extern void mirror_release_sm_unit(md_dev64_t);
extern void mirror_set_sm_state(mm_submirror_t *,
mm_submirror_ic_t *, sm_state_t, int);
extern int poke_hotspares(void);
extern void build_submirror(mm_unit_t *, int, int);
extern int mirror_build_incore(mm_unit_t *, int);
extern void set_sm_comp_state(mm_unit_t *, int, int, int,
extern int mirror_other_sources(mm_unit_t *, int, int, int);
extern void md_mirror_strategy(buf_t *, int, void *);
mddb_recid_t, IOLOCK *);
/* Externals from mirror_ioctl.c */
extern void reset_comp_states(mm_submirror_t *,
/* rename named service functions */
/* Externals from mirror_resync.c */
extern int unit_setup_resync(mm_unit_t *, int);
extern void mirror_process_unit_resync(mm_unit_t *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_MD_MIRROR_H */