Illumos 5314 - Remove "dbuf phys" db->db_data pointer aliases in ZFS

5314 Remove "dbuf phys" db->db_data pointer aliases in ZFS
Author: Justin T. Gibbs <justing@spectralogic.com>
Reviewed by: Andriy Gapon <avg@freebsd.org>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Will Andrews <willa@spectralogic.com>
Approved by: Dan McDonald <danmcd@omniti.com>

References:
  https://www.illumos.org/issues/5314
  https://github.com/illumos/illumos-gate/commit/c137962

Ported-by: Chris Dunlop <chris@onthe.net.au>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Justin T. Gibbs 2015-04-02 02:14:34 +11:00 committed by Brian Behlendorf
parent 945dd93525
commit d683ddbb72
32 changed files with 914 additions and 808 deletions

View File

@ -1928,8 +1928,8 @@ dump_dir(objset_t *os)
if (dds.dds_type == DMU_OST_META) { if (dds.dds_type == DMU_OST_META) {
dds.dds_creation_txg = TXG_INITIAL; dds.dds_creation_txg = TXG_INITIAL;
usedobjs = BP_GET_FILL(os->os_rootbp); usedobjs = BP_GET_FILL(os->os_rootbp);
refdbytes = os->os_spa->spa_dsl_pool-> refdbytes = dsl_dir_phys(os->os_spa->spa_dsl_pool->dp_mos_dir)->
dp_mos_dir->dd_phys->dd_used_bytes; dd_used_bytes;
} else { } else {
dmu_objset_space(os, &refdbytes, &scratch, &usedobjs, &scratch); dmu_objset_space(os, &refdbytes, &scratch, &usedobjs, &scratch);
} }

View File

@ -228,7 +228,6 @@ typedef struct dmu_buf_impl {
/* stuff we store for the user (see dmu_buf_set_user) */ /* stuff we store for the user (see dmu_buf_set_user) */
void *db_user_ptr; void *db_user_ptr;
void **db_user_data_ptr_ptr;
dmu_buf_evict_func_t *db_evict_func; dmu_buf_evict_func_t *db_evict_func;
uint8_t db_immediate_evict; uint8_t db_immediate_evict;

View File

@ -481,12 +481,6 @@ void dmu_buf_rele_array(dmu_buf_t **, int numbufs, void *tag);
* *
* user_ptr is for use by the user and can be obtained via dmu_buf_get_user(). * user_ptr is for use by the user and can be obtained via dmu_buf_get_user().
* *
* user_data_ptr_ptr should be NULL, or a pointer to a pointer which
* will be set to db->db_data when you are allowed to access it. Note
* that db->db_data (the pointer) can change when you do dmu_buf_read(),
* dmu_buf_tryupgrade(), dmu_buf_will_dirty(), or dmu_buf_will_fill().
* *user_data_ptr_ptr will be set to the new value when it changes.
*
* If non-NULL, pageout func will be called when this buffer is being * If non-NULL, pageout func will be called when this buffer is being
* excised from the cache, so that you can clean up the data structure * excised from the cache, so that you can clean up the data structure
* pointed to by user_ptr. * pointed to by user_ptr.
@ -494,17 +488,16 @@ void dmu_buf_rele_array(dmu_buf_t **, int numbufs, void *tag);
* dmu_evict_user() will call the pageout func for all buffers in a * dmu_evict_user() will call the pageout func for all buffers in a
* objset with a given pageout func. * objset with a given pageout func.
*/ */
void *dmu_buf_set_user(dmu_buf_t *db, void *user_ptr, void *user_data_ptr_ptr, void *dmu_buf_set_user(dmu_buf_t *db, void *user_ptr,
dmu_buf_evict_func_t *pageout_func); dmu_buf_evict_func_t *pageout_func);
/* /*
* set_user_ie is the same as set_user, but request immediate eviction * set_user_ie is the same as set_user, but request immediate eviction
* when hold count goes to zero. * when hold count goes to zero.
*/ */
void *dmu_buf_set_user_ie(dmu_buf_t *db, void *user_ptr, void *dmu_buf_set_user_ie(dmu_buf_t *db, void *user_ptr,
void *user_data_ptr_ptr, dmu_buf_evict_func_t *pageout_func);
void *dmu_buf_update_user(dmu_buf_t *db_fake, void *old_user_ptr,
void *user_ptr, void *user_data_ptr_ptr,
dmu_buf_evict_func_t *pageout_func); dmu_buf_evict_func_t *pageout_func);
void *dmu_buf_update_user(dmu_buf_t *db_fake, void *old_user_ptr,
void *user_ptr, dmu_buf_evict_func_t *pageout_func);
void dmu_evict_user(objset_t *os, dmu_buf_evict_func_t *func); void dmu_evict_user(objset_t *os, dmu_buf_evict_func_t *func);
/* /*

View File

@ -48,7 +48,7 @@ struct dsl_pool;
#define DS_FLAG_INCONSISTENT (1ULL<<0) #define DS_FLAG_INCONSISTENT (1ULL<<0)
#define DS_IS_INCONSISTENT(ds) \ #define DS_IS_INCONSISTENT(ds) \
((ds)->ds_phys->ds_flags & DS_FLAG_INCONSISTENT) (dsl_dataset_phys(ds)->ds_flags & DS_FLAG_INCONSISTENT)
/* /*
* Do not allow this dataset to be promoted. * Do not allow this dataset to be promoted.
@ -68,7 +68,7 @@ struct dsl_pool;
*/ */
#define DS_FLAG_DEFER_DESTROY (1ULL<<3) #define DS_FLAG_DEFER_DESTROY (1ULL<<3)
#define DS_IS_DEFER_DESTROY(ds) \ #define DS_IS_DEFER_DESTROY(ds) \
((ds)->ds_phys->ds_flags & DS_FLAG_DEFER_DESTROY) (dsl_dataset_phys(ds)->ds_flags & DS_FLAG_DEFER_DESTROY)
/* /*
* DS_FIELD_* are strings that are used in the "extensified" dataset zap object. * DS_FIELD_* are strings that are used in the "extensified" dataset zap object.
@ -127,7 +127,6 @@ typedef struct dsl_dataset_phys {
typedef struct dsl_dataset { typedef struct dsl_dataset {
/* Immutable: */ /* Immutable: */
struct dsl_dir *ds_dir; struct dsl_dir *ds_dir;
dsl_dataset_phys_t *ds_phys;
dmu_buf_t *ds_dbuf; dmu_buf_t *ds_dbuf;
uint64_t ds_object; uint64_t ds_object;
uint64_t ds_fsid_guid; uint64_t ds_fsid_guid;
@ -177,17 +176,26 @@ typedef struct dsl_dataset {
char ds_snapname[MAXNAMELEN]; char ds_snapname[MAXNAMELEN];
} dsl_dataset_t; } dsl_dataset_t;
static inline dsl_dataset_phys_t *
dsl_dataset_phys(dsl_dataset_t *ds)
{
return (ds->ds_dbuf->db_data);
}
/* /*
* The max length of a temporary tag prefix is the number of hex digits * The max length of a temporary tag prefix is the number of hex digits
* required to express UINT64_MAX plus one for the hyphen. * required to express UINT64_MAX plus one for the hyphen.
*/ */
#define MAX_TAG_PREFIX_LEN 17 #define MAX_TAG_PREFIX_LEN 17
#define dsl_dataset_is_snapshot(ds) \ static inline boolean_t
((ds)->ds_phys->ds_num_children != 0) dsl_dataset_is_snapshot(dsl_dataset_t *ds)
{
return (dsl_dataset_phys(ds)->ds_num_children != 0);
}
#define DS_UNIQUE_IS_ACCURATE(ds) \ #define DS_UNIQUE_IS_ACCURATE(ds) \
(((ds)->ds_phys->ds_flags & DS_FLAG_UNIQUE_ACCURATE) != 0) ((dsl_dataset_phys(ds)->ds_flags & DS_FLAG_UNIQUE_ACCURATE) != 0)
int dsl_dataset_hold(struct dsl_pool *dp, const char *name, void *tag, int dsl_dataset_hold(struct dsl_pool *dp, const char *name, void *tag,
dsl_dataset_t **dsp); dsl_dataset_t **dsp);

View File

@ -86,10 +86,11 @@ typedef struct dsl_dir_phys {
struct dsl_dir { struct dsl_dir {
/* These are immutable; no lock needed: */ /* These are immutable; no lock needed: */
uint64_t dd_object; uint64_t dd_object;
dsl_dir_phys_t *dd_phys;
dmu_buf_t *dd_dbuf;
dsl_pool_t *dd_pool; dsl_pool_t *dd_pool;
/* Stable until user eviction; no lock needed: */
dmu_buf_t *dd_dbuf;
/* protected by lock on pool's dp_dirty_dirs list */ /* protected by lock on pool's dp_dirty_dirs list */
txg_node_t dd_dirty_link; txg_node_t dd_dirty_link;
@ -111,6 +112,12 @@ struct dsl_dir {
char dd_myname[MAXNAMELEN]; char dd_myname[MAXNAMELEN];
}; };
static inline dsl_dir_phys_t *
dsl_dir_phys(dsl_dir_t *dd)
{
return (dd->dd_dbuf->db_data);
}
void dsl_dir_rele(dsl_dir_t *dd, void *tag); void dsl_dir_rele(dsl_dir_t *dd, void *tag);
int dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag, int dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
dsl_dir_t **, const char **tail); dsl_dir_t **, const char **tail);

View File

