usr/src/uts/common/fs/zfs/sys/dnode.h
author maybee
Sun, 26 Aug 2007 11:19:04 -0700
changeset 4944 96d96f8de974
parent 4787 602d3f97842c
child 6992 20c04e18c58c
permissions -rw-r--r--
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008) 6573361 panic turnstile_block, unowned mutex 6584864 $MOS is not properly bounded by pool size 6585265 need bonus resize interface 6587723 BAD TRAP: type=e (#pf Page fault) occurred in module "zfs" due to a NULL pointer dereference 6589799 dangling dbuf after zinject 6594025 panic: dangling dbufs during shutdown
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
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 873
diff changeset
     5
 * Common Development and Distribution License (the "License").
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 873
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
/*
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3025
diff changeset
    22
 * Copyright 2007 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_DNODE_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
#define	_SYS_DNODE_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/zfs_context.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
#include <sys/avl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
#include <sys/spa.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
#include <sys/txg.h>
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3025
diff changeset
    35
#include <sys/zio.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
#include <sys/refcount.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
#include <sys/dmu_zfetch.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
extern "C" {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
 * Flags.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
#define	DNODE_MUST_BE_ALLOCATED	1
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    47
#define	DNODE_MUST_BE_FREE	2
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    48
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
 * Fixed constants.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    51
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    52
#define	DNODE_SHIFT		9	/* 512 bytes */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    53
#define	DN_MIN_INDBLKSHIFT	10	/* 1k */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    54
#define	DN_MAX_INDBLKSHIFT	14	/* 16k */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    55
#define	DNODE_BLOCK_SHIFT	14	/* 16k */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
#define	DNODE_CORE_SIZE		64	/* 64 bytes for dnode sans blkptrs */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
#define	DN_MAX_OBJECT_SHIFT	48	/* 256 trillion (zfs_fid_t limit) */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
#define	DN_MAX_OFFSET_SHIFT	64	/* 2^64 bytes in a dnode */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    61
 * Derived constants.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    63
#define	DNODE_SIZE	(1 << DNODE_SHIFT)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
#define	DN_MAX_NBLKPTR	((DNODE_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
#define	DN_MAX_BONUSLEN	(DNODE_SIZE - DNODE_CORE_SIZE - (1 << SPA_BLKPTRSHIFT))
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 873
diff changeset
    66
#define	DN_MAX_OBJECT	(1ULL << DN_MAX_OBJECT_SHIFT)
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4787
diff changeset
    67
#define	DN_ZERO_BONUSLEN	(DN_MAX_BONUSLEN + 1)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
#define	DNODES_PER_BLOCK_SHIFT	(DNODE_BLOCK_SHIFT - DNODE_SHIFT)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
#define	DNODES_PER_BLOCK	(1ULL << DNODES_PER_BLOCK_SHIFT)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
#define	DNODES_PER_LEVEL_SHIFT	(DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
/* The +2 here is a cheesy way to round up */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    74
#define	DN_MAX_LEVELS	(2 + ((DN_MAX_OFFSET_SHIFT - SPA_MINBLOCKSHIFT) / \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    75
	(DN_MIN_INDBLKSHIFT - SPA_BLKPTRSHIFT)))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
#define	DN_BONUS(dnp)	((void*)((dnp)->dn_bonus + \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
	(((dnp)->dn_nblkptr - 1) * sizeof (blkptr_t))))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    79
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1646
diff changeset
    80
