usr/src/uts/common/fs/zfs/sys/zil.h
author eschrock
Tue, 16 May 2006 11:20:11 -0700
changeset 1986 628267397204
parent 1842 1712a484fc9d
child 2199 712a788c2dfd
permissions -rw-r--r--
6424405 zpool import destroyed_pool can damage existing pool using same devices
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     1
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     2
 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     3
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
1646
b4e43ae19fff 6393443 Remove remaining txg_wait_synced() from zfs unmount path.
perrin
parents: 789
diff changeset
     5
 * Common Development and Distribution License (the "License").
b4e43ae19fff 6393443 Remove remaining txg_wait_synced() from zfs unmount path.
perrin
parents: 789
diff changeset
     6
 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
/*
1646
b4e43ae19fff 6393443 Remove remaining txg_wait_synced() from zfs unmount path.
perrin
parents: 789
diff changeset
    22
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 * Use is subject to license terms.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    26
#ifndef	_SYS_ZIL_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
#define	_SYS_ZIL_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
#pragma ident	"%Z%%M%	%I%	%E% SMI"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
#include <sys/types.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
#include <sys/spa.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
#include <sys/zio.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
#include <sys/dmu.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
extern "C" {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
 * Intent log format:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
 * Each objset has its own intent log.  The log header (zil_header_t)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
 * for objset N's intent log is kept in the Nth object of the SPA's
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
 * intent_log objset.  The log header points to a chain of log blocks,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
 * each of which contains log records (i.e., transactions) followed by
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    47
 * a log block trailer (zil_trailer_t).  The format of a log record
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    48
 * depends on the record (or transaction) type, but all records begin
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
 * with a common structure that defines the type, length, and txg.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    51
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    52
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    53
 * Intent log header - this on disk structure holds fields to manage
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    54
 * the log.  All fields are 64 bit to easily handle cross architectures.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    55
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
typedef struct zil_header {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
	uint64_t zh_claim_txg;	/* txg in which log blocks were claimed */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
	uint64_t zh_replay_seq;	/* highest replayed sequence number */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
	blkptr_t zh_log;	/* log chain */
1807
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
    60
	uint64_t zh_claim_seq;	/* highest claimed sequence number */
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
    61
	uint64_t zh_pad[5];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
} zil_header_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    63
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
 * Log block trailer - structure at the end of the header and each log block
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
 * The zit_bt contains a zbt_cksum which for the intent log is
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
 * the sequence number of this log block. A seq of 0 is invalid.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
 * The zbt_cksum is checked by the SPA against the sequence
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
 * number passed in the blk_cksum field of the blkptr_t
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
typedef struct zil_trailer {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
	uint64_t zit_pad;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    74
	blkptr_t zit_next_blk;	/* next block in chain */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    75
	uint64_t zit_nused;	/* bytes in log block used */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
	zio_block_tail_t zit_bt; /* block trailer */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
} zil_trailer_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
1842
1712a484fc9d 6413731 pathologically slower fsync on 32 bit systems
perrin
parents: 1807
diff changeset
    79
#define	ZIL_MIN_BLKSZ	4096ULL
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
#define	ZIL_MAX_BLKSZ	SPA_MAXBLOCKSIZE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
#define	ZIL_BLK_DATA_SZ(lwb)	((lwb)->lwb_sz - sizeof (zil_trailer_t))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    82
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    83
/*
1807
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
    84
 * The words of a log block checksum.
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
    85
 */
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
    86
#define	ZIL_ZC_GUID_0	0
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
    87
#define	ZIL_ZC_GUID_1	1
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
    88
#define	ZIL_ZC_OBJSET	2
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
    89
#define	ZIL_ZC_SEQ	3
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
    90
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
    91
