dnode.h revision 9c9dc39aa72ac40bb2558d54adfa596d217135d9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_DNODE_H
#define _SYS_DNODE_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/zfs_context.h>
#include <sys/refcount.h>
#include <sys/dmu_zfetch.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Flags.
*/
#define DNODE_MUST_BE_ALLOCATED 1
#define DNODE_MUST_BE_FREE 2
/*
* Fixed constants.
*/
/*
* Derived constants.
*/
#define DN_META_DNODE_LEVELS \
/* The +2 here is a cheesy way to round up */
#define DN_MAX_OBJECT \
struct dmu_buf_impl;
struct objset_impl;
struct zio;
enum dnode_dirtycontext {
};
typedef struct dnode_phys {
/* accounting is protected by dn_dirty_mtx */
} dnode_phys_t;
typedef struct dnode {
/*
* lock ordering:
*
* db_mtx > dn_dirty_mtx
* dbuf_syncdone
*
* dn_struct_rwlock/r > dn_dirty_mtx
* dmu_object_info
*
* dn_struct_rwlock/r > db_mtx > dn_dirty_mtx
* dbuf_dirty
* dbuf_setdirty
*
* dn_struct_rwlock/w > db_mtx > dn_mtx
* dnode_increase_indirection -> dbuf_find
* dbuf_hold_impl
* dnode_set_bonus
*
* dn_struct_rwlock/w > dn_mtx
* dnode_increase_indirection
*
* dn_dirty_mtx > dn_mtx
* dnode_buf_pageout
*
* db_mtx > dn_mtx
* dbuf_create
*/
/*
* dn_struct_rwlock protects the structure of the dnode.
* In particular, it protects the number of levels of indirection.
*/
/*
* Our link on dataset's dd_dnodes list.
* Protected by dd_accounting_mtx.
*/
/* immutable: */
struct objset_impl *dn_objset;
struct dmu_buf_impl *dn_dbuf;
/*
* Copies of stuff in dn_phys. They're valid here even before
* the dnode is first synced.
*/
/*
* The following are kept up-to-date in the *open* context, the syncing
* context should only pay attention to the dn_next_* values.
*/
/* protected by os_lock: */
/* protected by dn_mtx: */
/* protected by own devices */
/*
* Performance hack: whenever we have a hold on the bonus buffer of a
* ZAP object, we will also have a hold on db0. This will keep the
* meta-data for a micro-zap object cached as long as the znode for the
* object is in the znode cache.
*/
struct dmu_buf_impl *dn_db0;
/* holds prefetch structure */
} dnode_t;
typedef struct free_range {
} free_range_t;
void *ref);
void dnode_init(void);
void dnode_fini(void);
#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 */