Skip to content

Commit

Permalink
DAOS-4698 rebuild: Rebuild object migration should execute applicable…
Browse files Browse the repository at this point in the history
… object punch for each migration. (#4895) (#5188)

Added object punch epoch to object enumeration.
Execute the punch during migrate.

Signed-off-by: Joseph Moore <joseph.moore@intel.com>
  • Loading branch information
jgmoore-or authored Mar 26, 2021
1 parent 325fd04 commit 9186db4
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/include/daos/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ enum {
OBJ_ITER_RECX,
OBJ_ITER_DKEY_EPOCH,
OBJ_ITER_AKEY_EPOCH,
OBJ_ITER_OBJ_PUNCH_EPOCH,
};

#define RECX_INLINE (1U << 0)
Expand Down
3 changes: 3 additions & 0 deletions src/include/daos_srv/daos_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ struct dss_enum_arg {
bool fill_recxs; /* type == S||R */
bool chk_key2big;
bool need_punch; /* need to pack punch epoch */
bool obj_punched; /* object punch is packed */
daos_epoch_range_t *eprs;
struct daos_csummer *csummer;
int eprs_cap;
Expand Down Expand Up @@ -751,6 +752,8 @@ struct dss_enum_unpack_io {
int ui_iods_cap;
int ui_iods_top;
int *ui_recxs_caps;
/* punched epoch for object */
daos_epoch_t ui_obj_punch_eph;
/* punched epochs for dkey */
daos_epoch_t ui_dkey_punch_eph;
d_sg_list_t *ui_sgls; /**< optional */
Expand Down
25 changes: 25 additions & 0 deletions src/object/obj_enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ fill_key(daos_handle_t ih, vos_iter_entry_t *key_ent, struct dss_enum_arg *arg,
kds_cap = arg->kds_cap - 1; /* one extra kds for punch eph */
else
kds_cap = arg->kds_cap;
if (type == OBJ_ITER_DKEY && arg->need_punch &&
key_ent->ie_obj_punch != 0 && !arg->obj_punched)
kds_cap--; /* extra kds for obj punch eph */

if (is_sgl_full(arg, total_size) || arg->kds_len >= kds_cap) {
/* NB: if it is rebuild object iteration, let's
Expand All @@ -262,6 +265,22 @@ fill_key(daos_handle_t ih, vos_iter_entry_t *key_ent, struct dss_enum_arg *arg,

iov = &arg->sgl->sg_iovs[arg->sgl_idx];

if (type == OBJ_ITER_DKEY && key_ent->ie_obj_punch && arg->need_punch &&
!arg->obj_punched) {
int pi_size = sizeof(key_ent->ie_obj_punch);

arg->kds[arg->kds_len].kd_key_len = pi_size;
arg->kds[arg->kds_len].kd_val_type = OBJ_ITER_OBJ_PUNCH_EPOCH;
arg->kds_len++;

D_ASSERT(iov->iov_len + pi_size < iov->iov_buf_len);
memcpy(iov->iov_buf + iov->iov_len, &key_ent->ie_obj_punch,
pi_size);

iov->iov_len += pi_size;
arg->obj_punched = true;
}

D_ASSERT(arg->kds_len < arg->kds_cap);
arg->kds[arg->kds_len].kd_key_len = key_ent->ie_key.iov_len;
arg->kds[arg->kds_len].kd_val_type = type;
Expand Down Expand Up @@ -1151,6 +1170,11 @@ enum_unpack_punched_ephs(daos_key_desc_t *kds, char *data,
if (kds->kd_key_len != sizeof(daos_epoch_t))
return -DER_INVAL;

if (kds->kd_val_type == OBJ_ITER_OBJ_PUNCH_EPOCH) {
memcpy(&io->ui_obj_punch_eph, data, kds->kd_key_len);
return 0;
}

if (kds->kd_val_type == OBJ_ITER_DKEY_EPOCH) {
memcpy(&io->ui_dkey_punch_eph, data, kds->kd_key_len);
return 0;
Expand Down Expand Up @@ -1299,6 +1323,7 @@ enum_obj_io_unpack_cb(daos_key_desc_t *kds, void *ptr, unsigned int size,
rc = enum_unpack_recxs(kds, ptr, io, unpack_arg->csum_iov,
unpack_arg->cb, unpack_arg->cb_arg);
break;
case OBJ_ITER_OBJ_PUNCH_EPOCH:
case OBJ_ITER_DKEY_EPOCH:
case OBJ_ITER_AKEY_EPOCH:
rc = enum_unpack_punched_ephs(kds, ptr, io);
Expand Down
16 changes: 16 additions & 0 deletions src/object/srv_obj_migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct migrate_one {
uuid_t mo_pool_uuid;
uuid_t mo_cont_uuid;
daos_unit_oid_t mo_oid;
daos_epoch_t mo_obj_punch_eph;
daos_epoch_t mo_dkey_punch_eph;
daos_epoch_t mo_epoch;
daos_epoch_t mo_update_epoch;
Expand Down Expand Up @@ -1326,6 +1327,19 @@ migrate_dkey(struct migrate_pool_tls *tls, struct migrate_one *mrone)
D_GOTO(obj_close, rc);
}

/* punch the object */
if (mrone->mo_obj_punch_eph) {
rc = vos_obj_punch(cont->sc_hdl, mrone->mo_oid,
mrone->mo_obj_punch_eph,
tls->mpt_version, VOS_OF_REPLAY_PC,
NULL, 0, NULL, NULL);
if (rc) {
D_ERROR(DF_UOID" punch obj failed: rc %d\n",
DP_UOID(mrone->mo_oid), rc);
D_GOTO(obj_close, rc);
}
}

rc = migrate_punch(tls, mrone, cont);
if (rc)
D_GOTO(obj_close, rc);
Expand Down Expand Up @@ -1695,6 +1709,7 @@ migrate_one_insert(struct enum_unpack_arg *arg,
daos_unit_oid_t oid = io->ui_oid;
daos_key_t *dkey = &io->ui_dkey;
daos_epoch_t dkey_punch_eph = io->ui_dkey_punch_eph;
daos_epoch_t obj_punch_eph = io->ui_obj_punch_eph;
daos_iod_t *iods = io->ui_iods;
daos_epoch_t *akey_ephs = io->ui_akey_punch_ephs;
daos_epoch_t *rec_ephs = io->ui_rec_punch_ephs;
Expand Down Expand Up @@ -1731,6 +1746,7 @@ migrate_one_insert(struct enum_unpack_arg *arg,

mrone->mo_epoch = arg->epr.epr_hi;
mrone->mo_update_epoch = epoch;
mrone->mo_obj_punch_eph = obj_punch_eph;
mrone->mo_dkey_punch_eph = dkey_punch_eph;
D_ALLOC_ARRAY(mrone->mo_akey_punch_ephs, iod_eph_total);
if (mrone->mo_akey_punch_ephs == NULL)
Expand Down
1 change: 1 addition & 0 deletions src/rebuild/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ rebuild_container_scan_cb(daos_handle_t ih, vos_iter_entry_t *entry,
param.ip_epr.epr_lo = 0;
param.ip_epr.epr_hi = DAOS_EPOCH_MAX;
param.ip_flags = VOS_IT_FOR_MIGRATION;
param.ip_flags |= VOS_IT_PUNCHED;
uuid_copy(arg->co_uuid, entry->ie_couuid);
rc = vos_iterate(&param, VOS_ITER_OBJ, false, &anchor,
rebuild_obj_scan_cb, NULL, arg, &dth);
Expand Down
2 changes: 0 additions & 2 deletions src/tests/suite/daos_rebuild_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,6 @@ rebuild_snap_punch_empty(void **state)
int i;
int rc;

skip(); /** DAOS-4698 */

if (!test_runable(arg, 4))
return;

Expand Down

0 comments on commit 9186db4

Please sign in to comment.