5314 Remove "dbuf phys" db->db_data pointer aliases in ZFS
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> Author: Justin T. Gibbs <justing@spectralogic.com> illumos/illumos-gate@c137962540
This commit is contained in:
parent
323b8f9383
commit
6d8516a342
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor-sys/illumos/dist/; revision=275551
@ -1857,8 +1857,8 @@ dump_dir(objset_t *os)
|
||||
if (dds.dds_type == DMU_OST_META) {
|
||||
dds.dds_creation_txg = TXG_INITIAL;
|
||||
usedobjs = BP_GET_FILL(os->os_rootbp);
|
||||
refdbytes = os->os_spa->spa_dsl_pool->
|
||||
dp_mos_dir->dd_phys->dd_used_bytes;
|
||||
refdbytes = dsl_dir_phys(os->os_spa->spa_dsl_pool->dp_mos_dir)->
|
||||
dd_used_bytes;
|
||||
} else {
|
||||
dmu_objset_space(os, &refdbytes, &scratch, &usedobjs, &scratch);
|
||||
}
|
||||
|
@ -223,11 +223,8 @@ dbuf_evict_user(dmu_buf_impl_t *db)
|
||||
if (db->db_level != 0 || db->db_evict_func == NULL)
|
||||
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_user_ptr = NULL;
|
||||
db->db_user_data_ptr_ptr = NULL;
|
||||
db->db_evict_func = NULL;
|
||||
}
|
||||
|
||||
@ -417,16 +414,6 @@ dbuf_verify(dmu_buf_impl_t *db)
|
||||
}
|
||||
#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
|
||||
dbuf_set_data(dmu_buf_impl_t *db, arc_buf_t *buf)
|
||||
{
|
||||
@ -437,7 +424,6 @@ dbuf_set_data(dmu_buf_impl_t *db, arc_buf_t *buf)
|
||||
db->db.db_data = buf->b_data;
|
||||
if (!arc_released(buf))
|
||||
arc_set_callback(buf, dbuf_do_evict, db);
|
||||
dbuf_update_data(db);
|
||||
} else {
|
||||
dbuf_evict_user(db);
|
||||
db->db.db_data = NULL;
|
||||
@ -543,7 +529,6 @@ dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t *flags)
|
||||
if (bonuslen)
|
||||
bcopy(DN_BONUS(dn->dn_phys), db->db.db_data, bonuslen);
|
||||
DB_DNODE_EXIT(db);
|
||||
dbuf_update_data(db);
|
||||
db->db_state = DB_CACHED;
|
||||
mutex_exit(&db->db_mtx);
|
||||
return;
|
||||
@ -1726,7 +1711,6 @@ dbuf_create(dnode_t *dn, uint8_t level, uint64_t blkid,
|
||||
db->db_blkptr = blkptr;
|
||||
|
||||
db->db_user_ptr = NULL;
|
||||
db->db_user_data_ptr_ptr = NULL;
|
||||
db->db_evict_func = NULL;
|
||||
db->db_immediate_evict = 0;
|
||||
db->db_freed_in_flight = 0;
|
||||
@ -1971,7 +1955,6 @@ dbuf_hold_impl(dnode_t *dn, uint8_t level, uint64_t blkid, int fail_sparse,
|
||||
}
|
||||
|
||||
(void) refcount_add(&db->db_holds, tag);
|
||||
dbuf_update_data(db);
|
||||
DBUF_VERIFY(db);
|
||||
mutex_exit(&db->db_mtx);
|
||||
|
||||
@ -2182,27 +2165,25 @@ dbuf_refcount(dmu_buf_impl_t *db)
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return (dmu_buf_update_user(db_fake, NULL, user_ptr,
|
||||
user_data_ptr_ptr, evict_func));
|
||||
return (dmu_buf_update_user(db_fake, NULL, user_ptr, evict_func));
|
||||
}
|
||||
|
||||
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_impl_t *db = (dmu_buf_impl_t *)db_fake;
|
||||
|
||||
db->db_immediate_evict = TRUE;
|
||||
return (dmu_buf_update_user(db_fake, NULL, user_ptr,
|
||||
user_data_ptr_ptr, evict_func));
|
||||
return (dmu_buf_update_user(db_fake, NULL, user_ptr, evict_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 *evict_func)
|
||||
dmu_buf_evict_func_t *evict_func)
|
||||
{
|
||||
dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
|
||||
ASSERT(db->db_level == 0);
|
||||
@ -2213,10 +2194,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) {
|
||||
db->db_user_ptr = user_ptr;
|
||||
db->db_user_data_ptr_ptr = user_data_ptr_ptr;
|
||||
db->db_evict_func = evict_func;
|
||||
|
||||
dbuf_update_data(db);
|
||||
} else {
|
||||
old_user_ptr = db->db_user_ptr;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ dmu_diff(const char *tosnap_name, const char *fromsnap_name,
|
||||
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_long_hold(tosnap, FTAG);
|
||||
|
@ -1479,12 +1479,12 @@ dmu_snapshot_realname(objset_t *os, char *name, char *real, int maxlen,
|
||||
dsl_dataset_t *ds = os->os_dsl_dataset;
|
||||
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 (zap_lookup_norm(ds->ds_dir->dd_pool->dp_meta_objset,
|
||||
ds->ds_phys->ds_snapnames_zapobj, name, 8, 1, &ignored, MT_FIRST,
|
||||
real, maxlen, conflict));
|
||||
dsl_dataset_phys(ds)->ds_snapnames_zapobj, name, 8, 1, &ignored,
|
||||
MT_FIRST, real, maxlen, conflict));
|
||||
}
|
||||
|
||||
int
|
||||
@ -1497,12 +1497,12 @@ dmu_snapshot_list_next(objset_t *os, int namelen, char *name,
|
||||
|
||||
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));
|
||||
|
||||
zap_cursor_init_serialized(&cursor,
|
||||
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) {
|
||||
zap_cursor_fini(&cursor);
|
||||
@ -1536,12 +1536,12 @@ dmu_dir_list_next(objset_t *os, int namelen, char *name,
|
||||
|
||||
/* there is no next dir on a snapshot! */
|
||||
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));
|
||||
|
||||
zap_cursor_init_serialized(&cursor,
|
||||
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) {
|
||||
zap_cursor_fini(&cursor);
|
||||
@ -1589,7 +1589,7 @@ dmu_objset_find_dp(dsl_pool_t *dp, uint64_t ddobj,
|
||||
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);
|
||||
|
||||
/*
|
||||
@ -1597,7 +1597,7 @@ dmu_objset_find_dp(dsl_pool_t *dp, uint64_t ddobj,
|
||||
*/
|
||||
if (flags & DS_FIND_CHILDREN) {
|
||||
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;
|
||||
(void) zap_cursor_advance(&zc)) {
|
||||
ASSERT3U(attr->za_integer_length, ==,
|
||||
@ -1626,7 +1626,9 @@ dmu_objset_find_dp(dsl_pool_t *dp, uint64_t ddobj,
|
||||
err = dsl_dataset_hold_obj(dp, thisobj, FTAG, &ds);
|
||||
|
||||
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);
|
||||
|
||||
for (zap_cursor_init(&zc, dp->dp_meta_objset, snapobj);
|
||||
@ -1701,7 +1703,7 @@ dmu_objset_find_impl(spa_t *spa, const char *name,
|
||||
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);
|
||||
|
||||
/*
|
||||
@ -1709,7 +1711,7 @@ dmu_objset_find_impl(spa_t *spa, const char *name,
|
||||
*/
|
||||
if (flags & DS_FIND_CHILDREN) {
|
||||
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;
|
||||
(void) zap_cursor_advance(&zc)) {
|
||||
ASSERT3U(attr->za_integer_length, ==,
|
||||
@ -1742,7 +1744,9 @@ dmu_objset_find_impl(spa_t *spa, const char *name,
|
||||
err = dsl_dataset_hold_obj(dp, thisobj, FTAG, &ds);
|
||||
|
||||
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);
|
||||
|
||||
for (zap_cursor_init(&zc, dp->dp_meta_objset, snapobj);
|
||||
|
@ -598,12 +598,12 @@ dmu_send_impl(void *tag, dsl_pool_t *dp, dsl_dataset_t *ds,
|
||||
featureflags);
|
||||
|
||||
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);
|
||||
if (is_clone)
|
||||
drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CLONE;
|
||||
drr->drr_u.drr_begin.drr_toguid = ds->ds_phys->ds_guid;
|
||||
if (ds->ds_phys->ds_flags & DS_FLAG_CI_DATASET)
|
||||
drr->drr_u.drr_begin.drr_toguid = dsl_dataset_phys(ds)->ds_guid;
|
||||
if (dsl_dataset_phys(ds)->ds_flags & DS_FLAG_CI_DATASET)
|
||||
drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CI_DATA;
|
||||
|
||||
if (fromzb != NULL) {
|
||||
@ -624,7 +624,7 @@ dmu_send_impl(void *tag, dsl_pool_t *dp, dsl_dataset_t *ds,
|
||||
dsp->dsa_proc = curproc;
|
||||
dsp->dsa_os = os;
|
||||
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);
|
||||
dsp->dsa_pending_op = PENDING_NONE;
|
||||
dsp->dsa_incremental = (fromzb != NULL);
|
||||
@ -710,9 +710,10 @@ dmu_send_obj(const char *pool, uint64_t tosnap, uint64_t fromsnap,
|
||||
}
|
||||
if (!dsl_dataset_is_before(ds, fromds, 0))
|
||||
err = SET_ERROR(EXDEV);
|
||||
zb.zbm_creation_time = fromds->ds_phys->ds_creation_time;
|
||||
zb.zbm_creation_txg = fromds->ds_phys->ds_creation_txg;
|
||||
zb.zbm_guid = fromds->ds_phys->ds_guid;
|
||||
zb.zbm_creation_time =
|
||||
dsl_dataset_phys(fromds)->ds_creation_time;
|
||||
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);
|
||||
dsl_dataset_rele(fromds, FTAG);
|
||||
err = dmu_send_impl(FTAG, dp, ds, &zb, is_clone,
|
||||
@ -779,10 +780,10 @@ dmu_send(const char *tosnap, const char *fromsnap,
|
||||
if (!dsl_dataset_is_before(ds, fromds, 0))
|
||||
err = SET_ERROR(EXDEV);
|
||||
zb.zbm_creation_time =
|
||||
fromds->ds_phys->ds_creation_time;
|
||||
dsl_dataset_phys(fromds)->ds_creation_time;
|
||||
zb.zbm_creation_txg =
|
||||
fromds->ds_phys->ds_creation_txg;
|
||||
zb.zbm_guid = fromds->ds_phys->ds_guid;
|
||||
dsl_dataset_phys(fromds)->ds_creation_txg;
|
||||
zb.zbm_guid = dsl_dataset_phys(fromds)->ds_guid;
|
||||
is_clone = (ds->ds_dir != fromds->ds_dir);
|
||||
dsl_dataset_rele(fromds, FTAG);
|
||||
}
|
||||
@ -829,7 +830,7 @@ dmu_send_estimate(dsl_dataset_t *ds, dsl_dataset_t *fromds, uint64_t *sizep)
|
||||
|
||||
/* Get uncompressed size estimate of changed data. */
|
||||
if (fromds == NULL) {
|
||||
size = ds->ds_phys->ds_uncompressed_bytes;
|
||||
size = dsl_dataset_phys(ds)->ds_uncompressed_bytes;
|
||||
} else {
|
||||
uint64_t used, comp;
|
||||
err = dsl_dataset_space_written(fromds, ds,
|
||||
@ -884,15 +885,15 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
|
||||
|
||||
/* temporary clone name must not exist */
|
||||
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);
|
||||
if (error != ENOENT)
|
||||
return (error == 0 ? EBUSY : error);
|
||||
|
||||
/* new snapshot name must not exist */
|
||||
error = zap_lookup(dp->dp_meta_objset,
|
||||
ds->ds_phys->ds_snapnames_zapobj, drba->drba_cookie->drc_tosnap,
|
||||
8, 1, &val);
|
||||
dsl_dataset_phys(ds)->ds_snapnames_zapobj,
|
||||
drba->drba_cookie->drc_tosnap, 8, 1, &val);
|
||||
if (error != ENOENT)
|
||||
return (error == 0 ? EEXIST : error);
|
||||
|
||||
@ -912,7 +913,7 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
|
||||
|
||||
if (fromguid != 0) {
|
||||
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. */
|
||||
while (obj != 0) {
|
||||
@ -924,9 +925,9 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
|
||||
dsl_dataset_rele(snap, FTAG);
|
||||
return (SET_ERROR(ENODEV));
|
||||
}
|
||||
if (snap->ds_phys->ds_guid == fromguid)
|
||||
if (dsl_dataset_phys(snap)->ds_guid == fromguid)
|
||||
break;
|
||||
obj = snap->ds_phys->ds_prev_snap_obj;
|
||||
obj = dsl_dataset_phys(snap)->ds_prev_snap_obj;
|
||||
dsl_dataset_rele(snap, FTAG);
|
||||
}
|
||||
if (obj == 0)
|
||||
@ -949,9 +950,9 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
|
||||
dsl_dataset_rele(snap, FTAG);
|
||||
} else {
|
||||
/* 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));
|
||||
drba->drba_snapobj = ds->ds_phys->ds_prev_snap_obj;
|
||||
drba->drba_snapobj = dsl_dataset_phys(ds)->ds_prev_snap_obj;
|
||||
}
|
||||
|
||||
return (0);
|
||||
@ -1069,7 +1070,7 @@ dmu_recv_begin_check(void *arg, dmu_tx_t *tx)
|
||||
dsl_dataset_rele(ds, FTAG);
|
||||
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(ds, FTAG);
|
||||
return (SET_ERROR(ENODEV));
|
||||
@ -1140,7 +1141,7 @@ dmu_recv_begin_sync(void *arg, dmu_tx_t *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
|
||||
@ -1777,7 +1778,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp,
|
||||
*/
|
||||
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);
|
||||
|
||||
@ -1940,8 +1941,11 @@ dmu_recv_end_check(void *arg, dmu_tx_t *tx)
|
||||
* the snap before drc_ds, because drc_ds can not
|
||||
* have any snaps of its own).
|
||||
*/
|
||||
uint64_t obj = origin_head->ds_phys->ds_prev_snap_obj;
|
||||
while (obj != drc->drc_ds->ds_phys->ds_prev_snap_obj) {
|
||||
uint64_t 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;
|
||||
error = dsl_dataset_hold_obj(dp, obj, FTAG,
|
||||
&snap);
|
||||
@ -1953,7 +1957,7 @@ dmu_recv_end_check(void *arg, dmu_tx_t *tx)
|
||||
error = dsl_destroy_snapshot_check_impl(
|
||||
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);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
@ -1999,13 +2003,16 @@ dmu_recv_end_sync(void *arg, dmu_tx_t *tx)
|
||||
* Destroy any snapshots of drc_tofs (origin_head)
|
||||
* after the origin (the snap before drc_ds).
|
||||
*/
|
||||
uint64_t obj = origin_head->ds_phys->ds_prev_snap_obj;
|
||||
while (obj != drc->drc_ds->ds_phys->ds_prev_snap_obj) {
|
||||
uint64_t 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;
|
||||
VERIFY0(dsl_dataset_hold_obj(dp, obj, FTAG,
|
||||
&snap));
|
||||
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,
|
||||
B_FALSE, tx);
|
||||
dsl_dataset_rele(snap, FTAG);
|
||||
@ -2021,15 +2028,16 @@ dmu_recv_end_sync(void *arg, dmu_tx_t *tx)
|
||||
|
||||
/* set snapshot's creation time and guid */
|
||||
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;
|
||||
origin_head->ds_prev->ds_phys->ds_guid =
|
||||
dsl_dataset_phys(origin_head->ds_prev)->ds_guid =
|
||||
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;
|
||||
|
||||
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_destroy_head_sync_impl(drc->drc_ds, tx);
|
||||
@ -2043,15 +2051,17 @@ dmu_recv_end_sync(void *arg, dmu_tx_t *tx)
|
||||
|
||||
/* set snapshot's creation time and guid */
|
||||
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;
|
||||
ds->ds_prev->ds_phys->ds_guid = drc->drc_drrb->drr_toguid;
|
||||
ds->ds_prev->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT;
|
||||
dsl_dataset_phys(ds->ds_prev)->ds_guid =
|
||||
drc->drc_drrb->drr_toguid;
|
||||
dsl_dataset_phys(ds->ds_prev)->ds_flags &=
|
||||
~DS_FLAG_INCONSISTENT;
|
||||
|
||||
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
|
||||
* we return to open context, so that when we free the dataset's dnode,
|
||||
@ -2077,7 +2087,7 @@ add_ds_to_guidmap(const char *name, avl_tree_t *guid_map, uint64_t snapobj)
|
||||
gmep = kmem_alloc(sizeof (*gmep), KM_SLEEP);
|
||||
err = dsl_dataset_hold_obj(dp, snapobj, gmep, &snapds);
|
||||
if (err == 0) {
|
||||
gmep->guid = snapds->ds_phys->ds_guid;
|
||||
gmep->guid = dsl_dataset_phys(snapds)->ds_guid;
|
||||
gmep->gme_ds = snapds;
|
||||
avl_add(guid_map, gmep);
|
||||
dsl_dataset_long_hold(snapds, gmep);
|
||||
|
@ -579,7 +579,7 @@ traverse_dataset(dsl_dataset_t *ds, uint64_t txg_start, int flags,
|
||||
blkptr_cb_t func, void *arg)
|
||||
{
|
||||
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
|
||||
@ -634,8 +634,8 @@ traverse_pool(spa_t *spa, uint64_t txg_start, int flags,
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
if (ds->ds_phys->ds_prev_snap_txg > txg)
|
||||
txg = ds->ds_phys->ds_prev_snap_txg;
|
||||
if (dsl_dataset_phys(ds)->ds_prev_snap_txg > txg)
|
||||
txg = dsl_dataset_phys(ds)->ds_prev_snap_txg;
|
||||
err = traverse_dataset(ds, txg, flags, func, arg);
|
||||
dsl_dataset_rele(ds, FTAG);
|
||||
if (err != 0)
|
||||
|
@ -713,6 +713,7 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name)
|
||||
{
|
||||
dmu_tx_hold_t *txh;
|
||||
dnode_t *dn;
|
||||
dsl_dataset_phys_t *ds_phys;
|
||||
uint64_t nblocks;
|
||||
int epbs, err;
|
||||
|
||||
@ -787,8 +788,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.
|
||||
*/
|
||||
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)
|
||||
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;
|
||||
else
|
||||
txh->txh_space_tooverwrite += 3 << dn->dn_indblkshift;
|
||||
|
@ -1116,7 +1116,7 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag,
|
||||
zrl_init(&dnh[i].dnh_zrlock);
|
||||
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)) {
|
||||
|
||||
for (i = 0; i < epb; i++) {
|
||||
|
@ -65,7 +65,7 @@ dsl_dataset_bmark_lookup(dsl_dataset_t *ds, const char *shortname,
|
||||
if (bmark_zapobj == 0)
|
||||
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;
|
||||
else
|
||||
mt = MT_EXACT;
|
||||
@ -208,10 +208,11 @@ dsl_bookmark_create_sync(void *arg, dmu_tx_t *tx)
|
||||
&bmark_fs->ds_bookmarks, tx));
|
||||
}
|
||||
|
||||
bmark_phys.zbm_guid = snapds->ds_phys->ds_guid;
|
||||
bmark_phys.zbm_creation_txg = snapds->ds_phys->ds_creation_txg;
|
||||
bmark_phys.zbm_guid = dsl_dataset_phys(snapds)->ds_guid;
|
||||
bmark_phys.zbm_creation_txg =
|
||||
dsl_dataset_phys(snapds)->ds_creation_txg;
|
||||
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,
|
||||
shortname, sizeof (uint64_t),
|
||||
@ -340,7 +341,7 @@ dsl_dataset_bookmark_remove(dsl_dataset_t *ds, const char *name, dmu_tx_t *tx)
|
||||
uint64_t bmark_zapobj = ds->ds_bookmarks;
|
||||
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;
|
||||
else
|
||||
mt = MT_EXACT;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -308,8 +308,9 @@ dsl_deadlist_regenerate(objset_t *os, uint64_t dlobj,
|
||||
while (mrs_obj != 0) {
|
||||
dsl_dataset_t *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);
|
||||
mrs_obj = ds->ds_phys->ds_prev_snap_obj;
|
||||
dsl_deadlist_add_key(&dl,
|
||||
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_deadlist_close(&dl);
|
||||
|
@ -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));
|
||||
|
||||
zapobj = dd->dd_phys->dd_deleg_zapobj;
|
||||
zapobj = dsl_dir_phys(dd)->dd_deleg_zapobj;
|
||||
if (zapobj == 0) {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ dsl_deleg_unset_sync(void *arg, dmu_tx_t *tx)
|
||||
uint64_t zapobj;
|
||||
|
||||
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) {
|
||||
dsl_dir_rele(dd, FTAG);
|
||||
return;
|
||||
@ -332,14 +332,14 @@ dsl_deleg_get(const char *ddname, nvlist_t **nvp)
|
||||
uint64_t n;
|
||||
char source[MAXNAMELEN];
|
||||
|
||||
if (dd->dd_phys->dd_deleg_zapobj == 0 ||
|
||||
zap_count(mos, dd->dd_phys->dd_deleg_zapobj, &n) != 0 ||
|
||||
n == 0)
|
||||
if (dsl_dir_phys(dd)->dd_deleg_zapobj == 0 ||
|
||||
zap_count(mos,
|
||||
dsl_dir_phys(dd)->dd_deleg_zapobj, &n) != 0 || n == 0)
|
||||
continue;
|
||||
|
||||
sp_nvp = fnvlist_alloc();
|
||||
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_advance(&basezc)) {
|
||||
zap_cursor_t zc;
|
||||
@ -594,7 +594,7 @@ dsl_deleg_access_impl(dsl_dataset_t *ds, const char *perm, cred_t *cr)
|
||||
if (!zoned)
|
||||
break;
|
||||
}
|
||||
zapobj = dd->dd_phys->dd_deleg_zapobj;
|
||||
zapobj = dsl_dir_phys(dd)->dd_deleg_zapobj;
|
||||
|
||||
if (zapobj == 0)
|
||||
continue;
|
||||
@ -673,7 +673,7 @@ copy_create_perms(dsl_dir_t *dd, uint64_t pzapobj,
|
||||
{
|
||||
objset_t *mos = dd->dd_pool->dp_meta_objset;
|
||||
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_attribute_t za;
|
||||
char whokey[ZFS_MAX_DELEG_NAME];
|
||||
@ -686,7 +686,7 @@ copy_create_perms(dsl_dir_t *dd, uint64_t pzapobj,
|
||||
|
||||
if (zapobj == 0) {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -724,7 +724,7 @@ dsl_deleg_set_create_perms(dsl_dir_t *sdd, dmu_tx_t *tx, cred_t *cr)
|
||||
return;
|
||||
|
||||
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)
|
||||
continue;
|
||||
|
@ -78,7 +78,7 @@ dsl_destroy_snapshot_check_impl(dsl_dataset_t *ds, boolean_t defer)
|
||||
/*
|
||||
* 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 (0);
|
||||
@ -147,12 +147,12 @@ process_old_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
|
||||
|
||||
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);
|
||||
if (poa->ds_prev && !poa->after_branch_point &&
|
||||
bp->blk_birth >
|
||||
poa->ds_prev->ds_phys->ds_prev_snap_txg) {
|
||||
poa->ds_prev->ds_phys->ds_unique_bytes +=
|
||||
dsl_dataset_phys(poa->ds_prev)->ds_prev_snap_txg) {
|
||||
dsl_dataset_phys(poa->ds_prev)->ds_unique_bytes +=
|
||||
bp_get_dsize_sync(dp->dp_spa, bp);
|
||||
}
|
||||
} 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,
|
||||
process_old_cb, &poa, tx));
|
||||
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 */
|
||||
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 */
|
||||
dsl_deadlist_close(&ds->ds_deadlist);
|
||||
dsl_deadlist_close(&ds_next->ds_deadlist);
|
||||
deadlist_obj = ds->ds_phys->ds_deadlist_obj;
|
||||
ds->ds_phys->ds_deadlist_obj = ds_next->ds_phys->ds_deadlist_obj;
|
||||
ds_next->ds_phys->ds_deadlist_obj = deadlist_obj;
|
||||
dsl_deadlist_open(&ds->ds_deadlist, mos, ds->ds_phys->ds_deadlist_obj);
|
||||
deadlist_obj = dsl_dataset_phys(ds)->ds_deadlist_obj;
|
||||
dsl_dataset_phys(ds)->ds_deadlist_obj =
|
||||
dsl_dataset_phys(ds_next)->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,
|
||||
ds_next->ds_phys->ds_deadlist_obj);
|
||||
dsl_dataset_phys(ds_next)->ds_deadlist_obj);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -212,10 +214,10 @@ 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
|
||||
* doesn't matter.
|
||||
*/
|
||||
if (ds->ds_dir->dd_phys->dd_clones == 0)
|
||||
if (dsl_dir_phys(ds->ds_dir)->dd_clones == 0)
|
||||
return;
|
||||
|
||||
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_advance(&zc)) {
|
||||
dsl_dataset_t *clone;
|
||||
@ -243,19 +245,20 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
|
||||
uint64_t obj;
|
||||
|
||||
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));
|
||||
|
||||
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);
|
||||
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, "");
|
||||
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. */
|
||||
spa_history_log_internal_ds(ds, "destroy", tx, "");
|
||||
@ -268,26 +271,28 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
|
||||
ASSERT0(zap_contains(mos, obj, DS_FIELD_LARGE_BLOCKS));
|
||||
spa_feature_decr(dp->dp_spa, SPA_FEATURE_LARGE_BLOCKS, tx);
|
||||
}
|
||||
if (ds->ds_phys->ds_prev_snap_obj != 0) {
|
||||
if (dsl_dataset_phys(ds)->ds_prev_snap_obj != 0) {
|
||||
ASSERT3P(ds->ds_prev, ==, NULL);
|
||||
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 =
|
||||
(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);
|
||||
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);
|
||||
if (ds->ds_phys->ds_next_snap_obj != 0) {
|
||||
if (dsl_dataset_phys(ds)->ds_next_snap_obj != 0) {
|
||||
VERIFY0(zap_add_int(mos,
|
||||
ds_prev->ds_phys->ds_next_clones_obj,
|
||||
ds->ds_phys->ds_next_snap_obj, tx));
|
||||
dsl_dataset_phys(ds_prev)->
|
||||
ds_next_clones_obj,
|
||||
dsl_dataset_phys(ds)->ds_next_snap_obj,
|
||||
tx));
|
||||
}
|
||||
}
|
||||
if (!after_branch_point) {
|
||||
ds_prev->ds_phys->ds_next_snap_obj =
|
||||
ds->ds_phys->ds_next_snap_obj;
|
||||
dsl_dataset_phys(ds_prev)->ds_next_snap_obj =
|
||||
dsl_dataset_phys(ds)->ds_next_snap_obj;
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,18 +301,18 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
|
||||
uint64_t used = 0, comp = 0, uncomp = 0;
|
||||
|
||||
VERIFY0(dsl_dataset_hold_obj(dp,
|
||||
ds->ds_phys->ds_next_snap_obj, FTAG, &ds_next));
|
||||
ASSERT3U(ds_next->ds_phys->ds_prev_snap_obj, ==, obj);
|
||||
dsl_dataset_phys(ds)->ds_next_snap_obj, FTAG, &ds_next));
|
||||
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);
|
||||
ds_next->ds_phys->ds_prev_snap_obj =
|
||||
ds->ds_phys->ds_prev_snap_obj;
|
||||
ds_next->ds_phys->ds_prev_snap_txg =
|
||||
ds->ds_phys->ds_prev_snap_txg;
|
||||
ASSERT3U(ds->ds_phys->ds_prev_snap_txg, ==,
|
||||
ds_prev ? ds_prev->ds_phys->ds_creation_txg : 0);
|
||||
dsl_dataset_phys(ds_next)->ds_prev_snap_obj =
|
||||
dsl_dataset_phys(ds)->ds_prev_snap_obj;
|
||||
dsl_dataset_phys(ds_next)->ds_prev_snap_txg =
|
||||
dsl_dataset_phys(ds)->ds_prev_snap_txg;
|
||||
ASSERT3U(dsl_dataset_phys(ds)->ds_prev_snap_txg, ==,
|
||||
ds_prev ? dsl_dataset_phys(ds_prev)->ds_creation_txg : 0);
|
||||
|
||||
if (ds_next->ds_deadlist.dl_oldfmt) {
|
||||
process_old_deadlist(ds, ds_prev, ds_next,
|
||||
@ -316,38 +321,38 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
|
||||
/* Adjust prev's unique space. */
|
||||
if (ds_prev && !after_branch_point) {
|
||||
dsl_deadlist_space_range(&ds_next->ds_deadlist,
|
||||
ds_prev->ds_phys->ds_prev_snap_txg,
|
||||
ds->ds_phys->ds_prev_snap_txg,
|
||||
dsl_dataset_phys(ds_prev)->ds_prev_snap_txg,
|
||||
dsl_dataset_phys(ds)->ds_prev_snap_txg,
|
||||
&used, &comp, &uncomp);
|
||||
ds_prev->ds_phys->ds_unique_bytes += used;
|
||||
dsl_dataset_phys(ds_prev)->ds_unique_bytes += used;
|
||||
}
|
||||
|
||||
/* Adjust snapused. */
|
||||
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);
|
||||
dsl_dir_diduse_space(ds->ds_dir, DD_USED_SNAP,
|
||||
-used, -comp, -uncomp, tx);
|
||||
|
||||
/* Move blocks to be freed to pool's free list. */
|
||||
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);
|
||||
dsl_dir_diduse_space(tx->tx_pool->dp_free_dir,
|
||||
DD_USED_HEAD, used, comp, uncomp, tx);
|
||||
|
||||
/* Merge our deadlist into next's and free it. */
|
||||
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_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);
|
||||
ds->ds_phys->ds_deadlist_obj = 0;
|
||||
dsl_dataset_phys(ds)->ds_deadlist_obj = 0;
|
||||
|
||||
/* Collapse range in clone heads */
|
||||
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)) {
|
||||
dsl_dataset_t *ds_nextnext;
|
||||
@ -362,21 +367,22 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
|
||||
* deadlist).
|
||||
*/
|
||||
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,
|
||||
ds->ds_phys->ds_prev_snap_txg,
|
||||
ds->ds_phys->ds_creation_txg,
|
||||
dsl_dataset_phys(ds)->ds_prev_snap_txg,
|
||||
dsl_dataset_phys(ds)->ds_creation_txg,
|
||||
&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);
|
||||
ASSERT3P(ds_next->ds_prev, ==, NULL);
|
||||
|
||||
/* Collapse range in this head. */
|
||||
dsl_dataset_t *hds;
|
||||
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,
|
||||
ds->ds_phys->ds_creation_txg, tx);
|
||||
dsl_dataset_phys(ds)->ds_creation_txg, tx);
|
||||
dsl_dataset_rele(hds, FTAG);
|
||||
|
||||
} else {
|
||||
@ -385,7 +391,7 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
|
||||
ds_next->ds_prev = NULL;
|
||||
if (ds_prev) {
|
||||
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));
|
||||
}
|
||||
|
||||
@ -399,7 +405,7 @@ dsl_destroy_snapshot_sync_impl(dsl_dataset_t *ds, boolean_t defer, dmu_tx_t *tx)
|
||||
if (old_unique < ds_next->ds_reserved) {
|
||||
int64_t mrsdelta;
|
||||
uint64_t new_unique =
|
||||
ds_next->ds_phys->ds_unique_bytes;
|
||||
dsl_dataset_phys(ds_next)->ds_unique_bytes;
|
||||
|
||||
ASSERT(old_unique <= new_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 */
|
||||
dsl_dataset_t *ds_head;
|
||||
ASSERT(ds->ds_phys->ds_snapnames_zapobj == 0);
|
||||
ASSERT(dsl_dataset_phys(ds)->ds_snapnames_zapobj == 0);
|
||||
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));
|
||||
#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);
|
||||
|
||||
if (ds->ds_phys->ds_next_clones_obj != 0) {
|
||||
if (dsl_dataset_phys(ds)->ds_next_clones_obj != 0) {
|
||||
uint64_t count;
|
||||
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,
|
||||
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)
|
||||
VERIFY0(zap_destroy(mos, ds->ds_phys->ds_props_obj, tx));
|
||||
if (ds->ds_phys->ds_userrefs_obj != 0)
|
||||
VERIFY0(zap_destroy(mos, ds->ds_phys->ds_userrefs_obj, tx));
|
||||
if (dsl_dataset_phys(ds)->ds_props_obj != 0)
|
||||
VERIFY0(zap_destroy(mos, dsl_dataset_phys(ds)->ds_props_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);
|
||||
ds->ds_dir = NULL;
|
||||
dmu_object_free_zapified(mos, obj, tx);
|
||||
@ -555,7 +564,8 @@ kill_blkptr(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
|
||||
dsl_free(ka->tx->tx_pool, ka->tx->tx_txg, bp);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -577,9 +587,10 @@ old_synchronous_dataset_destroy(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
ka.ds = ds;
|
||||
ka.tx = tx;
|
||||
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));
|
||||
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 {
|
||||
@ -608,21 +619,21 @@ dsl_destroy_head_check_impl(dsl_dataset_t *ds, int expected_holds)
|
||||
* from.)
|
||||
*/
|
||||
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));
|
||||
|
||||
/*
|
||||
* Can't delete if there are children of this fs.
|
||||
*/
|
||||
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)
|
||||
return (error);
|
||||
if (count != 0)
|
||||
return (SET_ERROR(EEXIST));
|
||||
|
||||
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) {
|
||||
/* We need to remove the origin snapshot as well. */
|
||||
if (!refcount_is_zero(&ds->ds_prev->ds_longholds))
|
||||
@ -660,7 +671,7 @@ dsl_dir_destroy_sync(uint64_t ddobj, dmu_tx_t *tx)
|
||||
|
||||
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.
|
||||
@ -679,16 +690,17 @@ dsl_dir_destroy_sync(uint64_t ddobj, dmu_tx_t *tx)
|
||||
*/
|
||||
dsl_dir_set_reservation_sync_impl(dd, 0, tx);
|
||||
|
||||
ASSERT0(dd->dd_phys->dd_used_bytes);
|
||||
ASSERT0(dd->dd_phys->dd_reserved);
|
||||
ASSERT0(dsl_dir_phys(dd)->dd_used_bytes);
|
||||
ASSERT0(dsl_dir_phys(dd)->dd_reserved);
|
||||
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, dd->dd_phys->dd_props_zapobj, tx));
|
||||
VERIFY0(dsl_deleg_destroy(mos, dd->dd_phys->dd_deleg_zapobj, tx));
|
||||
VERIFY0(zap_destroy(mos, dsl_dir_phys(dd)->dd_child_dir_zapobj, tx));
|
||||
VERIFY0(zap_destroy(mos, dsl_dir_phys(dd)->dd_props_zapobj, tx));
|
||||
VERIFY0(dsl_deleg_destroy(mos, dsl_dir_phys(dd)->dd_deleg_zapobj, tx));
|
||||
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);
|
||||
dmu_object_free_zapified(mos, ddobj, tx);
|
||||
@ -702,10 +714,10 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
uint64_t obj, ddobj, prevobj = 0;
|
||||
boolean_t rmorigin;
|
||||
|
||||
ASSERT3U(ds->ds_phys->ds_num_children, <=, 1);
|
||||
ASSERT3U(dsl_dataset_phys(ds)->ds_num_children, <=, 1);
|
||||
ASSERT(ds->ds_prev == NULL ||
|
||||
ds->ds_prev->ds_phys->ds_next_snap_obj != ds->ds_object);
|
||||
ASSERT3U(ds->ds_phys->ds_bp.blk_birth, <=, tx->tx_txg);
|
||||
dsl_dataset_phys(ds->ds_prev)->ds_next_snap_obj != ds->ds_object);
|
||||
ASSERT3U(dsl_dataset_phys(ds)->ds_bp.blk_birth, <=, tx->tx_txg);
|
||||
ASSERT(RRW_WRITE_HELD(&dp->dp_config_rwlock));
|
||||
|
||||
/* We need to log before removing it from the namespace. */
|
||||
@ -713,7 +725,7 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
|
||||
rmorigin = (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);
|
||||
|
||||
/* Remove our reservation. */
|
||||
@ -731,20 +743,21 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
|
||||
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 */
|
||||
ASSERT(ds->ds_prev != NULL);
|
||||
ASSERT3U(ds->ds_prev->ds_phys->ds_next_snap_obj, !=, obj);
|
||||
ASSERT0(ds->ds_phys->ds_next_snap_obj);
|
||||
ASSERT3U(dsl_dataset_phys(ds->ds_prev)->ds_next_snap_obj, !=,
|
||||
obj);
|
||||
ASSERT0(dsl_dataset_phys(ds)->ds_next_snap_obj);
|
||||
|
||||
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,
|
||||
obj, tx);
|
||||
}
|
||||
|
||||
ASSERT3U(ds->ds_prev->ds_phys->ds_num_children, >, 1);
|
||||
ds->ds_prev->ds_phys->ds_num_children--;
|
||||
ASSERT3U(dsl_dataset_phys(ds->ds_prev)->ds_num_children, >, 1);
|
||||
dsl_dataset_phys(ds->ds_prev)->ds_num_children--;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -753,9 +766,9 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
* safe to ignore the deadlist contents.)
|
||||
*/
|
||||
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);
|
||||
ds->ds_phys->ds_deadlist_obj = 0;
|
||||
dsl_dataset_phys(ds)->ds_deadlist_obj = 0;
|
||||
|
||||
objset_t *os;
|
||||
VERIFY0(dmu_objset_from_ds(ds, &os));
|
||||
@ -785,15 +798,16 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
scn->scn_async_destroying = B_TRUE;
|
||||
}
|
||||
|
||||
used = ds->ds_dir->dd_phys->dd_used_bytes;
|
||||
comp = ds->ds_dir->dd_phys->dd_compressed_bytes;
|
||||
uncomp = ds->ds_dir->dd_phys->dd_uncompressed_bytes;
|
||||
used = dsl_dir_phys(ds->ds_dir)->dd_used_bytes;
|
||||
comp = dsl_dir_phys(ds->ds_dir)->dd_compressed_bytes;
|
||||
uncomp = dsl_dir_phys(ds->ds_dir)->dd_uncompressed_bytes;
|
||||
|
||||
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,
|
||||
&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);
|
||||
dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD,
|
||||
-used, -comp, -uncomp, tx);
|
||||
@ -804,7 +818,7 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
if (ds->ds_prev != NULL) {
|
||||
if (spa_version(dp->dp_spa) >= SPA_VERSION_DIR_CLONES) {
|
||||
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));
|
||||
}
|
||||
prevobj = ds->ds_prev->ds_object;
|
||||
@ -823,22 +837,22 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
|
||||
/* Erase the link in the dir */
|
||||
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;
|
||||
ASSERT(ds->ds_phys->ds_snapnames_zapobj != 0);
|
||||
VERIFY0(zap_destroy(mos, ds->ds_phys->ds_snapnames_zapobj, tx));
|
||||
ASSERT(dsl_dataset_phys(ds)->ds_snapnames_zapobj != 0);
|
||||
VERIFY0(zap_destroy(mos,
|
||||
dsl_dataset_phys(ds)->ds_snapnames_zapobj, tx));
|
||||
|
||||
if (ds->ds_bookmarks != 0) {
|
||||
VERIFY0(zap_destroy(mos,
|
||||
ds->ds_bookmarks, tx));
|
||||
VERIFY0(zap_destroy(mos, ds->ds_bookmarks, tx));
|
||||
spa_feature_decr(dp->dp_spa, SPA_FEATURE_BOOKMARKS, tx);
|
||||
}
|
||||
|
||||
spa_prop_clear_bootfs(dp->dp_spa, ds->ds_object, tx);
|
||||
|
||||
ASSERT0(ds->ds_phys->ds_next_clones_obj);
|
||||
ASSERT0(ds->ds_phys->ds_props_obj);
|
||||
ASSERT0(ds->ds_phys->ds_userrefs_obj);
|
||||
ASSERT0(dsl_dataset_phys(ds)->ds_next_clones_obj);
|
||||
ASSERT0(dsl_dataset_phys(ds)->ds_props_obj);
|
||||
ASSERT0(dsl_dataset_phys(ds)->ds_userrefs_obj);
|
||||
dsl_dir_rele(ds->ds_dir, ds);
|
||||
ds->ds_dir = NULL;
|
||||
dmu_object_free_zapified(mos, obj, tx);
|
||||
@ -876,7 +890,7 @@ dsl_destroy_head_begin_sync(void *arg, dmu_tx_t *tx)
|
||||
|
||||
/* Mark it as inconsistent on-disk, in case we crash */
|
||||
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, "");
|
||||
dsl_dataset_rele(ds, FTAG);
|
||||
@ -919,7 +933,8 @@ dsl_destroy_head(const char *name)
|
||||
error = dmu_objset_own(name, DMU_OST_ANY, B_FALSE, FTAG, &os);
|
||||
if (error == 0) {
|
||||
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 (uint64_t obj = 0; error == 0;
|
||||
error = dmu_object_next(os, &obj, FALSE,
|
||||
prev_snap_txg))
|
||||
|
@ -121,6 +121,8 @@
|
||||
* 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);
|
||||
|
||||
/* ARGSUSED */
|
||||
@ -180,7 +182,6 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
|
||||
dd->dd_object = ddobj;
|
||||
dd->dd_dbuf = dbuf;
|
||||
dd->dd_pool = dp;
|
||||
dd->dd_phys = dbuf->db_data;
|
||||
mutex_init(&dd->dd_lock, NULL, MUTEX_DEFAULT, NULL);
|
||||
|
||||
list_create(&dd->dd_prop_cbs, sizeof (dsl_prop_cb_record_t),
|
||||
@ -188,9 +189,10 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
|
||||
|
||||
dsl_dir_snap_cmtime_update(dd);
|
||||
|
||||
if (dd->dd_phys->dd_parent_obj) {
|
||||
err = dsl_dir_hold_obj(dp, dd->dd_phys->dd_parent_obj,
|
||||
NULL, dd, &dd->dd_parent);
|
||||
if (dsl_dir_phys(dd)->dd_parent_obj) {
|
||||
err = dsl_dir_hold_obj(dp,
|
||||
dsl_dir_phys(dd)->dd_parent_obj, NULL, dd,
|
||||
&dd->dd_parent);
|
||||
if (err != 0)
|
||||
goto errout;
|
||||
if (tail) {
|
||||
@ -198,14 +200,16 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
|
||||
uint64_t foundobj;
|
||||
|
||||
err = zap_lookup(dp->dp_meta_objset,
|
||||
dd->dd_parent->dd_phys->dd_child_dir_zapobj,
|
||||
tail, sizeof (foundobj), 1, &foundobj);
|
||||
dsl_dir_phys(dd->dd_parent)->
|
||||
dd_child_dir_zapobj, tail,
|
||||
sizeof (foundobj), 1, &foundobj);
|
||||
ASSERT(err || foundobj == ddobj);
|
||||
#endif
|
||||
(void) strcpy(dd->dd_myname, tail);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
if (err != 0)
|
||||
@ -224,7 +228,8 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
|
||||
* Just look at its phys directly instead.
|
||||
*/
|
||||
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)
|
||||
goto errout;
|
||||
origin_phys = origin_bonus->db_data;
|
||||
@ -233,8 +238,7 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
|
||||
dmu_buf_rele(origin_bonus, FTAG);
|
||||
}
|
||||
|
||||
winner = dmu_buf_set_user_ie(dbuf, dd, &dd->dd_phys,
|
||||
dsl_dir_evict);
|
||||
winner = dmu_buf_set_user_ie(dbuf, dd, dsl_dir_evict);
|
||||
if (winner) {
|
||||
if (dd->dd_parent)
|
||||
dsl_dir_rele(dd->dd_parent, dd);
|
||||
@ -417,10 +421,10 @@ dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
|
||||
if (next[0] == '@')
|
||||
break;
|
||||
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,
|
||||
dd->dd_phys->dd_child_dir_zapobj,
|
||||
dsl_dir_phys(dd)->dd_child_dir_zapobj,
|
||||
buf, sizeof (ddobj), 1, &ddobj);
|
||||
if (err != 0) {
|
||||
if (err == ENOENT)
|
||||
@ -501,7 +505,7 @@ dsl_dir_init_fs_ss_count(dsl_dir_t *dd, dmu_tx_t *tx)
|
||||
za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
|
||||
|
||||
/* 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)) {
|
||||
dsl_dir_t *chld_dd;
|
||||
uint64_t count;
|
||||
@ -535,9 +539,9 @@ dsl_dir_init_fs_ss_count(dsl_dir_t *dd, dmu_tx_t *tx)
|
||||
zap_cursor_fini(zc);
|
||||
/* Count my snapshots (we counted children's snapshots above) */
|
||||
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_advance(zc)) {
|
||||
/* Don't count temporary snapshots */
|
||||
@ -686,7 +690,7 @@ dsl_enforce_ds_ss_limits(dsl_dir_t *dd, zfs_prop_t prop, cred_t *cr)
|
||||
return (ENFORCE_NEVER);
|
||||
#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);
|
||||
|
||||
ASSERT(dsl_pool_config_held(dd->dd_pool));
|
||||
@ -864,7 +868,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,
|
||||
DMU_OT_DSL_DIR, sizeof (dsl_dir_phys_t), tx);
|
||||
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));
|
||||
} else {
|
||||
/* it's the root dir */
|
||||
@ -896,9 +900,9 @@ dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds, const char *name,
|
||||
boolean_t
|
||||
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_phys->dd_origin_obj !=
|
||||
dsl_dir_phys(dd)->dd_origin_obj !=
|
||||
dd->dd_pool->dp_origin_snap->ds_object));
|
||||
}
|
||||
|
||||
@ -907,26 +911,27 @@ dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv)
|
||||
{
|
||||
mutex_enter(&dd->dd_lock);
|
||||
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED,
|
||||
dd->dd_phys->dd_used_bytes);
|
||||
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_QUOTA, dd->dd_phys->dd_quota);
|
||||
dsl_dir_phys(dd)->dd_used_bytes);
|
||||
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_QUOTA,
|
||||
dsl_dir_phys(dd)->dd_quota);
|
||||
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,
|
||||
dd->dd_phys->dd_compressed_bytes == 0 ? 100 :
|
||||
(dd->dd_phys->dd_uncompressed_bytes * 100 /
|
||||
dd->dd_phys->dd_compressed_bytes));
|
||||
dsl_dir_phys(dd)->dd_compressed_bytes == 0 ? 100 :
|
||||
(dsl_dir_phys(dd)->dd_uncompressed_bytes * 100 /
|
||||
dsl_dir_phys(dd)->dd_compressed_bytes));
|
||||
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_LOGICALUSED,
|
||||
dd->dd_phys->dd_uncompressed_bytes);
|
||||
if (dd->dd_phys->dd_flags & DD_FLAG_USED_BREAKDOWN) {
|
||||
dsl_dir_phys(dd)->dd_uncompressed_bytes);
|
||||
if (dsl_dir_phys(dd)->dd_flags & DD_FLAG_USED_BREAKDOWN) {
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
dd->dd_phys->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] +
|
||||
dsl_dir_phys(dd)->dd_used_breakdown[DD_USED_CHILD_RSRV]);
|
||||
}
|
||||
mutex_exit(&dd->dd_lock);
|
||||
|
||||
@ -951,7 +956,7 @@ dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv)
|
||||
char buf[MAXNAMELEN];
|
||||
|
||||
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_rele(ds, FTAG);
|
||||
dsl_prop_nvlist_add_string(nv, ZFS_PROP_ORIGIN, buf);
|
||||
@ -963,7 +968,7 @@ dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx)
|
||||
{
|
||||
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)) {
|
||||
/* up the hold count until we can be written out */
|
||||
@ -974,8 +979,9 @@ dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx)
|
||||
static int64_t
|
||||
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 new_accounted = MAX(used + delta, dd->dd_phys->dd_reserved);
|
||||
uint64_t old_accounted = MAX(used, dsl_dir_phys(dd)->dd_reserved);
|
||||
uint64_t new_accounted =
|
||||
MAX(used + delta, dsl_dir_phys(dd)->dd_reserved);
|
||||
return (new_accounted - old_accounted);
|
||||
}
|
||||
|
||||
@ -1034,9 +1040,9 @@ dsl_dir_space_available(dsl_dir_t *dd,
|
||||
}
|
||||
|
||||
mutex_enter(&dd->dd_lock);
|
||||
if (dd->dd_phys->dd_quota != 0)
|
||||
quota = dd->dd_phys->dd_quota;
|
||||
used = dd->dd_phys->dd_used_bytes;
|
||||
if (dsl_dir_phys(dd)->dd_quota != 0)
|
||||
quota = dsl_dir_phys(dd)->dd_quota;
|
||||
used = dsl_dir_phys(dd)->dd_used_bytes;
|
||||
if (!ondiskonly)
|
||||
used += dsl_dir_space_towrite(dd);
|
||||
|
||||
@ -1045,12 +1051,12 @@ dsl_dir_space_available(dsl_dir_t *dd,
|
||||
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
|
||||
* parent gave us.
|
||||
*/
|
||||
parentspace += dd->dd_phys->dd_reserved - used;
|
||||
parentspace += dsl_dir_phys(dd)->dd_reserved - used;
|
||||
}
|
||||
|
||||
if (dd == ancestor) {
|
||||
@ -1109,7 +1115,7 @@ dsl_dir_tempreserve_impl(dsl_dir_t *dd, uint64_t asize, boolean_t netfree,
|
||||
est_inflight = dsl_dir_space_towrite(dd);
|
||||
for (i = 0; i < TXG_SIZE; 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
|
||||
@ -1132,10 +1138,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,
|
||||
* 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;
|
||||
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
|
||||
@ -1189,7 +1195,7 @@ dsl_dir_tempreserve_impl(dsl_dir_t *dd, uint64_t asize, boolean_t netfree,
|
||||
|
||||
/* see if it's OK with our parent */
|
||||
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,
|
||||
parent_rsrv, netfree, ismos, TRUE, tr_list, tx, FALSE));
|
||||
@ -1308,7 +1314,7 @@ dsl_dir_willuse_space(dsl_dir_t *dd, int64_t space, dmu_tx_t *tx)
|
||||
if (space > 0)
|
||||
dd->dd_space_towrite[tx->tx_txg & TXG_MASK] += space;
|
||||
|
||||
est_used = dsl_dir_space_towrite(dd) + dd->dd_phys->dd_used_bytes;
|
||||
est_used = dsl_dir_space_towrite(dd) + dsl_dir_phys(dd)->dd_used_bytes;
|
||||
parent_space = parent_delta(dd, est_used, space);
|
||||
mutex_exit(&dd->dd_lock);
|
||||
|
||||
@ -1343,26 +1349,27 @@ dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type,
|
||||
|
||||
if (needlock)
|
||||
mutex_enter(&dd->dd_lock);
|
||||
accounted_delta = parent_delta(dd, dd->dd_phys->dd_used_bytes, used);
|
||||
ASSERT(used >= 0 || dd->dd_phys->dd_used_bytes >= -used);
|
||||
accounted_delta =
|
||||
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 ||
|
||||
dd->dd_phys->dd_compressed_bytes >= -compressed);
|
||||
dsl_dir_phys(dd)->dd_compressed_bytes >= -compressed);
|
||||
ASSERT(uncompressed >= 0 ||
|
||||
dd->dd_phys->dd_uncompressed_bytes >= -uncompressed);
|
||||
dd->dd_phys->dd_used_bytes += used;
|
||||
dd->dd_phys->dd_uncompressed_bytes += uncompressed;
|
||||
dd->dd_phys->dd_compressed_bytes += compressed;
|
||||
dsl_dir_phys(dd)->dd_uncompressed_bytes >= -uncompressed);
|
||||
dsl_dir_phys(dd)->dd_used_bytes += used;
|
||||
dsl_dir_phys(dd)->dd_uncompressed_bytes += uncompressed;
|
||||
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 ||
|
||||
dd->dd_phys->dd_used_breakdown[type] >= -used);
|
||||
dd->dd_phys->dd_used_breakdown[type] += used;
|
||||
dsl_dir_phys(dd)->dd_used_breakdown[type] >= -used);
|
||||
dsl_dir_phys(dd)->dd_used_breakdown[type] += used;
|
||||
#ifdef DEBUG
|
||||
dd_used_t t;
|
||||
uint64_t u = 0;
|
||||
for (t = 0; t < DD_USED_NUM; t++)
|
||||
u += dd->dd_phys->dd_used_breakdown[t];
|
||||
ASSERT3U(u, ==, dd->dd_phys->dd_used_bytes);
|
||||
u += dsl_dir_phys(dd)->dd_used_breakdown[t];
|
||||
ASSERT3U(u, ==, dsl_dir_phys(dd)->dd_used_bytes);
|
||||
#endif
|
||||
}
|
||||
if (needlock)
|
||||
@ -1385,17 +1392,18 @@ dsl_dir_transfer_space(dsl_dir_t *dd, int64_t delta,
|
||||
ASSERT(oldtype < 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;
|
||||
|
||||
dmu_buf_will_dirty(dd->dd_dbuf, tx);
|
||||
mutex_enter(&dd->dd_lock);
|
||||
ASSERT(delta > 0 ?
|
||||
dd->dd_phys->dd_used_breakdown[oldtype] >= delta :
|
||||
dd->dd_phys->dd_used_breakdown[newtype] >= -delta);
|
||||
ASSERT(dd->dd_phys->dd_used_bytes >= ABS(delta));
|
||||
dd->dd_phys->dd_used_breakdown[oldtype] -= delta;
|
||||
dd->dd_phys->dd_used_breakdown[newtype] += delta;
|
||||
dsl_dir_phys(dd)->dd_used_breakdown[oldtype] >= delta :
|
||||
dsl_dir_phys(dd)->dd_used_breakdown[newtype] >= -delta);
|
||||
ASSERT(dsl_dir_phys(dd)->dd_used_bytes >= ABS(delta));
|
||||
dsl_dir_phys(dd)->dd_used_breakdown[oldtype] -= delta;
|
||||
dsl_dir_phys(dd)->dd_used_breakdown[newtype] += delta;
|
||||
mutex_exit(&dd->dd_lock);
|
||||
}
|
||||
|
||||
@ -1439,8 +1447,8 @@ dsl_dir_set_quota_check(void *arg, dmu_tx_t *tx)
|
||||
*/
|
||||
towrite = dsl_dir_space_towrite(ds->ds_dir);
|
||||
if ((dmu_tx_is_syncing(tx) || towrite == 0) &&
|
||||
(newval < ds->ds_dir->dd_phys->dd_reserved ||
|
||||
newval < ds->ds_dir->dd_phys->dd_used_bytes + towrite)) {
|
||||
(newval < dsl_dir_phys(ds->ds_dir)->dd_reserved ||
|
||||
newval < dsl_dir_phys(ds->ds_dir)->dd_used_bytes + towrite)) {
|
||||
error = SET_ERROR(ENOSPC);
|
||||
}
|
||||
mutex_exit(&ds->ds_dir->dd_lock);
|
||||
@ -1473,7 +1481,7 @@ dsl_dir_set_quota_sync(void *arg, dmu_tx_t *tx)
|
||||
|
||||
dmu_buf_will_dirty(ds->ds_dir->dd_dbuf, tx);
|
||||
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);
|
||||
dsl_dataset_rele(ds, FTAG);
|
||||
}
|
||||
@ -1524,7 +1532,7 @@ dsl_dir_set_reservation_check(void *arg, dmu_tx_t *tx)
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (dd->dd_parent) {
|
||||
@ -1534,13 +1542,13 @@ dsl_dir_set_reservation_check(void *arg, dmu_tx_t *tx)
|
||||
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) -
|
||||
MAX(used, dd->dd_phys->dd_reserved);
|
||||
MAX(used, dsl_dir_phys(dd)->dd_reserved);
|
||||
|
||||
if (delta > avail ||
|
||||
(dd->dd_phys->dd_quota > 0 &&
|
||||
newval > dd->dd_phys->dd_quota))
|
||||
(dsl_dir_phys(dd)->dd_quota > 0 &&
|
||||
newval > dsl_dir_phys(dd)->dd_quota))
|
||||
error = SET_ERROR(ENOSPC);
|
||||
}
|
||||
|
||||
@ -1557,9 +1565,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);
|
||||
|
||||
mutex_enter(&dd->dd_lock);
|
||||
used = dd->dd_phys->dd_used_bytes;
|
||||
delta = MAX(used, value) - MAX(used, dd->dd_phys->dd_reserved);
|
||||
dd->dd_phys->dd_reserved = value;
|
||||
used = dsl_dir_phys(dd)->dd_used_bytes;
|
||||
delta = MAX(used, value) - MAX(used, dsl_dir_phys(dd)->dd_reserved);
|
||||
dsl_dir_phys(dd)->dd_reserved = value;
|
||||
|
||||
if (dd->dd_parent != NULL) {
|
||||
/* Roll up this additional usage into our ancestors */
|
||||
@ -1637,7 +1645,7 @@ would_change(dsl_dir_t *dd, int64_t delta, dsl_dir_t *ancestor)
|
||||
return (delta);
|
||||
|
||||
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);
|
||||
return (would_change(dd->dd_parent, delta, ancestor));
|
||||
}
|
||||
@ -1728,7 +1736,8 @@ dsl_dir_rename_check(void *arg, dmu_tx_t *tx)
|
||||
if (newparent != dd->dd_parent) {
|
||||
/* is there enough space? */
|
||||
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;
|
||||
uint64_t fs_cnt = 0;
|
||||
uint64_t ss_cnt = 0;
|
||||
@ -1833,17 +1842,18 @@ dsl_dir_rename_sync(void *arg, dmu_tx_t *tx)
|
||||
DD_FIELD_SNAPSHOT_COUNT, tx);
|
||||
|
||||
dsl_dir_diduse_space(dd->dd_parent, DD_USED_CHILD,
|
||||
-dd->dd_phys->dd_used_bytes,
|
||||
-dd->dd_phys->dd_compressed_bytes,
|
||||
-dd->dd_phys->dd_uncompressed_bytes, tx);
|
||||
-dsl_dir_phys(dd)->dd_used_bytes,
|
||||
-dsl_dir_phys(dd)->dd_compressed_bytes,
|
||||
-dsl_dir_phys(dd)->dd_uncompressed_bytes, tx);
|
||||
dsl_dir_diduse_space(newparent, DD_USED_CHILD,
|
||||
dd->dd_phys->dd_used_bytes,
|
||||
dd->dd_phys->dd_compressed_bytes,
|
||||
dd->dd_phys->dd_uncompressed_bytes, tx);
|
||||
dsl_dir_phys(dd)->dd_used_bytes,
|
||||
dsl_dir_phys(dd)->dd_compressed_bytes,
|
||||
dsl_dir_phys(dd)->dd_uncompressed_bytes, tx);
|
||||
|
||||
if (dd->dd_phys->dd_reserved > dd->dd_phys->dd_used_bytes) {
|
||||
uint64_t unused_rsrv = dd->dd_phys->dd_reserved -
|
||||
dd->dd_phys->dd_used_bytes;
|
||||
if (dsl_dir_phys(dd)->dd_reserved >
|
||||
dsl_dir_phys(dd)->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,
|
||||
-unused_rsrv, 0, 0, tx);
|
||||
@ -1855,18 +1865,19 @@ dsl_dir_rename_sync(void *arg, dmu_tx_t *tx)
|
||||
dmu_buf_will_dirty(dd->dd_dbuf, tx);
|
||||
|
||||
/* 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);
|
||||
ASSERT0(error);
|
||||
|
||||
(void) strcpy(dd->dd_myname, mynewname);
|
||||
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,
|
||||
newparent->dd_object, NULL, dd, &dd->dd_parent));
|
||||
|
||||
/* 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));
|
||||
|
||||
dsl_prop_notify_all(dd);
|
||||
|
@ -135,7 +135,7 @@ dsl_pool_open_special_dir(dsl_pool_t *dp, const char *name, dsl_dir_t **ddp)
|
||||
int err;
|
||||
|
||||
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);
|
||||
if (err)
|
||||
return (err);
|
||||
@ -217,11 +217,11 @@ dsl_pool_open(dsl_pool_t *dp)
|
||||
err = dsl_pool_open_special_dir(dp, ORIGIN_DIR_NAME, &dd);
|
||||
if (err)
|
||||
goto out;
|
||||
err = dsl_dataset_hold_obj(dp, dd->dd_phys->dd_head_dataset_obj,
|
||||
FTAG, &ds);
|
||||
err = dsl_dataset_hold_obj(dp,
|
||||
dsl_dir_phys(dd)->dd_head_dataset_obj, FTAG, &ds);
|
||||
if (err == 0) {
|
||||
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);
|
||||
dsl_dataset_rele(ds, FTAG);
|
||||
}
|
||||
@ -674,15 +674,15 @@ upgrade_clones_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
|
||||
if (err)
|
||||
return (err);
|
||||
|
||||
while (ds->ds_phys->ds_prev_snap_obj != 0) {
|
||||
err = dsl_dataset_hold_obj(dp, ds->ds_phys->ds_prev_snap_obj,
|
||||
FTAG, &prev);
|
||||
while (dsl_dataset_phys(ds)->ds_prev_snap_obj != 0) {
|
||||
err = dsl_dataset_hold_obj(dp,
|
||||
dsl_dataset_phys(ds)->ds_prev_snap_obj, FTAG, &prev);
|
||||
if (err) {
|
||||
dsl_dataset_rele(ds, FTAG);
|
||||
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;
|
||||
dsl_dataset_rele(ds, FTAG);
|
||||
ds = prev;
|
||||
@ -696,7 +696,7 @@ upgrade_clones_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
|
||||
* The $ORIGIN can't have any data, or the accounting
|
||||
* 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 */
|
||||
if (ds->ds_object == prev->ds_object) {
|
||||
@ -705,33 +705,35 @@ upgrade_clones_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
|
||||
}
|
||||
|
||||
dmu_buf_will_dirty(ds->ds_dbuf, tx);
|
||||
ds->ds_phys->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_obj = prev->ds_object;
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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(ds->ds_phys->ds_prev_snap_obj, ==, prev->ds_object);
|
||||
ASSERT3U(dsl_dir_phys(ds->ds_dir)->dd_origin_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);
|
||||
prev->ds_phys->ds_next_clones_obj =
|
||||
dsl_dataset_phys(prev)->ds_next_clones_obj =
|
||||
zap_create(dp->dp_meta_objset,
|
||||
DMU_OT_NEXT_CLONES, DMU_OT_NONE, 0, tx);
|
||||
}
|
||||
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);
|
||||
if (prev != dp->dp_origin_snap)
|
||||
@ -756,20 +758,22 @@ upgrade_dir_clones_cb(dsl_pool_t *dp, dsl_dataset_t *ds, void *arg)
|
||||
dmu_tx_t *tx = arg;
|
||||
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;
|
||||
|
||||
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);
|
||||
origin->ds_dir->dd_phys->dd_clones = zap_create(mos,
|
||||
DMU_OT_DSL_CLONES, DMU_OT_NONE, 0, tx);
|
||||
dsl_dir_phys(origin->ds_dir)->dd_clones =
|
||||
zap_create(mos, DMU_OT_DSL_CLONES, DMU_OT_NONE,
|
||||
0, tx);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@ -816,7 +820,7 @@ dsl_pool_create_origin(dsl_pool_t *dp, dmu_tx_t *tx)
|
||||
NULL, 0, kcred, tx);
|
||||
VERIFY0(dsl_dataset_hold_obj(dp, dsobj, FTAG, &ds));
|
||||
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));
|
||||
dsl_dataset_rele(ds, FTAG);
|
||||
}
|
||||
|
@ -105,8 +105,8 @@ dsl_prop_get_dd(dsl_dir_t *dd, const char *propname,
|
||||
}
|
||||
|
||||
/* Check for a local value. */
|
||||
err = zap_lookup(mos, dd->dd_phys->dd_props_zapobj, propname,
|
||||
intsz, numints, buf);
|
||||
err = zap_lookup(mos, dsl_dir_phys(dd)->dd_props_zapobj,
|
||||
propname, intsz, numints, buf);
|
||||
if (err != ENOENT) {
|
||||
if (setpoint != NULL && err == 0)
|
||||
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
|
||||
* inheritance entry.
|
||||
*/
|
||||
err = zap_contains(mos, dd->dd_phys->dd_props_zapobj,
|
||||
err = zap_contains(mos, dsl_dir_phys(dd)->dd_props_zapobj,
|
||||
inheritstr);
|
||||
if (err != 0 && err != ENOENT)
|
||||
break;
|
||||
|
||||
if (err == ENOENT) {
|
||||
/* 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);
|
||||
if (err != ENOENT) {
|
||||
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));
|
||||
inheritable = (prop == ZPROP_INVAL || zfs_prop_inheritable(prop));
|
||||
snapshot = dsl_dataset_is_snapshot(ds);
|
||||
zapobj = ds->ds_phys->ds_props_obj;
|
||||
zapobj = dsl_dataset_phys(ds)->ds_props_obj;
|
||||
|
||||
if (zapobj != 0) {
|
||||
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;
|
||||
zapobj = dd->dd_phys->dd_props_zapobj;
|
||||
zapobj = dsl_dir_phys(dd)->dd_props_zapobj;
|
||||
recvdstr = kmem_asprintf("%s%s", propname, ZPROP_RECVD_SUFFIX);
|
||||
|
||||
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
|
||||
* 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) {
|
||||
dsl_dir_rele(dd, FTAG);
|
||||
return;
|
||||
@ -497,7 +498,7 @@ dsl_prop_changed_notify(dsl_pool_t *dp, uint64_t ddobj,
|
||||
mutex_enter(&dd->dd_lock);
|
||||
for (cbr = list_head(&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)
|
||||
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);
|
||||
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_advance(&zc)) {
|
||||
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)) {
|
||||
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);
|
||||
ds->ds_phys->ds_props_obj =
|
||||
dsl_dataset_phys(ds)->ds_props_obj =
|
||||
zap_create(mos,
|
||||
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 {
|
||||
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) {
|
||||
@ -987,11 +988,11 @@ dsl_prop_get_all_ds(dsl_dataset_t *ds, nvlist_t **nvp,
|
||||
|
||||
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);
|
||||
dsl_dataset_name(ds, setpoint);
|
||||
err = dsl_prop_get_all_impl(mos, ds->ds_phys->ds_props_obj,
|
||||
setpoint, flags, *nvp);
|
||||
err = dsl_prop_get_all_impl(mos,
|
||||
dsl_dataset_phys(ds)->ds_props_obj, setpoint, flags, *nvp);
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
@ -1004,8 +1005,8 @@ dsl_prop_get_all_ds(dsl_dataset_t *ds, nvlist_t **nvp,
|
||||
flags |= DSL_PROP_GET_INHERITING;
|
||||
}
|
||||
dsl_dir_name(dd, setpoint);
|
||||
err = dsl_prop_get_all_impl(mos, dd->dd_phys->dd_props_zapobj,
|
||||
setpoint, flags, *nvp);
|
||||
err = dsl_prop_get_all_impl(mos,
|
||||
dsl_dir_phys(dd)->dd_props_zapobj, setpoint, flags, *nvp);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ dsl_scan_ds_maxtxg(dsl_dataset_t *ds)
|
||||
{
|
||||
uint64_t smt = ds->ds_dir->dd_pool->dp_scan->scn_phys.scn_max_txg;
|
||||
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);
|
||||
}
|
||||
|
||||
@ -814,11 +814,12 @@ dsl_scan_ds_destroyed(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
if (dsl_dataset_is_snapshot(ds)) {
|
||||
/* Note, scn_cur_{min,max}_txg stays the same. */
|
||||
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; "
|
||||
"reset zb_objset to %llu",
|
||||
(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;
|
||||
} else {
|
||||
SET_BOOKMARK(&scn->scn_phys.scn_bookmark,
|
||||
@ -829,7 +830,7 @@ dsl_scan_ds_destroyed(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
}
|
||||
} else if (zap_lookup_int_key(dp->dp_meta_objset,
|
||||
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,
|
||||
scn->scn_phys.scn_queue_obj, ds->ds_object, tx));
|
||||
if (dsl_dataset_is_snapshot(ds)) {
|
||||
@ -840,11 +841,13 @@ dsl_scan_ds_destroyed(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
*/
|
||||
VERIFY(zap_add_int_key(dp->dp_meta_objset,
|
||||
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; "
|
||||
"replacing with %llu",
|
||||
(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 {
|
||||
zfs_dbgmsg("destroying ds %llu; in queue; removing",
|
||||
(u_longlong_t)ds->ds_object);
|
||||
@ -871,26 +874,26 @@ dsl_scan_ds_snapshotted(dsl_dataset_t *ds, dmu_tx_t *tx)
|
||||
if (scn->scn_phys.scn_state != DSS_SCANNING)
|
||||
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) {
|
||||
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; "
|
||||
"reset zb_objset to %llu",
|
||||
(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,
|
||||
scn->scn_phys.scn_queue_obj, ds->ds_object, &mintxg) == 0) {
|
||||
VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset,
|
||||
scn->scn_phys.scn_queue_obj, ds->ds_object, tx));
|
||||
VERIFY(zap_add_int_key(dp->dp_meta_objset,
|
||||
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; "
|
||||
"replacing with %llu",
|
||||
(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);
|
||||
}
|
||||
@ -923,8 +926,8 @@ dsl_scan_ds_clone_swapped(dsl_dataset_t *ds1, dsl_dataset_t *ds2, dmu_tx_t *tx)
|
||||
ds1->ds_object, &mintxg) == 0) {
|
||||
int err;
|
||||
|
||||
ASSERT3U(mintxg, ==, ds1->ds_phys->ds_prev_snap_txg);
|
||||
ASSERT3U(mintxg, ==, ds2->ds_phys->ds_prev_snap_txg);
|
||||
ASSERT3U(mintxg, ==, dsl_dataset_phys(ds1)->ds_prev_snap_txg);
|
||||
ASSERT3U(mintxg, ==, dsl_dataset_phys(ds2)->ds_prev_snap_txg);
|
||||
VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset,
|
||||
scn->scn_phys.scn_queue_obj, ds1->ds_object, tx));
|
||||
err = zap_add_int_key(dp->dp_meta_objset,
|
||||
@ -942,8 +945,8 @@ dsl_scan_ds_clone_swapped(dsl_dataset_t *ds1, dsl_dataset_t *ds2, dmu_tx_t *tx)
|
||||
(u_longlong_t)ds2->ds_object);
|
||||
} else if (zap_lookup_int_key(dp->dp_meta_objset,
|
||||
scn->scn_phys.scn_queue_obj, ds2->ds_object, &mintxg) == 0) {
|
||||
ASSERT3U(mintxg, ==, ds1->ds_phys->ds_prev_snap_txg);
|
||||
ASSERT3U(mintxg, ==, ds2->ds_phys->ds_prev_snap_txg);
|
||||
ASSERT3U(mintxg, ==, dsl_dataset_phys(ds1)->ds_prev_snap_txg);
|
||||
ASSERT3U(mintxg, ==, dsl_dataset_phys(ds2)->ds_prev_snap_txg);
|
||||
VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset,
|
||||
scn->scn_phys.scn_queue_obj, ds2->ds_object, tx));
|
||||
VERIFY(0 == zap_add_int_key(dp->dp_meta_objset,
|
||||
@ -971,17 +974,17 @@ enqueue_clones_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
|
||||
int err;
|
||||
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);
|
||||
|
||||
err = dsl_dataset_hold_obj(dp, hds->ds_object, FTAG, &ds);
|
||||
if (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;
|
||||
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);
|
||||
if (err)
|
||||
@ -990,7 +993,7 @@ enqueue_clones_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, 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);
|
||||
return (0);
|
||||
}
|
||||
@ -1021,7 +1024,7 @@ dsl_scan_visitds(dsl_scan_t *scn, uint64_t dsobj, dmu_tx_t *tx)
|
||||
* Iterate over the bps in this ds.
|
||||
*/
|
||||
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);
|
||||
|
||||
char *dsname = kmem_alloc(ZFS_MAXNAMELEN, KM_SLEEP);
|
||||
dsl_dataset_name(ds, dsname);
|
||||
@ -1055,14 +1058,15 @@ dsl_scan_visitds(dsl_scan_t *scn, uint64_t dsobj, dmu_tx_t *tx)
|
||||
/*
|
||||
* 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,
|
||||
scn->scn_phys.scn_queue_obj, ds->ds_phys->ds_next_snap_obj,
|
||||
ds->ds_phys->ds_creation_txg, tx) == 0);
|
||||
scn->scn_phys.scn_queue_obj,
|
||||
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;
|
||||
if (ds->ds_phys->ds_next_clones_obj != 0) {
|
||||
if (dsl_dataset_phys(ds)->ds_next_clones_obj != 0) {
|
||||
uint64_t count;
|
||||
/*
|
||||
* A bug in a previous version of the code could
|
||||
@ -1072,17 +1076,17 @@ dsl_scan_visitds(dsl_scan_t *scn, uint64_t dsobj, dmu_tx_t *tx)
|
||||
* next_clones_obj when its count is correct.
|
||||
*/
|
||||
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 &&
|
||||
count == ds->ds_phys->ds_num_children - 1)
|
||||
count == dsl_dataset_phys(ds)->ds_num_children - 1)
|
||||
usenext = B_TRUE;
|
||||
}
|
||||
|
||||
if (usenext) {
|
||||
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,
|
||||
ds->ds_phys->ds_creation_txg, tx));
|
||||
dsl_dataset_phys(ds)->ds_creation_txg, tx));
|
||||
} else {
|
||||
struct enqueue_clones_arg eca;
|
||||
eca.tx = tx;
|
||||
@ -1110,10 +1114,10 @@ enqueue_cb(dsl_pool_t *dp, dsl_dataset_t *hds, void *arg)
|
||||
if (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;
|
||||
err = dsl_dataset_hold_obj(dp, ds->ds_phys->ds_prev_snap_obj,
|
||||
FTAG, &prev);
|
||||
err = dsl_dataset_hold_obj(dp,
|
||||
dsl_dataset_phys(ds)->ds_prev_snap_obj, FTAG, &prev);
|
||||
if (err) {
|
||||
dsl_dataset_rele(ds, FTAG);
|
||||
return (err);
|
||||
@ -1122,7 +1126,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 (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(prev, FTAG);
|
||||
return (0);
|
||||
@ -1132,7 +1136,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,
|
||||
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);
|
||||
return (0);
|
||||
}
|
||||
@ -1307,7 +1311,7 @@ dsl_scan_visit(dsl_scan_t *scn, dmu_tx_t *tx)
|
||||
} else {
|
||||
scn->scn_phys.scn_cur_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);
|
||||
dsl_dataset_rele(ds, FTAG);
|
||||
@ -1494,9 +1498,9 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
|
||||
if (err != 0)
|
||||
return;
|
||||
if (!scn->scn_async_destroying && zfs_free_leak_on_eio &&
|
||||
(dp->dp_free_dir->dd_phys->dd_used_bytes != 0 ||
|
||||
dp->dp_free_dir->dd_phys->dd_compressed_bytes != 0 ||
|
||||
dp->dp_free_dir->dd_phys->dd_uncompressed_bytes != 0)) {
|
||||
(dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes != 0 ||
|
||||
dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes != 0 ||
|
||||
dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes != 0)) {
|
||||
/*
|
||||
* We have finished background destroying, but there is still
|
||||
* some space left in the dp_free_dir. Transfer this leaked
|
||||
@ -1511,19 +1515,19 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
|
||||
rrw_exit(&dp->dp_config_rwlock, FTAG);
|
||||
}
|
||||
dsl_dir_diduse_space(dp->dp_leak_dir, DD_USED_HEAD,
|
||||
dp->dp_free_dir->dd_phys->dd_used_bytes,
|
||||
dp->dp_free_dir->dd_phys->dd_compressed_bytes,
|
||||
dp->dp_free_dir->dd_phys->dd_uncompressed_bytes, tx);
|
||||
dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes,
|
||||
dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes,
|
||||
dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes, tx);
|
||||
dsl_dir_diduse_space(dp->dp_free_dir, DD_USED_HEAD,
|
||||
-dp->dp_free_dir->dd_phys->dd_used_bytes,
|
||||
-dp->dp_free_dir->dd_phys->dd_compressed_bytes,
|
||||
-dp->dp_free_dir->dd_phys->dd_uncompressed_bytes, tx);
|
||||
-dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes,
|
||||
-dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes,
|
||||
-dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes, tx);
|
||||
}
|
||||
if (!scn->scn_async_destroying) {
|
||||
/* finished; verify that space accounting went to zero */
|
||||
ASSERT0(dp->dp_free_dir->dd_phys->dd_used_bytes);
|
||||
ASSERT0(dp->dp_free_dir->dd_phys->dd_compressed_bytes);
|
||||
ASSERT0(dp->dp_free_dir->dd_phys->dd_uncompressed_bytes);
|
||||
ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes);
|
||||
ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes);
|
||||
ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes);
|
||||
}
|
||||
|
||||
if (scn->scn_phys.scn_state != DSS_SCANNING)
|
||||
|
@ -163,7 +163,7 @@ dsl_sync_task_sync(dsl_sync_task_t *dst, dmu_tx_t *tx)
|
||||
uint64_t quota = dsl_pool_adjustedsize(dp,
|
||||
dst->dst_space_check == ZFS_SPACE_CHECK_RESERVED) -
|
||||
metaslab_class_get_deferred(spa_normal_class(dp->dp_spa));
|
||||
uint64_t used = dp->dp_root_dir->dd_phys->dd_used_bytes;
|
||||
uint64_t used = dsl_dir_phys(dp->dp_root_dir)->dd_used_bytes;
|
||||
/* MOS space is triple-dittoed, so we multiply by 3. */
|
||||
if (dst->dst_space > 0 && used + dst->dst_space * 3 > quota) {
|
||||
dst->dst_error = SET_ERROR(ENOSPC);
|
||||
|
@ -64,10 +64,10 @@ dsl_dataset_user_hold_check_one(dsl_dataset_t *ds, const char *htag,
|
||||
return (SET_ERROR(E2BIG));
|
||||
|
||||
/* 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;
|
||||
|
||||
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);
|
||||
if (error == 0)
|
||||
error = SET_ERROR(EEXIST);
|
||||
@ -140,16 +140,16 @@ dsl_dataset_user_hold_sync_one_impl(nvlist_t *tmpholds, dsl_dataset_t *ds,
|
||||
|
||||
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
|
||||
* the userrefs zap object.
|
||||
*/
|
||||
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);
|
||||
} else {
|
||||
zapobj = ds->ds_phys->ds_userrefs_obj;
|
||||
zapobj = dsl_dataset_phys(ds)->ds_userrefs_obj;
|
||||
}
|
||||
ds->ds_userrefs++;
|
||||
|
||||
@ -360,7 +360,7 @@ dsl_dataset_user_release_check_one(dsl_dataset_user_release_arg_t *ddura,
|
||||
|
||||
numholds = 0;
|
||||
mos = ds->ds_dir->dd_pool->dp_meta_objset;
|
||||
zapobj = ds->ds_phys->ds_userrefs_obj;
|
||||
zapobj = dsl_dataset_phys(ds)->ds_userrefs_obj;
|
||||
holds_found = fnvlist_alloc();
|
||||
|
||||
for (nvpair_t *pair = nvlist_next_nvpair(holds, NULL); pair != NULL;
|
||||
@ -398,7 +398,8 @@ dsl_dataset_user_release_check_one(dsl_dataset_user_release_arg_t *ddura,
|
||||
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) {
|
||||
/* we need to destroy the snapshot as well */
|
||||
if (dsl_dataset_long_held(ds)) {
|
||||
@ -484,8 +485,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);
|
||||
VERIFY(error == 0 || error == ENOENT);
|
||||
|
||||
VERIFY0(zap_remove(mos, ds->ds_phys->ds_userrefs_obj, holdname,
|
||||
tx));
|
||||
VERIFY0(zap_remove(mos, dsl_dataset_phys(ds)->ds_userrefs_obj,
|
||||
holdname, tx));
|
||||
ds->ds_userrefs--;
|
||||
|
||||
spa_history_log_internal_ds(ds, "release", tx,
|
||||
@ -514,7 +515,7 @@ dsl_dataset_user_release_sync(void *arg, dmu_tx_t *tx)
|
||||
fnvpair_value_nvlist(pair), tx);
|
||||
if (nvlist_exists(ddura->ddura_todelete, name)) {
|
||||
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));
|
||||
dsl_destroy_snapshot_sync_impl(ds, B_FALSE, tx);
|
||||
}
|
||||
@ -644,13 +645,13 @@ dsl_dataset_get_holds(const char *dsname, nvlist_t *nvl)
|
||||
return (err);
|
||||
}
|
||||
|
||||
if (ds->ds_phys->ds_userrefs_obj != 0) {
|
||||
if (dsl_dataset_phys(ds)->ds_userrefs_obj != 0) {
|
||||
zap_attribute_t *za;
|
||||
zap_cursor_t zc;
|
||||
|
||||
za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
|
||||
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_advance(&zc)) {
|
||||
fnvlist_add_uint64(nvl, za->za_name,
|
||||
|
@ -1345,7 +1345,7 @@ sa_handle_destroy(sa_handle_t *hdl)
|
||||
{
|
||||
mutex_enter(&hdl->sa_lock);
|
||||
(void) dmu_buf_update_user((dmu_buf_t *)hdl->sa_bonus, hdl,
|
||||
NULL, NULL, NULL);
|
||||
NULL, NULL);
|
||||
|
||||
if (hdl->sa_bonus_tab) {
|
||||
sa_idx_tab_rele(hdl->sa_os, hdl->sa_bonus_tab);
|
||||
@ -1392,8 +1392,7 @@ sa_handle_get_from_db(objset_t *os, dmu_buf_t *db, void *userp,
|
||||
|
||||
error = sa_build_index(handle, SA_BONUS);
|
||||
newhandle = (hdl_type == SA_HDL_SHARED) ?
|
||||
dmu_buf_set_user_ie(db, handle,
|
||||
NULL, sa_evict) : NULL;
|
||||
dmu_buf_set_user_ie(db, handle, sa_evict) : NULL;
|
||||
|
||||
if (newhandle != NULL) {
|
||||
kmem_cache_free(sa_cache, handle);
|
||||
@ -1911,7 +1910,7 @@ void
|
||||
sa_update_user(sa_handle_t *newhdl, sa_handle_t *oldhdl)
|
||||
{
|
||||
(void) dmu_buf_update_user((dmu_buf_t *)newhdl->sa_bonus,
|
||||
oldhdl, newhdl, NULL, sa_evict);
|
||||
oldhdl, newhdl, sa_evict);
|
||||
oldhdl->sa_bonus = NULL;
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,8 @@ spa_prop_get_config(spa_t *spa, nvlist_t **nvp)
|
||||
*/
|
||||
if (pool->dp_free_dir != 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 {
|
||||
spa_prop_add_list(*nvp, ZPOOL_PROP_FREEING,
|
||||
NULL, 0, src);
|
||||
@ -249,7 +250,8 @@ spa_prop_get_config(spa_t *spa, nvlist_t **nvp)
|
||||
|
||||
if (pool->dp_leak_dir != 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 {
|
||||
spa_prop_add_list(*nvp, ZPOOL_PROP_LEAKED,
|
||||
NULL, 0, src);
|
||||
|
@ -520,7 +520,7 @@ spa_history_log_internal_dd(dsl_dir_t *dd, const char *operation,
|
||||
dsl_dir_name(dd, namebuf);
|
||||
fnvlist_add_string(nvl, ZPOOL_HIST_DSNAME, namebuf);
|
||||
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);
|
||||
log_internal(nvl, operation, dd->dd_pool->dp_spa, tx, fmt, adx);
|
||||
|
@ -228,7 +228,6 @@ typedef struct dmu_buf_impl {
|
||||
|
||||
/* stuff we store for the user (see dmu_buf_set_user) */
|
||||
void *db_user_ptr;
|
||||
void **db_user_data_ptr_ptr;
|
||||
dmu_buf_evict_func_t *db_evict_func;
|
||||
|
||||
uint8_t db_immediate_evict;
|
||||
|
@ -484,12 +484,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_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
|
||||
* excised from the cache, so that you can clean up the data structure
|
||||
* pointed to by user_ptr.
|
||||
@ -497,17 +491,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
|
||||
* 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);
|
||||
/*
|
||||
* set_user_ie is the same as set_user, but request immediate eviction
|
||||
* when hold count goes to zero.
|
||||
*/
|
||||
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);
|
||||
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);
|
||||
|
||||
/*
|
||||
|
@ -48,7 +48,7 @@ struct dsl_pool;
|
||||
|
||||
#define DS_FLAG_INCONSISTENT (1ULL<<0)
|
||||
#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.
|
||||
@ -68,7 +68,7 @@ struct dsl_pool;
|
||||
*/
|
||||
#define DS_FLAG_DEFER_DESTROY (1ULL<<3)
|
||||
#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.
|
||||
@ -134,7 +134,6 @@ typedef struct dsl_dataset_phys {
|
||||
typedef struct dsl_dataset {
|
||||
/* Immutable: */
|
||||
struct dsl_dir *ds_dir;
|
||||
dsl_dataset_phys_t *ds_phys;
|
||||
dmu_buf_t *ds_dbuf;
|
||||
uint64_t ds_object;
|
||||
uint64_t ds_fsid_guid;
|
||||
@ -186,17 +185,26 @@ typedef struct dsl_dataset {
|
||||
char ds_snapname[MAXNAMELEN];
|
||||
} dsl_dataset_t;
|
||||
|
||||
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
|
||||
* required to express UINT64_MAX plus one for the hyphen.
|
||||
*/
|
||||
#define MAX_TAG_PREFIX_LEN 17
|
||||
|
||||
#define dsl_dataset_is_snapshot(ds) \
|
||||
((ds)->ds_phys->ds_num_children != 0)
|
||||
inline boolean_t
|
||||
dsl_dataset_is_snapshot(dsl_dataset_t *ds)
|
||||
{
|
||||
return (dsl_dataset_phys(ds)->ds_num_children != 0);
|
||||
}
|
||||
|
||||
#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,
|
||||
dsl_dataset_t **dsp);
|
||||
|
@ -86,10 +86,11 @@ typedef struct dsl_dir_phys {
|
||||
struct dsl_dir {
|
||||
/* These are immutable; no lock needed: */
|
||||
uint64_t dd_object;
|
||||
dsl_dir_phys_t *dd_phys;
|
||||
dmu_buf_t *dd_dbuf;
|
||||
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 */
|
||||
txg_node_t dd_dirty_link;
|
||||
|
||||
@ -111,6 +112,12 @@ struct dsl_dir {
|
||||
char dd_myname[MAXNAMELEN];
|
||||
};
|
||||
|
||||
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);
|
||||
int dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
|
||||
dsl_dir_t **, const char **tail);
|
||||
|
@ -70,7 +70,7 @@ typedef struct mzap_ent {
|
||||
} mzap_ent_t;
|
||||
|
||||
#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
|
||||
@ -104,7 +104,7 @@ struct zap_leaf;
|
||||
* word number (1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap)).
|
||||
*/
|
||||
#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))]
|
||||
|
||||
/*
|
||||
@ -149,8 +149,6 @@ typedef struct zap {
|
||||
uint64_t zap_salt;
|
||||
union {
|
||||
struct {
|
||||
zap_phys_t *zap_phys;
|
||||
|
||||
/*
|
||||
* zap_num_entries_mtx protects
|
||||
* zap_num_entries
|
||||
@ -159,7 +157,6 @@ typedef struct zap {
|
||||
int zap_block_shift;
|
||||
} zap_fat;
|
||||
struct {
|
||||
mzap_phys_t *zap_phys;
|
||||
int16_t zap_num_entries;
|
||||
int16_t zap_num_chunks;
|
||||
int16_t zap_alloc_next;
|
||||
@ -168,6 +165,18 @@ typedef struct zap {
|
||||
} zap_u;
|
||||
} zap_t;
|
||||
|
||||
inline zap_phys_t *
|
||||
zap_f_phys(zap_t *zap)
|
||||
{
|
||||
return (zap->zap_dbuf->db_data);
|
||||
}
|
||||
|
||||
inline mzap_phys_t *
|
||||
zap_m_phys(zap_t *zap)
|
||||
{
|
||||
return (zap->zap_dbuf->db_data);
|
||||
}
|
||||
|
||||
typedef struct zap_name {
|
||||
zap_t *zn_zap;
|
||||
int zn_key_intlen;
|
||||
|
@ -83,7 +83,7 @@ struct zap_stats;
|
||||
*/
|
||||
#define ZAP_LEAF_CHUNK(l, idx) \
|
||||
((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)
|
||||
|
||||
typedef enum zap_chunk_type {
|
||||
@ -156,9 +156,13 @@ typedef struct zap_leaf {
|
||||
uint64_t l_blkid; /* 1<<ZAP_BLOCK_SHIFT byte block off */
|
||||
int l_bs; /* block size shift */
|
||||
dmu_buf_t *l_dbuf;
|
||||
zap_leaf_phys_t *l_phys;
|
||||
} zap_leaf_t;
|
||||
|
||||
inline zap_leaf_phys_t *
|
||||
zap_leaf_phys(zap_leaf_t *l)
|
||||
{
|
||||
return (l->l_dbuf->db_data);
|
||||
}
|
||||
|
||||
typedef struct zap_entry_handle {
|
||||
/* Set by zap_leaf and public to ZAP */
|
||||
|
@ -50,10 +50,11 @@
|
||||
|
||||
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 uint64_t zap_allocate_blocks(zap_t *zap, int nblocks);
|
||||
|
||||
|
||||
void
|
||||
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));
|
||||
zap->zap_ismicro = FALSE;
|
||||
|
||||
(void) dmu_buf_update_user(zap->zap_dbuf, zap, zap,
|
||||
&zap->zap_f.zap_phys, zap_evict);
|
||||
(void) dmu_buf_update_user(zap->zap_dbuf, zap, zap, zap_evict);
|
||||
|
||||
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;
|
||||
|
||||
zp = zap->zap_f.zap_phys;
|
||||
zp = zap_f_phys(zap);
|
||||
/*
|
||||
* explicitly zero it since it might be coming from an
|
||||
* 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->l_dbuf = db;
|
||||
l->l_phys = db->db_data;
|
||||
|
||||
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
|
||||
* 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));
|
||||
|
||||
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
|
||||
* 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;
|
||||
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));
|
||||
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);
|
||||
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));
|
||||
dmu_buf_rele(db_new, FTAG);
|
||||
|
||||
zap->zap_f.zap_phys->zap_ptrtbl.zt_blk = newblk;
|
||||
zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks = 1;
|
||||
zap->zap_f.zap_phys->zap_ptrtbl.zt_shift++;
|
||||
zap_f_phys(zap)->zap_ptrtbl.zt_blk = newblk;
|
||||
zap_f_phys(zap)->zap_ptrtbl.zt_numblks = 1;
|
||||
zap_f_phys(zap)->zap_ptrtbl.zt_shift++;
|
||||
|
||||
ASSERT3U(1ULL << zap->zap_f.zap_phys->zap_ptrtbl.zt_shift, ==,
|
||||
zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks <<
|
||||
ASSERT3U(1ULL << zap_f_phys(zap)->zap_ptrtbl.zt_shift, ==,
|
||||
zap_f_phys(zap)->zap_ptrtbl.zt_numblks <<
|
||||
(FZAP_BLOCK_SHIFT(zap)-3));
|
||||
|
||||
return (0);
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
mutex_enter(&zap->zap_f.zap_num_entries_mtx);
|
||||
ASSERT(delta > 0 || zap->zap_f.zap_phys->zap_num_entries >= -delta);
|
||||
zap->zap_f.zap_phys->zap_num_entries += delta;
|
||||
ASSERT(delta > 0 || zap_f_phys(zap)->zap_num_entries >= -delta);
|
||||
zap_f_phys(zap)->zap_num_entries += delta;
|
||||
mutex_exit(&zap->zap_f.zap_num_entries_mtx);
|
||||
}
|
||||
|
||||
@ -383,8 +382,8 @@ zap_allocate_blocks(zap_t *zap, int nblocks)
|
||||
{
|
||||
uint64_t newblk;
|
||||
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock));
|
||||
newblk = zap->zap_f.zap_phys->zap_freeblk;
|
||||
zap->zap_f.zap_phys->zap_freeblk += nblocks;
|
||||
newblk = zap_f_phys(zap)->zap_freeblk;
|
||||
zap_f_phys(zap)->zap_freeblk += nblocks;
|
||||
return (newblk);
|
||||
}
|
||||
|
||||
@ -400,18 +399,17 @@ zap_create_leaf(zap_t *zap, dmu_tx_t *tx)
|
||||
rw_enter(&l->l_rwlock, RW_WRITER);
|
||||
l->l_blkid = zap_allocate_blocks(zap, 1);
|
||||
l->l_dbuf = NULL;
|
||||
l->l_phys = NULL;
|
||||
|
||||
VERIFY(0 == dmu_buf_hold(zap->zap_objset, zap->zap_object,
|
||||
l->l_blkid << FZAP_BLOCK_SHIFT(zap), NULL, &l->l_dbuf,
|
||||
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);
|
||||
dmu_buf_will_dirty(l->l_dbuf, tx);
|
||||
|
||||
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);
|
||||
}
|
||||
@ -421,7 +419,7 @@ fzap_count(zap_t *zap, uint64_t *count)
|
||||
{
|
||||
ASSERT(!zap->zap_ismicro);
|
||||
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);
|
||||
return (0);
|
||||
}
|
||||
@ -460,9 +458,8 @@ zap_open_leaf(uint64_t blkid, dmu_buf_t *db)
|
||||
l->l_blkid = blkid;
|
||||
l->l_bs = highbit64(db->db_size) - 1;
|
||||
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);
|
||||
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
|
||||
* 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
|
||||
@ -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 */
|
||||
ASSERT3P(&ZAP_LEAF_CHUNK(l, 0), ==,
|
||||
&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 */
|
||||
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);
|
||||
}
|
||||
@ -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);
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
if (lt == RW_WRITER)
|
||||
dmu_buf_will_dirty(db, tx);
|
||||
ASSERT3U(l->l_blkid, ==, blkid);
|
||||
ASSERT3P(l->l_dbuf, ==, db);
|
||||
ASSERT3P(l->l_phys, ==, l->l_dbuf->db_data);
|
||||
ASSERT3U(l->l_phys->l_hdr.lh_block_type, ==, ZBT_LEAF);
|
||||
ASSERT3U(l->l_phys->l_hdr.lh_magic, ==, ZAP_LEAF_MAGIC);
|
||||
ASSERT3U(zap_leaf_phys(l)->l_hdr.lh_block_type, ==, ZBT_LEAF);
|
||||
ASSERT3U(zap_leaf_phys(l)->l_hdr.lh_magic, ==, ZAP_LEAF_MAGIC);
|
||||
|
||||
*lp = l;
|
||||
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));
|
||||
|
||||
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks == 0) {
|
||||
if (zap_f_phys(zap)->zap_ptrtbl.zt_numblks == 0) {
|
||||
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);
|
||||
return (0);
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
@ -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(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;
|
||||
return (0);
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
|
||||
ASSERT(zap->zap_dbuf == NULL ||
|
||||
zap->zap_f.zap_phys == zap->zap_dbuf->db_data);
|
||||
ASSERT3U(zap->zap_f.zap_phys->zap_magic, ==, ZAP_MAGIC);
|
||||
idx = ZAP_HASH_IDX(h, zap->zap_f.zap_phys->zap_ptrtbl.zt_shift);
|
||||
zap_f_phys(zap) == zap->zap_dbuf->db_data);
|
||||
ASSERT3U(zap_f_phys(zap)->zap_magic, ==, ZAP_MAGIC);
|
||||
idx = ZAP_HASH_IDX(h, zap_f_phys(zap)->zap_ptrtbl.zt_shift);
|
||||
err = zap_idx_to_blk(zap, idx, &blk);
|
||||
if (err != 0)
|
||||
return (err);
|
||||
err = zap_get_leaf_byblk(zap, blk, tx, lt, lp);
|
||||
|
||||
ASSERT(err || ZAP_HASH_IDX(h, (*lp)->l_phys->l_hdr.lh_prefix_len) ==
|
||||
(*lp)->l_phys->l_hdr.lh_prefix);
|
||||
ASSERT(err ||
|
||||
ZAP_HASH_IDX(h, zap_leaf_phys(*lp)->l_hdr.lh_prefix_len) ==
|
||||
zap_leaf_phys(*lp)->l_hdr.lh_prefix);
|
||||
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;
|
||||
int prefix_diff, i, err;
|
||||
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));
|
||||
|
||||
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 ||
|
||||
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 */
|
||||
objset_t *os = zap->zap_objset;
|
||||
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);
|
||||
|
||||
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);
|
||||
if (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)
|
||||
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 */
|
||||
*lp = l;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
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), ==,
|
||||
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);
|
||||
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 */
|
||||
}
|
||||
|
||||
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 */
|
||||
zap_put_leaf(l);
|
||||
*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_t *zap = zn->zn_zap;
|
||||
int shift = zap->zap_f.zap_phys->zap_ptrtbl.zt_shift;
|
||||
int leaffull = (l->l_phys->l_hdr.lh_prefix_len == shift &&
|
||||
l->l_phys->l_hdr.lh_nfree < ZAP_LEAF_LOW_WATER);
|
||||
int shift = zap_f_phys(zap)->zap_ptrtbl.zt_shift;
|
||||
int leaffull = (zap_leaf_phys(l)->l_hdr.lh_prefix_len == shift &&
|
||||
zap_leaf_phys(l)->l_hdr.lh_nfree < ZAP_LEAF_LOW_WATER);
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
@ -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 */
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -937,7 +934,7 @@ fzap_prefetch(zap_name_t *zn)
|
||||
int bs;
|
||||
|
||||
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)
|
||||
return;
|
||||
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 &&
|
||||
(ZAP_HASH_IDX(zc->zc_hash,
|
||||
zc->zc_leaf->l_phys->l_hdr.lh_prefix_len) !=
|
||||
zc->zc_leaf->l_phys->l_hdr.lh_prefix)) {
|
||||
zap_leaf_phys(zc->zc_leaf)->l_hdr.lh_prefix_len) !=
|
||||
zap_leaf_phys(zc->zc_leaf)->l_hdr.lh_prefix)) {
|
||||
rw_enter(&zc->zc_leaf->l_rwlock, RW_READER);
|
||||
zap_put_leaf(zc->zc_leaf);
|
||||
zc->zc_leaf = NULL;
|
||||
@ -1191,10 +1188,11 @@ fzap_cursor_retrieve(zap_t *zap, zap_cursor_t *zc, zap_attribute_t *za)
|
||||
|
||||
if (err == ENOENT) {
|
||||
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_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;
|
||||
} else {
|
||||
zap_put_leaf(zc->zc_leaf);
|
||||
@ -1261,25 +1259,25 @@ fzap_get_stats(zap_t *zap, zap_stats_t *zs)
|
||||
/*
|
||||
* Set zap_phys_t fields
|
||||
*/
|
||||
zs->zs_num_leafs = zap->zap_f.zap_phys->zap_num_leafs;
|
||||
zs->zs_num_entries = zap->zap_f.zap_phys->zap_num_entries;
|
||||
zs->zs_num_blocks = zap->zap_f.zap_phys->zap_freeblk;
|
||||
zs->zs_block_type = zap->zap_f.zap_phys->zap_block_type;
|
||||
zs->zs_magic = zap->zap_f.zap_phys->zap_magic;
|
||||
zs->zs_salt = zap->zap_f.zap_phys->zap_salt;
|
||||
zs->zs_num_leafs = zap_f_phys(zap)->zap_num_leafs;
|
||||
zs->zs_num_entries = zap_f_phys(zap)->zap_num_entries;
|
||||
zs->zs_num_blocks = zap_f_phys(zap)->zap_freeblk;
|
||||
zs->zs_block_type = zap_f_phys(zap)->zap_block_type;
|
||||
zs->zs_magic = zap_f_phys(zap)->zap_magic;
|
||||
zs->zs_salt = zap_f_phys(zap)->zap_salt;
|
||||
|
||||
/*
|
||||
* Set zap_ptrtbl fields
|
||||
*/
|
||||
zs->zs_ptrtbl_len = 1ULL << zap->zap_f.zap_phys->zap_ptrtbl.zt_shift;
|
||||
zs->zs_ptrtbl_nextblk = zap->zap_f.zap_phys->zap_ptrtbl.zt_nextblk;
|
||||
zs->zs_ptrtbl_len = 1ULL << zap_f_phys(zap)->zap_ptrtbl.zt_shift;
|
||||
zs->zs_ptrtbl_nextblk = zap_f_phys(zap)->zap_ptrtbl.zt_nextblk;
|
||||
zs->zs_ptrtbl_blks_copied =
|
||||
zap->zap_f.zap_phys->zap_ptrtbl.zt_blks_copied;
|
||||
zs->zs_ptrtbl_zt_blk = zap->zap_f.zap_phys->zap_ptrtbl.zt_blk;
|
||||
zs->zs_ptrtbl_zt_numblks = zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks;
|
||||
zs->zs_ptrtbl_zt_shift = zap->zap_f.zap_phys->zap_ptrtbl.zt_shift;
|
||||
zap_f_phys(zap)->zap_ptrtbl.zt_blks_copied;
|
||||
zs->zs_ptrtbl_zt_blk = zap_f_phys(zap)->zap_ptrtbl.zt_blk;
|
||||
zs->zs_ptrtbl_zt_numblks = zap_f_phys(zap)->zap_ptrtbl.zt_numblks;
|
||||
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. */
|
||||
zap_stats_ptrtbl(zap, &ZAP_EMBEDDED_PTRTBL_ENT(zap, 0),
|
||||
1 << ZAP_EMBEDDED_PTRTBL_SHIFT(zap), zs);
|
||||
@ -1287,16 +1285,16 @@ fzap_get_stats(zap_t *zap, zap_stats_t *zs)
|
||||
int b;
|
||||
|
||||
dmu_prefetch(zap->zap_objset, zap->zap_object,
|
||||
zap->zap_f.zap_phys->zap_ptrtbl.zt_blk << bs,
|
||||
zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks << bs);
|
||||
zap_f_phys(zap)->zap_ptrtbl.zt_blk << 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++) {
|
||||
dmu_buf_t *db;
|
||||
int err;
|
||||
|
||||
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);
|
||||
if (err == 0) {
|
||||
zap_stats_ptrtbl(zap, db->db_data,
|
||||
@ -1333,7 +1331,7 @@ fzap_count_write(zap_name_t *zn, int add, uint64_t *towrite,
|
||||
* could extend the table.
|
||||
*/
|
||||
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;
|
||||
else
|
||||
*towrite += (zap->zap_dbuf->db_size * 3);
|
||||
|
@ -48,10 +48,12 @@ static uint16_t *zap_leaf_rehash_entry(zap_leaf_t *l, uint16_t entry);
|
||||
|
||||
#define LEAF_HASH(l, h) \
|
||||
((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
|
||||
zap_memset(void *a, int c, size_t n)
|
||||
@ -105,8 +107,11 @@ zap_leaf_byteswap(zap_leaf_phys_t *buf, int size)
|
||||
{
|
||||
int i;
|
||||
zap_leaf_t l;
|
||||
dmu_buf_t l_dbuf;
|
||||
|
||||
l_dbuf.db_data = buf;
|
||||
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_prefix = BSWAP_64(buf->l_hdr.lh_prefix);
|
||||
@ -158,18 +163,20 @@ zap_leaf_init(zap_leaf_t *l, boolean_t sort)
|
||||
int i;
|
||||
|
||||
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(l->l_phys->l_hash, CHAIN_END, 2*ZAP_LEAF_HASH_NUMENTRIES(l));
|
||||
zap_memset(&zap_leaf_phys(l)->l_hdr, 0,
|
||||
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++) {
|
||||
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, ZAP_LEAF_NUMCHUNKS(l)-1).l_free.lf_next = CHAIN_END;
|
||||
l->l_phys->l_hdr.lh_block_type = ZBT_LEAF;
|
||||
l->l_phys->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_block_type = ZBT_LEAF;
|
||||
zap_leaf_phys(l)->l_hdr.lh_magic = ZAP_LEAF_MAGIC;
|
||||
zap_leaf_phys(l)->l_hdr.lh_nfree = ZAP_LEAF_NUMCHUNKS(l);
|
||||
if (sort)
|
||||
l->l_phys->l_hdr.lh_flags |= ZLF_ENTRIES_CDSORTED;
|
||||
zap_leaf_phys(l)->l_hdr.lh_flags |= ZLF_ENTRIES_CDSORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -181,15 +188,16 @@ zap_leaf_chunk_alloc(zap_leaf_t *l)
|
||||
{
|
||||
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(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);
|
||||
}
|
||||
@ -198,16 +206,16 @@ static void
|
||||
zap_leaf_chunk_free(zap_leaf_t *l, uint16_t chunk)
|
||||
{
|
||||
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));
|
||||
ASSERT(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 */
|
||||
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++;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -393,7 +401,7 @@ zap_leaf_lookup(zap_leaf_t *l, zap_name_t *zn, zap_entry_handle_t *zeh)
|
||||
uint16_t *chunkp;
|
||||
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:
|
||||
for (chunkp = LEAF_HASH_ENTPTR(l, zn->zn_hash);
|
||||
@ -413,7 +421,7 @@ zap_leaf_lookup(zap_leaf_t *l, zap_name_t *zn, zap_entry_handle_t *zeh)
|
||||
* lowest-cd match for MT_FIRST.
|
||||
*/
|
||||
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,
|
||||
le->le_name_numints)) {
|
||||
zeh->zeh_num_integers = le->le_value_numints;
|
||||
@ -453,10 +461,10 @@ zap_leaf_lookup_closest(zap_leaf_t *l,
|
||||
uint16_t lh;
|
||||
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 (chunk = l->l_phys->l_hash[lh];
|
||||
for (chunk = zap_leaf_phys(l)->l_hash[lh];
|
||||
chunk != CHAIN_END; chunk = le->le_next) {
|
||||
le = ZAP_LEAF_ENTRY(l, chunk);
|
||||
|
||||
@ -536,7 +544,7 @@ zap_entry_update(zap_entry_handle_t *zeh,
|
||||
delta_chunks = ZAP_LEAF_ARRAY_NCHUNKS(num_integers * integer_size) -
|
||||
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));
|
||||
|
||||
zap_leaf_array_free(l, &le->le_value_chunk);
|
||||
@ -566,7 +574,7 @@ zap_entry_remove(zap_entry_handle_t *zeh)
|
||||
*zeh->zeh_chunkp = le->le_next;
|
||||
zap_leaf_chunk_free(l, entry_chunk);
|
||||
|
||||
l->l_phys->l_hdr.lh_nentries--;
|
||||
zap_leaf_phys(l)->l_hdr.lh_nentries--;
|
||||
}
|
||||
|
||||
int
|
||||
@ -590,7 +598,7 @@ zap_entry_create(zap_leaf_t *l, zap_name_t *zn, uint32_t cd,
|
||||
|
||||
if (cd == ZAP_NEED_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;
|
||||
|
||||
for (chunk = *LEAF_HASH_ENTPTR(l, h);
|
||||
@ -626,7 +634,7 @@ zap_entry_create(zap_leaf_t *l, zap_name_t *zn, uint32_t cd,
|
||||
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));
|
||||
|
||||
/* make the entry */
|
||||
@ -647,7 +655,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 */
|
||||
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_num_integers = num_integers;
|
||||
@ -781,8 +789,8 @@ zap_leaf_transfer_entry(zap_leaf_t *l, int entry, zap_leaf_t *nl)
|
||||
|
||||
zap_leaf_chunk_free(l, entry);
|
||||
|
||||
l->l_phys->l_hdr.lh_nentries--;
|
||||
nl->l_phys->l_hdr.lh_nentries++;
|
||||
zap_leaf_phys(l)->l_hdr.lh_nentries--;
|
||||
zap_leaf_phys(nl)->l_hdr.lh_nentries++;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -792,19 +800,22 @@ void
|
||||
zap_leaf_split(zap_leaf_t *l, zap_leaf_t *nl, boolean_t sort)
|
||||
{
|
||||
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 */
|
||||
l->l_phys->l_hdr.lh_prefix <<= 1;
|
||||
l->l_phys->l_hdr.lh_prefix_len++;
|
||||
nl->l_phys->l_hdr.lh_prefix = l->l_phys->l_hdr.lh_prefix | 1;
|
||||
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(l)->l_hdr.lh_prefix_len++;
|
||||
zap_leaf_phys(nl)->l_hdr.lh_prefix =
|
||||
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 */
|
||||
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)
|
||||
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
|
||||
@ -832,25 +843,25 @@ zap_leaf_stats(zap_t *zap, zap_leaf_t *l, zap_stats_t *zs)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
n = zap->zap_f.zap_phys->zap_ptrtbl.zt_shift -
|
||||
l->l_phys->l_hdr.lh_prefix_len;
|
||||
n = zap_f_phys(zap)->zap_ptrtbl.zt_shift -
|
||||
zap_leaf_phys(l)->l_hdr.lh_prefix_len;
|
||||
n = MIN(n, ZAP_HISTOGRAM_SIZE-1);
|
||||
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);
|
||||
zs->zs_blocks_with_n5_entries[n]++;
|
||||
|
||||
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));
|
||||
n = MIN(n, ZAP_HISTOGRAM_SIZE-1);
|
||||
zs->zs_blocks_n_tenths_full[n]++;
|
||||
|
||||
for (i = 0; i < ZAP_LEAF_HASH_NUMENTRIES(l); i++) {
|
||||
int nentries = 0;
|
||||
int chunk = l->l_phys->l_hash[i];
|
||||
int chunk = zap_leaf_phys(l)->l_hash[i];
|
||||
|
||||
while (chunk != CHAIN_END) {
|
||||
struct zap_leaf_entry *le =
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include <sys/sunddi.h>
|
||||
#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);
|
||||
|
||||
uint64_t
|
||||
@ -46,7 +48,7 @@ zap_getflags(zap_t *zap)
|
||||
{
|
||||
if (zap->zap_ismicro)
|
||||
return (0);
|
||||
return (zap->zap_u.zap_fat.zap_phys->zap_flags);
|
||||
return (zap_f_phys(zap)->zap_flags);
|
||||
}
|
||||
|
||||
int
|
||||
@ -385,7 +387,7 @@ mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
|
||||
* it, because zap_lockdir() checks zap_ismicro without the lock
|
||||
* 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) {
|
||||
rw_exit(&zap->zap_rwlock);
|
||||
@ -397,15 +399,15 @@ mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
|
||||
}
|
||||
|
||||
if (zap->zap_ismicro) {
|
||||
zap->zap_salt = zap->zap_m.zap_phys->mz_salt;
|
||||
zap->zap_normflags = zap->zap_m.zap_phys->mz_normflags;
|
||||
zap->zap_salt = zap_m_phys(zap)->mz_salt;
|
||||
zap->zap_normflags = zap_m_phys(zap)->mz_normflags;
|
||||
zap->zap_m.zap_num_chunks = db->db_size / MZAP_ENT_LEN - 1;
|
||||
avl_create(&zap->zap_m.zap_avl, mze_compare,
|
||||
sizeof (mzap_ent_t), offsetof(mzap_ent_t, mze_node));
|
||||
|
||||
for (i = 0; i < zap->zap_m.zap_num_chunks; i++) {
|
||||
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]) {
|
||||
zap_name_t *zn;
|
||||
|
||||
@ -417,8 +419,8 @@ mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
zap->zap_salt = zap->zap_f.zap_phys->zap_salt;
|
||||
zap->zap_normflags = zap->zap_f.zap_phys->zap_normflags;
|
||||
zap->zap_salt = zap_f_phys(zap)->zap_salt;
|
||||
zap->zap_normflags = zap_f_phys(zap)->zap_normflags;
|
||||
|
||||
ASSERT3U(sizeof (struct zap_leaf_header), ==,
|
||||
2*ZAP_LEAF_CHUNKSIZE);
|
||||
@ -428,7 +430,7 @@ mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
|
||||
* other members.
|
||||
*/
|
||||
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
|
||||
@ -436,7 +438,7 @@ mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
|
||||
*/
|
||||
ASSERT3U((uintptr_t)&ZAP_EMBEDDED_PTRTBL_ENT(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);
|
||||
}
|
||||
rw_exit(&zap->zap_rwlock);
|
||||
@ -939,7 +941,7 @@ mzap_addent(zap_name_t *zn, uint64_t value)
|
||||
|
||||
#ifdef ZFS_DEBUG
|
||||
for (i = 0; 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];
|
||||
ASSERT(strcmp(zn->zn_key_orig, mze->mze_name) != 0);
|
||||
}
|
||||
#endif
|
||||
@ -950,7 +952,7 @@ mzap_addent(zap_name_t *zn, uint64_t value)
|
||||
|
||||
again:
|
||||
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) {
|
||||
mze->mze_value = value;
|
||||
mze->mze_cd = cd;
|
||||
@ -1151,7 +1153,7 @@ zap_remove_norm(objset_t *os, uint64_t zapobj, const char *name,
|
||||
err = SET_ERROR(ENOENT);
|
||||
} else {
|
||||
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));
|
||||
mze_remove(zap, mze);
|
||||
}
|
||||
|
@ -916,7 +916,7 @@ zfs_secpolicy_promote(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
|
||||
dd = clone->ds_dir;
|
||||
|
||||
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) {
|
||||
dsl_dataset_rele(clone, FTAG);
|
||||
dsl_pool_rele(dp, FTAG);
|
||||
@ -4309,7 +4309,8 @@ zfs_ioc_send(zfs_cmd_t *zc)
|
||||
}
|
||||
|
||||
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_pool_rele(dp, FTAG);
|
||||
}
|
||||
@ -4873,7 +4874,7 @@ zfs_ioc_next_obj(zfs_cmd_t *zc)
|
||||
return (error);
|
||||
|
||||
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);
|
||||
return (error);
|
||||
|
Loading…
Reference in New Issue
Block a user