bool udf_record_destroy(as_rec *rec) { if (!rec) { return false; } udf_record *urecord = (udf_record *) as_rec_source(rec); udf_record_close(urecord); udf_record_cleanup(urecord, true); return true; }
/* * Write the record to the storage in case there are write and closes the * record and frees up the stuff. With the pickled buf for each udf_record * it create single pickled buf for the entire LDT to be sent to the remote * for replica. * * Parameter: * lrecord : LDT record to operate on * pickled_* (out) to be populated is null if there was delete * lrecord_op (out) is set properly for the entire ldt * set_id : Set id for record. Passed for delete operation. * * Returns: 0 on success * otherwise on failure */ static int rw_finish(ldt_record *lrecord, write_request *wr, udf_optype * lrecord_op, uint16_t set_id) { int subrec_count = 0; udf_optype h_urecord_op = UDF_OPTYPE_READ; *lrecord_op = UDF_OPTYPE_READ; udf_record *h_urecord = as_rec_source(lrecord->h_urec); bool is_ldt = false; int ret = 0; getop(h_urecord, &h_urecord_op); if (h_urecord_op == UDF_OPTYPE_DELETE) { post_processing(h_urecord, &h_urecord_op, set_id); wr->pickled_buf = NULL; wr->pickled_sz = 0; as_rec_props_clear(&wr->pickled_rec_props); *lrecord_op = UDF_OPTYPE_DELETE; } else { if (h_urecord_op == UDF_OPTYPE_WRITE) { *lrecord_op = UDF_OPTYPE_WRITE; } FOR_EACH_SUBRECORD(i, j, lrecord) { udf_optype c_urecord_op = UDF_OPTYPE_READ; udf_record *c_urecord = &lrecord->chunk[i].slots[j].c_urecord; getop(c_urecord, &c_urecord_op); if (UDF_OP_IS_WRITE(c_urecord_op)) { is_ldt = true; subrec_count++; } post_processing(c_urecord, &c_urecord_op, set_id); } // Process the parent record in the end .. this is to make sure // the lock is held till the end. post_processing(h_urecord, &h_urecord_op, set_id); if (is_ldt) { // Create the multiop pickled buf for thr_rw.c ret = as_ldt_record_pickle(lrecord, &wr->pickled_buf, &wr->pickled_sz); FOR_EACH_SUBRECORD(i, j, lrecord) { udf_record *c_urecord = &lrecord->chunk[i].slots[j].c_urecord; // Cleanup in case pickle code bailed out // 1. either because this single node run no replica // 2. failed to pack stuff up. udf_record_cleanup(c_urecord, true); } } else {
/* * Write the record to the storage in case there are write and closes the * record and frees up the stuff. With the pickled buf for each udf_record * it create single pickled buf for the entire LDT to be sent to the remote * for replica. * * Parameter: * lrecord : LDT record to operate on * pickled_* (out) to be populated is null if there was delete * lrecord_op (out) is set properly for the entire ldt * set_id : Set id for record. Passed for delete operation. * * Returns: true always */ bool udf_rw_finish(ldt_record *lrecord, write_request *wr, udf_optype * lrecord_op, uint16_t set_id) { // LDT: Commit all the changes being done to the all records. // TODO: remove limit of 6 (note -- it's temporarily up to 20) udf_optype urecord_op = UDF_OPTYPE_READ; *lrecord_op = UDF_OPTYPE_READ; udf_record *h_urecord = as_rec_source(lrecord->h_urec); bool is_ldt = false; int ret = 0; udf_rw_post_processing(h_urecord, &urecord_op, set_id); if (urecord_op == UDF_OPTYPE_DELETE) { wr->pickled_buf = NULL; wr->pickled_sz = 0; wr->pickled_void_time = 0; as_rec_props_clear(&wr->pickled_rec_props); wr->ldt_rectype_bits = h_urecord->ldt_rectype_bits; *lrecord_op = UDF_OPTYPE_DELETE; } else { if (urecord_op == UDF_OPTYPE_WRITE) { *lrecord_op = UDF_OPTYPE_WRITE; } FOR_EACH_SUBRECORD(i, lrecord) { is_ldt = true; udf_record *c_urecord = &lrecord->chunk[i].c_urecord; udf_rw_post_processing(c_urecord, &urecord_op, set_id); if (urecord_op == UDF_OPTYPE_WRITE) { *lrecord_op = UDF_OPTYPE_LDT_WRITE; } } if (is_ldt) { // Create the multiop pickled buf for thr_rw.c ret = ldt_record_pickle(lrecord, &wr->pickled_buf, &wr->pickled_sz, &wr->pickled_void_time); FOR_EACH_SUBRECORD(i, lrecord) { udf_record *c_urecord = &lrecord->chunk[i].c_urecord; // Cleanup in case pickle code bailed out // 1. either because this single node run no replica // 2. failed to pack stuff up. udf_record_cleanup(c_urecord, true); } } else {