stmf_sbd.h revision b77b9231da168bb31490f65bf2697f6031b7f601
/*
* 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 2011 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _STMF_SBD_H
#define _STMF_SBD_H
#ifdef __cplusplus
extern "C" {
#endif
typedef stmf_status_t sbd_status_t;
extern char sbd_vendor_id[];
extern char sbd_product_id[];
extern char sbd_revision[];
extern char *sbd_mgmt_url;
extern uint16_t sbd_mgmt_url_alloc_size;
extern krwlock_t sbd_global_prop_lock;
/*
* Error codes
*/
#define SBD_SUCCESS STMF_SUCCESS
#define SBD_FAILURE STMF_LU_FAILURE
#define SHARED_META_DATA_SIZE 65536
#define SBD_META_OFFSET 4096
/*
* sms endianess
*/
#define SMS_BIG_ENDIAN 0x00
#define SMS_LITTLE_ENDIAN 0xFF
#ifdef _BIG_ENDIAN
#define SMS_DATA_ORDER SMS_BIG_ENDIAN
#else
#define SMS_DATA_ORDER SMS_LITTLE_ENDIAN
#endif
#define SBD_MAGIC 0x53554e5342444c55
#define SBD_VER_MAJOR 1
#define SBD_VER_MINOR 1
#define SBD_VER_SUBMINOR 0
#if 0
typedef struct sbd_meta_start {
#endif
typedef struct sm_section_hdr {
/*
* sbd meta section identifiers
*/
#define SMS_ID_LU_INFO_1_0 0
#define SMS_ID_LU_INFO_1_1 1
#define SMS_ID_PGR_INFO 2
#define SMS_ID_UNUSED 0x1000
typedef struct sbd_lu_info_1_0 {
typedef struct sbd_lu_info_1_1 {
char sli_rev[4];
char sli_vid[8];
char sli_pid[16];
/*
* Essetially zfs volume name for zvols to verify that the
* metadata is coming in from the correct zvol and not from a
* clone. Has no meaning in any other case.
*/
/*
* Data filename or the media filename when the metadata is in
* a separate file. Its not needed if the metadata is shared
* with data as the user supplied name is the data filename.
*/
/*
* In case there is no separate meta, sli_meta_fname_offset wont
* be valid. The same is true for zfs based metadata. The data_fname
* is the zvol.
*/
/*
* sli flags
*/
#define SLI_SEPARATE_META 0x0001
#define SLI_WRITE_PROTECTED 0x0002
#define SLI_VID_VALID 0x0004
#define SLI_PID_VALID 0x0008
#define SLI_REV_VALID 0x0010
#define SLI_META_FNAME_VALID 0x0020
#define SLI_DATA_FNAME_VALID 0x0040
#define SLI_SERIAL_VALID 0x0080
#define SLI_ALIAS_VALID 0x0100
#define SLI_WRITEBACK_CACHE_DISABLE 0x0200
#define SLI_ZFS_META 0x0400
#define SLI_MGMT_URL_VALID 0x0800
struct sbd_it_data;
typedef struct sbd_lu {
/* Current LU state */
char *sl_name; /* refers to meta or data */
/* Metadata */
char *sl_alias;
char *sl_meta_filename; /* If applicable */
char *sl_mgmt_url;
char sl_vendor_id[8];
char sl_product_id[16];
char sl_revision[4];
/* zfs metadata */
char *sl_zfs_meta;
/* opaque handles for zvol direct calls */
void *sl_zvol_minor_hdl;
void *sl_zvol_objset_hdl;
void *sl_zvol_zil_hdl;
void *sl_zvol_rl_hdl;
void *sl_zvol_bonus_hdl;
/* Backing store */
char *sl_data_filename;
struct sbd_it_data *sl_it_list;
} sbd_lu_t;
/*
* sl_flags
*/
#define SL_LINKED 0x00000001
#define SL_META_OPENED 0x00000002
#define SL_REGISTERED 0x00000004
#define SL_META_NEEDS_FLUSH 0x00000008
#define SL_DATA_NEEDS_FLUSH 0x00000010
#define SL_VID_VALID 0x00000020
#define SL_PID_VALID 0x00000040
#define SL_REV_VALID 0x00000080
#define SL_WRITE_PROTECTED 0x00000100
#define SL_MEDIA_LOADED 0x00000200
#define SL_LU_HAS_SCSI2_RESERVATION 0x00000400
#define SL_WRITEBACK_CACHE_DISABLE 0x00000800
#define SL_SAVED_WRITE_CACHE_DISABLE 0x00001000
#define SL_MEDIUM_REMOVAL_PREVENTED 0x00002000
#define SL_NO_DATA_DKIOFLUSH 0x00004000
#define SL_SHARED_META 0x00008000
#define SL_ZFS_META 0x00010000
#define SL_WRITEBACK_CACHE_SET_UNSUPPORTED 0x00020000
#define SL_FLUSH_ON_DISABLED_WRITECACHE 0x00040000
#define SL_CALL_ZVOL 0x00080000
#define SL_UNMAP_ENABLED 0x00100000
/*
* sl_trans_op. LU is undergoing some transition and this field
* tells what kind of transition that is.
*/
#define SL_OP_NONE 0
#define SL_OP_CREATE_REGISTER_LU 1
#define SL_OP_IMPORT_LU 2
#define SL_OP_DELETE_LU 3
#define SL_OP_MODIFY_LU 4
#define SL_OP_LU_PROPS 5
#ifdef __cplusplus
}
#endif
#endif /* _STMF_SBD_H */