dnode.h revision 79d728325e257b05859d2eef4a4dfbefdce05a76
/*
* 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 (c) 2012, 2016 by Delphix. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
*/
#ifndef _SYS_DNODE_H
#define _SYS_DNODE_H
#include <sys/zfs_context.h>
#include <sys/refcount.h>
#include <sys/dmu_zfetch.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* dnode_hold() flags.
*/
#define DNODE_MUST_BE_ALLOCATED 1
#define DNODE_MUST_BE_FREE 2
/*
* dnode_next_offset() flags.
*/
#define DNODE_FIND_HOLE 1
#define DNODE_FIND_BACKWARDS 2
#define DNODE_FIND_HAVELOCK 4
/*
* Fixed constants.
*/
/*
* dnode id flags
*
* Note: a file will never ever have its
* ids moved from bonus->spill
* and only in a crypto environment would it be on spill
*/
#define DN_ID_CHKED_BONUS 0x1
#define DN_ID_CHKED_SPILL 0x2
#define DN_ID_OLD_EXIST 0x4
#define DN_ID_NEW_EXIST 0x8
/*
* Derived constants.
*/
#define DN_KILL_SPILLBLK (1)
/*
* This is inaccurate if the indblkshift of the particular object is not the
* max. But it's only used by userland to calculate the zvol reservation.
*/
/* The +2 here is a cheesy way to round up */
struct dmu_buf_impl;
struct objset;
struct zio;
enum dnode_dirtycontext {
};
/* Is dn_used in bytes? if not, it's in multiples of SPA_MINBLOCKSIZE */
#define DNODE_FLAG_USED_BYTES (1<<0)
/* Does dnode have a SA spill blkptr in bonus? */
typedef struct dnode_phys {
/* accounting is protected by dn_dirty_mtx */
} dnode_phys_t;
struct dnode {
/*
* Protects the structure of the dnode, including the number of levels
* of indirection (dn_nlevels), dn_maxblkid, and dn_next_*
*/
/* Our link on dn_objset->os_dnodes list; protected by os_lock. */
/* immutable: */
struct dmu_buf_impl *dn_dbuf;
struct dnode_handle *dn_handle;
/*
* Copies of stuff in dn_phys. They're valid in the open
* context (eg. even before the dnode is first synced).
* Where necessary, these are protected by dn_struct_rwlock.
*/
/* protected by dn_dbufs_mtx; declared here to fill 32-bit hole */
/* There are no level-0 blocks of this blkid or higher in dn_dbufs */
/* protected by os_lock: */
/* protected by dn_mtx: */
/* protected by own devices */
/*
* Descendent dbufs, ordered by dbuf_compare. Note that dn_dbufs
* can contain multiple dbufs of the same (level, blkid) when a
* dbuf is marked DB_EVICTING without being removed from
* dn_dbufs. To maintain the avl invariant that there cannot be
* duplicate entries, we order the dbufs by an arbitrary value -
* their address in memory. This means that dn_dbufs cannot be used to
* directly look up a dbuf. Instead, callers must use avl_walk, have
* a reference to the dbuf, or look up a non-existant node with
* db_state = DB_SEARCH (see dbuf_free_range for an example).
*/
/* protected by dn_struct_rwlock */
/* parent IO for current sync write */
/* used in syncing context */
int dn_id_flags;
/* holds prefetch structure */
};
/*
* Adds a level of indirection between the dbuf and the dnode to avoid
* iterating descendent dbufs in dnode_move(). Handles are not allocated
* individually, but as an array of child dnodes in dnode_hold_impl().
*/
typedef struct dnode_handle {
/* Protects dnh_dnode from modification by dnode_move(). */
typedef struct dnode_children {
typedef struct free_range {
} free_range_t;
void dnode_init(void);
void dnode_fini(void);
#define DNODE_IS_CACHEABLE(_dn) \
#define DNODE_META_IS_CACHEABLE(_dn) \
#ifdef ZFS_DEBUG
/*
* There should be a ## between the string literal and fmt, to make it
* clear that we're joining two strings together, but that piece of shit
* gcc doesn't support that preprocessor token.
*/
if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
char __db_buf[32]; \
if (__db_obj == DMU_META_DNODE_OBJECT) \
else \
(u_longlong_t)__db_obj);\
__db_buf, __VA_ARGS__); \
} \
#else
#define DNODE_VERIFY(dn)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SYS_DNODE_H */