/*
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
 * Intent log transaction types and record structures
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
#define	TX_CREATE	1		/* Create file */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    95
#define	TX_MKDIR	2		/* Make directory */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    96
#define	TX_MKXATTR	3		/* Make XATTR directory */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    97
#define	TX_SYMLINK	4		/* Create symbolic link to a file */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    98
#define	TX_REMOVE	5		/* Remove file */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    99
#define	TX_RMDIR	6		/* Remove directory */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   100
#define	TX_LINK		7		/* Create hard link to a file */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   101
#define	TX_RENAME	8		/* Rename a file */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   102
#define	TX_WRITE	9		/* File write */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   103
#define	TX_TRUNCATE	10		/* Truncate a file */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   104
#define	TX_SETATTR	11		/* Set file attributes */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   105
#define	TX_ACL		12		/* Set acl */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   106
#define	TX_MAX_TYPE	13		/* Max transaction type */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   107
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   108
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   109
 * Format of log records.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
 * The fields are carefully defined to allow them to be aligned
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   111
 * and sized the same on sparc & intel architectures.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   112
 * Each log record has a common structure at the beginning.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   113
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   114
typedef struct {			/* common log record header */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   115
	uint64_t	lrc_txtype;	/* intent log transaction type */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   116
	uint64_t	lrc_reclen;	/* transaction record length */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   117
	uint64_t	lrc_txg;	/* dmu transaction group number */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   118
	uint64_t	lrc_seq;	/* intent log sequence number */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   119
} lr_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   120
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   121
typedef struct {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   122
	lr_t		lr_common;	/* common portion of log record */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   123
	uint64_t	lr_doid;	/* object id of directory */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   124
	uint64_t	lr_foid;	/* object id of created file object */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   125
	uint64_t	lr_mode;	/* mode of object */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   126
	uint64_t	lr_uid;		/* uid of object */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   127
	uint64_t	lr_gid;		/* gid of object */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   128
	uint64_t	lr_gen;		/* generation (txg of creation) */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   129
	uint64_t	lr_crtime[2];	/* creation time */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   130
	uint64_t	lr_rdev;	/* rdev of object to create */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   131
	/* name of object to create follows this */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   132
	/* for symlinks, link content follows name */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   133
} lr_create_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   134
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   135
typedef struct {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   136
	lr_t		lr_common;	/* common portion of log record */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   137
	uint64_t	lr_doid;	/* obj id of directory */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   138
	/* name of object to remove follows this */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   139
} lr_remove_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   140
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   141
typedef struct {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   142
	lr_t		lr_common;	/* common portion of log record */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   143
	uint64_t	lr_doid;	/* obj id of directory */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   144
	uint64_t	lr_link_obj;	/* obj id of link */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   145
	/* name of object to link follows this */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   146
} lr_link_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   147
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   148
typedef struct {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   149
	lr_t		lr_common;	/* common portion of log record */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   150
	uint64_t	lr_sdoid;	/* obj id of source directory */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   151
	uint64_t	lr_tdoid;	/* obj id of target directory */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   152
	/* 2 strings: names of source and destination follow this */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   153
} lr_rename_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   154
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   155
typedef struct {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   156
	lr_t		lr_common;	/* common portion of log record */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   157
	uint64_t	lr_foid;	/* file object to write */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   158
	uint64_t	lr_offset;	/* offset to write to */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   159
	uint64_t	lr_length;	/* user data length to write */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   160
	uint64_t	lr_blkoff;	/* offset represented by lr_blkptr */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   161
	blkptr_t	lr_blkptr;	/* spa block pointer for replay */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   162
	/* write data will follow for small writes */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   163
} lr_write_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   164
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   165
typedef struct {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   166
	lr_t		lr_common;	/* common portion of log record */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   167
	uint64_t	lr_foid;	/* object id of file to truncate */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   168
	uint64_t	lr_offset;	/* offset to truncate from */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   169
	uint64_t	lr_length;	/* length to truncate */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   170
} lr_truncate_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   171
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   172
typedef struct {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   173
	lr_t		lr_common;	/* common portion of log record */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   174
	uint64_t	lr_foid;	/* file object to change attributes */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   175
	uint64_t	lr_mask;	/* mask of attributes to set */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   176
	uint64_t	lr_mode;	/* mode to set */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   177
	uint64_t	lr_uid;		/* uid to set */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   178
	uint64_t	lr_gid;		/* gid to set */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   179
	uint64_t	lr_size;	/* size to set */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   180
	uint64_t	lr_atime[2];	/* access time */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   181
	uint64_t	lr_mtime[2];	/* modification time */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   182
} lr_setattr_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   183
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   184
typedef struct {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   185
	lr_t		lr_common;	/* common portion of log record */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   186
	uint64_t	lr_foid;	/* obj id of file */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   187
	uint64_t	lr_aclcnt;	/* number of acl entries */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   188
	/* lr_aclcnt number of ace_t entries follow this */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   189
} lr_acl_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   190
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   191
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   192
 * ZIL structure definitions, interface function prototype and globals.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   193
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   194
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   195
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   196
 * ZFS intent log transaction structure
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   197
 */
