Пример #1
0
static int op_alloc(const LogEntry* e, Page* p) {
  assert(e->update.arg_size >= sizeof(alloc_arg));

  const alloc_arg* arg = stasis_log_entry_update_args_cptr(e);
  recordid rid = {
    p->id,
    arg->slot,
    arg->type
  };

  int ret = operate_helper(e->xid,p,rid);

  int64_t size = stasis_record_length_read(e->xid,p,rid);

  if(e->update.arg_size == sizeof(alloc_arg) + size) {
    // if we're aborting a dealloc we better have a sane preimage to apply
    rid.size = size;
    stasis_record_write(e->xid,p,rid,(const byte*)(arg+1));
    rid.size = arg->type;
  } else {
    // otherwise, no preimage
    assert(e->update.arg_size == sizeof(alloc_arg));
  }
  return ret;
}
Пример #2
0
static int op_increment(const LogEntry* e, Page* p) {
  int i;

  assert(e->update.arg_size == sizeof(slotid_t));
  recordid r = {p->id, *(const slotid_t*)stasis_log_entry_update_args_cptr(e), sizeof(int)};

  stasis_record_read(e->xid, p, r, (byte*)&i);
  i++;
  stasis_record_write(e->xid, p, r, (byte*)&i);

  return 0;
}