zil.h revision 893a6d32980d24be1349478f44169009d4801c25
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_ZIL_H
#define _SYS_ZIL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Intent log format:
*
* Each objset has its own intent log. The log header (zil_header_t)
* for objset N's intent log is kept in the Nth object of the SPA's
* intent_log objset. The log header points to a chain of log blocks,
* each of which contains log records (i.e., transactions) followed by
* a log block trailer (zil_trailer_t). The format of a log record
* depends on the record (or transaction) type, but all records begin
* with a common structure that defines the type, length, and txg.
*/
/*
* Intent log header - this on disk structure holds fields to manage
* the log. All fields are 64 bit to easily handle cross architectures.
*/
typedef struct zil_header {
} zil_header_t;
/*
* Log block trailer - structure at the end of the header and each log block
*
* The zit_bt contains a zbt_cksum which for the intent log is
* the sequence number of this log block. A seq of 0 is invalid.
* The zbt_cksum is checked by the SPA against the sequence
* number passed in the blk_cksum field of the blkptr_t
*/
typedef struct zil_trailer {
#define ZIL_MIN_BLKSZ 4096ULL
#define ZIL_MAX_BLKSZ SPA_MAXBLOCKSIZE
/*
* The words of a log block checksum.
*/
#define ZIL_ZC_GUID_0 0
#define ZIL_ZC_GUID_1 1
#define ZIL_ZC_OBJSET 2
#define ZIL_ZC_SEQ 3
/*
* Intent log transaction types and record structures
*/
/*
* Format of log records.
* The fields are carefully defined to allow them to be aligned
* and sized the same on sparc & intel architectures.
* Each log record has a common structure at the beginning.
*
* Note, lrc_seq holds two different sequence numbers. Whilst in memory
* it contains the transaction sequence number. The log record on
* disk holds the sequence number of all log records which is used to
* ensure we don't replay the same record. The two sequence numbers are
* different because the transactions can now be pushed out of order.
*/
typedef struct { /* common log record header */
} lr_t;
typedef struct {
/* name of object to create follows this */
/* for symlinks, link content follows name */
} lr_create_t;
typedef struct {
/* name of object to remove follows this */
} lr_remove_t;
typedef struct {
/* name of object to link follows this */
} lr_link_t;
typedef struct {
/* 2 strings: names of source and destination follow this */
} lr_rename_t;
typedef struct {
/* write data will follow for small writes */
} lr_write_t;
typedef struct {
typedef struct {
} lr_setattr_t;
typedef struct {
/* lr_aclcnt number of ace_t entries follow this */
} lr_acl_t;
/*
* ZIL structure definitions, interface function prototype and globals.
*/
/*
* ZFS intent log transaction structure
*/
typedef enum {
WR_INDIRECT, /* indirect - a large write (dmu_sync() data */
/* and put blkptr in log, rather than actual data) */
WR_COPIED, /* immediate - data is copied into lr_write_t */
WR_NEED_COPY, /* immediate - data needs to be copied if pushed */
typedef struct itx {
void *itx_private; /* type-specific opaque data */
/* followed by type-specific part of lr_xx_t and its immediate data */
} itx_t;
/*
* zgd_t is passed through dmu_sync() to the callback routine zfs_get_done()
* to handle the cleanup of the dmu_sync() buffer write
*/
typedef struct {
} zgd_t;
typedef int zil_replay_func_t();
extern void zil_init(void);
extern void zil_fini(void);
extern int zil_disable;
#ifdef __cplusplus
}
#endif
#endif /* _SYS_ZIL_H */