1669
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 1646
diff changeset
   198
typedef enum {
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 1646
diff changeset
   199
	WR_INDIRECT,	/* indirect - a large write (dmu_sync() data */
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 1646
diff changeset
   200
			/* and put blkptr in log, rather than actual data) */
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 1646
diff changeset
   201
	WR_COPIED,	/* immediate - data is copied into lr_write_t */
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 1646
diff changeset
   202
	WR_NEED_COPY,	/* immediate - data needs to be copied if pushed */
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 1646
diff changeset
   203
} itx_wr_state_t;
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 1646
diff changeset
   204
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   205
typedef struct itx {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   206
	list_node_t	itx_node;	/* linkage on zl_itx_list */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   207
	void		*itx_private;	/* type-specific opaque data */
1669
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 1646
diff changeset
   208
	itx_wr_state_t	itx_wr_state;	/* write state */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   209
	lr_t		itx_lr;		/* common part of log record */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   210
	/* followed by type-specific part of lr_xx_t and its immediate data */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   211
} itx_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   212
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   213
typedef void zil_parse_blk_func_t(zilog_t *zilog, blkptr_t *bp, void *arg,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   214
    uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   215
typedef void zil_parse_lr_func_t(zilog_t *zilog, lr_t *lr, void *arg,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   216
    uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   217
typedef int zil_replay_func_t();
1669
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 1646
diff changeset
   218
typedef int zil_get_data_t(void *arg, lr_write_t *lr, char *dbuf);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   219
1807
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
   220
extern uint64_t	zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   221
    zil_parse_lr_func_t *parse_lr_func, void *arg, uint64_t txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   222
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   223
extern void	zil_init(void);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   224
extern void	zil_fini(void);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   225
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   226
extern zilog_t	*zil_alloc(objset_t *os, zil_header_t *zh_phys);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   227
extern void	zil_free(zilog_t *zilog);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   228
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   229
extern zilog_t	*zil_open(objset_t *os, zil_get_data_t *get_data);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   230
extern void	zil_close(zilog_t *zilog);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   231
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   232
extern void	zil_replay(objset_t *os, void *arg, uint64_t *txgp,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   233
    zil_replay_func_t *replay_func[TX_MAX_TYPE], void (*rm_wait)(void *));
1807
35c8b566d7af 6410711 intent log blocks don't get invited to pool parties
bonwick
parents: 1669
diff changeset
   234
extern void	zil_destroy(zilog_t *zilog, boolean_t keep_first);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   235
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   236
extern itx_t	*zil_itx_create(int txtype, size_t lrsize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   237
extern uint64_t zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   238
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   239
extern void	zil_commit(zilog_t *zilog, uint64_t seq, int ioflag);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   240
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   241
extern void	zil_claim(char *osname, void *txarg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   242
extern void	zil_sync(zilog_t *zilog, dmu_tx_t *tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   243
extern void	zil_clean(zilog_t *zilog);
1646
b4e43ae19fff 6393443 Remove remaining txg_wait_synced() from zfs unmount path.
perrin
parents: 789
diff changeset
   244
extern int	zil_is_committed(zilog_t *zilog);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   245
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   246
extern int	zil_suspend(zilog_t *zilog);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   247
extern void	zil_resume(zilog_t *zilog);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   248
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   249
extern int zil_disable;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   250
extern int zil_always;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   251
extern int zil_purge;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   252
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   253
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   254
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   255
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   256
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   257
#endif	/* _SYS_ZIL_H */