@ -70,7 +70,7 @@ typedef struct mzap_ent {
} mzap_ent_t; } mzap_ent_t;
#define MZE_PHYS(zap, mze) \ #define MZE_PHYS(zap, mze) \
(&(zap)->zap_m.zap_phys->mz_chunk[(mze)->mze_chunkid]) (&zap_m_phys(zap)->mz_chunk[(mze)->mze_chunkid])
/* /*
* The (fat) zap is stored in one object. It is an array of * The (fat) zap is stored in one object. It is an array of
@ -104,7 +104,7 @@ struct zap_leaf;
* word number (1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap)). * word number (1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap)).
*/ */
#define ZAP_EMBEDDED_PTRTBL_ENT(zap, idx) \ #define ZAP_EMBEDDED_PTRTBL_ENT(zap, idx) \
((uint64_t *)(zap)->zap_f.zap_phys) \ ((uint64_t *)zap_f_phys(zap)) \
[(idx) + (1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap))] [(idx) + (1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap))]
/* /*
@ -149,8 +149,6 @@ typedef struct zap {
uint64_t zap_salt; uint64_t zap_salt;
union { union {
struct { struct {
zap_phys_t *zap_phys;
/* /*
* zap_num_entries_mtx protects * zap_num_entries_mtx protects
* zap_num_entries * zap_num_entries
@ -159,7 +157,6 @@ typedef struct zap {
int zap_block_shift; int zap_block_shift;
} zap_fat; } zap_fat;
struct { struct {
mzap_phys_t *zap_phys;
int16_t zap_num_entries; int16_t zap_num_entries;
int16_t zap_num_chunks; int16_t zap_num_chunks;
int16_t zap_alloc_next; int16_t zap_alloc_next;
@ -168,6 +165,18 @@ typedef struct zap {
} zap_u; } zap_u;
} zap_t; } zap_t;
static inline zap_phys_t *
zap_f_phys(zap_t *zap)
{
return (zap->zap_dbuf->db_data);
}
static inline mzap_phys_t *
zap_m_phys(zap_t *zap)
{
return (zap->zap_dbuf->db_data);
}
typedef struct zap_name { typedef struct zap_name {
zap_t *zn_zap; zap_t *zn_zap;
int zn_key_intlen; int zn_key_intlen;

View File

@ -83,7 +83,7 @@ struct zap_stats;
*/ */
#define ZAP_LEAF_CHUNK(l, idx) \ #define ZAP_LEAF_CHUNK(l, idx) \
((zap_leaf_chunk_t *) \ ((zap_leaf_chunk_t *) \
((l)->l_phys->l_hash + ZAP_LEAF_HASH_NUMENTRIES(l)))[idx] (zap_leaf_phys(l)->l_hash + ZAP_LEAF_HASH_NUMENTRIES(l)))[idx]
#define ZAP_LEAF_ENTRY(l, idx) (&ZAP_LEAF_CHUNK(l, idx).l_entry) #define ZAP_LEAF_ENTRY(l, idx) (&ZAP_LEAF_CHUNK(l, idx).l_entry)
typedef enum zap_chunk_type { typedef enum zap_chunk_type {
@ -156,9 +156,13 @@ typedef struct zap_leaf {
uint64_t l_blkid; /* 1<<ZAP_BLOCK_SHIFT byte block off */ uint64_t l_blkid; /* 1<<ZAP_BLOCK_SHIFT byte block off */
int l_bs; /* block size shift */ int l_bs; /* block size shift */
dmu_buf_t *l_dbuf; dmu_buf_t *l_dbuf;
zap_leaf_phys_t *l_phys;
} zap_leaf_t; } zap_leaf_t;
static inline zap_leaf_phys_t *
zap_leaf_phys(zap_leaf_t *l)
{
return (l->l_dbuf->db_data);
}
typedef struct zap_entry_handle { typedef struct zap_entry_handle {
/* Set by zap_leaf and public to ZAP */ /* Set by zap_leaf and public to ZAP */

View File

@ -255,11 +255,8 @@ dbuf_evict_user(dmu_buf_impl_t *db)
if (db->db_level != 0 || db->db_evict_func == NULL) if (db->db_level != 0 || db->db_evict_func == NULL)
return; return;
if (db->db_user_data_ptr_ptr)
*db->db_user_data_ptr_ptr = db->db.db_data;
db->db_evict_func(&db->db, db->db_user_ptr); db->db_evict_func(&db->db, db->db_user_ptr);
db->db_user_ptr = NULL; db->db_user_ptr = NULL;
db->db_user_data_ptr_ptr = NULL;
db->db_evict_func = NULL; db->db_evict_func = NULL;
} }
@ -473,16 +470,6 @@ dbuf_verify(dmu_buf_impl_t *db)
} }
#endif #endif
static void
dbuf_update_data(dmu_buf_impl_t *db)
{
ASSERT(MUTEX_HELD(&db->db_mtx));
if (db->db_level == 0 && db->db_user_data_ptr_ptr) {
ASSERT(!refcount_is_zero(&db->db_holds));
*db->db_user_data_ptr_ptr = db->db.db_data;
}
}
static void static void
dbuf_set_data(dmu_buf_impl_t *db, arc_buf_t *buf) dbuf_set_data(dmu_buf_impl_t *db, arc_buf_t *buf)
{ {
@ -493,7 +480,6 @@ dbuf_set_data(dmu_buf_impl_t *db, arc_buf_t *buf)
db->db.db_data = buf->b_data; db->db.db_data = buf->b_data;
if (!arc_released(buf)) if (!arc_released(buf))
arc_set_callback(buf, dbuf_do_evict, db); arc_set_callback(buf, dbuf_do_evict, db);
dbuf_update_data(db);
} else { } else {
dbuf_evict_user(db); dbuf_evict_user(db);
db->db.db_data = NULL; db->db.db_data = NULL;
@ -600,7 +586,6 @@ dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t *flags)
if (bonuslen) if (bonuslen)
bcopy(DN_BONUS(dn->dn_phys), db->db.db_data, bonuslen); bcopy(DN_BONUS(dn->dn_phys), db->db.db_data, bonuslen);
DB_DNODE_EXIT(db); DB_DNODE_EXIT(db);
dbuf_update_data(db);
db->db_state = DB_CACHED; db->db_state = DB_CACHED;
mutex_exit(&db->db_mtx); mutex_exit(&db->db_mtx);
return (0); return (0);
@ -1801,7 +1786,6 @@ dbuf_create(dnode_t *dn, uint8_t level, uint64_t blkid,
db->db_blkptr = blkptr; db->db_blkptr = blkptr;
db->db_user_ptr = NULL; db->db_user_ptr = NULL;
db->db_user_data_ptr_ptr = NULL;
db->db_evict_func = NULL; db->db_evict_func = NULL;
db->db_immediate_evict = 0; db->db_immediate_evict = 0;
db->db_freed_in_flight = 0; db->db_freed_in_flight = 0;
@ -2052,7 +2036,6 @@ top:
} }
(void) refcount_add(&dh->dh_db->db_holds, dh->dh_tag); (void) refcount_add(&dh->dh_db->db_holds, dh->dh_tag);
dbuf_update_data(dh->dh_db);
DBUF_VERIFY(dh->dh_db); DBUF_VERIFY(dh->dh_db);
mutex_exit(&dh->dh_db->db_mtx); mutex_exit(&dh->dh_db->db_mtx);
@ -2342,27 +2325,25 @@ dbuf_refcount(dmu_buf_impl_t *db)
} }
void * void *
dmu_buf_set_user(dmu_buf_t *db_fake, void *user_ptr, void *user_data_ptr_ptr, dmu_buf_set_user(dmu_buf_t *db_fake, void *user_ptr,
dmu_buf_evict_func_t *evict_func) dmu_buf_evict_func_t *evict_func)
{ {
return (dmu_buf_update_user(db_fake, NULL, user_ptr, return (dmu_buf_update_user(db_fake, NULL, user_ptr, evict_func));
user_data_ptr_ptr, evict_func));
} }
void * void *
dmu_buf_set_user_ie(dmu_buf_t *db_fake, void *user_ptr, void *user_data_ptr_ptr, dmu_buf_set_user_ie(dmu_buf_t *db_fake, void *user_ptr,
dmu_buf_evict_func_t *evict_func) dmu_buf_evict_func_t *evict_func)
{ {
dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
db->db_immediate_evict = TRUE; db->db_immediate_evict = TRUE;
return (dmu_buf_update_user(db_fake, NULL, user_ptr, return (dmu_buf_update_user(db_fake, NULL, user_ptr, evict_func));
user_data_ptr_ptr, evict_func));
} }
void * void *
dmu_buf_update_user(dmu_buf_t *db_fake, void *old_user_ptr, void *user_ptr, dmu_buf_update_user(dmu_buf_t *db_fake, void *old_user_ptr, void *user_ptr,
void *user_data_ptr_ptr, dmu_buf_evict_func_t *evict_func) dmu_buf_evict_func_t *evict_func)
{ {
dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
ASSERT(db->db_level == 0); ASSERT(db->db_level == 0);
@ -2373,10 +2354,7 @@ dmu_buf_update_user(dmu_buf_t *db_fake, void *old_user_ptr, void *user_ptr,
if (db->db_user_ptr == old_user_ptr) { if (db->db_user_ptr == old_user_ptr) {
db->db_user_ptr = user_ptr; db->db_user_ptr = user_ptr;
db->db_user_data_ptr_ptr = user_data_ptr_ptr;
db->db_evict_func = evict_func; db->db_evict_func = evict_func;
dbuf_update_data(db);
} else { } else {
old_user_ptr = db->db_user_ptr; old_user_ptr = db->db_user_ptr;
} }

View File

@ -194,7 +194,7 @@ dmu_diff(const char *tosnap_name, const char *fromsnap_name,
return (SET_ERROR(EXDEV)); return (SET_ERROR(EXDEV));
} }
fromtxg = fromsnap->ds_phys->ds_creation_txg; fromtxg = dsl_dataset_phys(fromsnap)->ds_creation_txg;
dsl_dataset_rele(fromsnap, FTAG); dsl_dataset_rele(fromsnap, FTAG);
dsl_dataset_long_hold(tosnap, FTAG); dsl_dataset_long_hold(tosnap, FTAG);

View File

@ -1465,12 +1465,12 @@ dmu_snapshot_realname(objset_t *os, char *name, char *real, int maxlen,
dsl_dataset_t *ds = os->os_dsl_dataset; dsl_dataset_t *ds = os->os_dsl_dataset;
uint64_t ignored; uint64_t ignored;
if (ds->ds_phys->ds_snapnames_zapobj == 0) if (dsl_dataset_phys(ds)->ds_snapnames_zapobj == 0)
return (SET_ERROR(ENOENT)); return (SET_ERROR(ENOENT));
return (zap_lookup_norm(ds->ds_dir->dd_pool->dp_meta_objset, return (zap_lookup_norm(ds->ds_dir->dd_pool->dp_meta_objset,
ds->ds_phys->ds_snapnames_zapobj, name, 8, 1, &ignored, MT_FIRST, dsl_dataset_phys(ds)->ds_snapnames_zapobj, name, 8, 1, &ignored,
real, maxlen, conflict)); MT_FIRST, real, maxlen, conflict));
} }
int int
@ -1483,12 +1483,12 @@ dmu_snapshot_list_next(objset_t *os, int namelen, char *name,
ASSERT(dsl_pool_config_held(dmu_objset_pool(os))); ASSERT(dsl_pool_config_held(dmu_objset_pool(os)));
if (ds->ds_phys->ds_snapnames_zapobj == 0) if (dsl_dataset_phys(ds)->ds_snapnames_zapobj == 0)
return (SET_ERROR(ENOENT)); return (SET_ERROR(ENOENT));
zap_cursor_init_serialized(&cursor, zap_cursor_init_serialized(&cursor,
ds->ds_dir->dd_pool->dp_meta_objset, ds->ds_dir->dd_pool->dp_meta_objset,
ds->ds_phys->ds_snapnames_zapobj, *offp); dsl_dataset_phys(ds)->ds_snapnames_zapobj, *offp);
if (zap_cursor_retrieve(&cursor, &attr) != 0) { if (zap_cursor_retrieve(&cursor, &attr) != 0) {
zap_cursor_fini(&cursor); zap_cursor_fini(&cursor);
@ -1528,12 +1528,12 @@ dmu_dir_list_next(objset_t *os, int namelen, char *name,
/* there is no next dir on a snapshot! */ /* there is no next dir on a snapshot! */
if (os->os_dsl_dataset->ds_object != if (os->os_dsl_dataset->ds_object !=
dd->dd_phys->dd_head_dataset_obj) dsl_dir_phys(dd)->dd_head_dataset_obj)
return (SET_ERROR(ENOENT)); return (SET_ERROR(ENOENT));
zap_cursor_init_serialized(&cursor, zap_cursor_init_serialized(&cursor,
dd->dd_pool->dp_meta_objset, dd->dd_pool->dp_meta_objset,
dd->dd_phys->dd_child_dir_zapobj, *offp); dsl_dir_phys(dd)->dd_child_dir_zapobj, *offp);
if (zap_cursor_retrieve(&cursor, &attr) != 0) { if (zap_cursor_retrieve(&cursor, &attr) != 0) {
zap_cursor_fini(&cursor); zap_cursor_fini(&cursor);
@ -1581,7 +1581,7 @@ dmu_objset_find_dp(dsl_pool_t *dp, uint64_t ddobj,
return (0); return (0);
} }
thisobj = dd->dd_phys->dd_head_dataset_obj; thisobj = dsl_dir_phys(dd)->dd_head_dataset_obj;
attr = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); attr = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
/* /*
@ -1589,7 +1589,7 @@ dmu_objset_find_dp(dsl_pool_t *dp, uint64_t ddobj,
*/ */
if (flags & DS_FIND_CHILDREN) { if (flags & DS_FIND_CHILDREN) {
for (zap_cursor_init(&zc, dp->dp_meta_objset, for (zap_cursor_init(&zc, dp->dp_meta_objset,
dd->dd_phys->dd_child_dir_zapobj); dsl_dir_phys(dd)->dd_child_dir_zapobj);
zap_cursor_retrieve(&zc, attr) == 0; zap_cursor_retrieve(&zc, attr) == 0;
(void) zap_cursor_advance(&zc)) { (void) zap_cursor_advance(&zc)) {
ASSERT3U(attr->za_integer_length, ==, ASSERT3U(attr->za_integer_length, ==,
@ -1618,7 +1618,9 @@ dmu_objset_find_dp(dsl_pool_t *dp, uint64_t ddobj,
err = dsl_dataset_hold_obj(dp, thisobj, FTAG, &ds); err = dsl_dataset_hold_obj(dp, thisobj, FTAG, &ds);
if (err == 0) { if (err == 0) {
uint64_t snapobj = ds->ds_phys->ds_snapnames_zapobj; uint64_t snapobj;
snapobj = dsl_dataset_phys(ds)->ds_snapnames_zapobj;
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
for (zap_cursor_init(&zc, dp->dp_meta_objset, snapobj); for (zap_cursor_init(&zc, dp->dp_meta_objset, snapobj);
@ -1693,7 +1695,7 @@ dmu_objset_find_impl(spa_t *spa, const char *name,
return (0); return (0);
} }
thisobj = dd->dd_phys->dd_head_dataset_obj; thisobj = dsl_dir_phys(dd)->dd_head_dataset_obj;
attr = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); attr = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
/* /*
@ -1701,7 +1703,7 @@ dmu_objset_find_impl(spa_t *spa, const char *name,
*/ */
if (flags & DS_FIND_CHILDREN) { if (flags & DS_FIND_CHILDREN) {
for (zap_cursor_init(&zc, dp->dp_meta_objset, for (zap_cursor_init(&zc, dp->dp_meta_objset,
dd->dd_phys->dd_child_dir_zapobj); dsl_dir_phys(dd)->dd_child_dir_zapobj);
zap_cursor_retrieve(&zc, attr) == 0; zap_cursor_retrieve(&zc, attr) == 0;
(void) zap_cursor_advance(&zc)) { (void) zap_cursor_advance(&zc)) {
ASSERT3U(attr->za_integer_length, ==, ASSERT3U(attr->za_integer_length, ==,
@ -1734,7 +1736,9 @@ dmu_objset_find_impl(spa_t *spa, const char *name,
err = dsl_dataset_hold_obj(dp, thisobj, FTAG, &ds); err = dsl_dataset_hold_obj(dp, thisobj, FTAG, &ds);
if (err == 0) { if (err == 0) {
uint64_t snapobj = ds->ds_phys->ds_snapnames_zapobj; uint64_t snapobj;
snapobj = dsl_dataset_phys(ds)->ds_snapnames_zapobj;
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
for (zap_cursor_init(&zc, dp->dp_meta_objset, snapobj); for (zap_cursor_init(&zc, dp->dp_meta_objset, snapobj);

View File

@ -602,12 +602,12 @@ dmu_send_impl(void *tag, dsl_pool_t *dp, dsl_dataset_t *ds,
featureflags); featureflags);
drr->drr_u.drr_begin.drr_creation_time = drr->drr_u.drr_begin.drr_creation_time =
ds->ds_phys->ds_creation_time; dsl_dataset_phys(ds)->ds_creation_time;
drr->drr_u.drr_begin.drr_type = dmu_objset_type(os); drr->drr_u.drr_begin.drr_type = dmu_objset_type(os);
if (is_clone) if (is_clone)
drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CLONE; drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CLONE;
drr->drr_u.drr_begin.drr_toguid = ds->ds_phys->ds_guid; drr->drr_u.drr_begin.drr_toguid = dsl_dataset_phys(ds)->ds_guid;
if (ds->ds_phys->ds_flags & DS_FLAG_CI_DATASET) if (dsl_dataset_phys(ds)->ds_flags & DS_FLAG_CI_DATASET)
drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CI_DATA; drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CI_DATA;
if (fromzb != NULL) { if (fromzb != NULL) {
@ -628,7 +628,7 @@ dmu_send_impl(void *tag, dsl_pool_t *dp, dsl_dataset_t *ds,
dsp->dsa_proc = curproc; dsp->dsa_proc = curproc;
dsp->dsa_os = os; dsp->dsa_os = os;
dsp->dsa_off = off; dsp->dsa_off = off;
dsp->dsa_toguid = ds->ds_phys->ds_guid; dsp->dsa_toguid = dsl_dataset_phys(ds)->ds_guid;
ZIO_SET_CHECKSUM(&dsp->dsa_zc, 0, 0, 0, 0); ZIO_SET_CHECKSUM(&dsp->dsa_zc, 0, 0, 0, 0);
dsp->dsa_pending_op = PENDING_NONE; dsp->dsa_pending_op = PENDING_NONE;
dsp->dsa_incremental = (fromzb != NULL); dsp->dsa_incremental = (fromzb != NULL);
@ -713,9 +713,10 @@ dmu_send_obj(const char *pool, uint64_t tosnap, uint64_t fromsnap,
} }
if (!dsl_dataset_is_before(ds, fromds, 0)) if (!dsl_dataset_is_before(ds, fromds, 0))
err = SET_ERROR(EXDEV); err = SET_ERROR(EXDEV);
zb.zbm_creation_time = fromds->ds_phys->ds_creation_time; zb.zbm_creation_time =
zb.zbm_creation_txg = fromds->ds_phys->ds_creation_txg; dsl_dataset_phys(fromds)->ds_creation_time;
zb.zbm_guid = fromds->ds_phys->ds_guid; zb.zbm_creation_txg = dsl_dataset_phys(fromds)->ds_creation_txg;
zb.zbm_guid = dsl_dataset_phys(fromds)->ds_guid;
is_clone = (fromds->ds_dir != ds->ds_dir); is_clone = (fromds->ds_dir != ds->ds_dir);
dsl_dataset_rele(fromds, FTAG); dsl_dataset_rele(fromds, FTAG);
err = dmu_send_impl(FTAG, dp, ds, &zb, is_clone, embedok, err = dmu_send_impl(FTAG, dp, ds, &zb, is_clone, embedok,
@ -781,10 +782,10 @@ dmu_send(const char *tosnap, const char *fromsnap, boolean_t embedok,
if (!dsl_dataset_is_before(ds, fromds, 0)) if (!dsl_dataset_is_before(ds, fromds, 0))
err = SET_ERROR(EXDEV); err = SET_ERROR(EXDEV);
zb.zbm_creation_time = zb.zbm_creation_time =
fromds->ds_phys->ds_creation_time; dsl_dataset_phys(fromds)->ds_creation_time;
zb.zbm_creation_txg = zb.zbm_creation_txg =
fromds->ds_phys->ds_creation_txg; dsl_dataset_phys(fromds)->ds_creation_txg;
zb.zbm_guid = fromds->ds_phys->ds_guid; zb.zbm_guid = dsl_dataset_phys(fromds)->ds_guid;
is_clone = (ds->ds_dir != fromds->ds_dir); is_clone = (ds->ds_dir != fromds->ds_dir);
dsl_dataset_rele(fromds, FTAG); dsl_dataset_rele(fromds, FTAG);
} }
@ -831,7 +832,7 @@ dmu_send_estimate(dsl_dataset_t *ds, dsl_dataset_t *fromds, uint64_t *sizep)
/* Get uncompressed size estimate of changed data. */ /* Get uncompressed size estimate of changed data. */
if (fromds == NULL) { if (fromds == NULL) {
size = ds->ds_phys->ds_uncompressed_bytes; size = dsl_dataset_phys(ds)->ds_uncompressed_bytes;
} else { } else {
uint64_t used, comp; uint64_t used, comp;
err = dsl_dataset_space_written(fromds, ds, err = dsl_dataset_space_written(fromds, ds,
@ -885,15 +886,15 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
/* temporary clone name must not exist */ /* temporary clone name must not exist */
error = zap_lookup(dp->dp_meta_objset, error = zap_lookup(dp->dp_meta_objset,
ds->ds_dir->dd_phys->dd_child_dir_zapobj, recv_clone_name, dsl_dir_phys(ds->ds_dir)->dd_child_dir_zapobj, recv_clone_name,
8, 1, &val); 8, 1, &val);
if (error != ENOENT) if (error != ENOENT)
return (error == 0 ? EBUSY : error); return (error == 0 ? EBUSY : error);
/* new snapshot name must not exist */ /* new snapshot name must not exist */
error = zap_lookup(dp->dp_meta_objset, error = zap_lookup(dp->dp_meta_objset,
ds->ds_phys->ds_snapnames_zapobj, drba->drba_cookie->drc_tosnap, dsl_dataset_phys(ds)->ds_snapnames_zapobj,
8, 1, &val); drba->drba_cookie->drc_tosnap, 8, 1, &val);
if (error != ENOENT) if (error != ENOENT)
return (error == 0 ? EEXIST : error); return (error == 0 ? EEXIST : error);
@ -913,7 +914,7 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
if (fromguid != 0) { if (fromguid != 0) {
dsl_dataset_t *snap; dsl_dataset_t *snap;
uint64_t obj = ds->ds_phys->ds_prev_snap_obj; uint64_t obj = dsl_dataset_phys(ds)->ds_prev_snap_obj;
/* Find snapshot in this dir that matches fromguid. */ /* Find snapshot in this dir that matches fromguid. */
while (obj != 0) { while (obj != 0) {
@ -925,9 +926,9 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
dsl_dataset_rele(snap, FTAG); dsl_dataset_rele(snap, FTAG);
return (SET_ERROR(ENODEV)); return (SET_ERROR(ENODEV));
} }
if (snap->ds_phys->ds_guid == fromguid) if (dsl_dataset_phys(snap)->ds_guid == fromguid)
break; break;
obj = snap->ds_phys->ds_prev_snap_obj; obj = dsl_dataset_phys(snap)->ds_prev_snap_obj;
dsl_dataset_rele(snap, FTAG); dsl_dataset_rele(snap, FTAG);
} }
if (obj == 0) if (obj == 0)
@ -950,9 +951,9 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
dsl_dataset_rele(snap, FTAG); dsl_dataset_rele(snap, FTAG);
} else { } else {
/* if full, most recent snapshot must be $ORIGIN */ /* if full, most recent snapshot must be $ORIGIN */
if (ds->ds_phys->ds_prev_snap_txg >= TXG_INITIAL) if (dsl_dataset_phys(ds)->ds_prev_snap_txg >= TXG_INITIAL)
return (SET_ERROR(ENODEV)); return (SET_ERROR(ENODEV));
drba->drba_snapobj = ds->ds_phys->ds_prev_snap_obj; drba->drba_snapobj = dsl_dataset_phys(ds)->ds_prev_snap_obj;
} }
return (0); return (0);
@ -1061,7 +1062,7 @@ dmu_recv_begin_check(void *arg, dmu_tx_t *tx)
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
return (SET_ERROR(EINVAL)); return (SET_ERROR(EINVAL));
} }
if (origin->ds_phys->ds_guid != fromguid) { if (dsl_dataset_phys(origin)->ds_guid != fromguid) {
dsl_dataset_rele(origin, FTAG); dsl_dataset_rele(origin, FTAG);
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
return (SET_ERROR(ENODEV)); return (SET_ERROR(ENODEV));
@ -1125,7 +1126,7 @@ dmu_recv_begin_sync(void *arg, dmu_tx_t *tx)
VERIFY0(dsl_dataset_own_obj(dp, dsobj, dmu_recv_tag, &newds)); VERIFY0(dsl_dataset_own_obj(dp, dsobj, dmu_recv_tag, &newds));
dmu_buf_will_dirty(newds->ds_dbuf, tx); dmu_buf_will_dirty(newds->ds_dbuf, tx);
newds->ds_phys->ds_flags |= DS_FLAG_INCONSISTENT; dsl_dataset_phys(newds)->ds_flags |= DS_FLAG_INCONSISTENT;
/* /*
* If we actually created a non-clone, we need to create the * If we actually created a non-clone, we need to create the
@ -1764,7 +1765,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp,
*/ */
VERIFY0(dmu_objset_from_ds(drc->drc_ds, &os)); VERIFY0(dmu_objset_from_ds(drc->drc_ds, &os));
ASSERT(drc->drc_ds->ds_phys->ds_flags & DS_FLAG_INCONSISTENT); ASSERT(dsl_dataset_phys(drc->drc_ds)->ds_flags & DS_FLAG_INCONSISTENT);
featureflags = DMU_GET_FEATUREFLAGS(drc->drc_drrb->drr_versioninfo); featureflags = DMU_GET_FEATUREFLAGS(drc->drc_drrb->drr_versioninfo);
@ -1927,8 +1928,11 @@ dmu_recv_end_check(void *arg, dmu_tx_t *tx)
* the snap before drc_ds, because drc_ds can not * the snap before drc_ds, because drc_ds can not
* have any snaps of its own). * have any snaps of its own).
*/ */
uint64_t obj = origin_head->ds_phys->ds_prev_snap_obj; uint64_t obj;
while (obj != drc->drc_ds->ds_phys->ds_prev_snap_obj) {
obj = dsl_dataset_phys(origin_head)->ds_prev_snap_obj;
while (obj !=
dsl_dataset_phys(drc->drc_ds)->ds_prev_snap_obj) {
dsl_dataset_t *snap; dsl_dataset_t *snap;
error = dsl_dataset_hold_obj(dp, obj, FTAG, error = dsl_dataset_hold_obj(dp, obj, FTAG,
&snap); &snap);
@ -1940,7 +1944,7 @@ dmu_recv_end_check(void *arg, dmu_tx_t *tx)
error = dsl_destroy_snapshot_check_impl( error = dsl_destroy_snapshot_check_impl(
snap, B_FALSE); snap, B_FALSE);
} }
obj = snap->ds_phys->ds_prev_snap_obj; obj = dsl_dataset_phys(snap)->ds_prev_snap_obj;
dsl_dataset_rele(snap, FTAG); dsl_dataset_rele(snap, FTAG);
if (error != 0) if (error != 0)
return (error); return (error);
@ -1986,13 +1990,16 @@ dmu_recv_end_sync(void *arg, dmu_tx_t *tx)
* Destroy any snapshots of drc_tofs (origin_head) * Destroy any snapshots of drc_tofs (origin_head)
* after the origin (the snap before drc_ds). * after the origin (the snap before drc_ds).
*/ */
uint64_t obj = origin_head->ds_phys->ds_prev_snap_obj; uint64_t obj;
while (obj != drc->drc_ds->ds_phys->ds_prev_snap_obj) {
obj = dsl_dataset_phys(origin_head)->ds_prev_snap_obj;
while (obj !=
dsl_dataset_phys(drc->drc_ds)->ds_prev_snap_obj) {
dsl_dataset_t *snap; dsl_dataset_t *snap;
VERIFY0(dsl_dataset_hold_obj(dp, obj, FTAG, VERIFY0(dsl_dataset_hold_obj(dp, obj, FTAG,
&snap)); &snap));
ASSERT3P(snap->ds_dir, ==, origin_head->ds_dir); ASSERT3P(snap->ds_dir, ==, origin_head->ds_dir);
obj = snap->ds_phys->ds_prev_snap_obj; obj = dsl_dataset_phys(snap)->ds_prev_snap_obj;
dsl_destroy_snapshot_sync_impl(snap, dsl_destroy_snapshot_sync_impl(snap,
B_FALSE, tx); B_FALSE, tx);
dsl_dataset_rele(snap, FTAG); dsl_dataset_rele(snap, FTAG);
@ -2008,15 +2015,16 @@ dmu_recv_end_sync(void *arg, dmu_tx_t *tx)
/* set snapshot's creation time and guid */ /* set snapshot's creation time and guid */
dmu_buf_will_dirty(origin_head->ds_prev->ds_dbuf, tx); dmu_buf_will_dirty(origin_head->ds_prev->ds_dbuf, tx);
origin_head->ds_prev->ds_phys->ds_creation_time = dsl_dataset_phys(origin_head->ds_prev)->ds_creation_time =
drc->drc_drrb->drr_creation_time; drc->drc_drrb->drr_creation_time;
origin_head->ds_prev->ds_phys->ds_guid = dsl_dataset_phys(origin_head->ds_prev)->ds_guid =
drc->drc_drrb->drr_toguid; drc->drc_drrb->drr_toguid;
origin_head->ds_prev->ds_phys->ds_flags &= dsl_dataset_phys(origin_head->ds_prev)->ds_flags &=
~DS_FLAG_INCONSISTENT; ~DS_FLAG_INCONSISTENT;
dmu_buf_will_dirty(origin_head->ds_dbuf, tx); dmu_buf_will_dirty(origin_head->ds_dbuf, tx);
origin_head->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT; dsl_dataset_phys(origin_head)->ds_flags &=
~DS_FLAG_INCONSISTENT;
dsl_dataset_rele(origin_head, FTAG); dsl_dataset_rele(origin_head, FTAG);
dsl_destroy_head_sync_impl(drc->drc_ds, tx); dsl_destroy_head_sync_impl(drc->drc_ds, tx);
@ -2030,15 +2038,17 @@ dmu_recv_end_sync(void *arg, dmu_tx_t *tx)
/* set snapshot's creation time and guid */ /* set snapshot's creation time and guid */
dmu_buf_will_dirty(ds->ds_prev->ds_dbuf, tx); dmu_buf_will_dirty(ds->ds_prev->ds_dbuf, tx);
ds->ds_prev->ds_phys->ds_creation_time = dsl_dataset_phys(ds->ds_prev)->ds_creation_time =
drc->drc_drrb->drr_creation_time; drc->drc_drrb->drr_creation_time;
ds->ds_prev->ds_phys->ds_guid = drc->drc_drrb->drr_toguid; dsl_dataset_phys(ds->ds_prev)->ds_guid =
ds->ds_prev->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT; drc->drc_drrb->drr_toguid;
dsl_dataset_phys(ds->ds_prev)->ds_flags &=
~DS_FLAG_INCONSISTENT;
dmu_buf_will_dirty(ds->ds_dbuf, tx); dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT; dsl_dataset_phys(ds)->ds_flags &= ~DS_FLAG_INCONSISTENT;
} }
drc->drc_newsnapobj = drc->drc_ds->ds_phys->ds_prev_snap_obj; drc->drc_newsnapobj = dsl_dataset_phys(drc->drc_ds)->ds_prev_snap_obj;
/* /*
* Release the hold from dmu_recv_begin. This must be done before * Release the hold from dmu_recv_begin. This must be done before
* we return to open context, so that when we free the dataset's dnode, * we return to open context, so that when we free the dataset's dnode,
@ -2064,7 +2074,7 @@ add_ds_to_guidmap(const char *name, avl_tree_t *guid_map, uint64_t snapobj)
gmep = kmem_alloc(sizeof (*gmep), KM_SLEEP); gmep = kmem_alloc(sizeof (*gmep), KM_SLEEP);
err = dsl_dataset_hold_obj(dp, snapobj, gmep, &snapds); err = dsl_dataset_hold_obj(dp, snapobj, gmep, &snapds);
if (err == 0) { if (err == 0) {
gmep->guid = snapds->ds_phys->ds_guid; gmep->guid = dsl_dataset_phys(snapds)->ds_guid;
gmep->gme_ds = snapds; gmep->gme_ds = snapds;
avl_add(guid_map, gmep); avl_add(guid_map, gmep);
dsl_dataset_long_hold(snapds, gmep); dsl_dataset_long_hold(snapds, gmep);

View File

@ -590,7 +590,7 @@ traverse_dataset(dsl_dataset_t *ds, uint64_t txg_start, int flags,
blkptr_cb_t func, void *arg) blkptr_cb_t func, void *arg)
{ {
return (traverse_impl(ds->ds_dir->dd_pool->dp_spa, ds, ds->ds_object, return (traverse_impl(ds->ds_dir->dd_pool->dp_spa, ds, ds->ds_object,
&ds->ds_phys->ds_bp, txg_start, NULL, flags, func, arg)); &dsl_dataset_phys(ds)->ds_bp, txg_start, NULL, flags, func, arg));
} }
int int
@ -645,8 +645,8 @@ traverse_pool(spa_t *spa, uint64_t txg_start, int flags,
continue; continue;
break; break;
} }
if (ds->ds_phys->ds_prev_snap_txg > txg) if (dsl_dataset_phys(ds)->ds_prev_snap_txg > txg)
txg = ds->ds_phys->ds_prev_snap_txg; txg = dsl_dataset_phys(ds)->ds_prev_snap_txg;
err = traverse_dataset(ds, txg, flags, func, arg); err = traverse_dataset(ds, txg, flags, func, arg);
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
if (err != 0) if (err != 0)

View File

@ -699,6 +699,7 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name)
{ {
dmu_tx_hold_t *txh; dmu_tx_hold_t *txh;
dnode_t *dn; dnode_t *dn;
dsl_dataset_phys_t *ds_phys;
uint64_t nblocks; uint64_t nblocks;
int epbs, err; int epbs, err;
@ -773,8 +774,9 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name)
* we'll have to modify an indirect twig for each. * we'll have to modify an indirect twig for each.
*/ */
epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
ds_phys = dsl_dataset_phys(dn->dn_objset->os_dsl_dataset);
for (nblocks = dn->dn_maxblkid >> epbs; nblocks != 0; nblocks >>= epbs) for (nblocks = dn->dn_maxblkid >> epbs; nblocks != 0; nblocks >>= epbs)
if (dn->dn_objset->os_dsl_dataset->ds_phys->ds_prev_snap_obj) if (ds_phys->ds_prev_snap_obj)
txh->txh_space_towrite += 3 << dn->dn_indblkshift; txh->txh_space_towrite += 3 << dn->dn_indblkshift;
else else
txh->txh_space_tooverwrite += 3 << dn->dn_indblkshift; txh->txh_space_tooverwrite += 3 << dn->dn_indblkshift;

View File

@ -1116,7 +1116,7 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag,
zrl_init(&dnh[i].dnh_zrlock); zrl_init(&dnh[i].dnh_zrlock);
dnh[i].dnh_dnode = NULL; dnh[i].dnh_dnode = NULL;
} }
if ((winner = dmu_buf_set_user(&db->db, children_dnodes, NULL, if ((winner = dmu_buf_set_user(&db->db, children_dnodes,
dnode_buf_pageout))) { dnode_buf_pageout))) {
for (i = 0; i < epb; i++) { for (i = 0; i < epb; i++) {

View File

@ -65,7 +65,7 @@ dsl_dataset_bmark_lookup(dsl_dataset_t *ds, const char *shortname,
if (bmark_zapobj == 0) if (bmark_zapobj == 0)
return (SET_ERROR(ESRCH)); return (SET_ERROR(ESRCH));
if (ds->ds_phys->ds_flags & DS_FLAG_CI_DATASET) if (dsl_dataset_phys(ds)->ds_flags & DS_FLAG_CI_DATASET)
mt = MT_FIRST; mt = MT_FIRST;
else else
mt = MT_EXACT; mt = MT_EXACT;
@ -210,10 +210,11 @@ dsl_bookmark_create_sync(void *arg, dmu_tx_t *tx)
&bmark_fs->ds_bookmarks, tx)); &bmark_fs->ds_bookmarks, tx));
} }
bmark_phys.zbm_guid = snapds->ds_phys->ds_guid; bmark_phys.zbm_guid = dsl_dataset_phys(snapds)->ds_guid;
bmark_phys.zbm_creation_txg = snapds->ds_phys->ds_creation_txg; bmark_phys.zbm_creation_txg =
dsl_dataset_phys(snapds)->ds_creation_txg;
bmark_phys.zbm_creation_time = bmark_phys.zbm_creation_time =
snapds->ds_phys->ds_creation_time; dsl_dataset_phys(snapds)->ds_creation_time;
VERIFY0(zap_add(mos, bmark_fs->ds_bookmarks, VERIFY0(zap_add(mos, bmark_fs->ds_bookmarks,
shortname, sizeof (uint64_t), shortname, sizeof (uint64_t),
@ -342,7 +343,7 @@ dsl_dataset_bookmark_remove(dsl_dataset_t *ds, const char *name, dmu_tx_t *tx)
uint64_t bmark_zapobj = ds->ds_bookmarks; uint64_t bmark_zapobj = ds->ds_bookmarks;
matchtype_t mt; matchtype_t mt;
if (ds->ds_phys->ds_flags & DS_FLAG_CI_DATASET) if (dsl_dataset_phys(ds)->ds_flags & DS_FLAG_CI_DATASET)
mt = MT_FIRST; mt = MT_FIRST;
else else
mt = MT_EXACT; mt = MT_EXACT;

File diff suppressed because it is too large Load Diff

View File

@ -310,8 +310,9 @@ dsl_deadlist_regenerate(objset_t *os, uint64_t dlobj,
while (mrs_obj != 0) { while (mrs_obj != 0) {
dsl_dataset_t *ds; dsl_dataset_t *ds;
VERIFY3U(0, ==, dsl_dataset_hold_obj(dp, mrs_obj, FTAG, &ds)); VERIFY3U(0, ==, dsl_dataset_hold_obj(dp, mrs_obj, FTAG, &ds));
dsl_deadlist_add_key(&dl, ds->ds_phys->ds_prev_snap_txg, tx); dsl_deadlist_add_key(&dl,
mrs_obj = ds->ds_phys->ds_prev_snap_obj; dsl_dataset_phys(ds)->ds_prev_snap_txg, tx);
mrs_obj = dsl_dataset_phys(ds)->ds_prev_snap_obj;
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
} }
dsl_deadlist_close(&dl); dsl_deadlist_close(&dl);

View File

@ -164,10 +164,10 @@ dsl_deleg_set_sync(void *arg, dmu_tx_t *tx)
VERIFY0(dsl_dir_hold(dp, dda->dda_name, FTAG, &dd, NULL)); VERIFY0(dsl_dir_hold(dp, dda->dda_name, FTAG, &dd, NULL));
zapobj = dd->dd_phys->dd_deleg_zapobj; zapobj = dsl_dir_phys(dd)->dd_deleg_zapobj;
if (zapobj == 0) { if (zapobj == 0) {
dmu_buf_will_dirty(dd->dd_dbuf, tx); dmu_buf_will_dirty(dd->dd_dbuf, tx);
zapobj = dd->dd_phys->dd_deleg_zapobj = zap_create(mos, zapobj = dsl_dir_phys(dd)->dd_deleg_zapobj = zap_create(mos,
DMU_OT_DSL_PERMS, DMU_OT_NONE, 0, tx); DMU_OT_DSL_PERMS, DMU_OT_NONE, 0, tx);
} }
@ -208,7 +208,7 @@ dsl_deleg_unset_sync(void *arg, dmu_tx_t *tx)
uint64_t zapobj; uint64_t zapobj;
VERIFY0(dsl_dir_hold(dp, dda->dda_name, FTAG, &dd, NULL)); VERIFY0(dsl_dir_hold(dp, dda->dda_name, FTAG, &dd, NULL));
zapobj = dd->dd_phys->dd_deleg_zapobj; zapobj = dsl_dir_phys(dd)->dd_deleg_zapobj;
if (zapobj == 0) { if (zapobj == 0) {
dsl_dir_rele(dd, FTAG); dsl_dir_rele(dd, FTAG);
return; return;
@ -337,14 +337,14 @@ dsl_deleg_get(const char *ddname, nvlist_t **nvp)
nvlist_t *sp_nvp; nvlist_t *sp_nvp;
uint64_t n; uint64_t n;
if (dd->dd_phys->dd_deleg_zapobj == 0 || if (dsl_dir_phys(dd)->dd_deleg_zapobj == 0 ||
zap_count(mos, dd->dd_phys->dd_deleg_zapobj, &n) != 0 || zap_count(mos,
n == 0) dsl_dir_phys(dd)->dd_deleg_zapobj, &n) != 0 || n == 0)
continue; continue;
sp_nvp = fnvlist_alloc(); sp_nvp = fnvlist_alloc();
for (zap_cursor_init(basezc, mos, for (zap_cursor_init(basezc, mos,
dd->dd_phys->dd_deleg_zapobj); dsl_dir_phys(dd)->dd_deleg_zapobj);
zap_cursor_retrieve(basezc, baseza) == 0; zap_cursor_retrieve(basezc, baseza) == 0;
zap_cursor_advance(basezc)) { zap_cursor_advance(basezc)) {
nvlist_t *perms_nvp; nvlist_t *perms_nvp;
@ -603,7 +603,7 @@ dsl_deleg_access_impl(dsl_dataset_t *ds, const char *perm, cred_t *cr)
if (!zoned) if (!zoned)
break; break;
} }
zapobj = dd->dd_phys->dd_deleg_zapobj; zapobj = dsl_dir_phys(dd)->dd_deleg_zapobj;
if (zapobj == 0) if (zapobj == 0)
continue; continue;
@ -682,7 +682,7 @@ copy_create_perms(dsl_dir_t *dd, uint64_t pzapobj,
{ {
objset_t *mos = dd->dd_pool->dp_meta_objset; objset_t *mos = dd->dd_pool->dp_meta_objset;
uint64_t jumpobj, pjumpobj; uint64_t jumpobj, pjumpobj;
uint64_t zapobj = dd->dd_phys->dd_deleg_zapobj; uint64_t zapobj = dsl_dir_phys(dd)->dd_deleg_zapobj;
zap_cursor_t zc; zap_cursor_t zc;
zap_attribute_t za; zap_attribute_t za;
char whokey[ZFS_MAX_DELEG_NAME]; char whokey[ZFS_MAX_DELEG_NAME];
@ -695,7 +695,7 @@ copy_create_perms(dsl_dir_t *dd, uint64_t pzapobj,
if (zapobj == 0) { if (zapobj == 0) {
dmu_buf_will_dirty(dd->dd_dbuf, tx); dmu_buf_will_dirty(dd->dd_dbuf, tx);
zapobj = dd->dd_phys->dd_deleg_zapobj = zap_create(mos, zapobj = dsl_dir_phys(dd)->dd_deleg_zapobj = zap_create(mos,
DMU_OT_DSL_PERMS, DMU_OT_NONE, 0, tx); DMU_OT_DSL_PERMS, DMU_OT_NONE, 0, tx);
} }
@ -733,7 +733,7 @@ dsl_deleg_set_create_perms(dsl_dir_t *sdd, dmu_tx_t *tx, cred_t *cr)
return; return;
for (dd = sdd->dd_parent; dd != NULL; dd = dd->dd_parent) { for (dd = sdd->dd_parent; dd != NULL; dd = dd->dd_parent) {
uint64_t pzapobj = dd->dd_phys->dd_deleg_zapobj; uint64_t pzapobj = dsl_dir_phys(dd)->dd_deleg_zapobj;
if (pzapobj == 0) if (pzapobj == 0)
continue; continue;

View File

@ -78,7 +78,7 @@ dsl_destroy_snapshot_check_impl(dsl_dataset_t *ds, boolean_t defer)
/* /*
* Can't delete a branch point. * Can't delete a branch point.
*/ */
if (ds->ds_phys->ds_num_children > 1) if (dsl_dataset_phys(ds)->ds_num_children > 1)
return (SET_ERROR(EEXIST)); return (SET_ERROR(EEXIST));
return (0); return (0);
@ -147,12 +147,12 @@ process_old_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
ASSERT(!BP_IS_HOLE(bp)); ASSERT(!BP_IS_HOLE(bp));
if (bp->blk_birth <= poa->ds->ds_phys->ds_prev_snap_txg) { if (bp->blk_birth <= dsl_dataset_phys(poa->ds)->ds_prev_snap_txg) {
dsl_deadlist_insert(&poa->ds->ds_deadlist, bp, tx); dsl_deadlist_insert(&poa->ds->ds_deadlist, bp, tx);
if (poa->ds_prev && !poa->after_branch_point && if (poa->ds_prev && !poa->after_branch_point &&
bp->blk_birth > bp->blk_birth >
poa->ds_prev->ds_phys->ds_prev_snap_txg) { dsl_dataset_phys(poa->ds_prev)->ds_prev_snap_txg) {
poa->ds_prev->ds_phys->ds_unique_bytes += dsl_dataset_phys(poa->ds_prev)->ds_unique_bytes +=
bp_get_dsize_sync(dp->dp_spa, bp); bp_get_dsize_sync(dp->dp_spa, bp);
} }
} else { } else {
@ -183,7 +183,7 @@ process_old_deadlist(dsl_dataset_t *ds, dsl_dataset_t *ds_prev,
VERIFY0(bpobj_iterate(&ds_next->ds_deadlist.dl_bpobj, VERIFY0(bpobj_iterate(&ds_next->ds_deadlist.dl_bpobj,
process_old_cb, &poa, tx)); process_old_cb, &poa, tx));
VERIFY0(zio_wait(poa.pio)); VERIFY0(zio_wait(poa.pio));
ASSERT3U(poa.used, ==, ds->ds_phys->ds_unique_bytes); ASSERT3U(poa.used, ==, dsl_dataset_phys(ds)->ds_unique_bytes);
/* change snapused */ /* change snapused */
dsl_dir_diduse_space(ds->ds_dir, DD_USED_SNAP, dsl_dir_diduse_space(ds->ds_dir, DD_USED_SNAP,
@ -192,12 +192,14 @@ process_old_deadlist(dsl_dataset_t *ds, dsl_dataset_t *ds_prev,
/* swap next's deadlist to our deadlist */ /* swap next's deadlist to our deadlist */
dsl_deadlist_close(&ds->ds_deadlist); dsl_deadlist_close(&ds->ds_deadlist);
dsl_deadlist_close(&ds_next->ds_deadlist); dsl_deadlist_close(&ds_next->ds_deadlist);
deadlist_obj = ds->ds_phys->ds_deadlist_obj; deadlist_obj = dsl_dataset_phys(ds)->ds_deadlist_obj;
ds->ds_phys->ds_deadlist_obj = ds_next->ds_phys->ds_deadlist_obj; dsl_dataset_phys(ds)->ds_deadlist_obj =
ds_next->ds_phys->ds_deadlist_obj = deadlist_obj; dsl_dataset_phys(ds_next)->ds_deadlist_obj;
dsl_deadlist_open(&ds->ds_deadlist, mos, ds->ds_phys->ds_deadlist_obj); dsl_dataset_phys(ds_next)->ds_deadlist_obj = deadlist_obj;
dsl_deadlist_open(&ds->ds_deadlist, mos,
dsl_dataset_phys(ds)->ds_deadlist_obj);
dsl_deadlist_open(&ds_next->ds_deadlist, mos, dsl_deadlist_open(&ds_next->ds_deadlist, mos,
ds_next->ds_phys->ds_deadlist_obj); dsl_dataset_phys(ds_next)->ds_deadlist_obj);
} }
static void static void
@ -212,13 +214,13 @@ dsl_dataset_remove_clones_key(dsl_dataset_t *ds, uint64_t mintxg, dmu_tx_t *tx)
* find the clones, but dsl_deadlist_remove_key() is a no-op so it * find the clones, but dsl_deadlist_remove_key() is a no-op so it
* doesn't matter. * doesn't matter.
*/ */
if (ds->ds_dir->dd_phys->dd_clones == 0) if (dsl_dir_phys(ds->ds_dir)->dd_clones == 0)
return; return;
zc = kmem_alloc(sizeof (zap_cursor_t), KM_SLEEP); zc = kmem_alloc(sizeof (zap_cursor_t), KM_SLEEP);
za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
for (zap_cursor_init(zc, mos, ds->ds_dir->dd_phys->dd_clones); for (zap_cursor_init(zc, mos, dsl_dir_phys(ds->ds_dir)->dd_clones);
zap_cursor_retrieve(zc, za) == 0; zap_cursor_retrieve(zc, za) == 0;
zap_cursor_advance(zc)) { zap_cursor_advance(zc)) {
dsl_dataset_t *clone; dsl_dataset_t *clone;
@ -253,19 +255,20 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
ASSERT(RRW_WRITE_HELD(&dp->dp_config_rwlock)); ASSERT(RRW_WRITE_HELD(&dp->dp_config_rwlock));
ASSERT3U(ds->ds_phys->ds_bp.blk_birth, <=, tx->tx_txg); ASSERT3U(dsl_dataset_phys(ds)->ds_bp.blk_birth, <=, tx->tx_txg);
ASSERT(refcount_is_zero(&ds->ds_longholds)); ASSERT(refcount_is_zero(&ds->ds_longholds));
if (defer && if (defer &&
(ds->ds_userrefs > 0 || ds->ds_phys->ds_num_children > 1)) { (ds->ds_userrefs > 0 ||
dsl_dataset_phys(ds)->ds_num_children > 1)) {
ASSERT(spa_version(dp->dp_spa) >= SPA_VERSION_USERREFS); ASSERT(spa_version(dp->dp_spa) >= SPA_VERSION_USERREFS);
dmu_buf_will_dirty(ds->ds_dbuf, tx); dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_phys->ds_flags |= DS_FLAG_DEFER_DESTROY; dsl_dataset_phys(ds)->ds_flags |= DS_FLAG_DEFER_DESTROY;
spa_history_log_internal_ds(ds, "defer_destroy", tx, ""); spa_history_log_internal_ds(ds, "defer_destroy", tx, "");
return; return;
} }
ASSERT3U(ds->ds_phys->ds_num_children, <=, 1); ASSERT3U(dsl_dataset_phys(ds)->ds_num_children, <=, 1);
/* We need to log before removing it from the namespace. */ /* We need to log before removing it from the namespace. */
spa_history_log_internal_ds(ds, "destroy", tx, ""); spa_history_log_internal_ds(ds, "destroy", tx, "");
@ -274,42 +277,44 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
obj = ds->ds_object; obj = ds->ds_object;
if (ds->ds_phys->ds_prev_snap_obj != 0) { if (dsl_dataset_phys(ds)->ds_prev_snap_obj != 0) {
ASSERT3P(ds->ds_prev, ==, NULL); ASSERT3P(ds->ds_prev, ==, NULL);
VERIFY0(dsl_dataset_hold_obj(dp, VERIFY0(dsl_dataset_hold_obj(dp,
ds->ds_phys->ds_prev_snap_obj, FTAG, &ds_prev)); dsl_dataset_phys(ds)->ds_prev_snap_obj, FTAG, &ds_prev));
after_branch_point = after_branch_point =
(ds_prev->ds_phys->ds_next_snap_obj != obj); (dsl_dataset_phys(ds_prev)->ds_next_snap_obj != obj);
dmu_buf_will_dirty(ds_prev->ds_dbuf, tx); dmu_buf_will_dirty(ds_prev->ds_dbuf, tx);
if (after_branch_point && if (after_branch_point &&
ds_prev->ds_phys->ds_next_clones_obj != 0) { dsl_dataset_phys(ds_prev)->ds_next_clones_obj != 0) {
dsl_dataset_remove_from_next_clones(ds_prev, obj, tx); dsl_dataset_remove_from_next_clones(ds_prev, obj, tx);
if (ds->ds_phys->ds_next_snap_obj != 0) { if (dsl_dataset_phys(ds)->ds_next_snap_obj != 0) {
VERIFY0(zap_add_int(mos, VERIFY0(zap_add_int(mos,
ds_prev->ds_phys->ds_next_clones_obj, dsl_dataset_phys(ds_prev)->
ds->ds_phys->ds_next_snap_obj, tx)); ds_next_clones_obj,
dsl_dataset_phys(ds)->ds_next_snap_obj,
tx));
} }
} }
if (!after_branch_point) { if (!after_branch_point) {
ds_prev->ds_phys->ds_next_snap_obj = dsl_dataset_phys(ds_prev)->ds_next_snap_obj =
ds->ds_phys->ds_next_snap_obj; dsl_dataset_phys(ds)->ds_next_snap_obj;
} }
} }
VERIFY0(dsl_dataset_hold_obj(dp, VERIFY0(dsl_dataset_hold_obj(dp,
ds->ds_phys->ds_next_snap_obj, FTAG, &ds_next)); dsl_dataset_phys(ds)->ds_next_snap_obj, FTAG, &ds_next));
ASSERT3U(ds_next->ds_phys->ds_prev_snap_obj, ==, obj); ASSERT3U(dsl_dataset_phys(ds_next)->ds_prev_snap_obj, ==, obj);
old_unique = ds_next->ds_phys->ds_unique_bytes; old_unique = dsl_dataset_phys(ds_next)->ds_unique_bytes;
dmu_buf_will_dirty(ds_next->ds_dbuf, tx); dmu_buf_will_dirty(ds_next->ds_dbuf, tx);
ds_next->ds_phys->ds_prev_snap_obj = dsl_dataset_phys(ds_next)->ds_prev_snap_obj =
ds->ds_phys->ds_prev_snap_obj; dsl_dataset_phys(ds)->ds_prev_snap_obj;
ds_next->ds_phys->ds_prev_snap_txg = dsl_dataset_phys(ds_next)->ds_prev_snap_txg =
ds->ds_phys->ds_prev_snap_txg; dsl_dataset_phys(ds)->ds_prev_snap_txg;
ASSERT3U(ds->ds_phys->ds_prev_snap_txg, ==, ASSERT3U(dsl_dataset_phys(ds)->ds_prev_snap_txg, ==,
ds_prev ? ds_prev->ds_phys->ds_creation_txg : 0); ds_prev ? dsl_dataset_phys(ds_prev)->ds_creation_txg : 0);
if (ds_next->ds_deadlist.dl_oldfmt) { if (ds_next->ds_deadlist.dl_oldfmt) {
process_old_deadlist(ds, ds_prev, ds_next, process_old_deadlist(ds, ds_prev, ds_next,
@ -318,38 +323,38 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
/* Adjust prev's unique space. */ /* Adjust prev's unique space. */
if (ds_prev && !after_branch_point) { if (ds_prev && !after_branch_point) {
dsl_deadlist_space_range(&ds_next->ds_deadlist, dsl_deadlist_space_range(&ds_next->ds_deadlist,
ds_prev->ds_phys->ds_prev_snap_txg, dsl_dataset_phys(ds_prev)->ds_prev_snap_txg,
ds->ds_phys->ds_prev_snap_txg, dsl_dataset_phys(ds)->ds_prev_snap_txg,
&used, &comp, &uncomp); &used, &comp, &uncomp);
ds_prev->ds_phys->ds_unique_bytes += used; dsl_dataset_phys(ds_prev)->ds_unique_bytes += used;
} }
/* Adjust snapused. */ /* Adjust snapused. */
dsl_deadlist_space_range(&ds_next->ds_deadlist, dsl_deadlist_space_range(&ds_next->ds_deadlist,
ds->ds_phys->ds_prev_snap_txg, UINT64_MAX, dsl_dataset_phys(ds)->ds_prev_snap_txg, UINT64_MAX,
&used, &comp, &uncomp); &used, &comp, &uncomp);
dsl_dir_diduse_space(ds->ds_dir, DD_USED_SNAP, dsl_dir_diduse_space(ds->ds_dir, DD_USED_SNAP,
-used, -comp, -uncomp, tx); -used, -comp, -uncomp, tx);
/* Move blocks to be freed to pool's free list. */ /* Move blocks to be freed to pool's free list. */
dsl_deadlist_move_bpobj(&ds_next->ds_deadlist, dsl_deadlist_move_bpobj(&ds_next->ds_deadlist,
&dp->dp_free_bpobj, ds->ds_phys->ds_prev_snap_txg, &dp->dp_free_bpobj, dsl_dataset_phys(ds)->ds_prev_snap_txg,
tx); tx);
dsl_dir_diduse_space(tx->tx_pool->dp_free_dir, dsl_dir_diduse_space(tx->tx_pool->dp_free_dir,
DD_USED_HEAD, used, comp, uncomp, tx); DD_USED_HEAD, used, comp, uncomp, tx);
/* Merge our deadlist into next's and free it. */ /* Merge our deadlist into next's and free it. */
dsl_deadlist_merge(&ds_next->ds_deadlist, dsl_deadlist_merge(&ds_next->ds_deadlist,
ds->ds_phys->ds_deadlist_obj, tx); dsl_dataset_phys(ds)->ds_deadlist_obj, tx);
} }
dsl_deadlist_close(&ds->ds_deadlist); dsl_deadlist_close(&ds->ds_deadlist);
dsl_deadlist_free(mos, ds->ds_phys->ds_deadlist_obj, tx); dsl_deadlist_free(mos, dsl_dataset_phys(ds)->ds_deadlist_obj, tx);
dmu_buf_will_dirty(ds->ds_dbuf, tx); dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_phys->ds_deadlist_obj = 0; dsl_dataset_phys(ds)->ds_deadlist_obj = 0;
/* Collapse range in clone heads */ /* Collapse range in clone heads */
dsl_dataset_remove_clones_key(ds, dsl_dataset_remove_clones_key(ds,
ds->ds_phys->ds_creation_txg, tx); dsl_dataset_phys(ds)->ds_creation_txg, tx);
if (dsl_dataset_is_snapshot(ds_next)) { if (dsl_dataset_is_snapshot(ds_next)) {
dsl_dataset_t *ds_nextnext; dsl_dataset_t *ds_nextnext;
@ -364,20 +369,21 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
* deadlist). * deadlist).
*/ */
VERIFY0(dsl_dataset_hold_obj(dp, VERIFY0(dsl_dataset_hold_obj(dp,
ds_next->ds_phys->ds_next_snap_obj, FTAG, &ds_nextnext)); dsl_dataset_phys(ds_next)->ds_next_snap_obj,
FTAG, &ds_nextnext));
dsl_deadlist_space_range(&ds_nextnext->ds_deadlist, dsl_deadlist_space_range(&ds_nextnext->ds_deadlist,
ds->ds_phys->ds_prev_snap_txg, dsl_dataset_phys(ds)->ds_prev_snap_txg,
ds->ds_phys->ds_creation_txg, dsl_dataset_phys(ds)->ds_creation_txg,
&used, &comp, &uncomp); &used, &comp, &uncomp);
ds_next->ds_phys->ds_unique_bytes += used; dsl_dataset_phys(ds_next)->ds_unique_bytes += used;
dsl_dataset_rele(ds_nextnext, FTAG); dsl_dataset_rele(ds_nextnext, FTAG);
ASSERT3P(ds_next->ds_prev, ==, NULL); ASSERT3P(ds_next->ds_prev, ==, NULL);
/* Collapse range in this head. */ /* Collapse range in this head. */
VERIFY0(dsl_dataset_hold_obj(dp, VERIFY0(dsl_dataset_hold_obj(dp,
ds->ds_dir->dd_phys->dd_head_dataset_obj, FTAG, &hds)); dsl_dir_phys(ds->ds_dir)->dd_head_dataset_obj, FTAG, &hds));
dsl_deadlist_remove_key(&hds->ds_deadlist, dsl_deadlist_remove_key(&hds->ds_deadlist,
ds->ds_phys->ds_creation_txg, tx); dsl_dataset_phys(ds)->ds_creation_txg, tx);
dsl_dataset_rele(hds, FTAG); dsl_dataset_rele(hds, FTAG);
} else { } else {
@ -386,7 +392,7 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
ds_next->ds_prev = NULL; ds_next->ds_prev = NULL;
if (ds_prev) { if (ds_prev) {
VERIFY0(dsl_dataset_hold_obj(dp, VERIFY0(dsl_dataset_hold_obj(dp,
ds->ds_phys->ds_prev_snap_obj, dsl_dataset_phys(ds)->ds_prev_snap_obj,
ds_next, &ds_next->ds_prev)); ds_next, &ds_next->ds_prev));
} }
@ -400,7 +406,7 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
if (old_unique < ds_next->ds_reserved) { if (old_unique < ds_next->ds_reserved) {
int64_t mrsdelta; int64_t mrsdelta;
uint64_t new_unique = uint64_t new_unique =
ds_next->ds_phys->ds_unique_bytes; dsl_dataset_phys(ds_next)->ds_unique_bytes;
ASSERT(old_unique <= new_unique); ASSERT(old_unique <= new_unique);
mrsdelta = MIN(new_unique - old_unique, mrsdelta = MIN(new_unique - old_unique,
@ -421,9 +427,9 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
} }
/* remove from snapshot namespace */ /* remove from snapshot namespace */
ASSERT(ds->ds_phys->ds_snapnames_zapobj == 0); ASSERT(dsl_dataset_phys(ds)->ds_snapnames_zapobj == 0);
VERIFY0(dsl_dataset_hold_obj(dp, VERIFY0(dsl_dataset_hold_obj(dp,
ds->ds_dir->dd_phys->dd_head_dataset_obj, FTAG, &ds_head)); dsl_dir_phys(ds->ds_dir)->dd_head_dataset_obj, FTAG, &ds_head));
VERIFY0(dsl_dataset_get_snapname(ds)); VERIFY0(dsl_dataset_get_snapname(ds));
#ifdef ZFS_DEBUG #ifdef ZFS_DEBUG
{ {
@ -443,17 +449,20 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
spa_prop_clear_bootfs(dp->dp_spa, ds->ds_object, tx); spa_prop_clear_bootfs(dp->dp_spa, ds->ds_object, tx);
if (ds->ds_phys->ds_next_clones_obj != 0) { if (dsl_dataset_phys(ds)->ds_next_clones_obj != 0) {
ASSERTV(uint64_t count); ASSERTV(uint64_t count);
ASSERT0(zap_count(mos, ASSERT0(zap_count(mos,
ds->ds_phys->ds_next_clones_obj, &count) && count == 0); dsl_dataset_phys(ds)->ds_next_clones_obj, &count) &&
count == 0);
VERIFY0(dmu_object_free(mos, VERIFY0(dmu_object_free(mos,
ds->ds_phys->ds_next_clones_obj, tx)); dsl_dataset_phys(ds)->ds_next_clones_obj, tx));
} }
if (ds->ds_phys->ds_props_obj != 0) if (dsl_dataset_phys(ds)->ds_props_obj != 0)
VERIFY0(zap_destroy(mos, ds->ds_phys->ds_props_obj, tx)); VERIFY0(zap_destroy(mos, dsl_dataset_phys(ds)->ds_props_obj,
if (ds->ds_phys->ds_userrefs_obj != 0) tx));
VERIFY0(zap_destroy(mos, ds->ds_phys->ds_userrefs_obj, tx)); if (dsl_dataset_phys(ds)->ds_userrefs_obj != 0)
VERIFY0(zap_destroy(mos, dsl_dataset_phys(ds)->ds_userrefs_obj,
tx));
dsl_dir_rele(ds->ds_dir, ds); dsl_dir_rele(ds->ds_dir, ds);
ds->ds_dir = NULL; ds->ds_dir = NULL;
dmu_object_free_zapified(mos, obj, tx); dmu_object_free_zapified(mos, obj, tx);
@ -556,7 +565,8 @@ kill_blkptr(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
dsl_free(ka->tx->tx_pool, ka->tx->tx_txg, bp); dsl_free(ka->tx->tx_pool, ka->tx->tx_txg, bp);
} else { } else {
ASSERT(zilog == NULL); ASSERT(zilog == NULL);
ASSERT3U(bp->blk_birth, >, ka->ds->ds_phys->ds_prev_snap_txg); ASSERT3U(bp->blk_birth, >,
dsl_dataset_phys(ka->ds)->ds_prev_snap_txg);
(void) dsl_dataset_block_kill(ka->ds, bp, tx, B_FALSE); (void) dsl_dataset_block_kill(ka->ds, bp, tx, B_FALSE);
} }
@ -578,9 +588,10 @@ old_synchronous_dataset_destroy(dsl_dataset_t *ds, dmu_tx_t *tx)
ka.ds = ds; ka.ds = ds;
ka.tx = tx; ka.tx = tx;
VERIFY0(traverse_dataset(ds, VERIFY0(traverse_dataset(ds,
ds->ds_phys->ds_prev_snap_txg, TRAVERSE_POST, dsl_dataset_phys(ds)->ds_prev_snap_txg, TRAVERSE_POST,
kill_blkptr, &ka)); kill_blkptr, &ka));
ASSERT(!DS_UNIQUE_IS_ACCURATE(ds) || ds->ds_phys->ds_unique_bytes == 0); ASSERT(!DS_UNIQUE_IS_ACCURATE(ds) ||
dsl_dataset_phys(ds)->ds_unique_bytes == 0);
} }
typedef struct dsl_destroy_head_arg { typedef struct dsl_destroy_head_arg {
@ -609,21 +620,21 @@ dsl_destroy_head_check_impl(dsl_dataset_t *ds, int expected_holds)
* from.) * from.)
*/ */
if (ds->ds_prev != NULL && if (ds->ds_prev != NULL &&
ds->ds_prev->ds_phys->ds_next_snap_obj == ds->ds_object) dsl_dataset_phys(ds->ds_prev)->ds_next_snap_obj == ds->ds_object)
return (SET_ERROR(EBUSY)); return (SET_ERROR(EBUSY));
/* /*
* Can't delete if there are children of this fs. * Can't delete if there are children of this fs.
*/ */
error = zap_count(mos, error = zap_count(mos,
ds->ds_dir->dd_phys->dd_child_dir_zapobj, &count); dsl_dir_phys(ds->ds_dir)->dd_child_dir_zapobj, &count);
if (error != 0) if (error != 0)
return (error); return (error);
if (count != 0) if (count != 0)
return (SET_ERROR(EEXIST)); return (SET_ERROR(EEXIST));
if (dsl_dir_is_clone(ds->ds_dir) && DS_IS_DEFER_DESTROY(ds->ds_prev) && if (dsl_dir_is_clone(ds->ds_dir) && DS_IS_DEFER_DESTROY(ds->ds_prev) &&
ds->ds_prev->ds_phys->ds_num_children == 2 && dsl_dataset_phys(ds->ds_prev)->ds_num_children == 2 &&
ds->ds_prev->ds_userrefs == 0) { ds->ds_prev->ds_userrefs == 0) {
/* We need to remove the origin snapshot as well. */ /* We need to remove the origin snapshot as well. */
if (!refcount_is_zero(&ds->ds_prev->ds_longholds)) if (!refcount_is_zero(&ds->ds_prev->ds_longholds))
@ -661,7 +672,7 @@ dsl_dir_destroy_sync(uint64_t ddobj, dmu_tx_t *tx)
VERIFY0(dsl_dir_hold_obj(dp, ddobj, NULL, FTAG, &dd)); VERIFY0(dsl_dir_hold_obj(dp, ddobj, NULL, FTAG, &dd));
ASSERT0(dd->dd_phys->dd_head_dataset_obj); ASSERT0(dsl_dir_phys(dd)->dd_head_dataset_obj);
/* /*
* Decrement the filesystem count for all parent filesystems. * Decrement the filesystem count for all parent filesystems.
@ -680,16 +691,17 @@ dsl_dir_destroy_sync(uint64_t ddobj, dmu_tx_t *tx)
*/ */
dsl_dir_set_reservation_sync_impl(dd, 0, tx); dsl_dir_set_reservation_sync_impl(dd, 0, tx);
ASSERT0(dd->dd_phys->dd_used_bytes); ASSERT0(dsl_dir_phys(dd)->dd_used_bytes);
ASSERT0(dd->dd_phys->dd_reserved); ASSERT0(dsl_dir_phys(dd)->dd_reserved);
for (t = 0; t < DD_USED_NUM; t++) for (t = 0; t < DD_USED_NUM; t++)
ASSERT0(dd->dd_phys->dd_used_breakdown[t]); ASSERT0(dsl_dir_phys(dd)->dd_used_breakdown[t]);
VERIFY0(zap_destroy(mos, dd->dd_phys->dd_child_dir_zapobj, tx)); VERIFY0(zap_destroy(mos, dsl_dir_phys(dd)->dd_child_dir_zapobj, tx));
VERIFY0(zap_destroy(mos, dd->dd_phys->dd_props_zapobj, tx)); VERIFY0(zap_destroy(mos, dsl_dir_phys(dd)->dd_props_zapobj, tx));
VERIFY0(dsl_deleg_destroy(mos, dd->dd_phys->dd_deleg_zapobj, tx)); VERIFY0(dsl_deleg_destroy(mos, dsl_dir_phys(dd)->dd_deleg_zapobj, tx));
VERIFY0(zap_remove(mos, VERIFY0(zap_remove(mos,
dd->dd_parent->dd_phys->dd_child_dir_zapobj, dd->dd_myname, tx)); dsl_dir_phys(dd->dd_parent)->dd_child_dir_zapobj,
dd->dd_myname, tx));
dsl_dir_rele(dd, FTAG); dsl_dir_rele(dd, FTAG);
dmu_object_free_zapified(mos, ddobj, tx); dmu_object_free_zapified(mos, ddobj, tx);
@ -704,10 +716,10 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
boolean_t rmorigin; boolean_t rmorigin;
objset_t *os; objset_t *os;
ASSERT3U(ds->ds_phys->ds_num_children, <=, 1); ASSERT3U(dsl_dataset_phys(ds)->ds_num_children, <=, 1);
ASSERT(ds->ds_prev == NULL || ASSERT(ds->ds_prev == NULL ||
ds->ds_prev->ds_phys->ds_next_snap_obj != ds->ds_object); dsl_dataset_phys(ds->ds_prev)->ds_next_snap_obj != ds->ds_object);
ASSERT3U(ds->ds_phys->ds_bp.blk_birth, <=, tx->tx_txg); ASSERT3U(dsl_dataset_phys(ds)->ds_bp.blk_birth, <=, tx->tx_txg);
ASSERT(RRW_WRITE_HELD(&dp->dp_config_rwlock)); ASSERT(RRW_WRITE_HELD(&dp->dp_config_rwlock));
/* We need to log before removing it from the namespace. */ /* We need to log before removing it from the namespace. */
@ -715,7 +727,7 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
rmorigin = (dsl_dir_is_clone(ds->ds_dir) && rmorigin = (dsl_dir_is_clone(ds->ds_dir) &&
DS_IS_DEFER_DESTROY(ds->ds_prev) && DS_IS_DEFER_DESTROY(ds->ds_prev) &&
ds->ds_prev->ds_phys->ds_num_children == 2 && dsl_dataset_phys(ds->ds_prev)->ds_num_children == 2 &&
ds->ds_prev->ds_userrefs == 0); ds->ds_prev->ds_userrefs == 0);
/* Remove our reservation. */ /* Remove our reservation. */
@ -730,20 +742,21 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
obj = ds->ds_object; obj = ds->ds_object;
if (ds->ds_phys->ds_prev_snap_obj != 0) { if (dsl_dataset_phys(ds)->ds_prev_snap_obj != 0) {
/* This is a clone */ /* This is a clone */
ASSERT(ds->ds_prev != NULL); ASSERT(ds->ds_prev != NULL);
ASSERT3U(ds->ds_prev->ds_phys->ds_next_snap_obj, !=, obj); ASSERT3U(dsl_dataset_phys(ds->ds_prev)->ds_next_snap_obj, !=,
ASSERT0(ds->ds_phys->ds_next_snap_obj); obj);
ASSERT0(dsl_dataset_phys(ds)->ds_next_snap_obj);
dmu_buf_will_dirty(ds->ds_prev->ds_dbuf, tx); dmu_buf_will_dirty(ds->ds_prev->ds_dbuf, tx);
if (ds->ds_prev->ds_phys->ds_next_clones_obj != 0) { if (dsl_dataset_phys(ds->ds_prev)->ds_next_clones_obj != 0) {
dsl_dataset_remove_from_next_clones(ds->ds_prev, dsl_dataset_remove_from_next_clones(ds->ds_prev,
obj, tx); obj, tx);
} }
ASSERT3U(ds->ds_prev->ds_phys->ds_num_children, >, 1); ASSERT3U(dsl_dataset_phys(ds->ds_prev)->ds_num_children, >, 1);
ds->ds_prev->ds_phys->ds_num_children--; dsl_dataset_phys(ds->ds_prev)->ds_num_children--;
} }
/* /*
@ -752,9 +765,9 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
* safe to ignore the deadlist contents.) * safe to ignore the deadlist contents.)
*/ */
dsl_deadlist_close(&ds->ds_deadlist); dsl_deadlist_close(&ds->ds_deadlist);
dsl_deadlist_free(mos, ds->ds_phys->ds_deadlist_obj, tx); dsl_deadlist_free(mos, dsl_dataset_phys(ds)->ds_deadlist_obj, tx);
dmu_buf_will_dirty(ds->ds_dbuf, tx); dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_phys->ds_deadlist_obj = 0; dsl_dataset_phys(ds)->ds_deadlist_obj = 0;
VERIFY0(dmu_objset_from_ds(ds, &os)); VERIFY0(dmu_objset_from_ds(ds, &os));
@ -783,15 +796,16 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
scn->scn_async_destroying = B_TRUE; scn->scn_async_destroying = B_TRUE;
} }
used = ds->ds_dir->dd_phys->dd_used_bytes; used = dsl_dir_phys(ds->ds_dir)->dd_used_bytes;
comp = ds->ds_dir->dd_phys->dd_compressed_bytes; comp = dsl_dir_phys(ds->ds_dir)->dd_compressed_bytes;
uncomp = ds->ds_dir->dd_phys->dd_uncompressed_bytes; uncomp = dsl_dir_phys(ds->ds_dir)->dd_uncompressed_bytes;
ASSERT(!DS_UNIQUE_IS_ACCURATE(ds) || ASSERT(!DS_UNIQUE_IS_ACCURATE(ds) ||
ds->ds_phys->ds_unique_bytes == used); dsl_dataset_phys(ds)->ds_unique_bytes == used);
bptree_add(mos, dp->dp_bptree_obj, bptree_add(mos, dp->dp_bptree_obj,
&ds->ds_phys->ds_bp, ds->ds_phys->ds_prev_snap_txg, &dsl_dataset_phys(ds)->ds_bp,
dsl_dataset_phys(ds)->ds_prev_snap_txg,
used, comp, uncomp, tx); used, comp, uncomp, tx);
dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD, dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD,
-used, -comp, -uncomp, tx); -used, -comp, -uncomp, tx);
@ -802,7 +816,7 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
if (ds->ds_prev != NULL) { if (ds->ds_prev != NULL) {
if (spa_version(dp->dp_spa) >= SPA_VERSION_DIR_CLONES) { if (spa_version(dp->dp_spa) >= SPA_VERSION_DIR_CLONES) {
VERIFY0(zap_remove_int(mos, VERIFY0(zap_remove_int(mos,
ds->ds_prev->ds_dir->dd_phys->dd_clones, dsl_dir_phys(ds->ds_prev->ds_dir)->dd_clones,
ds->ds_object, tx)); ds->ds_object, tx));
} }
prevobj = ds->ds_prev->ds_object; prevobj = ds->ds_prev->ds_object;
@ -821,22 +835,22 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
/* Erase the link in the dir */ /* Erase the link in the dir */
dmu_buf_will_dirty(ds->ds_dir->dd_dbuf, tx); dmu_buf_will_dirty(ds->ds_dir->dd_dbuf, tx);
ds->ds_dir->dd_phys->dd_head_dataset_obj = 0; dsl_dir_phys(ds->ds_dir)->dd_head_dataset_obj = 0;
ddobj = ds->ds_dir->dd_object; ddobj = ds->ds_dir->dd_object;
ASSERT(ds->ds_phys->ds_snapnames_zapobj != 0); ASSERT(dsl_dataset_phys(ds)->ds_snapnames_zapobj != 0);
VERIFY0(zap_destroy(mos, ds->ds_phys->ds_snapnames_zapobj, tx)); VERIFY0(zap_destroy(mos,
dsl_dataset_phys(ds)->ds_snapnames_zapobj, tx));
if (ds->ds_bookmarks != 0) { if (ds->ds_bookmarks != 0) {
VERIFY0(zap_destroy(mos, VERIFY0(zap_destroy(mos, ds->ds_bookmarks, tx));
ds->ds_bookmarks, tx));
spa_feature_decr(dp->dp_spa, SPA_FEATURE_BOOKMARKS, tx); spa_feature_decr(dp->dp_spa, SPA_FEATURE_BOOKMARKS, tx);
} }
spa_prop_clear_bootfs(dp->dp_spa, ds->ds_object, tx); spa_prop_clear_bootfs(dp->dp_spa, ds->ds_object, tx);
ASSERT0(ds->ds_phys->ds_next_clones_obj); ASSERT0(dsl_dataset_phys(ds)->ds_next_clones_obj);
ASSERT0(ds->ds_phys->ds_props_obj); ASSERT0(dsl_dataset_phys(ds)->ds_props_obj);
ASSERT0(ds->ds_phys->ds_userrefs_obj); ASSERT0(dsl_dataset_phys(ds)->ds_userrefs_obj);
dsl_dir_rele(ds->ds_dir, ds); dsl_dir_rele(ds->ds_dir, ds);
ds->ds_dir = NULL; ds->ds_dir = NULL;
dmu_object_free_zapified(mos, obj, tx); dmu_object_free_zapified(mos, obj, tx);
@ -874,7 +888,7 @@ dsl_destroy_head_begin_sync(void *arg, dmu_tx_t *tx)
/* Mark it as inconsistent on-disk, in case we crash */ /* Mark it as inconsistent on-disk, in case we crash */
dmu_buf_will_dirty(ds->ds_dbuf, tx); dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_phys->ds_flags |= DS_FLAG_INCONSISTENT; dsl_dataset_phys(ds)->ds_flags |= DS_FLAG_INCONSISTENT;
spa_history_log_internal_ds(ds, "destroy begin", tx, ""); spa_history_log_internal_ds(ds, "destroy begin", tx, "");
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
@ -917,7 +931,8 @@ dsl_destroy_head(const char *name)
if (error == 0) { if (error == 0) {
uint64_t obj; uint64_t obj;
uint64_t prev_snap_txg = uint64_t prev_snap_txg =
dmu_objset_ds(os)->ds_phys->ds_prev_snap_txg; dsl_dataset_phys(dmu_objset_ds(os))->
ds_prev_snap_txg;
for (obj = 0; error == 0; for (obj = 0; error == 0;
error = dmu_object_next(os, &obj, FALSE, error = dmu_object_next(os, &obj, FALSE,
prev_snap_txg)) prev_snap_txg))

View File

@ -122,6 +122,8 @@
* such as those created by zfs diff. * such as those created by zfs diff.
*/ */
extern inline dsl_dir_phys_t *dsl_dir_phys(dsl_dir_t *dd);
static uint64_t dsl_dir_space_towrite(dsl_dir_t *dd); static uint64_t dsl_dir_space_towrite(dsl_dir_t *dd);
/* ARGSUSED */ /* ARGSUSED */
@ -181,7 +183,6 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
dd->dd_object = ddobj; dd->dd_object = ddobj;
dd->dd_dbuf = dbuf; dd->dd_dbuf = dbuf;
dd->dd_pool = dp; dd->dd_pool = dp;
dd->dd_phys = dbuf->db_data;
mutex_init(&dd->dd_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&dd->dd_lock, NULL, MUTEX_DEFAULT, NULL);
list_create(&dd->dd_prop_cbs, sizeof (dsl_prop_cb_record_t), list_create(&dd->dd_prop_cbs, sizeof (dsl_prop_cb_record_t),
@ -189,9 +190,10 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
dsl_dir_snap_cmtime_update(dd); dsl_dir_snap_cmtime_update(dd);
if (dd->dd_phys->dd_parent_obj) { if (dsl_dir_phys(dd)->dd_parent_obj) {
err = dsl_dir_hold_obj(dp, dd->dd_phys->dd_parent_obj, err = dsl_dir_hold_obj(dp,
NULL, dd, &dd->dd_parent); dsl_dir_phys(dd)->dd_parent_obj, NULL, dd,
&dd->dd_parent);
if (err != 0) if (err != 0)
goto errout; goto errout;
if (tail) { if (tail) {
@ -199,14 +201,16 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
uint64_t foundobj; uint64_t foundobj;
err = zap_lookup(dp->dp_meta_objset, err = zap_lookup(dp->dp_meta_objset,
dd->dd_parent->dd_phys->dd_child_dir_zapobj, dsl_dir_phys(dd->dd_parent)->
tail, sizeof (foundobj), 1, &foundobj); dd_child_dir_zapobj, tail,
sizeof (foundobj), 1, &foundobj);
ASSERT(err || foundobj == ddobj); ASSERT(err || foundobj == ddobj);
#endif #endif
(void) strcpy(dd->dd_myname, tail); (void) strcpy(dd->dd_myname, tail);
} else { } else {
err = zap_value_search(dp->dp_meta_objset, err = zap_value_search(dp->dp_meta_objset,
dd->dd_parent->dd_phys->dd_child_dir_zapobj, dsl_dir_phys(dd->dd_parent)->
dd_child_dir_zapobj,
ddobj, 0, dd->dd_myname); ddobj, 0, dd->dd_myname);
} }
if (err != 0) if (err != 0)
@ -225,7 +229,8 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
* Just look at its phys directly instead. * Just look at its phys directly instead.
*/ */
err = dmu_bonus_hold(dp->dp_meta_objset, err = dmu_bonus_hold(dp->dp_meta_objset,
dd->dd_phys->dd_origin_obj, FTAG, &origin_bonus); dsl_dir_phys(dd)->dd_origin_obj, FTAG,
&origin_bonus);
if (err != 0) if (err != 0)
goto errout; goto errout;
origin_phys = origin_bonus->db_data; origin_phys = origin_bonus->db_data;
@ -234,8 +239,7 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
dmu_buf_rele(origin_bonus, FTAG); dmu_buf_rele(origin_bonus, FTAG);
} }
winner = dmu_buf_set_user_ie(dbuf, dd, &dd->dd_phys, winner = dmu_buf_set_user_ie(dbuf, dd, dsl_dir_evict);
dsl_dir_evict);
if (winner) { if (winner) {
if (dd->dd_parent) if (dd->dd_parent)
dsl_dir_rele(dd->dd_parent, dd); dsl_dir_rele(dd->dd_parent, dd);
@ -421,10 +425,10 @@ dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
if (next[0] == '@') if (next[0] == '@')
break; break;
dprintf("looking up %s in obj%lld\n", dprintf("looking up %s in obj%lld\n",
buf, dd->dd_phys->dd_child_dir_zapobj); buf, dsl_dir_phys(dd)->dd_child_dir_zapobj);
err = zap_lookup(dp->dp_meta_objset, err = zap_lookup(dp->dp_meta_objset,
dd->dd_phys->dd_child_dir_zapobj, dsl_dir_phys(dd)->dd_child_dir_zapobj,
buf, sizeof (ddobj), 1, &ddobj); buf, sizeof (ddobj), 1, &ddobj);
if (err != 0) { if (err != 0) {
if (err == ENOENT) if (err == ENOENT)
@ -507,7 +511,7 @@ dsl_dir_init_fs_ss_count(dsl_dir_t *dd, dmu_tx_t *tx)
za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
/* Iterate my child dirs */ /* Iterate my child dirs */
for (zap_cursor_init(zc, os, dd->dd_phys->dd_child_dir_zapobj); for (zap_cursor_init(zc, os, dsl_dir_phys(dd)->dd_child_dir_zapobj);
zap_cursor_retrieve(zc, za) == 0; zap_cursor_advance(zc)) { zap_cursor_retrieve(zc, za) == 0; zap_cursor_advance(zc)) {
dsl_dir_t *chld_dd; dsl_dir_t *chld_dd;
uint64_t count; uint64_t count;
@ -541,9 +545,9 @@ dsl_dir_init_fs_ss_count(dsl_dir_t *dd, dmu_tx_t *tx)
zap_cursor_fini(zc); zap_cursor_fini(zc);
/* Count my snapshots (we counted children's snapshots above) */ /* Count my snapshots (we counted children's snapshots above) */
VERIFY0(dsl_dataset_hold_obj(dd->dd_pool, VERIFY0(dsl_dataset_hold_obj(dd->dd_pool,
dd->dd_phys->dd_head_dataset_obj, FTAG, &ds)); dsl_dir_phys(dd)->dd_head_dataset_obj, FTAG, &ds));
for (zap_cursor_init(zc, os, ds->ds_phys->ds_snapnames_zapobj); for (zap_cursor_init(zc, os, dsl_dataset_phys(ds)->ds_snapnames_zapobj);
zap_cursor_retrieve(zc, za) == 0; zap_cursor_retrieve(zc, za) == 0;
zap_cursor_advance(zc)) { zap_cursor_advance(zc)) {
/* Don't count temporary snapshots */ /* Don't count temporary snapshots */
@ -691,7 +695,7 @@ dsl_enforce_ds_ss_limits(dsl_dir_t *dd, zfs_prop_t prop, cred_t *cr)
return (ENFORCE_NEVER); return (ENFORCE_NEVER);
#endif #endif
if ((obj = dd->dd_phys->dd_head_dataset_obj) == 0) if ((obj = dsl_dir_phys(dd)->dd_head_dataset_obj) == 0)
return (ENFORCE_ALWAYS); return (ENFORCE_ALWAYS);
ASSERT(dsl_pool_config_held(dd->dd_pool)); ASSERT(dsl_pool_config_held(dd->dd_pool));
@ -869,7 +873,7 @@ dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds, const char *name,
ddobj = dmu_object_alloc(mos, DMU_OT_DSL_DIR, 0, ddobj = dmu_object_alloc(mos, DMU_OT_DSL_DIR, 0,
DMU_OT_DSL_DIR, sizeof (dsl_dir_phys_t), tx); DMU_OT_DSL_DIR, sizeof (dsl_dir_phys_t), tx);
if (pds) { if (pds) {
VERIFY(0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, VERIFY(0 == zap_add(mos, dsl_dir_phys(pds)->dd_child_dir_zapobj,
name, sizeof (uint64_t), 1, &ddobj, tx)); name, sizeof (uint64_t), 1, &ddobj, tx));
} else { } else {
/* it's the root dir */ /* it's the root dir */
@ -901,9 +905,9 @@ dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds, const char *name,
boolean_t boolean_t
dsl_dir_is_clone(dsl_dir_t *dd) dsl_dir_is_clone(dsl_dir_t *dd)
{ {
return (dd->dd_phys->dd_origin_obj && return (dsl_dir_phys(dd)->dd_origin_obj &&
(dd->dd_pool->dp_origin_snap == NULL || (dd->dd_pool->dp_origin_snap == NULL ||
dd->dd_phys->dd_origin_obj != dsl_dir_phys(dd)->dd_origin_obj !=
dd->dd_pool->dp_origin_snap->ds_object)); dd->dd_pool->dp_origin_snap->ds_object));
} }
@ -912,26 +916,27 @@ dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv)
{ {
mutex_enter(&dd->dd_lock); mutex_enter(&dd->dd_lock);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED, dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED,
dd->dd_phys->dd_used_bytes); dsl_dir_phys(dd)->dd_used_bytes);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_QUOTA, dd->dd_phys->dd_quota); dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_QUOTA,
dsl_dir_phys(dd)->dd_quota);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_RESERVATION, dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_RESERVATION,
dd->dd_phys->dd_reserved); dsl_dir_phys(dd)->dd_reserved);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO, dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO,
dd->dd_phys->dd_compressed_bytes == 0 ? 100 : dsl_dir_phys(dd)->dd_compressed_bytes == 0 ? 100 :
(dd->dd_phys->dd_uncompressed_bytes * 100 / (dsl_dir_phys(dd)->dd_uncompressed_bytes * 100 /
dd->dd_phys->dd_compressed_bytes)); dsl_dir_phys(dd)->dd_compressed_bytes));
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_LOGICALUSED, dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_LOGICALUSED,
dd->dd_phys->dd_uncompressed_bytes); dsl_dir_phys(dd)->dd_uncompressed_bytes);
if (dd->dd_phys->dd_flags & DD_FLAG_USED_BREAKDOWN) { if (dsl_dir_phys(dd)->dd_flags & DD_FLAG_USED_BREAKDOWN) {
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDSNAP, dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDSNAP,
dd->dd_phys->dd_used_breakdown[DD_USED_SNAP]); dsl_dir_phys(dd)->dd_used_breakdown[DD_USED_SNAP]);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDDS, dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDDS,
dd->dd_phys->dd_used_breakdown[DD_USED_HEAD]); dsl_dir_phys(dd)->dd_used_breakdown[DD_USED_HEAD]);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDREFRESERV, dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDREFRESERV,
dd->dd_phys->dd_used_breakdown[DD_USED_REFRSRV]); dsl_dir_phys(dd)->dd_used_breakdown[DD_USED_REFRSRV]);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDCHILD, dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USEDCHILD,
dd->dd_phys->dd_used_breakdown[DD_USED_CHILD] + dsl_dir_phys(dd)->dd_used_breakdown[DD_USED_CHILD] +
dd->dd_phys->dd_used_breakdown[DD_USED_CHILD_RSRV]); dsl_dir_phys(dd)->dd_used_breakdown[DD_USED_CHILD_RSRV]);
} }
mutex_exit(&dd->dd_lock); mutex_exit(&dd->dd_lock);
@ -956,7 +961,7 @@ dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv)
char buf[MAXNAMELEN]; char buf[MAXNAMELEN];
VERIFY0(dsl_dataset_hold_obj(dd->dd_pool, VERIFY0(dsl_dataset_hold_obj(dd->dd_pool,
dd->dd_phys->dd_origin_obj, FTAG, &ds)); dsl_dir_phys(dd)->dd_origin_obj, FTAG, &ds));
dsl_dataset_name(ds, buf); dsl_dataset_name(ds, buf);
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
dsl_prop_nvlist_add_string(nv, ZFS_PROP_ORIGIN, buf); dsl_prop_nvlist_add_string(nv, ZFS_PROP_ORIGIN, buf);
@ -968,7 +973,7 @@ dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx)
{ {
dsl_pool_t *dp = dd->dd_pool; dsl_pool_t *dp = dd->dd_pool;
ASSERT(dd->dd_phys); ASSERT(dsl_dir_phys(dd));
if (txg_list_add(&dp->dp_dirty_dirs, dd, tx->tx_txg)) { if (txg_list_add(&dp->dp_dirty_dirs, dd, tx->tx_txg)) {
/* up the hold count until we can be written out */ /* up the hold count until we can be written out */
@ -979,8 +984,9 @@ dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx)
static int64_t static int64_t
parent_delta(dsl_dir_t *dd, uint64_t used, int64_t delta) parent_delta(dsl_dir_t *dd, uint64_t used, int64_t delta)
{ {
uint64_t old_accounted = MAX(used, dd->dd_phys->dd_reserved); uint64_t old_accounted = MAX(used, dsl_dir_phys(dd)->dd_reserved);
uint64_t new_accounted = MAX(used + delta, dd->dd_phys->dd_reserved); uint64_t new_accounted =
MAX(used + delta, dsl_dir_phys(dd)->dd_reserved);
return (new_accounted - old_accounted); return (new_accounted - old_accounted);
} }
@ -1039,9 +1045,9 @@ dsl_dir_space_available(dsl_dir_t *dd,
} }
mutex_enter(&dd->dd_lock); mutex_enter(&dd->dd_lock);
if (dd->dd_phys->dd_quota != 0) if (dsl_dir_phys(dd)->dd_quota != 0)
quota = dd->dd_phys->dd_quota; quota = dsl_dir_phys(dd)->dd_quota;
used = dd->dd_phys->dd_used_bytes; used = dsl_dir_phys(dd)->dd_used_bytes;
if (!ondiskonly) if (!ondiskonly)
used += dsl_dir_space_towrite(dd); used += dsl_dir_space_towrite(dd);
@ -1050,12 +1056,12 @@ dsl_dir_space_available(dsl_dir_t *dd,
quota = MIN(quota, poolsize); quota = MIN(quota, poolsize);
} }
if (dd->dd_phys->dd_reserved > used && parentspace != UINT64_MAX) { if (dsl_dir_phys(dd)->dd_reserved > used && parentspace != UINT64_MAX) {
/* /*
* We have some space reserved, in addition to what our * We have some space reserved, in addition to what our
* parent gave us. * parent gave us.
*/ */
parentspace += dd->dd_phys->dd_reserved - used; parentspace += dsl_dir_phys(dd)->dd_reserved - used;
} }
if (dd == ancestor) { if (dd == ancestor) {
@ -1114,7 +1120,7 @@ dsl_dir_tempreserve_impl(dsl_dir_t *dd, uint64_t asize, boolean_t netfree,
est_inflight = dsl_dir_space_towrite(dd); est_inflight = dsl_dir_space_towrite(dd);
for (i = 0; i < TXG_SIZE; i++) for (i = 0; i < TXG_SIZE; i++)
est_inflight += dd->dd_tempreserved[i]; est_inflight += dd->dd_tempreserved[i];
used_on_disk = dd->dd_phys->dd_used_bytes; used_on_disk = dsl_dir_phys(dd)->dd_used_bytes;
/* /*
* On the first iteration, fetch the dataset's used-on-disk and * On the first iteration, fetch the dataset's used-on-disk and
@ -1138,10 +1144,10 @@ dsl_dir_tempreserve_impl(dsl_dir_t *dd, uint64_t asize, boolean_t netfree,
* If this transaction will result in a net free of space, * If this transaction will result in a net free of space,
* we want to let it through. * we want to let it through.
*/ */
if (ignorequota || netfree || dd->dd_phys->dd_quota == 0) if (ignorequota || netfree || dsl_dir_phys(dd)->dd_quota == 0)
quota = UINT64_MAX; quota = UINT64_MAX;
else else
quota = dd->dd_phys->dd_quota; quota = dsl_dir_phys(dd)->dd_quota;
/* /*
* Adjust the quota against the actual pool size at the root * Adjust the quota against the actual pool size at the root
@ -1196,7 +1202,7 @@ dsl_dir_tempreserve_impl(dsl_dir_t *dd, uint64_t asize, boolean_t netfree,
/* see if it's OK with our parent */ /* see if it's OK with our parent */
if (dd->dd_parent && parent_rsrv) { if (dd->dd_parent && parent_rsrv) {
boolean_t ismos = (dd->dd_phys->dd_head_dataset_obj == 0); boolean_t ismos = (dsl_dir_phys(dd)->dd_head_dataset_obj == 0);
return (dsl_dir_tempreserve_impl(dd->dd_parent, return (dsl_dir_tempreserve_impl(dd->dd_parent,
parent_rsrv, netfree, ismos, TRUE, tr_list, tx, FALSE)); parent_rsrv, netfree, ismos, TRUE, tr_list, tx, FALSE));
@ -1321,7 +1327,7 @@ dsl_dir_willuse_space(dsl_dir_t *dd, int64_t space, dmu_tx_t *tx)
dd->dd_space_towrite[tx->tx_txg & TXG_MASK] += space; dd->dd_space_towrite[tx->tx_txg & TXG_MASK] += space;
est_used = dsl_dir_space_towrite(dd) + est_used = dsl_dir_space_towrite(dd) +
dd->dd_phys->dd_used_bytes; dsl_dir_phys(dd)->dd_used_bytes;
parent_space = parent_delta(dd, est_used, space); parent_space = parent_delta(dd, est_used, space);
mutex_exit(&dd->dd_lock); mutex_exit(&dd->dd_lock);
@ -1356,27 +1362,28 @@ dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type,
if (needlock) if (needlock)
mutex_enter(&dd->dd_lock); mutex_enter(&dd->dd_lock);
accounted_delta = parent_delta(dd, dd->dd_phys->dd_used_bytes, used); accounted_delta =
ASSERT(used >= 0 || dd->dd_phys->dd_used_bytes >= -used); parent_delta(dd, dsl_dir_phys(dd)->dd_used_bytes, used);
ASSERT(used >= 0 || dsl_dir_phys(dd)->dd_used_bytes >= -used);
ASSERT(compressed >= 0 || ASSERT(compressed >= 0 ||
dd->dd_phys->dd_compressed_bytes >= -compressed); dsl_dir_phys(dd)->dd_compressed_bytes >= -compressed);
ASSERT(uncompressed >= 0 || ASSERT(uncompressed >= 0 ||
dd->dd_phys->dd_uncompressed_bytes >= -uncompressed); dsl_dir_phys(dd)->dd_uncompressed_bytes >= -uncompressed);
dd->dd_phys->dd_used_bytes += used; dsl_dir_phys(dd)->dd_used_bytes += used;
dd->dd_phys->dd_uncompressed_bytes += uncompressed; dsl_dir_phys(dd)->dd_uncompressed_bytes += uncompressed;
dd->dd_phys->dd_compressed_bytes += compressed; dsl_dir_phys(dd)->dd_compressed_bytes += compressed;
if (dd->dd_phys->dd_flags & DD_FLAG_USED_BREAKDOWN) { if (dsl_dir_phys(dd)->dd_flags & DD_FLAG_USED_BREAKDOWN) {
ASSERT(used > 0 || ASSERT(used > 0 ||
dd->dd_phys->dd_used_breakdown[type] >= -used); dsl_dir_phys(dd)->dd_used_breakdown[type] >= -used);
dd->dd_phys->dd_used_breakdown[type] += used; dsl_dir_phys(dd)->dd_used_breakdown[type] += used;
#ifdef DEBUG #ifdef DEBUG
{ {
dd_used_t t; dd_used_t t;
uint64_t u = 0; uint64_t u = 0;
for (t = 0; t < DD_USED_NUM; t++) for (t = 0; t < DD_USED_NUM; t++)
u += dd->dd_phys->dd_used_breakdown[t]; u += dsl_dir_phys(dd)->dd_used_breakdown[t];
ASSERT3U(u, ==, dd->dd_phys->dd_used_bytes); ASSERT3U(u, ==, dsl_dir_phys(dd)->dd_used_bytes);
} }
#endif #endif
} }
@ -1400,17 +1407,18 @@ dsl_dir_transfer_space(dsl_dir_t *dd, int64_t delta,
ASSERT(oldtype < DD_USED_NUM); ASSERT(oldtype < DD_USED_NUM);
ASSERT(newtype < DD_USED_NUM); ASSERT(newtype < DD_USED_NUM);
if (delta == 0 || !(dd->dd_phys->dd_flags & DD_FLAG_USED_BREAKDOWN)) if (delta == 0 ||
!(dsl_dir_phys(dd)->dd_flags & DD_FLAG_USED_BREAKDOWN))
return; return;
dmu_buf_will_dirty(dd->dd_dbuf, tx); dmu_buf_will_dirty(dd->dd_dbuf, tx);
mutex_enter(&dd->dd_lock); mutex_enter(&dd->dd_lock);
ASSERT(delta > 0 ? ASSERT(delta > 0 ?
dd->dd_phys->dd_used_breakdown[oldtype] >= delta : dsl_dir_phys(dd)->dd_used_breakdown[oldtype] >= delta :
dd->dd_phys->dd_used_breakdown[newtype] >= -delta); dsl_dir_phys(dd)->dd_used_breakdown[newtype] >= -delta);
ASSERT(dd->dd_phys->dd_used_bytes >= ABS(delta)); ASSERT(dsl_dir_phys(dd)->dd_used_bytes >= ABS(delta));
dd->dd_phys->dd_used_breakdown[oldtype] -= delta; dsl_dir_phys(dd)->dd_used_breakdown[oldtype] -= delta;
dd->dd_phys->dd_used_breakdown[newtype] += delta; dsl_dir_phys(dd)->dd_used_breakdown[newtype] += delta;
mutex_exit(&dd->dd_lock); mutex_exit(&dd->dd_lock);
} }
@ -1454,8 +1462,8 @@ dsl_dir_set_quota_check(void *arg, dmu_tx_t *tx)
*/ */
towrite = dsl_dir_space_towrite(ds->ds_dir); towrite = dsl_dir_space_towrite(ds->ds_dir);
if ((dmu_tx_is_syncing(tx) || towrite == 0) && if ((dmu_tx_is_syncing(tx) || towrite == 0) &&
(newval < ds->ds_dir->dd_phys->dd_reserved || (newval < dsl_dir_phys(ds->ds_dir)->dd_reserved ||
newval < ds->ds_dir->dd_phys->dd_used_bytes + towrite)) { newval < dsl_dir_phys(ds->ds_dir)->dd_used_bytes + towrite)) {
error = SET_ERROR(ENOSPC); error = SET_ERROR(ENOSPC);
} }
mutex_exit(&ds->ds_dir->dd_lock); mutex_exit(&ds->ds_dir->dd_lock);
@ -1488,7 +1496,7 @@ dsl_dir_set_quota_sync(void *arg, dmu_tx_t *tx)
dmu_buf_will_dirty(ds->ds_dir->dd_dbuf, tx); dmu_buf_will_dirty(ds->ds_dir->dd_dbuf, tx);
mutex_enter(&ds->ds_dir->dd_lock); mutex_enter(&ds->ds_dir->dd_lock);
ds->ds_dir->dd_phys->dd_quota = newval; dsl_dir_phys(ds->ds_dir)->dd_quota = newval;
mutex_exit(&ds->ds_dir->dd_lock); mutex_exit(&ds->ds_dir->dd_lock);
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
} }
@ -1539,7 +1547,7 @@ dsl_dir_set_reservation_check(void *arg, dmu_tx_t *tx)
} }
mutex_enter(&dd->dd_lock); mutex_enter(&dd->dd_lock);
used = dd->dd_phys->dd_used_bytes; used = dsl_dir_phys(dd)->dd_used_bytes;
mutex_exit(&dd->dd_lock); mutex_exit(&dd->dd_lock);
if (dd->dd_parent) { if (dd->dd_parent) {
@ -1549,13 +1557,13 @@ dsl_dir_set_reservation_check(void *arg, dmu_tx_t *tx)
avail = dsl_pool_adjustedsize(dd->dd_pool, B_FALSE) - used; avail = dsl_pool_adjustedsize(dd->dd_pool, B_FALSE) - used;
} }
if (MAX(used, newval) > MAX(used, dd->dd_phys->dd_reserved)) { if (MAX(used, newval) > MAX(used, dsl_dir_phys(dd)->dd_reserved)) {
uint64_t delta = MAX(used, newval) - uint64_t delta = MAX(used, newval) -
MAX(used, dd->dd_phys->dd_reserved); MAX(used, dsl_dir_phys(dd)->dd_reserved);
if (delta > avail || if (delta > avail ||
(dd->dd_phys->dd_quota > 0 && (dsl_dir_phys(dd)->dd_quota > 0 &&
newval > dd->dd_phys->dd_quota)) newval > dsl_dir_phys(dd)->dd_quota))
error = SET_ERROR(ENOSPC); error = SET_ERROR(ENOSPC);
} }
@ -1572,9 +1580,9 @@ dsl_dir_set_reservation_sync_impl(dsl_dir_t *dd, uint64_t value, dmu_tx_t *tx)
dmu_buf_will_dirty(dd->dd_dbuf, tx); dmu_buf_will_dirty(dd->dd_dbuf, tx);
mutex_enter(&dd->dd_lock); mutex_enter(&dd->dd_lock);
used = dd->dd_phys->dd_used_bytes; used = dsl_dir_phys(dd)->dd_used_bytes;
delta = MAX(used, value) - MAX(used, dd->dd_phys->dd_reserved); delta = MAX(used, value) - MAX(used, dsl_dir_phys(dd)->dd_reserved);
dd->dd_phys->dd_reserved = value; dsl_dir_phys(dd)->dd_reserved = value;
if (dd->dd_parent != NULL) { if (dd->dd_parent != NULL) {
/* Roll up this additional usage into our ancestors */ /* Roll up this additional usage into our ancestors */
@ -1651,7 +1659,7 @@ would_change(dsl_dir_t *dd, int64_t delta, dsl_dir_t *ancestor)
return (delta); return (delta);
mutex_enter(&dd->dd_lock); mutex_enter(&dd->dd_lock);
delta = parent_delta(dd, dd->dd_phys->dd_used_bytes, delta); delta = parent_delta(dd, dsl_dir_phys(dd)->dd_used_bytes, delta);
mutex_exit(&dd->dd_lock); mutex_exit(&dd->dd_lock);
return (would_change(dd->dd_parent, delta, ancestor)); return (would_change(dd->dd_parent, delta, ancestor));
} }
@ -1742,7 +1750,8 @@ dsl_dir_rename_check(void *arg, dmu_tx_t *tx)
if (newparent != dd->dd_parent) { if (newparent != dd->dd_parent) {
/* is there enough space? */ /* is there enough space? */
uint64_t myspace = uint64_t myspace =
MAX(dd->dd_phys->dd_used_bytes, dd->dd_phys->dd_reserved); MAX(dsl_dir_phys(dd)->dd_used_bytes,
dsl_dir_phys(dd)->dd_reserved);
objset_t *os = dd->dd_pool->dp_meta_objset; objset_t *os = dd->dd_pool->dp_meta_objset;
uint64_t fs_cnt = 0; uint64_t fs_cnt = 0;
uint64_t ss_cnt = 0; uint64_t ss_cnt = 0;
@ -1841,17 +1850,18 @@ dsl_dir_rename_sync(void *arg, dmu_tx_t *tx)
DD_FIELD_SNAPSHOT_COUNT, tx); DD_FIELD_SNAPSHOT_COUNT, tx);
dsl_dir_diduse_space(dd->dd_parent, DD_USED_CHILD, dsl_dir_diduse_space(dd->dd_parent, DD_USED_CHILD,
-dd->dd_phys->dd_used_bytes, -dsl_dir_phys(dd)->dd_used_bytes,
-dd->dd_phys->dd_compressed_bytes, -dsl_dir_phys(dd)->dd_compressed_bytes,
-dd->dd_phys->dd_uncompressed_bytes, tx); -dsl_dir_phys(dd)->dd_uncompressed_bytes, tx);
dsl_dir_diduse_space(newparent, DD_USED_CHILD, dsl_dir_diduse_space(newparent, DD_USED_CHILD,
dd->dd_phys->dd_used_bytes, dsl_dir_phys(dd)->dd_used_bytes,
dd->dd_phys->dd_compressed_bytes, dsl_dir_phys(dd)->dd_compressed_bytes,
dd->dd_phys->dd_uncompressed_bytes, tx); dsl_dir_phys(dd)->dd_uncompressed_bytes, tx);
if (dd->dd_phys->dd_reserved > dd->dd_phys->dd_used_bytes) { if (dsl_dir_phys(dd)->dd_reserved >
uint64_t unused_rsrv = dd->dd_phys->dd_reserved - dsl_dir_phys(dd)->dd_used_bytes) {
dd->dd_phys->dd_used_bytes; uint64_t unused_rsrv = dsl_dir_phys(dd)->dd_reserved -
dsl_dir_phys(dd)->dd_used_bytes;
dsl_dir_diduse_space(dd->dd_parent, DD_USED_CHILD_RSRV, dsl_dir_diduse_space(dd->dd_parent, DD_USED_CHILD_RSRV,
-unused_rsrv, 0, 0, tx); -unused_rsrv, 0, 0, tx);
@ -1863,18 +1873,19 @@ dsl_dir_rename_sync(void *arg, dmu_tx_t *tx)
dmu_buf_will_dirty(dd->dd_dbuf, tx); dmu_buf_will_dirty(dd->dd_dbuf, tx);
/* remove from old parent zapobj */ /* remove from old parent zapobj */
error = zap_remove(mos, dd->dd_parent->dd_phys->dd_child_dir_zapobj, error = zap_remove(mos,
dsl_dir_phys(dd->dd_parent)->dd_child_dir_zapobj,
dd->dd_myname, tx); dd->dd_myname, tx);
ASSERT0(error); ASSERT0(error);
(void) strcpy(dd->dd_myname, mynewname); (void) strcpy(dd->dd_myname, mynewname);
dsl_dir_rele(dd->dd_parent, dd); dsl_dir_rele(dd->dd_parent, dd);
dd->dd_phys->dd_parent_obj = newparent->dd_object; dsl_dir_phys(dd)->dd_parent_obj = newparent->dd_object;
VERIFY0(dsl_dir_hold_obj(dp, VERIFY0(dsl_dir_hold_obj(dp,
newparent->dd_object, NULL, dd, &dd->dd_parent)); newparent->dd_object, NULL, dd, &dd->dd_parent));
/* add to new parent zapobj */ /* add to new parent zapobj */
VERIFY0(zap_add(mos, newparent->dd_phys->dd_child_dir_zapobj, VERIFY0(zap_add(mos, dsl_dir_phys(newparent)->dd_child_dir_zapobj,
dd->dd_myname, 8, 1, &dd->dd_object, tx)); dd->dd_myname, 8, 1, &dd->dd_object, tx));
#ifdef _KERNEL #ifdef _KERNEL

View File

@ -137,7 +137,7 @@ dsl_pool_open_special_dir(dsl_pool_t *dp, const char *name, dsl_dir_t **ddp)
int err; int err;
err = zap_lookup(dp->dp_meta_objset, err = zap_lookup(dp->dp_meta_objset,
dp->dp_root_dir->dd_phys->dd_child_dir_zapobj, dsl_dir_phys(dp->dp_root_dir)->dd_child_dir_zapobj,
name, sizeof (obj), 1, &obj); name, sizeof (obj), 1, &obj);
if (err) if (err)
return (err); return (err);
@ -219,11 +219,11 @@ dsl_pool_open(dsl_pool_t *dp)
err = dsl_pool_open_special_dir(dp, ORIGIN_DIR_NAME, &dd); err = dsl_pool_open_special_dir(dp, ORIGIN_DIR_NAME, &dd);
if (err) if (err)
goto out; goto out;
err = dsl_dataset_hold_obj(dp, dd->dd_phys->dd_head_dataset_obj, err = dsl_dataset_hold_obj(dp,
FTAG, &ds); dsl_dir_phys(dd)->dd_head_dataset_obj, FTAG, &ds);
if (err == 0) { if (err == 0) {
err = dsl_dataset_hold_obj(dp, err = dsl_dataset_hold_obj(dp,
ds->ds_phys->ds_prev_snap_obj, dp, dsl_dataset_phys(ds)->ds_prev_snap_obj, dp,
&dp->dp_origin_snap); &dp->dp_origin_snap);
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
} }
@ -683,15 +683,15 @@ upgrade_clones_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
if (err) if (err)
return (err); return (err);
while (ds->ds_phys->ds_prev_snap_obj != 0) { while (dsl_dataset_phys(ds)->ds_prev_snap_obj != 0) {
err = dsl_dataset_hold_obj(dp, ds->ds_phys->ds_prev_snap_obj, err = dsl_dataset_hold_obj(dp,
FTAG, &prev); dsl_dataset_phys(ds)->ds_prev_snap_obj, FTAG, &prev);
if (err) { if (err) {
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
return (err); return (err);
} }
if (prev->ds_phys->ds_next_snap_obj != ds->ds_object) if (dsl_dataset_phys(prev)->ds_next_snap_obj != ds->ds_object)
break; break;
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
ds = prev; ds = prev;
@ -705,7 +705,7 @@ upgrade_clones_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
* The $ORIGIN can't have any data, or the accounting * The $ORIGIN can't have any data, or the accounting
* will be wrong. * will be wrong.
*/ */
ASSERT0(prev->ds_phys->ds_bp.blk_birth); ASSERT0(dsl_dataset_phys(prev)->ds_bp.blk_birth);
/* The origin doesn't get attached to itself */ /* The origin doesn't get attached to itself */
if (ds->ds_object == prev->ds_object) { if (ds->ds_object == prev->ds_object) {
@ -714,33 +714,35 @@ upgrade_clones_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
} }
dmu_buf_will_dirty(ds->ds_dbuf, tx); dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_phys->ds_prev_snap_obj = prev->ds_object; dsl_dataset_phys(ds)->ds_prev_snap_obj = prev->ds_object;
ds->ds_phys->ds_prev_snap_txg = prev->ds_phys->ds_creation_txg; dsl_dataset_phys(ds)->ds_prev_snap_txg =
dsl_dataset_phys(prev)->ds_creation_txg;
dmu_buf_will_dirty(ds->ds_dir->dd_dbuf, tx); dmu_buf_will_dirty(ds->ds_dir->dd_dbuf, tx);
ds->ds_dir->dd_phys->dd_origin_obj = prev->ds_object; dsl_dir_phys(ds->ds_dir)->dd_origin_obj = prev->ds_object;
dmu_buf_will_dirty(prev->ds_dbuf, tx); dmu_buf_will_dirty(prev->ds_dbuf, tx);
prev->ds_phys->ds_num_children++; dsl_dataset_phys(prev)->ds_num_children++;
if (ds->ds_phys->ds_next_snap_obj == 0) { if (dsl_dataset_phys(ds)->ds_next_snap_obj == 0) {
ASSERT(ds->ds_prev == NULL); ASSERT(ds->ds_prev == NULL);
VERIFY0(dsl_dataset_hold_obj(dp, VERIFY0(dsl_dataset_hold_obj(dp,
ds->ds_phys->ds_prev_snap_obj, ds, &ds->ds_prev)); dsl_dataset_phys(ds)->ds_prev_snap_obj,
ds, &ds->ds_prev));
} }
} }
ASSERT3U(ds->ds_dir->dd_phys->dd_origin_obj, ==, prev->ds_object); ASSERT3U(dsl_dir_phys(ds->ds_dir)->dd_origin_obj, ==, prev->ds_object);
ASSERT3U(ds->ds_phys->ds_prev_snap_obj, ==, prev->ds_object); ASSERT3U(dsl_dataset_phys(ds)->ds_prev_snap_obj, ==, prev->ds_object);
if (prev->ds_phys->ds_next_clones_obj == 0) { if (dsl_dataset_phys(prev)->ds_next_clones_obj == 0) {
dmu_buf_will_dirty(prev->ds_dbuf, tx); dmu_buf_will_dirty(prev->ds_dbuf, tx);
prev->ds_phys->ds_next_clones_obj = dsl_dataset_phys(prev)->ds_next_clones_obj =
zap_create(dp->dp_meta_objset, zap_create(dp->dp_meta_objset,
DMU_OT_NEXT_CLONES, DMU_OT_NONE, 0, tx); DMU_OT_NEXT_CLONES, DMU_OT_NONE, 0, tx);
} }
VERIFY0(zap_add_int(dp->dp_meta_objset, VERIFY0(zap_add_int(dp->dp_meta_objset,
prev->ds_phys->ds_next_clones_obj, ds->ds_object, tx)); dsl_dataset_phys(prev)->ds_next_clones_obj, ds->ds_object, tx));
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
if (prev != dp->dp_origin_snap) if (prev != dp->dp_origin_snap)
@ -765,20 +767,22 @@ upgrade_dir_clones_cb(dsl_pool_t *dp, dsl_dataset_t *ds, void *arg)
dmu_tx_t *tx = arg; dmu_tx_t *tx = arg;
objset_t *mos = dp->dp_meta_objset; objset_t *mos = dp->dp_meta_objset;
if (ds->ds_dir->dd_phys->dd_origin_obj != 0) { if (dsl_dir_phys(ds->ds_dir)->dd_origin_obj != 0) {
dsl_dataset_t *origin; dsl_dataset_t *origin;
VERIFY0(dsl_dataset_hold_obj(dp, VERIFY0(dsl_dataset_hold_obj(dp,
ds->ds_dir->dd_phys->dd_origin_obj, FTAG, &origin)); dsl_dir_phys(ds->ds_dir)->dd_origin_obj, FTAG, &origin));
if (origin->ds_dir->dd_phys->dd_clones == 0) { if (dsl_dir_phys(origin->ds_dir)->dd_clones == 0) {
dmu_buf_will_dirty(origin->ds_dir->dd_dbuf, tx); dmu_buf_will_dirty(origin->ds_dir->dd_dbuf, tx);
origin->ds_dir->dd_phys->dd_clones = zap_create(mos, dsl_dir_phys(origin->ds_dir)->dd_clones =
DMU_OT_DSL_CLONES, DMU_OT_NONE, 0, tx); zap_create(mos, DMU_OT_DSL_CLONES, DMU_OT_NONE,
0, tx);
} }
VERIFY0(zap_add_int(dp->dp_meta_objset, VERIFY0(zap_add_int(dp->dp_meta_objset,
origin->ds_dir->dd_phys->dd_clones, ds->ds_object, tx)); dsl_dir_phys(origin->ds_dir)->dd_clones,
ds->ds_object, tx));
dsl_dataset_rele(origin, FTAG); dsl_dataset_rele(origin, FTAG);
} }
@ -826,7 +830,7 @@ dsl_pool_create_origin(dsl_pool_t *dp, dmu_tx_t *tx)
NULL, 0, kcred, tx); NULL, 0, kcred, tx);
VERIFY0(dsl_dataset_hold_obj(dp, dsobj, FTAG, &ds)); VERIFY0(dsl_dataset_hold_obj(dp, dsobj, FTAG, &ds));
dsl_dataset_snapshot_sync_impl(ds, ORIGIN_DIR_NAME, tx); dsl_dataset_snapshot_sync_impl(ds, ORIGIN_DIR_NAME, tx);
VERIFY0(dsl_dataset_hold_obj(dp, ds->ds_phys->ds_prev_snap_obj, VERIFY0(dsl_dataset_hold_obj(dp, dsl_dataset_phys(ds)->ds_prev_snap_obj,
dp, &dp->dp_origin_snap)); dp, &dp->dp_origin_snap));
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
} }

View File

@ -105,8 +105,8 @@ dsl_prop_get_dd(dsl_dir_t *dd, const char *propname,
} }
/* Check for a local value. */ /* Check for a local value. */
err = zap_lookup(mos, dd->dd_phys->dd_props_zapobj, propname, err = zap_lookup(mos, dsl_dir_phys(dd)->dd_props_zapobj,
intsz, numints, buf); propname, intsz, numints, buf);
if (err != ENOENT) { if (err != ENOENT) {
if (setpoint != NULL && err == 0) if (setpoint != NULL && err == 0)
dsl_dir_name(dd, setpoint); dsl_dir_name(dd, setpoint);
@ -117,14 +117,14 @@ dsl_prop_get_dd(dsl_dir_t *dd, const char *propname,
* Skip the check for a received value if there is an explicit * Skip the check for a received value if there is an explicit
* inheritance entry. * inheritance entry.
*/ */
err = zap_contains(mos, dd->dd_phys->dd_props_zapobj, err = zap_contains(mos, dsl_dir_phys(dd)->dd_props_zapobj,
inheritstr); inheritstr);
if (err != 0 && err != ENOENT) if (err != 0 && err != ENOENT)
break; break;
if (err == ENOENT) { if (err == ENOENT) {
/* Check for a received value. */ /* Check for a received value. */
err = zap_lookup(mos, dd->dd_phys->dd_props_zapobj, err = zap_lookup(mos, dsl_dir_phys(dd)->dd_props_zapobj,
recvdstr, intsz, numints, buf); recvdstr, intsz, numints, buf);
if (err != ENOENT) { if (err != ENOENT) {
if (setpoint != NULL && err == 0) { if (setpoint != NULL && err == 0) {
@ -169,7 +169,7 @@ dsl_prop_get_ds(dsl_dataset_t *ds, const char *propname,
ASSERT(dsl_pool_config_held(ds->ds_dir->dd_pool)); ASSERT(dsl_pool_config_held(ds->ds_dir->dd_pool));
inheritable = (prop == ZPROP_INVAL || zfs_prop_inheritable(prop)); inheritable = (prop == ZPROP_INVAL || zfs_prop_inheritable(prop));
snapshot = dsl_dataset_is_snapshot(ds); snapshot = dsl_dataset_is_snapshot(ds);
zapobj = ds->ds_phys->ds_props_obj; zapobj = dsl_dataset_phys(ds)->ds_props_obj;
if (zapobj != 0) { if (zapobj != 0) {
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset;
@ -327,7 +327,7 @@ dsl_prop_predict(dsl_dir_t *dd, const char *propname,
} }
mos = dd->dd_pool->dp_meta_objset; mos = dd->dd_pool->dp_meta_objset;
zapobj = dd->dd_phys->dd_props_zapobj; zapobj = dsl_dir_phys(dd)->dd_props_zapobj;
recvdstr = kmem_asprintf("%s%s", propname, ZPROP_RECVD_SUFFIX); recvdstr = kmem_asprintf("%s%s", propname, ZPROP_RECVD_SUFFIX);
version = spa_version(dd->dd_pool->dp_spa); version = spa_version(dd->dd_pool->dp_spa);
@ -486,7 +486,8 @@ dsl_prop_changed_notify(dsl_pool_t *dp, uint64_t ddobj,
* If the prop is set here, then this change is not * If the prop is set here, then this change is not
* being inherited here or below; stop the recursion. * being inherited here or below; stop the recursion.
*/ */
err = zap_contains(mos, dd->dd_phys->dd_props_zapobj, propname); err = zap_contains(mos, dsl_dir_phys(dd)->dd_props_zapobj,
propname);
if (err == 0) { if (err == 0) {
dsl_dir_rele(dd, FTAG); dsl_dir_rele(dd, FTAG);
return; return;
@ -497,7 +498,7 @@ dsl_prop_changed_notify(dsl_pool_t *dp, uint64_t ddobj,
mutex_enter(&dd->dd_lock); mutex_enter(&dd->dd_lock);
for (cbr = list_head(&dd->dd_prop_cbs); cbr; for (cbr = list_head(&dd->dd_prop_cbs); cbr;
cbr = list_next(&dd->dd_prop_cbs, cbr)) { cbr = list_next(&dd->dd_prop_cbs, cbr)) {
uint64_t propobj = cbr->cbr_ds->ds_phys->ds_props_obj; uint64_t propobj = dsl_dataset_phys(cbr->cbr_ds)->ds_props_obj;
if (strcmp(cbr->cbr_propname, propname) != 0) if (strcmp(cbr->cbr_propname, propname) != 0)
continue; continue;
@ -515,7 +516,7 @@ dsl_prop_changed_notify(dsl_pool_t *dp, uint64_t ddobj,
za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
for (zap_cursor_init(&zc, mos, for (zap_cursor_init(&zc, mos,
dd->dd_phys->dd_child_dir_zapobj); dsl_dir_phys(dd)->dd_child_dir_zapobj);
zap_cursor_retrieve(&zc, za) == 0; zap_cursor_retrieve(&zc, za) == 0;
zap_cursor_advance(&zc)) { zap_cursor_advance(&zc)) {
dsl_prop_changed_notify(dp, za->za_first_integer, dsl_prop_changed_notify(dp, za->za_first_integer,
@ -546,15 +547,15 @@ dsl_prop_set_sync_impl(dsl_dataset_t *ds, const char *propname,
if (dsl_dataset_is_snapshot(ds)) { if (dsl_dataset_is_snapshot(ds)) {
ASSERT(version >= SPA_VERSION_SNAP_PROPS); ASSERT(version >= SPA_VERSION_SNAP_PROPS);
if (ds->ds_phys->ds_props_obj == 0) { if (dsl_dataset_phys(ds)->ds_props_obj == 0) {
dmu_buf_will_dirty(ds->ds_dbuf, tx); dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_phys->ds_props_obj = dsl_dataset_phys(ds)->ds_props_obj =
zap_create(mos, zap_create(mos,
DMU_OT_DSL_PROPS, DMU_OT_NONE, 0, tx); DMU_OT_DSL_PROPS, DMU_OT_NONE, 0, tx);
} }
zapobj = ds->ds_phys->ds_props_obj; zapobj = dsl_dataset_phys(ds)->ds_props_obj;
} else { } else {
zapobj = ds->ds_dir->dd_phys->dd_props_zapobj; zapobj = dsl_dir_phys(ds->ds_dir)->dd_props_zapobj;
} }
if (version < SPA_VERSION_RECVD_PROPS) { if (version < SPA_VERSION_RECVD_PROPS) {
@ -987,11 +988,11 @@ dsl_prop_get_all_ds(dsl_dataset_t *ds, nvlist_t **nvp,
ASSERT(dsl_pool_config_held(dp)); ASSERT(dsl_pool_config_held(dp));
if (ds->ds_phys->ds_props_obj != 0) { if (dsl_dataset_phys(ds)->ds_props_obj != 0) {
ASSERT(flags & DSL_PROP_GET_SNAPSHOT); ASSERT(flags & DSL_PROP_GET_SNAPSHOT);
dsl_dataset_name(ds, setpoint); dsl_dataset_name(ds, setpoint);
err = dsl_prop_get_all_impl(mos, ds->ds_phys->ds_props_obj, err = dsl_prop_get_all_impl(mos,
setpoint, flags, *nvp); dsl_dataset_phys(ds)->ds_props_obj, setpoint, flags, *nvp);
if (err) if (err)
goto out; goto out;
} }
@ -1004,8 +1005,8 @@ dsl_prop_get_all_ds(dsl_dataset_t *ds, nvlist_t **nvp,
flags |= DSL_PROP_GET_INHERITING; flags |= DSL_PROP_GET_INHERITING;
} }
dsl_dir_name(dd, setpoint); dsl_dir_name(dd, setpoint);
err = dsl_prop_get_all_impl(mos, dd->dd_phys->dd_props_zapobj, err = dsl_prop_get_all_impl(mos,
setpoint, flags, *nvp); dsl_dir_phys(dd)->dd_props_zapobj, setpoint, flags, *nvp);
if (err) if (err)
break; break;
} }

View File

@ -416,7 +416,7 @@ dsl_scan_ds_maxtxg(dsl_dataset_t *ds)
{ {
uint64_t smt = ds->ds_dir->dd_pool->dp_scan->scn_phys.scn_max_txg; uint64_t smt = ds->ds_dir->dd_pool->dp_scan->scn_phys.scn_max_txg;
if (dsl_dataset_is_snapshot(ds)) if (dsl_dataset_is_snapshot(ds))
return (MIN(smt, ds->ds_phys->ds_creation_txg)); return (MIN(smt, dsl_dataset_phys(ds)->ds_creation_txg));
return (smt); return (smt);
} }
@ -849,11 +849,12 @@ dsl_scan_ds_destroyed(dsl_dataset_t *ds, dmu_tx_t *tx)
if (dsl_dataset_is_snapshot(ds)) { if (dsl_dataset_is_snapshot(ds)) {
/* Note, scn_cur_{min,max}_txg stays the same. */ /* Note, scn_cur_{min,max}_txg stays the same. */
scn->scn_phys.scn_bookmark.zb_objset = scn->scn_phys.scn_bookmark.zb_objset =
ds->ds_phys->ds_next_snap_obj; dsl_dataset_phys(ds)->ds_next_snap_obj;
zfs_dbgmsg("destroying ds %llu; currently traversing; " zfs_dbgmsg("destroying ds %llu; currently traversing; "
"reset zb_objset to %llu", "reset zb_objset to %llu",
(u_longlong_t)ds->ds_object, (u_longlong_t)ds->ds_object,
(u_longlong_t)ds->ds_phys->ds_next_snap_obj); (u_longlong_t)dsl_dataset_phys(ds)->
ds_next_snap_obj);
scn->scn_phys.scn_flags |= DSF_VISIT_DS_AGAIN; scn->scn_phys.scn_flags |= DSF_VISIT_DS_AGAIN;
} else { } else {
SET_BOOKMARK(&scn->scn_phys.scn_bookmark, SET_BOOKMARK(&scn->scn_phys.scn_bookmark,
@ -864,7 +865,7 @@ dsl_scan_ds_destroyed(dsl_dataset_t *ds, dmu_tx_t *tx)
} }
} else if (zap_lookup_int_key(dp->dp_meta_objset, } else if (zap_lookup_int_key(dp->dp_meta_objset,
scn->scn_phys.scn_queue_obj, ds->ds_object, &mintxg) == 0) { scn->scn_phys.scn_queue_obj, ds->ds_object, &mintxg) == 0) {
ASSERT3U(ds->ds_phys->ds_num_children, <=, 1); ASSERT3U(dsl_dataset_phys(ds)->ds_num_children, <=, 1);
VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset, VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset,
scn->scn_phys.scn_queue_obj, ds->ds_object, tx)); scn->scn_phys.scn_queue_obj, ds->ds_object, tx));
if (dsl_dataset_is_snapshot(ds)) { if (dsl_dataset_is_snapshot(ds)) {
@ -875,11 +876,13 @@ dsl_scan_ds_destroyed(dsl_dataset_t *ds, dmu_tx_t *tx)
*/ */
VERIFY(zap_add_int_key(dp->dp_meta_objset, VERIFY(zap_add_int_key(dp->dp_meta_objset,
scn->scn_phys.scn_queue_obj, scn->scn_phys.scn_queue_obj,
ds->ds_phys->ds_next_snap_obj, mintxg, tx) == 0); dsl_dataset_phys(ds)->ds_next_snap_obj,
mintxg, tx) == 0);
zfs_dbgmsg("destroying ds %llu; in queue; " zfs_dbgmsg("destroying ds %llu; in queue; "
"replacing with %llu", "replacing with %llu",
(u_longlong_t)ds->ds_object, (u_longlong_t)ds->ds_object,
(u_longlong_t)ds->ds_phys->ds_next_snap_obj); (u_longlong_t)dsl_dataset_phys(ds)->
ds_next_snap_obj);
} else { } else {
zfs_dbgmsg("destroying ds %llu; in queue; removing", zfs_dbgmsg("destroying ds %llu; in queue; removing",
(u_longlong_t)ds->ds_object); (u_longlong_t)ds->ds_object);
@ -906,26 +909,26 @@ dsl_scan_ds_snapshotted(dsl_dataset_t *ds, dmu_tx_t *tx)
if (scn->scn_phys.scn_state != DSS_SCANNING) if (scn->scn_phys.scn_state != DSS_SCANNING)
return; return;
ASSERT(ds->ds_phys->ds_prev_snap_obj != 0); ASSERT(dsl_dataset_phys(ds)->ds_prev_snap_obj != 0);
if (scn->scn_phys.scn_bookmark.zb_objset == ds->ds_object) { if (scn->scn_phys.scn_bookmark.zb_objset == ds->ds_object) {
scn->scn_phys.scn_bookmark.zb_objset = scn->scn_phys.scn_bookmark.zb_objset =
ds->ds_phys->ds_prev_snap_obj; dsl_dataset_phys(ds)->ds_prev_snap_obj;
zfs_dbgmsg("snapshotting ds %llu; currently traversing; " zfs_dbgmsg("snapshotting ds %llu; currently traversing; "
"reset zb_objset to %llu", "reset zb_objset to %llu",
(u_longlong_t)ds->ds_object, (u_longlong_t)ds->ds_object,
(u_longlong_t)ds->ds_phys->ds_prev_snap_obj); (u_longlong_t)dsl_dataset_phys(ds)->ds_prev_snap_obj);
} else if (zap_lookup_int_key(dp->dp_meta_objset, } else if (zap_lookup_int_key(dp->dp_meta_objset,
scn->scn_phys.scn_queue_obj, ds->ds_object, &mintxg) == 0) { scn->scn_phys.scn_queue_obj, ds->ds_object, &mintxg) == 0) {
VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset, VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset,
scn->scn_phys.scn_queue_obj, ds->ds_object, tx)); scn->scn_phys.scn_queue_obj, ds->ds_object, tx));
VERIFY(zap_add_int_key(dp->dp_meta_objset, VERIFY(zap_add_int_key(dp->dp_meta_objset,
scn->scn_phys.scn_queue_obj, scn->scn_phys.scn_queue_obj,
ds->ds_phys->ds_prev_snap_obj, mintxg, tx) == 0); dsl_dataset_phys(ds)->ds_prev_snap_obj, mintxg, tx) == 0);
zfs_dbgmsg("snapshotting ds %llu; in queue; " zfs_dbgmsg("snapshotting ds %llu; in queue; "
"replacing with %llu", "replacing with %llu",
(u_longlong_t)ds->ds_object, (u_longlong_t)ds->ds_object,
(u_longlong_t)ds->ds_phys->ds_prev_snap_obj); (u_longlong_t)dsl_dataset_phys(ds)->ds_prev_snap_obj);
} }
dsl_scan_sync_state(scn, tx); dsl_scan_sync_state(scn, tx);
} }
@ -958,8 +961,8 @@ dsl_scan_ds_clone_swapped(dsl_dataset_t *ds1, dsl_dataset_t *ds2, dmu_tx_t *tx)
ds1->ds_object, &mintxg) == 0) { ds1->ds_object, &mintxg) == 0) {
int err; int err;
ASSERT3U(mintxg, ==, ds1->ds_phys->ds_prev_snap_txg); ASSERT3U(mintxg, ==, dsl_dataset_phys(ds1)->ds_prev_snap_txg);
ASSERT3U(mintxg, ==, ds2->ds_phys->ds_prev_snap_txg); ASSERT3U(mintxg, ==, dsl_dataset_phys(ds2)->ds_prev_snap_txg);
VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset, VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset,
scn->scn_phys.scn_queue_obj, ds1->ds_object, tx)); scn->scn_phys.scn_queue_obj, ds1->ds_object, tx));
err = zap_add_int_key(dp->dp_meta_objset, err = zap_add_int_key(dp->dp_meta_objset,
@ -977,8 +980,8 @@ dsl_scan_ds_clone_swapped(dsl_dataset_t *ds1, dsl_dataset_t *ds2, dmu_tx_t *tx)
(u_longlong_t)ds2->ds_object); (u_longlong_t)ds2->ds_object);
} else if (zap_lookup_int_key(dp->dp_meta_objset, } else if (zap_lookup_int_key(dp->dp_meta_objset,
scn->scn_phys.scn_queue_obj, ds2->ds_object, &mintxg) == 0) { scn->scn_phys.scn_queue_obj, ds2->ds_object, &mintxg) == 0) {
ASSERT3U(mintxg, ==, ds1->ds_phys->ds_prev_snap_txg); ASSERT3U(mintxg, ==, dsl_dataset_phys(ds1)->ds_prev_snap_txg);
ASSERT3U(mintxg, ==, ds2->ds_phys->ds_prev_snap_txg); ASSERT3U(mintxg, ==, dsl_dataset_phys(ds2)->ds_prev_snap_txg);
VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset, VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset,
scn->scn_phys.scn_queue_obj, ds2->ds_object, tx)); scn->scn_phys.scn_queue_obj, ds2->ds_object, tx));
VERIFY(0 == zap_add_int_key(dp->dp_meta_objset, VERIFY(0 == zap_add_int_key(dp->dp_meta_objset,
@ -1006,17 +1009,17 @@ enqueue_clones_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
int err; int err;
dsl_scan_t *scn = dp->dp_scan; dsl_scan_t *scn = dp->dp_scan;
if (hds->ds_dir->dd_phys->dd_origin_obj != eca->originobj) if (dsl_dir_phys(hds->ds_dir)->dd_origin_obj != eca->originobj)
return (0); return (0);
err = dsl_dataset_hold_obj(dp, hds->ds_object, FTAG, &ds); err = dsl_dataset_hold_obj(dp, hds->ds_object, FTAG, &ds);
if (err) if (err)
return (err); return (err);
while (ds->ds_phys->ds_prev_snap_obj != eca->originobj) { while (dsl_dataset_phys(ds)->ds_prev_snap_obj != eca->originobj) {
dsl_dataset_t *prev; dsl_dataset_t *prev;
err = dsl_dataset_hold_obj(dp, err = dsl_dataset_hold_obj(dp,
ds->ds_phys->ds_prev_snap_obj, FTAG, &prev); dsl_dataset_phys(ds)->ds_prev_snap_obj, FTAG, &prev);
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
if (err) if (err)
@ -1025,7 +1028,7 @@ enqueue_clones_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
} }
VERIFY(zap_add_int_key(dp->dp_meta_objset, VERIFY(zap_add_int_key(dp->dp_meta_objset,
scn->scn_phys.scn_queue_obj, ds->ds_object, scn->scn_phys.scn_queue_obj, ds->ds_object,
ds->ds_phys->ds_prev_snap_txg, eca->tx) == 0); dsl_dataset_phys(ds)->ds_prev_snap_txg, eca->tx) == 0);
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
return (0); return (0);
} }
@ -1057,7 +1060,7 @@ dsl_scan_visitds(dsl_scan_t *scn, uint64_t dsobj, dmu_tx_t *tx)
* Iterate over the bps in this ds. * Iterate over the bps in this ds.
*/ */
dmu_buf_will_dirty(ds->ds_dbuf, tx); dmu_buf_will_dirty(ds->ds_dbuf, tx);
dsl_scan_visit_rootbp(scn, ds, &ds->ds_phys->ds_bp, tx); dsl_scan_visit_rootbp(scn, ds, &dsl_dataset_phys(ds)->ds_bp, tx);
dsname = kmem_alloc(ZFS_MAXNAMELEN, KM_SLEEP); dsname = kmem_alloc(ZFS_MAXNAMELEN, KM_SLEEP);
dsl_dataset_name(ds, dsname); dsl_dataset_name(ds, dsname);
@ -1091,14 +1094,15 @@ dsl_scan_visitds(dsl_scan_t *scn, uint64_t dsobj, dmu_tx_t *tx)
/* /*
* Add descendent datasets to work queue. * Add descendent datasets to work queue.
*/ */
if (ds->ds_phys->ds_next_snap_obj != 0) { if (dsl_dataset_phys(ds)->ds_next_snap_obj != 0) {
VERIFY(zap_add_int_key(dp->dp_meta_objset, VERIFY(zap_add_int_key(dp->dp_meta_objset,
scn->scn_phys.scn_queue_obj, ds->ds_phys->ds_next_snap_obj, scn->scn_phys.scn_queue_obj,
ds->ds_phys->ds_creation_txg, tx) == 0); dsl_dataset_phys(ds)->ds_next_snap_obj,
dsl_dataset_phys(ds)->ds_creation_txg, tx) == 0);
} }
if (ds->ds_phys->ds_num_children > 1) { if (dsl_dataset_phys(ds)->ds_num_children > 1) {
boolean_t usenext = B_FALSE; boolean_t usenext = B_FALSE;
if (ds->ds_phys->ds_next_clones_obj != 0) { if (dsl_dataset_phys(ds)->ds_next_clones_obj != 0) {
uint64_t count; uint64_t count;
/* /*
* A bug in a previous version of the code could * A bug in a previous version of the code could
@ -1108,17 +1112,17 @@ dsl_scan_visitds(dsl_scan_t *scn, uint64_t dsobj, dmu_tx_t *tx)
* next_clones_obj when its count is correct. * next_clones_obj when its count is correct.
*/ */
int err = zap_count(dp->dp_meta_objset, int err = zap_count(dp->dp_meta_objset,
ds->ds_phys->ds_next_clones_obj, &count); dsl_dataset_phys(ds)->ds_next_clones_obj, &count);
if (err == 0 && if (err == 0 &&
count == ds->ds_phys->ds_num_children - 1) count == dsl_dataset_phys(ds)->ds_num_children - 1)
usenext = B_TRUE; usenext = B_TRUE;
} }
if (usenext) { if (usenext) {
VERIFY0(zap_join_key(dp->dp_meta_objset, VERIFY0(zap_join_key(dp->dp_meta_objset,
ds->ds_phys->ds_next_clones_obj, dsl_dataset_phys(ds)->ds_next_clones_obj,
scn->scn_phys.scn_queue_obj, scn->scn_phys.scn_queue_obj,
ds->ds_phys->ds_creation_txg, tx)); dsl_dataset_phys(ds)->ds_creation_txg, tx));
} else { } else {
struct enqueue_clones_arg eca; struct enqueue_clones_arg eca;
eca.tx = tx; eca.tx = tx;
@ -1146,10 +1150,10 @@ enqueue_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
if (err) if (err)
return (err); return (err);
while (ds->ds_phys->ds_prev_snap_obj != 0) { while (dsl_dataset_phys(ds)->ds_prev_snap_obj != 0) {
dsl_dataset_t *prev; dsl_dataset_t *prev;
err = dsl_dataset_hold_obj(dp, ds->ds_phys->ds_prev_snap_obj, err = dsl_dataset_hold_obj(dp,
FTAG, &prev); dsl_dataset_phys(ds)->ds_prev_snap_obj, FTAG, &prev);
if (err) { if (err) {
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
return (err); return (err);
@ -1158,7 +1162,7 @@ enqueue_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
/* /*
* If this is a clone, we don't need to worry about it for now. * If this is a clone, we don't need to worry about it for now.
*/ */
if (prev->ds_phys->ds_next_snap_obj != ds->ds_object) { if (dsl_dataset_phys(prev)->ds_next_snap_obj != ds->ds_object) {
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
dsl_dataset_rele(prev, FTAG); dsl_dataset_rele(prev, FTAG);
return (0); return (0);
@ -1168,7 +1172,7 @@ enqueue_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
} }
VERIFY(zap_add_int_key(dp->dp_meta_objset, scn->scn_phys.scn_queue_obj, VERIFY(zap_add_int_key(dp->dp_meta_objset, scn->scn_phys.scn_queue_obj,
ds->ds_object, ds->ds_phys->ds_prev_snap_txg, tx) == 0); ds->ds_object, dsl_dataset_phys(ds)->ds_prev_snap_txg, tx) == 0);
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
return (0); return (0);
} }
@ -1348,7 +1352,7 @@ dsl_scan_visit(dsl_scan_t *scn, dmu_tx_t *tx)
} else { } else {
scn->scn_phys.scn_cur_min_txg = scn->scn_phys.scn_cur_min_txg =
MAX(scn->scn_phys.scn_min_txg, MAX(scn->scn_phys.scn_min_txg,
ds->ds_phys->ds_prev_snap_txg); dsl_dataset_phys(ds)->ds_prev_snap_txg);
} }
scn->scn_phys.scn_cur_max_txg = dsl_scan_ds_maxtxg(ds); scn->scn_phys.scn_cur_max_txg = dsl_scan_ds_maxtxg(ds);
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);
@ -1534,9 +1538,9 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
if (err != 0) if (err != 0)
return; return;
if (!scn->scn_async_destroying && zfs_free_leak_on_eio && if (!scn->scn_async_destroying && zfs_free_leak_on_eio &&
(dp->dp_free_dir->dd_phys->dd_used_bytes != 0 || (dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes != 0 ||
dp->dp_free_dir->dd_phys->dd_compressed_bytes != 0 || dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes != 0 ||
dp->dp_free_dir->dd_phys->dd_uncompressed_bytes != 0)) { dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes != 0)) {
/* /*
* We have finished background destroying, but there is still * We have finished background destroying, but there is still
* some space left in the dp_free_dir. Transfer this leaked * some space left in the dp_free_dir. Transfer this leaked
@ -1551,19 +1555,19 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
rrw_exit(&dp->dp_config_rwlock, FTAG); rrw_exit(&dp->dp_config_rwlock, FTAG);
} }
dsl_dir_diduse_space(dp->dp_leak_dir, DD_USED_HEAD, dsl_dir_diduse_space(dp->dp_leak_dir, DD_USED_HEAD,
dp->dp_free_dir->dd_phys->dd_used_bytes, dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes,
dp->dp_free_dir->dd_phys->dd_compressed_bytes, dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes,
dp->dp_free_dir->dd_phys->dd_uncompressed_bytes, tx); dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes, tx);
dsl_dir_diduse_space(dp->dp_free_dir, DD_USED_HEAD, dsl_dir_diduse_space(dp->dp_free_dir, DD_USED_HEAD,
-dp->dp_free_dir->dd_phys->dd_used_bytes, -dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes,
-dp->dp_free_dir->dd_phys->dd_compressed_bytes, -dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes,
-dp->dp_free_dir->dd_phys->dd_uncompressed_bytes, tx); -dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes, tx);
} }
if (!scn->scn_async_destroying) { if (!scn->scn_async_destroying) {
/* finished; verify that space accounting went to zero */ /* finished; verify that space accounting went to zero */
ASSERT0(dp->dp_free_dir->dd_phys->dd_used_bytes); ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes);
ASSERT0(dp->dp_free_dir->dd_phys->dd_compressed_bytes); ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes);
ASSERT0(dp->dp_free_dir->dd_phys->dd_uncompressed_bytes); ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes);
} }
if (scn->scn_phys.scn_state != DSS_SCANNING) if (scn->scn_phys.scn_state != DSS_SCANNING)

View File

@ -152,7 +152,7 @@ dsl_sync_task_sync(dsl_sync_task_t *dst, dmu_tx_t *tx)
*/ */
quota = dsl_pool_adjustedsize(dp, B_FALSE) - quota = dsl_pool_adjustedsize(dp, B_FALSE) -
metaslab_class_get_deferred(spa_normal_class(dp->dp_spa)); metaslab_class_get_deferred(spa_normal_class(dp->dp_spa));
used = dp->dp_root_dir->dd_phys->dd_used_bytes; used = dsl_dir_phys(dp->dp_root_dir)->dd_used_bytes;
/* MOS space is triple-dittoed, so we multiply by 3. */ /* MOS space is triple-dittoed, so we multiply by 3. */
if (dst->dst_space > 0 && used + dst->dst_space * 3 > quota) { if (dst->dst_space > 0 && used + dst->dst_space * 3 > quota) {
dst->dst_error = SET_ERROR(ENOSPC); dst->dst_error = SET_ERROR(ENOSPC);

View File

@ -64,10 +64,10 @@ dsl_dataset_user_hold_check_one(dsl_dataset_t *ds, const char *htag,
return (SET_ERROR(E2BIG)); return (SET_ERROR(E2BIG));
/* tags must be unique (if ds already exists) */ /* tags must be unique (if ds already exists) */
if (ds != NULL && ds->ds_phys->ds_userrefs_obj != 0) { if (ds != NULL && dsl_dataset_phys(ds)->ds_userrefs_obj != 0) {
uint64_t value; uint64_t value;
error = zap_lookup(mos, ds->ds_phys->ds_userrefs_obj, error = zap_lookup(mos, dsl_dataset_phys(ds)->ds_userrefs_obj,
htag, 8, 1, &value); htag, 8, 1, &value);
if (error == 0) if (error == 0)
error = SET_ERROR(EEXIST); error = SET_ERROR(EEXIST);
@ -141,16 +141,16 @@ dsl_dataset_user_hold_sync_one_impl(nvlist_t *tmpholds, dsl_dataset_t *ds,
ASSERT(RRW_WRITE_HELD(&dp->dp_config_rwlock)); ASSERT(RRW_WRITE_HELD(&dp->dp_config_rwlock));
if (ds->ds_phys->ds_userrefs_obj == 0) { if (dsl_dataset_phys(ds)->ds_userrefs_obj == 0) {
/* /*
* This is the first user hold for this dataset. Create * This is the first user hold for this dataset. Create
* the userrefs zap object. * the userrefs zap object.
*/ */
dmu_buf_will_dirty(ds->ds_dbuf, tx); dmu_buf_will_dirty(ds->ds_dbuf, tx);
zapobj = ds->ds_phys->ds_userrefs_obj = zapobj = dsl_dataset_phys(ds)->ds_userrefs_obj =
zap_create(mos, DMU_OT_USERREFS, DMU_OT_NONE, 0, tx); zap_create(mos, DMU_OT_USERREFS, DMU_OT_NONE, 0, tx);
} else { } else {
zapobj = ds->ds_phys->ds_userrefs_obj; zapobj = dsl_dataset_phys(ds)->ds_userrefs_obj;
} }
ds->ds_userrefs++; ds->ds_userrefs++;
@ -362,7 +362,7 @@ dsl_dataset_user_release_check_one(dsl_dataset_user_release_arg_t *ddura,
numholds = 0; numholds = 0;
mos = ds->ds_dir->dd_pool->dp_meta_objset; mos = ds->ds_dir->dd_pool->dp_meta_objset;
zapobj = ds->ds_phys->ds_userrefs_obj; zapobj = dsl_dataset_phys(ds)->ds_userrefs_obj;
VERIFY0(nvlist_alloc(&holds_found, NV_UNIQUE_NAME, KM_SLEEP)); VERIFY0(nvlist_alloc(&holds_found, NV_UNIQUE_NAME, KM_SLEEP));
for (pair = nvlist_next_nvpair(holds, NULL); pair != NULL; for (pair = nvlist_next_nvpair(holds, NULL); pair != NULL;
@ -400,7 +400,8 @@ dsl_dataset_user_release_check_one(dsl_dataset_user_release_arg_t *ddura,
numholds++; numholds++;
} }
if (DS_IS_DEFER_DESTROY(ds) && ds->ds_phys->ds_num_children == 1 && if (DS_IS_DEFER_DESTROY(ds) &&
dsl_dataset_phys(ds)->ds_num_children == 1 &&
ds->ds_userrefs == numholds) { ds->ds_userrefs == numholds) {
/* we need to destroy the snapshot as well */ /* we need to destroy the snapshot as well */
if (dsl_dataset_long_held(ds)) { if (dsl_dataset_long_held(ds)) {
@ -488,8 +489,8 @@ dsl_dataset_user_release_sync_one(dsl_dataset_t *ds, nvlist_t *holds,
error = dsl_pool_user_release(dp, ds->ds_object, holdname, tx); error = dsl_pool_user_release(dp, ds->ds_object, holdname, tx);
VERIFY(error == 0 || error == ENOENT); VERIFY(error == 0 || error == ENOENT);
VERIFY0(zap_remove(mos, ds->ds_phys->ds_userrefs_obj, holdname, VERIFY0(zap_remove(mos, dsl_dataset_phys(ds)->ds_userrefs_obj,
tx)); holdname, tx));
ds->ds_userrefs--; ds->ds_userrefs--;
spa_history_log_internal_ds(ds, "release", tx, spa_history_log_internal_ds(ds, "release", tx,
@ -519,7 +520,7 @@ dsl_dataset_user_release_sync(void *arg, dmu_tx_t *tx)
fnvpair_value_nvlist(pair), tx); fnvpair_value_nvlist(pair), tx);
if (nvlist_exists(ddura->ddura_todelete, name)) { if (nvlist_exists(ddura->ddura_todelete, name)) {
ASSERT(ds->ds_userrefs == 0 && ASSERT(ds->ds_userrefs == 0 &&
ds->ds_phys->ds_num_children == 1 && dsl_dataset_phys(ds)->ds_num_children == 1 &&
DS_IS_DEFER_DESTROY(ds)); DS_IS_DEFER_DESTROY(ds));
dsl_destroy_snapshot_sync_impl(ds, B_FALSE, tx); dsl_destroy_snapshot_sync_impl(ds, B_FALSE, tx);
} }
@ -651,13 +652,13 @@ dsl_dataset_get_holds(const char *dsname, nvlist_t *nvl)
return (err); return (err);
} }
if (ds->ds_phys->ds_userrefs_obj != 0) { if (dsl_dataset_phys(ds)->ds_userrefs_obj != 0) {
zap_attribute_t *za; zap_attribute_t *za;
zap_cursor_t zc; zap_cursor_t zc;
za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
for (zap_cursor_init(&zc, ds->ds_dir->dd_pool->dp_meta_objset, for (zap_cursor_init(&zc, ds->ds_dir->dd_pool->dp_meta_objset,
ds->ds_phys->ds_userrefs_obj); dsl_dataset_phys(ds)->ds_userrefs_obj);
zap_cursor_retrieve(&zc, za) == 0; zap_cursor_retrieve(&zc, za) == 0;
zap_cursor_advance(&zc)) { zap_cursor_advance(&zc)) {
fnvlist_add_uint64(nvl, za->za_name, fnvlist_add_uint64(nvl, za->za_name,

View File

@ -1363,7 +1363,7 @@ sa_handle_destroy(sa_handle_t *hdl)
{ {
mutex_enter(&hdl->sa_lock); mutex_enter(&hdl->sa_lock);
(void) dmu_buf_update_user((dmu_buf_t *)hdl->sa_bonus, hdl, (void) dmu_buf_update_user((dmu_buf_t *)hdl->sa_bonus, hdl,
NULL, NULL, NULL); NULL, NULL);
if (hdl->sa_bonus_tab) { if (hdl->sa_bonus_tab) {
sa_idx_tab_rele(hdl->sa_os, hdl->sa_bonus_tab); sa_idx_tab_rele(hdl->sa_os, hdl->sa_bonus_tab);
@ -1410,8 +1410,7 @@ sa_handle_get_from_db(objset_t *os, dmu_buf_t *db, void *userp,
error = sa_build_index(handle, SA_BONUS); error = sa_build_index(handle, SA_BONUS);
newhandle = (hdl_type == SA_HDL_SHARED) ? newhandle = (hdl_type == SA_HDL_SHARED) ?
dmu_buf_set_user_ie(db, handle, dmu_buf_set_user_ie(db, handle, sa_evict) : NULL;
NULL, sa_evict) : NULL;
if (newhandle != NULL) { if (newhandle != NULL) {
kmem_cache_free(sa_cache, handle); kmem_cache_free(sa_cache, handle);
@ -1951,7 +1950,7 @@ void
sa_update_user(sa_handle_t *newhdl, sa_handle_t *oldhdl) sa_update_user(sa_handle_t *newhdl, sa_handle_t *oldhdl)
{ {
(void) dmu_buf_update_user((dmu_buf_t *)newhdl->sa_bonus, (void) dmu_buf_update_user((dmu_buf_t *)newhdl->sa_bonus,
oldhdl, newhdl, NULL, sa_evict); oldhdl, newhdl, sa_evict);
oldhdl->sa_bonus = NULL; oldhdl->sa_bonus = NULL;
} }

View File

@ -237,7 +237,8 @@ spa_prop_get_config(spa_t *spa, nvlist_t **nvp)
*/ */
if (pool->dp_free_dir != NULL) { if (pool->dp_free_dir != NULL) {
spa_prop_add_list(*nvp, ZPOOL_PROP_FREEING, NULL, spa_prop_add_list(*nvp, ZPOOL_PROP_FREEING, NULL,
pool->dp_free_dir->dd_phys->dd_used_bytes, src); dsl_dir_phys(pool->dp_free_dir)->dd_used_bytes,
src);
} else { } else {
spa_prop_add_list(*nvp, ZPOOL_PROP_FREEING, spa_prop_add_list(*nvp, ZPOOL_PROP_FREEING,
NULL, 0, src); NULL, 0, src);
@ -245,7 +246,8 @@ spa_prop_get_config(spa_t *spa, nvlist_t **nvp)
if (pool->dp_leak_dir != NULL) { if (pool->dp_leak_dir != NULL) {
spa_prop_add_list(*nvp, ZPOOL_PROP_LEAKED, NULL, spa_prop_add_list(*nvp, ZPOOL_PROP_LEAKED, NULL,
pool->dp_leak_dir->dd_phys->dd_used_bytes, src); dsl_dir_phys(pool->dp_leak_dir)->dd_used_bytes,
src);
} else { } else {
spa_prop_add_list(*nvp, ZPOOL_PROP_LEAKED, spa_prop_add_list(*nvp, ZPOOL_PROP_LEAKED,
NULL, 0, src); NULL, 0, src);

View File

@ -520,7 +520,7 @@ spa_history_log_internal_dd(dsl_dir_t *dd, const char *operation,
dsl_dir_name(dd, namebuf); dsl_dir_name(dd, namebuf);
fnvlist_add_string(nvl, ZPOOL_HIST_DSNAME, namebuf); fnvlist_add_string(nvl, ZPOOL_HIST_DSNAME, namebuf);
fnvlist_add_uint64(nvl, ZPOOL_HIST_DSID, fnvlist_add_uint64(nvl, ZPOOL_HIST_DSID,
dd->dd_phys->dd_head_dataset_obj); dsl_dir_phys(dd)->dd_head_dataset_obj);
va_start(adx, fmt); va_start(adx, fmt);
log_internal(nvl, operation, dd->dd_pool->dp_spa, tx, fmt, adx); log_internal(nvl, operation, dd->dd_pool->dp_spa, tx, fmt, adx);

View File

@ -50,10 +50,11 @@
int fzap_default_block_shift = 14; /* 16k blocksize */ int fzap_default_block_shift = 14; /* 16k blocksize */
extern inline zap_phys_t *zap_f_phys(zap_t *zap);
static void zap_leaf_pageout(dmu_buf_t *db, void *vl); static void zap_leaf_pageout(dmu_buf_t *db, void *vl);
static uint64_t zap_allocate_blocks(zap_t *zap, int nblocks); static uint64_t zap_allocate_blocks(zap_t *zap, int nblocks);
void void
fzap_byteswap(void *vbuf, size_t size) fzap_byteswap(void *vbuf, size_t size)
{ {
@ -80,13 +81,12 @@ fzap_upgrade(zap_t *zap, dmu_tx_t *tx, zap_flags_t flags)
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); ASSERT(RW_WRITE_HELD(&zap->zap_rwlock));
zap->zap_ismicro = FALSE; zap->zap_ismicro = FALSE;
(void) dmu_buf_update_user(zap->zap_dbuf, zap, zap, (void) dmu_buf_update_user(zap->zap_dbuf, zap, zap, zap_evict);
&zap->zap_f.zap_phys, zap_evict);
mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, 0, 0); mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, 0, 0);
zap->zap_f.zap_block_shift = highbit64(zap->zap_dbuf->db_size) - 1; zap->zap_f.zap_block_shift = highbit64(zap->zap_dbuf->db_size) - 1;
zp = zap->zap_f.zap_phys; zp = zap_f_phys(zap);
/* /*
* explicitly zero it since it might be coming from an * explicitly zero it since it might be coming from an
* initialized microzap * initialized microzap
@ -117,7 +117,6 @@ fzap_upgrade(zap_t *zap, dmu_tx_t *tx, zap_flags_t flags)
l = kmem_zalloc(sizeof (zap_leaf_t), KM_SLEEP); l = kmem_zalloc(sizeof (zap_leaf_t), KM_SLEEP);
l->l_dbuf = db; l->l_dbuf = db;
l->l_phys = db->db_data;
zap_leaf_init(l, zp->zap_normflags != 0); zap_leaf_init(l, zp->zap_normflags != 0);
@ -325,10 +324,10 @@ zap_grow_ptrtbl(zap_t *zap, dmu_tx_t *tx)
* If we are within 2 bits of running out, stop growing, since * If we are within 2 bits of running out, stop growing, since
* this is already an aberrant condition. * this is already an aberrant condition.
*/ */
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_shift >= zap_hashbits(zap) - 2) if (zap_f_phys(zap)->zap_ptrtbl.zt_shift >= zap_hashbits(zap) - 2)
return (SET_ERROR(ENOSPC)); return (SET_ERROR(ENOSPC));
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks == 0) { if (zap_f_phys(zap)->zap_ptrtbl.zt_numblks == 0) {
/* /*
* We are outgrowing the "embedded" ptrtbl (the one * We are outgrowing the "embedded" ptrtbl (the one
* stored in the header block). Give it its own entire * stored in the header block). Give it its own entire
@ -338,9 +337,9 @@ zap_grow_ptrtbl(zap_t *zap, dmu_tx_t *tx)
dmu_buf_t *db_new; dmu_buf_t *db_new;
int err; int err;
ASSERT3U(zap->zap_f.zap_phys->zap_ptrtbl.zt_shift, ==, ASSERT3U(zap_f_phys(zap)->zap_ptrtbl.zt_shift, ==,
ZAP_EMBEDDED_PTRTBL_SHIFT(zap)); ZAP_EMBEDDED_PTRTBL_SHIFT(zap));
ASSERT0(zap->zap_f.zap_phys->zap_ptrtbl.zt_blk); ASSERT0(zap_f_phys(zap)->zap_ptrtbl.zt_blk);
newblk = zap_allocate_blocks(zap, 1); newblk = zap_allocate_blocks(zap, 1);
err = dmu_buf_hold(zap->zap_objset, zap->zap_object, err = dmu_buf_hold(zap->zap_objset, zap->zap_object,
@ -353,17 +352,17 @@ zap_grow_ptrtbl(zap_t *zap, dmu_tx_t *tx)
db_new->db_data, 1 << ZAP_EMBEDDED_PTRTBL_SHIFT(zap)); db_new->db_data, 1 << ZAP_EMBEDDED_PTRTBL_SHIFT(zap));
dmu_buf_rele(db_new, FTAG); dmu_buf_rele(db_new, FTAG);
zap->zap_f.zap_phys->zap_ptrtbl.zt_blk = newblk; zap_f_phys(zap)->zap_ptrtbl.zt_blk = newblk;
zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks = 1; zap_f_phys(zap)->zap_ptrtbl.zt_numblks = 1;
zap->zap_f.zap_phys->zap_ptrtbl.zt_shift++; zap_f_phys(zap)->zap_ptrtbl.zt_shift++;
ASSERT3U(1ULL << zap->zap_f.zap_phys->zap_ptrtbl.zt_shift, ==, ASSERT3U(1ULL << zap_f_phys(zap)->zap_ptrtbl.zt_shift, ==,
zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks << zap_f_phys(zap)->zap_ptrtbl.zt_numblks <<
(FZAP_BLOCK_SHIFT(zap)-3)); (FZAP_BLOCK_SHIFT(zap)-3));
return (0); return (0);
} else { } else {
return (zap_table_grow(zap, &zap->zap_f.zap_phys->zap_ptrtbl, return (zap_table_grow(zap, &zap_f_phys(zap)->zap_ptrtbl,
zap_ptrtbl_transfer, tx)); zap_ptrtbl_transfer, tx));
} }
} }
@ -373,8 +372,8 @@ zap_increment_num_entries(zap_t *zap, int delta, dmu_tx_t *tx)
{ {
dmu_buf_will_dirty(zap->zap_dbuf, tx); dmu_buf_will_dirty(zap->zap_dbuf, tx);
mutex_enter(&zap->zap_f.zap_num_entries_mtx); mutex_enter(&zap->zap_f.zap_num_entries_mtx);
ASSERT(delta > 0 || zap->zap_f.zap_phys->zap_num_entries >= -delta); ASSERT(delta > 0 || zap_f_phys(zap)->zap_num_entries >= -delta);
zap->zap_f.zap_phys->zap_num_entries += delta; zap_f_phys(zap)->zap_num_entries += delta;
mutex_exit(&zap->zap_f.zap_num_entries_mtx); mutex_exit(&zap->zap_f.zap_num_entries_mtx);
} }
@ -383,8 +382,8 @@ zap_allocate_blocks(zap_t *zap, int nblocks)
{ {
uint64_t newblk; uint64_t newblk;
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); ASSERT(RW_WRITE_HELD(&zap->zap_rwlock));
newblk = zap->zap_f.zap_phys->zap_freeblk; newblk = zap_f_phys(zap)->zap_freeblk;
zap->zap_f.zap_phys->zap_freeblk += nblocks; zap_f_phys(zap)->zap_freeblk += nblocks;
return (newblk); return (newblk);
} }
@ -400,18 +399,17 @@ zap_create_leaf(zap_t *zap, dmu_tx_t *tx)
rw_enter(&l->l_rwlock, RW_WRITER); rw_enter(&l->l_rwlock, RW_WRITER);
l->l_blkid = zap_allocate_blocks(zap, 1); l->l_blkid = zap_allocate_blocks(zap, 1);
l->l_dbuf = NULL; l->l_dbuf = NULL;
l->l_phys = NULL;
VERIFY(0 == dmu_buf_hold(zap->zap_objset, zap->zap_object, VERIFY(0 == dmu_buf_hold(zap->zap_objset, zap->zap_object,
l->l_blkid << FZAP_BLOCK_SHIFT(zap), NULL, &l->l_dbuf, l->l_blkid << FZAP_BLOCK_SHIFT(zap), NULL, &l->l_dbuf,
DMU_READ_NO_PREFETCH)); DMU_READ_NO_PREFETCH));
winner = dmu_buf_set_user(l->l_dbuf, l, &l->l_phys, zap_leaf_pageout); winner = dmu_buf_set_user(l->l_dbuf, l, zap_leaf_pageout);
ASSERT(winner == NULL); ASSERT(winner == NULL);
dmu_buf_will_dirty(l->l_dbuf, tx); dmu_buf_will_dirty(l->l_dbuf, tx);
zap_leaf_init(l, zap->zap_normflags != 0); zap_leaf_init(l, zap->zap_normflags != 0);
zap->zap_f.zap_phys->zap_num_leafs++; zap_f_phys(zap)->zap_num_leafs++;
return (l); return (l);
} }
@ -421,7 +419,7 @@ fzap_count(zap_t *zap, uint64_t *count)
{ {
ASSERT(!zap->zap_ismicro); ASSERT(!zap->zap_ismicro);
mutex_enter(&zap->zap_f.zap_num_entries_mtx); /* unnecessary */ mutex_enter(&zap->zap_f.zap_num_entries_mtx); /* unnecessary */
*count = zap->zap_f.zap_phys->zap_num_entries; *count = zap_f_phys(zap)->zap_num_entries;
mutex_exit(&zap->zap_f.zap_num_entries_mtx); mutex_exit(&zap->zap_f.zap_num_entries_mtx);
return (0); return (0);
} }
@ -460,9 +458,8 @@ zap_open_leaf(uint64_t blkid, dmu_buf_t *db)
l->l_blkid = blkid; l->l_blkid = blkid;
l->l_bs = highbit64(db->db_size) - 1; l->l_bs = highbit64(db->db_size) - 1;
l->l_dbuf = db; l->l_dbuf = db;
l->l_phys = NULL;
winner = dmu_buf_set_user(db, l, &l->l_phys, zap_leaf_pageout); winner = dmu_buf_set_user(db, l, zap_leaf_pageout);
rw_exit(&l->l_rwlock); rw_exit(&l->l_rwlock);
if (winner != NULL) { if (winner != NULL) {
@ -476,7 +473,7 @@ zap_open_leaf(uint64_t blkid, dmu_buf_t *db)
* chain. There should be no chained leafs (as we have removed * chain. There should be no chained leafs (as we have removed
* support for them). * support for them).
*/ */
ASSERT0(l->l_phys->l_hdr.lh_pad1); ASSERT0(zap_leaf_phys(l)->l_hdr.lh_pad1);
/* /*
* There should be more hash entries than there can be * There should be more hash entries than there can be
@ -486,11 +483,11 @@ zap_open_leaf(uint64_t blkid, dmu_buf_t *db)
/* The chunks should begin at the end of the hash table */ /* The chunks should begin at the end of the hash table */
ASSERT3P(&ZAP_LEAF_CHUNK(l, 0), ==, (zap_leaf_chunk_t *) ASSERT3P(&ZAP_LEAF_CHUNK(l, 0), ==, (zap_leaf_chunk_t *)
&l->l_phys->l_hash[ZAP_LEAF_HASH_NUMENTRIES(l)]); &zap_leaf_phys(l)->l_hash[ZAP_LEAF_HASH_NUMENTRIES(l)]);
/* The chunks should end at the end of the block */ /* The chunks should end at the end of the block */
ASSERT3U((uintptr_t)&ZAP_LEAF_CHUNK(l, ZAP_LEAF_NUMCHUNKS(l)) - ASSERT3U((uintptr_t)&ZAP_LEAF_CHUNK(l, ZAP_LEAF_NUMCHUNKS(l)) -
(uintptr_t)l->l_phys, ==, l->l_dbuf->db_size); (uintptr_t)zap_leaf_phys(l), ==, l->l_dbuf->db_size);
return (l); return (l);
} }
@ -523,16 +520,15 @@ zap_get_leaf_byblk(zap_t *zap, uint64_t blkid, dmu_tx_t *tx, krw_t lt,
rw_enter(&l->l_rwlock, lt); rw_enter(&l->l_rwlock, lt);
/* /*
* Must lock before dirtying, otherwise l->l_phys could change, * Must lock before dirtying, otherwise zap_leaf_phys(l) could change,
* causing ASSERT below to fail. * causing ASSERT below to fail.
*/ */
if (lt == RW_WRITER) if (lt == RW_WRITER)
dmu_buf_will_dirty(db, tx); dmu_buf_will_dirty(db, tx);
ASSERT3U(l->l_blkid, ==, blkid); ASSERT3U(l->l_blkid, ==, blkid);
ASSERT3P(l->l_dbuf, ==, db); ASSERT3P(l->l_dbuf, ==, db);
ASSERT3P(l->l_phys, ==, l->l_dbuf->db_data); ASSERT3U(zap_leaf_phys(l)->l_hdr.lh_block_type, ==, ZBT_LEAF);
ASSERT3U(l->l_phys->l_hdr.lh_block_type, ==, ZBT_LEAF); ASSERT3U(zap_leaf_phys(l)->l_hdr.lh_magic, ==, ZAP_LEAF_MAGIC);
ASSERT3U(l->l_phys->l_hdr.lh_magic, ==, ZAP_LEAF_MAGIC);
*lp = l; *lp = l;
return (0); return (0);
@ -543,13 +539,13 @@ zap_idx_to_blk(zap_t *zap, uint64_t idx, uint64_t *valp)
{ {
ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); ASSERT(RW_LOCK_HELD(&zap->zap_rwlock));
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks == 0) { if (zap_f_phys(zap)->zap_ptrtbl.zt_numblks == 0) {
ASSERT3U(idx, <, ASSERT3U(idx, <,
(1ULL << zap->zap_f.zap_phys->zap_ptrtbl.zt_shift)); (1ULL << zap_f_phys(zap)->zap_ptrtbl.zt_shift));
*valp = ZAP_EMBEDDED_PTRTBL_ENT(zap, idx); *valp = ZAP_EMBEDDED_PTRTBL_ENT(zap, idx);
return (0); return (0);
} else { } else {
return (zap_table_load(zap, &zap->zap_f.zap_phys->zap_ptrtbl, return (zap_table_load(zap, &zap_f_phys(zap)->zap_ptrtbl,
idx, valp)); idx, valp));
} }
} }
@ -560,11 +556,11 @@ zap_set_idx_to_blk(zap_t *zap, uint64_t idx, uint64_t blk, dmu_tx_t *tx)
ASSERT(tx != NULL); ASSERT(tx != NULL);
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); ASSERT(RW_WRITE_HELD(&zap->zap_rwlock));
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_blk == 0) { if (zap_f_phys(zap)->zap_ptrtbl.zt_blk == 0) {
ZAP_EMBEDDED_PTRTBL_ENT(zap, idx) = blk; ZAP_EMBEDDED_PTRTBL_ENT(zap, idx) = blk;
return (0); return (0);
} else { } else {
return (zap_table_store(zap, &zap->zap_f.zap_phys->zap_ptrtbl, return (zap_table_store(zap, &zap_f_phys(zap)->zap_ptrtbl,
idx, blk, tx)); idx, blk, tx));
} }
} }
@ -576,16 +572,17 @@ zap_deref_leaf(zap_t *zap, uint64_t h, dmu_tx_t *tx, krw_t lt, zap_leaf_t **lp)
int err; int err;
ASSERT(zap->zap_dbuf == NULL || ASSERT(zap->zap_dbuf == NULL ||
zap->zap_f.zap_phys == zap->zap_dbuf->db_data); zap_f_phys(zap) == zap->zap_dbuf->db_data);
ASSERT3U(zap->zap_f.zap_phys->zap_magic, ==, ZAP_MAGIC); ASSERT3U(zap_f_phys(zap)->zap_magic, ==, ZAP_MAGIC);
idx = ZAP_HASH_IDX(h, zap->zap_f.zap_phys->zap_ptrtbl.zt_shift); idx = ZAP_HASH_IDX(h, zap_f_phys(zap)->zap_ptrtbl.zt_shift);
err = zap_idx_to_blk(zap, idx, &blk); err = zap_idx_to_blk(zap, idx, &blk);
if (err != 0) if (err != 0)
return (err); return (err);
err = zap_get_leaf_byblk(zap, blk, tx, lt, lp); err = zap_get_leaf_byblk(zap, blk, tx, lt, lp);
ASSERT(err || ZAP_HASH_IDX(h, (*lp)->l_phys->l_hdr.lh_prefix_len) == ASSERT(err ||
(*lp)->l_phys->l_hdr.lh_prefix); ZAP_HASH_IDX(h, zap_leaf_phys(*lp)->l_hdr.lh_prefix_len) ==
zap_leaf_phys(*lp)->l_hdr.lh_prefix);
return (err); return (err);
} }
@ -597,16 +594,16 @@ zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx, zap_leaf_t **lp)
zap_leaf_t *nl; zap_leaf_t *nl;
int prefix_diff, i, err; int prefix_diff, i, err;
uint64_t sibling; uint64_t sibling;
int old_prefix_len = l->l_phys->l_hdr.lh_prefix_len; int old_prefix_len = zap_leaf_phys(l)->l_hdr.lh_prefix_len;
ASSERT3U(old_prefix_len, <=, zap->zap_f.zap_phys->zap_ptrtbl.zt_shift); ASSERT3U(old_prefix_len, <=, zap_f_phys(zap)->zap_ptrtbl.zt_shift);
ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); ASSERT(RW_LOCK_HELD(&zap->zap_rwlock));
ASSERT3U(ZAP_HASH_IDX(hash, old_prefix_len), ==, ASSERT3U(ZAP_HASH_IDX(hash, old_prefix_len), ==,
l->l_phys->l_hdr.lh_prefix); zap_leaf_phys(l)->l_hdr.lh_prefix);
if (zap_tryupgradedir(zap, tx) == 0 || if (zap_tryupgradedir(zap, tx) == 0 ||
old_prefix_len == zap->zap_f.zap_phys->zap_ptrtbl.zt_shift) { old_prefix_len == zap_f_phys(zap)->zap_ptrtbl.zt_shift) {
/* We failed to upgrade, or need to grow the pointer table */ /* We failed to upgrade, or need to grow the pointer table */
objset_t *os = zap->zap_objset; objset_t *os = zap->zap_objset;
uint64_t object = zap->zap_object; uint64_t object = zap->zap_object;
@ -621,7 +618,7 @@ zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx, zap_leaf_t **lp)
ASSERT(!zap->zap_ismicro); ASSERT(!zap->zap_ismicro);
while (old_prefix_len == while (old_prefix_len ==
zap->zap_f.zap_phys->zap_ptrtbl.zt_shift) { zap_f_phys(zap)->zap_ptrtbl.zt_shift) {
err = zap_grow_ptrtbl(zap, tx); err = zap_grow_ptrtbl(zap, tx);
if (err) if (err)
return (err); return (err);
@ -631,18 +628,18 @@ zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx, zap_leaf_t **lp)
if (err) if (err)
return (err); return (err);
if (l->l_phys->l_hdr.lh_prefix_len != old_prefix_len) { if (zap_leaf_phys(l)->l_hdr.lh_prefix_len != old_prefix_len) {
/* it split while our locks were down */ /* it split while our locks were down */
*lp = l; *lp = l;
return (0); return (0);
} }
} }
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); ASSERT(RW_WRITE_HELD(&zap->zap_rwlock));
ASSERT3U(old_prefix_len, <, zap->zap_f.zap_phys->zap_ptrtbl.zt_shift); ASSERT3U(old_prefix_len, <, zap_f_phys(zap)->zap_ptrtbl.zt_shift);
ASSERT3U(ZAP_HASH_IDX(hash, old_prefix_len), ==, ASSERT3U(ZAP_HASH_IDX(hash, old_prefix_len), ==,
l->l_phys->l_hdr.lh_prefix); zap_leaf_phys(l)->l_hdr.lh_prefix);
prefix_diff = zap->zap_f.zap_phys->zap_ptrtbl.zt_shift - prefix_diff = zap_f_phys(zap)->zap_ptrtbl.zt_shift -
(old_prefix_len + 1); (old_prefix_len + 1);
sibling = (ZAP_HASH_IDX(hash, old_prefix_len + 1) | 1) << prefix_diff; sibling = (ZAP_HASH_IDX(hash, old_prefix_len + 1) | 1) << prefix_diff;
@ -664,7 +661,7 @@ zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx, zap_leaf_t **lp)
ASSERT0(err); /* we checked for i/o errors above */ ASSERT0(err); /* we checked for i/o errors above */
} }
if (hash & (1ULL << (64 - l->l_phys->l_hdr.lh_prefix_len))) { if (hash & (1ULL << (64 - zap_leaf_phys(l)->l_hdr.lh_prefix_len))) {
/* we want the sibling */ /* we want the sibling */
zap_put_leaf(l); zap_put_leaf(l);
*lp = nl; *lp = nl;
@ -680,13 +677,13 @@ static void
zap_put_leaf_maybe_grow_ptrtbl(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx) zap_put_leaf_maybe_grow_ptrtbl(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx)
{ {
zap_t *zap = zn->zn_zap; zap_t *zap = zn->zn_zap;
int shift = zap->zap_f.zap_phys->zap_ptrtbl.zt_shift; int shift = zap_f_phys(zap)->zap_ptrtbl.zt_shift;
int leaffull = (l->l_phys->l_hdr.lh_prefix_len == shift && int leaffull = (zap_leaf_phys(l)->l_hdr.lh_prefix_len == shift &&
l->l_phys->l_hdr.lh_nfree < ZAP_LEAF_LOW_WATER); zap_leaf_phys(l)->l_hdr.lh_nfree < ZAP_LEAF_LOW_WATER);
zap_put_leaf(l); zap_put_leaf(l);
if (leaffull || zap->zap_f.zap_phys->zap_ptrtbl.zt_nextblk) { if (leaffull || zap_f_phys(zap)->zap_ptrtbl.zt_nextblk) {
int err; int err;
/* /*
@ -706,7 +703,7 @@ zap_put_leaf_maybe_grow_ptrtbl(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx)
} }
/* could have finished growing while our locks were down */ /* could have finished growing while our locks were down */
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_shift == shift) if (zap_f_phys(zap)->zap_ptrtbl.zt_shift == shift)
(void) zap_grow_ptrtbl(zap, tx); (void) zap_grow_ptrtbl(zap, tx);
} }
} }
@ -937,7 +934,7 @@ fzap_prefetch(zap_name_t *zn)
int bs; int bs;
idx = ZAP_HASH_IDX(zn->zn_hash, idx = ZAP_HASH_IDX(zn->zn_hash,
zap->zap_f.zap_phys->zap_ptrtbl.zt_shift); zap_f_phys(zap)->zap_ptrtbl.zt_shift);
if (zap_idx_to_blk(zap, idx, &blk) != 0) if (zap_idx_to_blk(zap, idx, &blk) != 0)
return; return;
bs = FZAP_BLOCK_SHIFT(zap); bs = FZAP_BLOCK_SHIFT(zap);
@ -1169,8 +1166,8 @@ fzap_cursor_retrieve(zap_t *zap, zap_cursor_t *zc, zap_attribute_t *za)
if (zc->zc_leaf && if (zc->zc_leaf &&
(ZAP_HASH_IDX(zc->zc_hash, (ZAP_HASH_IDX(zc->zc_hash,
zc->zc_leaf->l_phys->l_hdr.lh_prefix_len) != zap_leaf_phys(zc->zc_leaf)->l_hdr.lh_prefix_len) !=
zc->zc_leaf->l_phys->l_hdr.lh_prefix)) { zap_leaf_phys(zc->zc_leaf)->l_hdr.lh_prefix)) {
rw_enter(&zc->zc_leaf->l_rwlock, RW_READER); rw_enter(&zc->zc_leaf->l_rwlock, RW_READER);
zap_put_leaf(zc->zc_leaf); zap_put_leaf(zc->zc_leaf);
zc->zc_leaf = NULL; zc->zc_leaf = NULL;
@ -1191,10 +1188,11 @@ again:
if (err == ENOENT) { if (err == ENOENT) {
uint64_t nocare = uint64_t nocare =
(1ULL << (64 - l->l_phys->l_hdr.lh_prefix_len)) - 1; (1ULL << (64 - zap_leaf_phys(l)->l_hdr.lh_prefix_len)) - 1;
zc->zc_hash = (zc->zc_hash & ~nocare) + nocare + 1; zc->zc_hash = (zc->zc_hash & ~nocare) + nocare + 1;
zc->zc_cd = 0; zc->zc_cd = 0;
if (l->l_phys->l_hdr.lh_prefix_len == 0 || zc->zc_hash == 0) { if (zap_leaf_phys(l)->l_hdr.lh_prefix_len == 0 ||
zc->zc_hash == 0) {
zc->zc_hash = -1ULL; zc->zc_hash = -1ULL;
} else { } else {
zap_put_leaf(zc->zc_leaf); zap_put_leaf(zc->zc_leaf);
@ -1286,25 +1284,25 @@ fzap_get_stats(zap_t *zap, zap_stats_t *zs)
/* /*
* Set zap_phys_t fields * Set zap_phys_t fields
*/ */
zs->zs_num_leafs = zap->zap_f.zap_phys->zap_num_leafs; zs->zs_num_leafs = zap_f_phys(zap)->zap_num_leafs;
zs->zs_num_entries = zap->zap_f.zap_phys->zap_num_entries; zs->zs_num_entries = zap_f_phys(zap)->zap_num_entries;
zs->zs_num_blocks = zap->zap_f.zap_phys->zap_freeblk; zs->zs_num_blocks = zap_f_phys(zap)->zap_freeblk;
zs->zs_block_type = zap->zap_f.zap_phys->zap_block_type; zs->zs_block_type = zap_f_phys(zap)->zap_block_type;
zs->zs_magic = zap->zap_f.zap_phys->zap_magic; zs->zs_magic = zap_f_phys(zap)->zap_magic;
zs->zs_salt = zap->zap_f.zap_phys->zap_salt; zs->zs_salt = zap_f_phys(zap)->zap_salt;
/* /*
* Set zap_ptrtbl fields * Set zap_ptrtbl fields
*/ */
zs->zs_ptrtbl_len = 1ULL << zap->zap_f.zap_phys->zap_ptrtbl.zt_shift; zs->zs_ptrtbl_len = 1ULL << zap_f_phys(zap)->zap_ptrtbl.zt_shift;
zs->zs_ptrtbl_nextblk = zap->zap_f.zap_phys->zap_ptrtbl.zt_nextblk; zs->zs_ptrtbl_nextblk = zap_f_phys(zap)->zap_ptrtbl.zt_nextblk;
zs->zs_ptrtbl_blks_copied = zs->zs_ptrtbl_blks_copied =
zap->zap_f.zap_phys->zap_ptrtbl.zt_blks_copied; zap_f_phys(zap)->zap_ptrtbl.zt_blks_copied;
zs->zs_ptrtbl_zt_blk = zap->zap_f.zap_phys->zap_ptrtbl.zt_blk; zs->zs_ptrtbl_zt_blk = zap_f_phys(zap)->zap_ptrtbl.zt_blk;
zs->zs_ptrtbl_zt_numblks = zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks; zs->zs_ptrtbl_zt_numblks = zap_f_phys(zap)->zap_ptrtbl.zt_numblks;
zs->zs_ptrtbl_zt_shift = zap->zap_f.zap_phys->zap_ptrtbl.zt_shift; zs->zs_ptrtbl_zt_shift = zap_f_phys(zap)->zap_ptrtbl.zt_shift;
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks == 0) { if (zap_f_phys(zap)->zap_ptrtbl.zt_numblks == 0) {
/* the ptrtbl is entirely in the header block. */ /* the ptrtbl is entirely in the header block. */
zap_stats_ptrtbl(zap, &ZAP_EMBEDDED_PTRTBL_ENT(zap, 0), zap_stats_ptrtbl(zap, &ZAP_EMBEDDED_PTRTBL_ENT(zap, 0),
1 << ZAP_EMBEDDED_PTRTBL_SHIFT(zap), zs); 1 << ZAP_EMBEDDED_PTRTBL_SHIFT(zap), zs);
@ -1312,16 +1310,16 @@ fzap_get_stats(zap_t *zap, zap_stats_t *zs)
int b; int b;
dmu_prefetch(zap->zap_objset, zap->zap_object, dmu_prefetch(zap->zap_objset, zap->zap_object,
zap->zap_f.zap_phys->zap_ptrtbl.zt_blk << bs, zap_f_phys(zap)->zap_ptrtbl.zt_blk << bs,
zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks << bs); zap_f_phys(zap)->zap_ptrtbl.zt_numblks << bs);
for (b = 0; b < zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks; for (b = 0; b < zap_f_phys(zap)->zap_ptrtbl.zt_numblks;
b++) { b++) {
dmu_buf_t *db; dmu_buf_t *db;
int err; int err;
err = dmu_buf_hold(zap->zap_objset, zap->zap_object, err = dmu_buf_hold(zap->zap_objset, zap->zap_object,
(zap->zap_f.zap_phys->zap_ptrtbl.zt_blk + b) << bs, (zap_f_phys(zap)->zap_ptrtbl.zt_blk + b) << bs,
FTAG, &db, DMU_READ_NO_PREFETCH); FTAG, &db, DMU_READ_NO_PREFETCH);
if (err == 0) { if (err == 0) {
zap_stats_ptrtbl(zap, db->db_data, zap_stats_ptrtbl(zap, db->db_data,
@ -1358,7 +1356,7 @@ fzap_count_write(zap_name_t *zn, int add, uint64_t *towrite,
* could extend the table. * could extend the table.
*/ */
if (add) { if (add) {
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_blk == 0) if (zap_f_phys(zap)->zap_ptrtbl.zt_blk == 0)
*towrite += zap->zap_dbuf->db_size; *towrite += zap->zap_dbuf->db_size;
else else
*towrite += (zap->zap_dbuf->db_size * 3); *towrite += (zap->zap_dbuf->db_size * 3);

View File

@ -48,10 +48,12 @@ static uint16_t *zap_leaf_rehash_entry(zap_leaf_t *l, uint16_t entry);
#define LEAF_HASH(l, h) \ #define LEAF_HASH(l, h) \
((ZAP_LEAF_HASH_NUMENTRIES(l)-1) & \ ((ZAP_LEAF_HASH_NUMENTRIES(l)-1) & \
((h) >> (64 - ZAP_LEAF_HASH_SHIFT(l)-(l)->l_phys->l_hdr.lh_prefix_len))) ((h) >> \
(64 - ZAP_LEAF_HASH_SHIFT(l) - zap_leaf_phys(l)->l_hdr.lh_prefix_len)))
#define LEAF_HASH_ENTPTR(l, h) (&(l)->l_phys->l_hash[LEAF_HASH(l, h)]) #define LEAF_HASH_ENTPTR(l, h) (&zap_leaf_phys(l)->l_hash[LEAF_HASH(l, h)])
extern inline zap_leaf_phys_t *zap_leaf_phys(zap_leaf_t *l);
static void static void
zap_memset(void *a, int c, size_t n) zap_memset(void *a, int c, size_t n)
@ -107,8 +109,11 @@ zap_leaf_byteswap(zap_leaf_phys_t *buf, int size)
{ {
int i; int i;
zap_leaf_t l; zap_leaf_t l;
dmu_buf_t l_dbuf;
l_dbuf.db_data = buf;
l.l_bs = highbit64(size) - 1; l.l_bs = highbit64(size) - 1;
l.l_phys = buf; l.l_dbuf = &l_dbuf;
buf->l_hdr.lh_block_type = BSWAP_64(buf->l_hdr.lh_block_type); buf->l_hdr.lh_block_type = BSWAP_64(buf->l_hdr.lh_block_type);
buf->l_hdr.lh_prefix = BSWAP_64(buf->l_hdr.lh_prefix); buf->l_hdr.lh_prefix = BSWAP_64(buf->l_hdr.lh_prefix);
@ -161,18 +166,20 @@ zap_leaf_init(zap_leaf_t *l, boolean_t sort)
int i; int i;
l->l_bs = highbit64(l->l_dbuf->db_size) - 1; l->l_bs = highbit64(l->l_dbuf->db_size) - 1;
zap_memset(&l->l_phys->l_hdr, 0, sizeof (struct zap_leaf_header)); zap_memset(&zap_leaf_phys(l)->l_hdr, 0,
zap_memset(l->l_phys->l_hash, CHAIN_END, 2*ZAP_LEAF_HASH_NUMENTRIES(l)); sizeof (struct zap_leaf_header));
zap_memset(zap_leaf_phys(l)->l_hash, CHAIN_END,
2*ZAP_LEAF_HASH_NUMENTRIES(l));
for (i = 0; i < ZAP_LEAF_NUMCHUNKS(l); i++) { for (i = 0; i < ZAP_LEAF_NUMCHUNKS(l); i++) {
ZAP_LEAF_CHUNK(l, i).l_free.lf_type = ZAP_CHUNK_FREE; ZAP_LEAF_CHUNK(l, i).l_free.lf_type = ZAP_CHUNK_FREE;
ZAP_LEAF_CHUNK(l, i).l_free.lf_next = i+1; ZAP_LEAF_CHUNK(l, i).l_free.lf_next = i+1;
} }
ZAP_LEAF_CHUNK(l, ZAP_LEAF_NUMCHUNKS(l)-1).l_free.lf_next = CHAIN_END; ZAP_LEAF_CHUNK(l, ZAP_LEAF_NUMCHUNKS(l)-1).l_free.lf_next = CHAIN_END;
l->l_phys->l_hdr.lh_block_type = ZBT_LEAF; zap_leaf_phys(l)->l_hdr.lh_block_type = ZBT_LEAF;
l->l_phys->l_hdr.lh_magic = ZAP_LEAF_MAGIC; zap_leaf_phys(l)->l_hdr.lh_magic = ZAP_LEAF_MAGIC;
l->l_phys->l_hdr.lh_nfree = ZAP_LEAF_NUMCHUNKS(l); zap_leaf_phys(l)->l_hdr.lh_nfree = ZAP_LEAF_NUMCHUNKS(l);
if (sort) if (sort)
l->l_phys->l_hdr.lh_flags |= ZLF_ENTRIES_CDSORTED; zap_leaf_phys(l)->l_hdr.lh_flags |= ZLF_ENTRIES_CDSORTED;
} }
/* /*
@ -184,15 +191,16 @@ zap_leaf_chunk_alloc(zap_leaf_t *l)
{ {
int chunk; int chunk;
ASSERT(l->l_phys->l_hdr.lh_nfree > 0); ASSERT(zap_leaf_phys(l)->l_hdr.lh_nfree > 0);
chunk = l->l_phys->l_hdr.lh_freelist; chunk = zap_leaf_phys(l)->l_hdr.lh_freelist;
ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l)); ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l));
ASSERT3U(ZAP_LEAF_CHUNK(l, chunk).l_free.lf_type, ==, ZAP_CHUNK_FREE); ASSERT3U(ZAP_LEAF_CHUNK(l, chunk).l_free.lf_type, ==, ZAP_CHUNK_FREE);
l->l_phys->l_hdr.lh_freelist = ZAP_LEAF_CHUNK(l, chunk).l_free.lf_next; zap_leaf_phys(l)->l_hdr.lh_freelist =
ZAP_LEAF_CHUNK(l, chunk).l_free.lf_next;
l->l_phys->l_hdr.lh_nfree--; zap_leaf_phys(l)->l_hdr.lh_nfree--;
return (chunk); return (chunk);
} }
@ -201,16 +209,16 @@ static void
zap_leaf_chunk_free(zap_leaf_t *l, uint16_t chunk) zap_leaf_chunk_free(zap_leaf_t *l, uint16_t chunk)
{ {
struct zap_leaf_free *zlf = &ZAP_LEAF_CHUNK(l, chunk).l_free; struct zap_leaf_free *zlf = &ZAP_LEAF_CHUNK(l, chunk).l_free;
ASSERT3U(l->l_phys->l_hdr.lh_nfree, <, ZAP_LEAF_NUMCHUNKS(l)); ASSERT3U(zap_leaf_phys(l)->l_hdr.lh_nfree, <, ZAP_LEAF_NUMCHUNKS(l));
ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l)); ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l));
ASSERT(zlf->lf_type != ZAP_CHUNK_FREE); ASSERT(zlf->lf_type != ZAP_CHUNK_FREE);
zlf->lf_type = ZAP_CHUNK_FREE; zlf->lf_type = ZAP_CHUNK_FREE;
zlf->lf_next = l->l_phys->l_hdr.lh_freelist; zlf->lf_next = zap_leaf_phys(l)->l_hdr.lh_freelist;
bzero(zlf->lf_pad, sizeof (zlf->lf_pad)); /* help it to compress */ bzero(zlf->lf_pad, sizeof (zlf->lf_pad)); /* help it to compress */
l->l_phys->l_hdr.lh_freelist = chunk; zap_leaf_phys(l)->l_hdr.lh_freelist = chunk;
l->l_phys->l_hdr.lh_nfree++; zap_leaf_phys(l)->l_hdr.lh_nfree++;
} }
/* /*
@ -396,7 +404,7 @@ zap_leaf_lookup(zap_leaf_t *l, zap_name_t *zn, zap_entry_handle_t *zeh)
uint16_t *chunkp; uint16_t *chunkp;
struct zap_leaf_entry *le; struct zap_leaf_entry *le;
ASSERT3U(l->l_phys->l_hdr.lh_magic, ==, ZAP_LEAF_MAGIC); ASSERT3U(zap_leaf_phys(l)->l_hdr.lh_magic, ==, ZAP_LEAF_MAGIC);
again: again:
for (chunkp = LEAF_HASH_ENTPTR(l, zn->zn_hash); for (chunkp = LEAF_HASH_ENTPTR(l, zn->zn_hash);
@ -416,7 +424,7 @@ again:
* lowest-cd match for MT_FIRST. * lowest-cd match for MT_FIRST.
*/ */
ASSERT(zn->zn_matchtype == MT_EXACT || ASSERT(zn->zn_matchtype == MT_EXACT ||
(l->l_phys->l_hdr.lh_flags & ZLF_ENTRIES_CDSORTED)); (zap_leaf_phys(l)->l_hdr.lh_flags & ZLF_ENTRIES_CDSORTED));
if (zap_leaf_array_match(l, zn, le->le_name_chunk, if (zap_leaf_array_match(l, zn, le->le_name_chunk,
le->le_name_numints)) { le->le_name_numints)) {
zeh->zeh_num_integers = le->le_value_numints; zeh->zeh_num_integers = le->le_value_numints;
@ -456,10 +464,10 @@ zap_leaf_lookup_closest(zap_leaf_t *l,
uint16_t lh; uint16_t lh;
struct zap_leaf_entry *le; struct zap_leaf_entry *le;
ASSERT3U(l->l_phys->l_hdr.lh_magic, ==, ZAP_LEAF_MAGIC); ASSERT3U(zap_leaf_phys(l)->l_hdr.lh_magic, ==, ZAP_LEAF_MAGIC);
for (lh = LEAF_HASH(l, h); lh <= bestlh; lh++) { for (lh = LEAF_HASH(l, h); lh <= bestlh; lh++) {
for (chunk = l->l_phys->l_hash[lh]; for (chunk = zap_leaf_phys(l)->l_hash[lh];
chunk != CHAIN_END; chunk = le->le_next) { chunk != CHAIN_END; chunk = le->le_next) {
le = ZAP_LEAF_ENTRY(l, chunk); le = ZAP_LEAF_ENTRY(l, chunk);
@ -539,7 +547,7 @@ zap_entry_update(zap_entry_handle_t *zeh,
delta_chunks = ZAP_LEAF_ARRAY_NCHUNKS(num_integers * integer_size) - delta_chunks = ZAP_LEAF_ARRAY_NCHUNKS(num_integers * integer_size) -
ZAP_LEAF_ARRAY_NCHUNKS(le->le_value_numints * le->le_value_intlen); ZAP_LEAF_ARRAY_NCHUNKS(le->le_value_numints * le->le_value_intlen);
if ((int)l->l_phys->l_hdr.lh_nfree < delta_chunks) if ((int)zap_leaf_phys(l)->l_hdr.lh_nfree < delta_chunks)
return (SET_ERROR(EAGAIN)); return (SET_ERROR(EAGAIN));
zap_leaf_array_free(l, &le->le_value_chunk); zap_leaf_array_free(l, &le->le_value_chunk);
@ -569,7 +577,7 @@ zap_entry_remove(zap_entry_handle_t *zeh)
*zeh->zeh_chunkp = le->le_next; *zeh->zeh_chunkp = le->le_next;
zap_leaf_chunk_free(l, entry_chunk); zap_leaf_chunk_free(l, entry_chunk);
l->l_phys->l_hdr.lh_nentries--; zap_leaf_phys(l)->l_hdr.lh_nentries--;
} }
int int
@ -593,7 +601,7 @@ zap_entry_create(zap_leaf_t *l, zap_name_t *zn, uint32_t cd,
if (cd == ZAP_NEED_CD) { if (cd == ZAP_NEED_CD) {
/* find the lowest unused cd */ /* find the lowest unused cd */
if (l->l_phys->l_hdr.lh_flags & ZLF_ENTRIES_CDSORTED) { if (zap_leaf_phys(l)->l_hdr.lh_flags & ZLF_ENTRIES_CDSORTED) {
cd = 0; cd = 0;
for (chunk = *LEAF_HASH_ENTPTR(l, h); for (chunk = *LEAF_HASH_ENTPTR(l, h);
@ -629,7 +637,7 @@ zap_entry_create(zap_leaf_t *l, zap_name_t *zn, uint32_t cd,
ASSERT3U(cd, <, zap_maxcd(zn->zn_zap)); ASSERT3U(cd, <, zap_maxcd(zn->zn_zap));
} }
if (l->l_phys->l_hdr.lh_nfree < numchunks) if (zap_leaf_phys(l)->l_hdr.lh_nfree < numchunks)
return (SET_ERROR(EAGAIN)); return (SET_ERROR(EAGAIN));
/* make the entry */ /* make the entry */
@ -650,7 +658,7 @@ zap_entry_create(zap_leaf_t *l, zap_name_t *zn, uint32_t cd,
/* XXX if we did the search above, we could just use that */ /* XXX if we did the search above, we could just use that */
chunkp = zap_leaf_rehash_entry(l, chunk); chunkp = zap_leaf_rehash_entry(l, chunk);
l->l_phys->l_hdr.lh_nentries++; zap_leaf_phys(l)->l_hdr.lh_nentries++;
zeh->zeh_leaf = l; zeh->zeh_leaf = l;
zeh->zeh_num_integers = num_integers; zeh->zeh_num_integers = num_integers;
@ -784,8 +792,8 @@ zap_leaf_transfer_entry(zap_leaf_t *l, int entry, zap_leaf_t *nl)
zap_leaf_chunk_free(l, entry); zap_leaf_chunk_free(l, entry);
l->l_phys->l_hdr.lh_nentries--; zap_leaf_phys(l)->l_hdr.lh_nentries--;
nl->l_phys->l_hdr.lh_nentries++; zap_leaf_phys(nl)->l_hdr.lh_nentries++;
} }
/* /*
@ -795,19 +803,22 @@ void
zap_leaf_split(zap_leaf_t *l, zap_leaf_t *nl, boolean_t sort) zap_leaf_split(zap_leaf_t *l, zap_leaf_t *nl, boolean_t sort)
{ {
int i; int i;
int bit = 64 - 1 - l->l_phys->l_hdr.lh_prefix_len; int bit = 64 - 1 - zap_leaf_phys(l)->l_hdr.lh_prefix_len;
/* set new prefix and prefix_len */ /* set new prefix and prefix_len */
l->l_phys->l_hdr.lh_prefix <<= 1; zap_leaf_phys(l)->l_hdr.lh_prefix <<= 1;
l->l_phys->l_hdr.lh_prefix_len++; zap_leaf_phys(l)->l_hdr.lh_prefix_len++;
nl->l_phys->l_hdr.lh_prefix = l->l_phys->l_hdr.lh_prefix | 1; zap_leaf_phys(nl)->l_hdr.lh_prefix =
nl->l_phys->l_hdr.lh_prefix_len = l->l_phys->l_hdr.lh_prefix_len; zap_leaf_phys(l)->l_hdr.lh_prefix | 1;
zap_leaf_phys(nl)->l_hdr.lh_prefix_len =
zap_leaf_phys(l)->l_hdr.lh_prefix_len;
/* break existing hash chains */ /* break existing hash chains */
zap_memset(l->l_phys->l_hash, CHAIN_END, 2*ZAP_LEAF_HASH_NUMENTRIES(l)); zap_memset(zap_leaf_phys(l)->l_hash, CHAIN_END,
2*ZAP_LEAF_HASH_NUMENTRIES(l));
if (sort) if (sort)
l->l_phys->l_hdr.lh_flags |= ZLF_ENTRIES_CDSORTED; zap_leaf_phys(l)->l_hdr.lh_flags |= ZLF_ENTRIES_CDSORTED;
/* /*
* Transfer entries whose hash bit 'bit' is set to nl; rehash * Transfer entries whose hash bit 'bit' is set to nl; rehash
@ -835,25 +846,25 @@ zap_leaf_stats(zap_t *zap, zap_leaf_t *l, zap_stats_t *zs)
{ {
int i, n; int i, n;
n = zap->zap_f.zap_phys->zap_ptrtbl.zt_shift - n = zap_f_phys(zap)->zap_ptrtbl.zt_shift -
l->l_phys->l_hdr.lh_prefix_len; zap_leaf_phys(l)->l_hdr.lh_prefix_len;
n = MIN(n, ZAP_HISTOGRAM_SIZE-1); n = MIN(n, ZAP_HISTOGRAM_SIZE-1);
zs->zs_leafs_with_2n_pointers[n]++; zs->zs_leafs_with_2n_pointers[n]++;
n = l->l_phys->l_hdr.lh_nentries/5; n = zap_leaf_phys(l)->l_hdr.lh_nentries/5;
n = MIN(n, ZAP_HISTOGRAM_SIZE-1); n = MIN(n, ZAP_HISTOGRAM_SIZE-1);
zs->zs_blocks_with_n5_entries[n]++; zs->zs_blocks_with_n5_entries[n]++;
n = ((1<<FZAP_BLOCK_SHIFT(zap)) - n = ((1<<FZAP_BLOCK_SHIFT(zap)) -
l->l_phys->l_hdr.lh_nfree * (ZAP_LEAF_ARRAY_BYTES+1))*10 / zap_leaf_phys(l)->l_hdr.lh_nfree * (ZAP_LEAF_ARRAY_BYTES+1))*10 /
(1<<FZAP_BLOCK_SHIFT(zap)); (1<<FZAP_BLOCK_SHIFT(zap));
n = MIN(n, ZAP_HISTOGRAM_SIZE-1); n = MIN(n, ZAP_HISTOGRAM_SIZE-1);
zs->zs_blocks_n_tenths_full[n]++; zs->zs_blocks_n_tenths_full[n]++;
for (i = 0; i < ZAP_LEAF_HASH_NUMENTRIES(l); i++) { for (i = 0; i < ZAP_LEAF_HASH_NUMENTRIES(l); i++) {
int nentries = 0; int nentries = 0;
int chunk = l->l_phys->l_hash[i]; int chunk = zap_leaf_phys(l)->l_hash[i];
while (chunk != CHAIN_END) { while (chunk != CHAIN_END) {
struct zap_leaf_entry *le = struct zap_leaf_entry *le =

View File

@ -38,6 +38,8 @@
#include <sys/sunddi.h> #include <sys/sunddi.h>
#endif #endif
extern inline mzap_phys_t *zap_m_phys(zap_t *zap);
static int mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags); static int mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags);
uint64_t uint64_t
@ -45,7 +47,7 @@ zap_getflags(zap_t *zap)
{ {
if (zap->zap_ismicro) if (zap->zap_ismicro)
return (0); return (0);
return (zap->zap_u.zap_fat.zap_phys->zap_flags); return (zap_f_phys(zap)->zap_flags);
} }
int int
@ -384,7 +386,7 @@ mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
* it, because zap_lockdir() checks zap_ismicro without the lock * it, because zap_lockdir() checks zap_ismicro without the lock
* held. * held.
*/ */
winner = dmu_buf_set_user(db, zap, &zap->zap_m.zap_phys, zap_evict); winner = dmu_buf_set_user(db, zap, zap_evict);
if (winner != NULL) { if (winner != NULL) {
rw_exit(&zap->zap_rwlock); rw_exit(&zap->zap_rwlock);
@ -396,15 +398,15 @@ mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
} }
if (zap->zap_ismicro) { if (zap->zap_ismicro) {
zap->zap_salt = zap->zap_m.zap_phys->mz_salt; zap->zap_salt = zap_m_phys(zap)->mz_salt;
zap->zap_normflags = zap->zap_m.zap_phys->mz_normflags; zap->zap_normflags = zap_m_phys(zap)->mz_normflags;
zap->zap_m.zap_num_chunks = db->db_size / MZAP_ENT_LEN - 1; zap->zap_m.zap_num_chunks = db->db_size / MZAP_ENT_LEN - 1;
avl_create(&zap->zap_m.zap_avl, mze_compare, avl_create(&zap->zap_m.zap_avl, mze_compare,
sizeof (mzap_ent_t), offsetof(mzap_ent_t, mze_node)); sizeof (mzap_ent_t), offsetof(mzap_ent_t, mze_node));
for (i = 0; i < zap->zap_m.zap_num_chunks; i++) { for (i = 0; i < zap->zap_m.zap_num_chunks; i++) {
mzap_ent_phys_t *mze = mzap_ent_phys_t *mze =
&zap->zap_m.zap_phys->mz_chunk[i]; &zap_m_phys(zap)->mz_chunk[i];
if (mze->mze_name[0]) { if (mze->mze_name[0]) {
zap_name_t *zn; zap_name_t *zn;
@ -416,8 +418,8 @@ mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
} }
} }
} else { } else {
zap->zap_salt = zap->zap_f.zap_phys->zap_salt; zap->zap_salt = zap_f_phys(zap)->zap_salt;
zap->zap_normflags = zap->zap_f.zap_phys->zap_normflags; zap->zap_normflags = zap_f_phys(zap)->zap_normflags;
ASSERT3U(sizeof (struct zap_leaf_header), ==, ASSERT3U(sizeof (struct zap_leaf_header), ==,
2*ZAP_LEAF_CHUNKSIZE); 2*ZAP_LEAF_CHUNKSIZE);
@ -427,7 +429,7 @@ mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
* other members. * other members.
*/ */
ASSERT3P(&ZAP_EMBEDDED_PTRTBL_ENT(zap, 0), >, ASSERT3P(&ZAP_EMBEDDED_PTRTBL_ENT(zap, 0), >,
&zap->zap_f.zap_phys->zap_salt); &zap_f_phys(zap)->zap_salt);
/* /*
* The embedded pointer table should end at the end of * The embedded pointer table should end at the end of
@ -435,7 +437,7 @@ mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
*/ */
ASSERT3U((uintptr_t)&ZAP_EMBEDDED_PTRTBL_ENT(zap, ASSERT3U((uintptr_t)&ZAP_EMBEDDED_PTRTBL_ENT(zap,
1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap)) - 1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap)) -
(uintptr_t)zap->zap_f.zap_phys, ==, (uintptr_t)zap_f_phys(zap), ==,
zap->zap_dbuf->db_size); zap->zap_dbuf->db_size);
} }
rw_exit(&zap->zap_rwlock); rw_exit(&zap->zap_rwlock);
@ -936,7 +938,7 @@ mzap_addent(zap_name_t *zn, uint64_t value)
#ifdef ZFS_DEBUG #ifdef ZFS_DEBUG
for (i = 0; i < zap->zap_m.zap_num_chunks; i++) { for (i = 0; i < zap->zap_m.zap_num_chunks; i++) {
ASSERTV(mzap_ent_phys_t *mze); ASSERTV(mzap_ent_phys_t *mze);
ASSERT(mze = &zap->zap_m.zap_phys->mz_chunk[i]); ASSERT(mze = &zap_m_phys(zap)->mz_chunk[i]);
ASSERT(strcmp(zn->zn_key_orig, mze->mze_name) != 0); ASSERT(strcmp(zn->zn_key_orig, mze->mze_name) != 0);
} }
#endif #endif
@ -947,7 +949,7 @@ mzap_addent(zap_name_t *zn, uint64_t value)
again: again:
for (i = start; i < zap->zap_m.zap_num_chunks; i++) { for (i = start; i < zap->zap_m.zap_num_chunks; i++) {
mzap_ent_phys_t *mze = &zap->zap_m.zap_phys->mz_chunk[i]; mzap_ent_phys_t *mze = &zap_m_phys(zap)->mz_chunk[i];
if (mze->mze_name[0] == 0) { if (mze->mze_name[0] == 0) {
mze->mze_value = value; mze->mze_value = value;
mze->mze_cd = cd; mze->mze_cd = cd;
@ -1149,7 +1151,7 @@ zap_remove_norm(objset_t *os, uint64_t zapobj, const char *name,
err = SET_ERROR(ENOENT); err = SET_ERROR(ENOENT);
} else { } else {
zap->zap_m.zap_num_entries--; zap->zap_m.zap_num_entries--;
bzero(&zap->zap_m.zap_phys->mz_chunk[mze->mze_chunkid], bzero(&zap_m_phys(zap)->mz_chunk[mze->mze_chunkid],
sizeof (mzap_ent_phys_t)); sizeof (mzap_ent_phys_t));
mze_remove(zap, mze); mze_remove(zap, mze);
} }

View File

@ -946,7 +946,7 @@ zfs_secpolicy_promote(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
dd = clone->ds_dir; dd = clone->ds_dir;
error = dsl_dataset_hold_obj(dd->dd_pool, error = dsl_dataset_hold_obj(dd->dd_pool,
dd->dd_phys->dd_origin_obj, FTAG, &origin); dsl_dir_phys(dd)->dd_origin_obj, FTAG, &origin);
if (error != 0) { if (error != 0) {
dsl_dataset_rele(clone, FTAG); dsl_dataset_rele(clone, FTAG);
dsl_pool_rele(dp, FTAG); dsl_pool_rele(dp, FTAG);
@ -4249,7 +4249,8 @@ zfs_ioc_send(zfs_cmd_t *zc)
} }
if (dsl_dir_is_clone(tosnap->ds_dir)) if (dsl_dir_is_clone(tosnap->ds_dir))
zc->zc_fromobj = tosnap->ds_dir->dd_phys->dd_origin_obj; zc->zc_fromobj =
dsl_dir_phys(tosnap->ds_dir)->dd_origin_obj;
dsl_dataset_rele(tosnap, FTAG); dsl_dataset_rele(tosnap, FTAG);
dsl_pool_rele(dp, FTAG); dsl_pool_rele(dp, FTAG);
} }
@ -4687,7 +4688,7 @@ zfs_ioc_next_obj(zfs_cmd_t *zc)
return (error); return (error);
error = dmu_object_next(os, &zc->zc_obj, B_FALSE, error = dmu_object_next(os, &zc->zc_obj, B_FALSE,
os->os_dsl_dataset->ds_phys->ds_prev_snap_txg); dsl_dataset_phys(os->os_dsl_dataset)->ds_prev_snap_txg);
dmu_objset_rele(os, FTAG); dmu_objset_rele(os, FTAG);
return (error); return (error);