#define	DN_USED_BYTES(dnp) (((dnp)->dn_flags & DNODE_FLAG_USED_BYTES) ? \
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1646
diff changeset
    81
	(dnp)->dn_used : (dnp)->dn_used << SPA_MINBLOCKSHIFT)
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1646
diff changeset
    82
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    83
#define	EPB(blkshift, typeshift)	(1 << (blkshift - typeshift))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    84
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    85
struct dmu_buf_impl;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    86
struct objset_impl;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
struct zio;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    88
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    89
enum dnode_dirtycontext {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    90
	DN_UNDIRTIED,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    91
	DN_DIRTY_OPEN,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
	DN_DIRTY_SYNC
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1646
diff changeset
    95
/* Is dn_used in bytes?  if not, it's in multiples of SPA_MINBLOCKSIZE */
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1646
diff changeset
    96
#define	DNODE_FLAG_USED_BYTES	(1<<0)
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1646
diff changeset
    97
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    98
typedef struct dnode_phys {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    99
	uint8_t dn_type;		/* dmu_object_type_t */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   100
	uint8_t dn_indblkshift;		/* ln2(indirect block size) */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   101
	uint8_t dn_nlevels;		/* 1=dn_blkptr->data blocks */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   102
	uint8_t dn_nblkptr;		/* length of dn_blkptr */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   103
	uint8_t dn_bonustype;		/* type of data in bonus buffer */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   104
	uint8_t	dn_checksum;		/* ZIO_CHECKSUM type */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   105
	uint8_t	dn_compress;		/* ZIO_COMPRESS type */
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1646
diff changeset
   106
	uint8_t dn_flags;		/* DNODE_FLAG_* */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   107
	uint16_t dn_datablkszsec;	/* data block size in 512b sectors */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   108
	uint16_t dn_bonuslen;		/* length of dn_bonus */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   109
	uint8_t dn_pad2[4];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   111
	/* accounting is protected by dn_dirty_mtx */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   112
	uint64_t dn_maxblkid;		/* largest allocated block ID */
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1646
diff changeset
   113
	uint64_t dn_used;		/* bytes (or sectors) of disk space */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   114
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   115
	uint64_t dn_pad3[4];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   116
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   117
	blkptr_t dn_blkptr[1];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   118
	uint8_t dn_bonus[DN_MAX_BONUSLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   119
} dnode_phys_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   120
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   121
typedef struct dnode {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   122
	/*
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   123
	 * dn_struct_rwlock protects the structure of the dnode,
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   124
	 * including the number of levels of indirection (dn_nlevels),
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   125
	 * dn_maxblkid, and dn_next_*
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   126
	 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   127
	krwlock_t dn_struct_rwlock;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   128
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   129
	/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   130
	 * Our link on dataset's dd_dnodes list.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   131
	 * Protected by dd_accounting_mtx.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   132
	 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   133
	list_node_t dn_link;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   134
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   135
	/* immutable: */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   136
	struct objset_impl *dn_objset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   137
	uint64_t dn_object;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   138
	struct dmu_buf_impl *dn_dbuf;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   139
	dnode_phys_t *dn_phys; /* pointer into dn->dn_dbuf->db.db_data */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   140
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   141
	/*
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   142
	 * Copies of stuff in dn_phys.  They're valid in the open
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   143
	 * context (eg. even before the dnode is first synced).
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   144
	 * Where necessary, these are protected by dn_struct_rwlock.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   145
	 */
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   146
	dmu_object_type_t dn_type;	/* object type */
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   147
	uint16_t dn_bonuslen;		/* bonus length */
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   148
	uint8_t dn_bonustype;		/* bonus type */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   149
	uint8_t dn_nblkptr;		/* number of blkptrs (immutable) */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   150
	uint8_t dn_checksum;		/* ZIO_CHECKSUM type */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   151
	uint8_t dn_compress;		/* ZIO_COMPRESS type */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   152
	uint8_t dn_nlevels;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   153
	uint8_t dn_indblkshift;
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   154
	uint8_t dn_datablkshift;	/* zero if blksz not power of 2! */
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   155
	uint16_t dn_datablkszsec;	/* in 512b sectors */
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   156
	uint32_t dn_datablksz;		/* in bytes */
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   157
	uint64_t dn_maxblkid;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   158
	uint8_t dn_next_nlevels[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   159
	uint8_t dn_next_indblkshift[TXG_SIZE];
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4787
diff changeset
   160
	uint16_t dn_next_bonuslen[TXG_SIZE];
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
   161
	uint32_t dn_next_blksz[TXG_SIZE];	/* next block size in bytes */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   162
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   163
	/* protected by os_lock: */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   164
	list_node_t dn_dirty_link[TXG_SIZE];	/* next on dataset's dirty */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   165
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   166
	/* protected by dn_mtx: */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   167
	kmutex_t dn_mtx;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3025
diff changeset
   168
	list_t dn_dirty_records[TXG_SIZE];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   169
	avl_tree_t dn_ranges[TXG_SIZE];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   170
	uint64_t dn_allocated_txg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   171
	uint64_t dn_free_txg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   172
	uint64_t dn_assigned_txg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   173
	kcondvar_t dn_notxholds;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   174
	enum dnode_dirtycontext dn_dirtyctx;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   175
	uint8_t *dn_dirtyctx_firstset;		/* dbg: contents meaningless */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   176
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   177
	/* protected by own devices */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   178
	refcount_t dn_tx_holds;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   179
	refcount_t dn_holds;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   180
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   181
	kmutex_t dn_dbufs_mtx;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   182
	list_t dn_dbufs;		/* linked list of descendent dbuf_t's */
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 873
diff changeset
   183
	struct dmu_buf_impl *dn_bonus;	/* bonus buffer dbuf */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   184
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3025
diff changeset
   185
	/* parent IO for current sync write */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3025
diff changeset
   186
	zio_t *dn_zio;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3025
diff changeset
   187
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   188
	/* holds prefetch structure */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   189
	struct zfetch	dn_zfetch;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   190
} dnode_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   191
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   192
typedef struct free_range {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   193
	avl_node_t fr_node;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   194
	uint64_t fr_blkid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   195
	uint64_t fr_nblks;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   196
} free_range_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   197
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   198
dnode_t *dnode_special_open(struct objset_impl *dd, dnode_phys_t *dnp,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   199
    uint64_t object);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   200
void dnode_special_close(dnode_t *dn);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   201
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4787
diff changeset
   202
void dnode_setbonuslen(dnode_t *dn, int newsize, dmu_tx_t *tx);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 873
diff changeset
   203
int dnode_hold(struct objset_impl *dd, uint64_t object,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 873
diff changeset
   204
    void *ref, dnode_t **dnp);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 873
diff changeset
   205
int dnode_hold_impl(struct objset_impl *dd, uint64_t object, int flag,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 873
diff changeset
   206
    void *ref, dnode_t **dnp);
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4787
diff changeset
   207
boolean_t dnode_add_ref(dnode_t *dn, void *ref);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   208
void dnode_rele(dnode_t *dn, void *ref);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   209
void dnode_setdirty(dnode_t *dn, dmu_tx_t *tx);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3025
diff changeset
   210
void dnode_sync(dnode_t *dn, dmu_tx_t *tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   211
void dnode_allocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, int ibs,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   212
    dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   213
void dnode_reallocate(dnode_t *dn, dmu_object_type_t ot, int blocksize,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   214
    dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   215
void dnode_free(dnode_t *dn, dmu_tx_t *tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   216
void dnode_byteswap(dnode_phys_t *dnp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   217
void dnode_buf_byteswap(void *buf, size_t size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   218
void dnode_verify(dnode_t *dn);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   219
int dnode_set_blksz(dnode_t *dn, uint64_t size, int ibs, dmu_tx_t *tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   220
uint64_t dnode_current_max_length(dnode_t *dn);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   221
void dnode_free_range(dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   222
void dnode_clear_range(dnode_t *dn, uint64_t blkid,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   223
    uint64_t nblks, dmu_tx_t *tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   224
void dnode_diduse_space(dnode_t *dn, int64_t space);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   225
void dnode_willuse_space(dnode_t *dn, int64_t space, dmu_tx_t *tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   226
void dnode_new_blkid(dnode_t *dn, uint64_t blkid, dmu_tx_t *tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   227
uint64_t dnode_block_freed(dnode_t *dn, uint64_t blkid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   228
void dnode_init(void);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   229
void dnode_fini(void);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   230
int dnode_next_offset(dnode_t *dn, boolean_t hole, uint64_t *off, int minlvl,
3025
4e5ee8301d84 6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents: 2885
diff changeset
   231
    uint64_t blkfill, uint64_t txg);
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4787
diff changeset
   232
void dnode_evict_dbufs(dnode_t *dn);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   233
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   234
#ifdef ZFS_DEBUG
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   235
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   236
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   237
 * There should be a ## between the string literal and fmt, to make it
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   238
 * clear that we're joining two strings together, but that piece of shit
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   239
 * gcc doesn't support that preprocessor token.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   240
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   241
#define	dprintf_dnode(dn, fmt, ...) do { \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   242
	if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   243
	char __db_buf[32]; \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   244
	uint64_t __db_obj = (dn)->dn_object; \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   245
	if (__db_obj == DMU_META_DNODE_OBJECT) \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   246
		(void) strcpy(__db_buf, "mdn"); \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   247
	else \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   248
		(void) snprintf(__db_buf, sizeof (__db_buf), "%lld", \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   249
		    (u_longlong_t)__db_obj);\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   250
	dprintf_ds((dn)->dn_objset->os_dsl_dataset, "obj=%s " fmt, \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   251
	    __db_buf, __VA_ARGS__); \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   252
	} \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   253
_NOTE(CONSTCOND) } while (0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   254
873
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
   255
#define	DNODE_VERIFY(dn)		dnode_verify(dn)
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
   256
#define	FREE_VERIFY(db, start, end, tx)	free_verify(db, start, end, tx)
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
   257
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   258
#else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   259
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   260
#define	dprintf_dnode(db, fmt, ...)
873
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
   261
#define	DNODE_VERIFY(dn)
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
   262
#define	FREE_VERIFY(db, start, end, tx)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   263
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   264
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   265
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   266
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   267
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   268
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   269
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   270
#endif	/* _SYS_DNODE_H */