stmf_sbd.h revision 450396635f70344c58b6b1e4db38cf17ff34445c
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#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[];
/*
* 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;
/* Backing store */
char *sl_data_filename;
struct sbd_it_data *sl_it_list;
} sbd_lu_t;
/*
* sl_flags
*/
#define SL_LINKED 0x00001
#define SL_META_OPENED 0x00002
#define SL_REGISTERED 0x00004
#define SL_META_NEEDS_FLUSH 0x00008
#define SL_DATA_NEEDS_FLUSH 0x00010
#define SL_VID_VALID 0x00020
#define SL_PID_VALID 0x00040
#define SL_REV_VALID 0x00080
#define SL_WRITE_PROTECTED 0x00100
#define SL_MEDIA_LOADED 0x00200
#define SL_LU_HAS_SCSI2_RESERVATION 0x00400
#define SL_WRITEBACK_CACHE_DISABLE 0x00800
#define SL_SAVED_WRITE_CACHE_DISABLE 0x01000
#define SL_MEDIUM_REMOVAL_PREVENTED 0x02000
#define SL_NO_DATA_DKIOFLUSH 0x04000
#define SL_SHARED_META 0x08000
#define SL_ZFS_META 0x10000
#define SL_WRITEBACK_CACHE_SET_UNSUPPORTED 0x20000
#define SL_FLUSH_ON_DISABLED_WRITECACHE 0x40000
/*
* 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 */