Rename flags to entry_type
This commit is contained in:
@@ -223,7 +223,7 @@ resume_1:
|
||||
bs->heap->unlock_entry(cur_oid, copy_id);
|
||||
goto resume_0;
|
||||
}
|
||||
assert(!end_wr->next() && end_wr->flags == (BS_HEAP_BIG_WRITE|BS_HEAP_STABLE));
|
||||
assert(!end_wr->next() && end_wr->entry_type == (BS_HEAP_BIG_WRITE|BS_HEAP_STABLE));
|
||||
clean_loc = end_wr->location;
|
||||
if (bs->log_level > 10)
|
||||
printf("Compacting %jx:%jx l%ju .. l%ju (last l%ju)\n", cur_oid.inode, cur_oid.stripe, end_wr->lsn, begin_wr->lsn, compact_lsn);
|
||||
|
||||
@@ -68,14 +68,14 @@ bool heap_write_t::needs_recheck(blockstore_heap_t *heap)
|
||||
|
||||
bool heap_write_t::needs_compact(blockstore_heap_t *heap)
|
||||
{
|
||||
return (flags == (BS_HEAP_SMALL_WRITE|BS_HEAP_STABLE) ||
|
||||
flags == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE) && heap->dsk->csum_block_size > heap->dsk->bitmap_granularity &&
|
||||
return (entry_type == (BS_HEAP_SMALL_WRITE|BS_HEAP_STABLE) ||
|
||||
entry_type == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE) && heap->dsk->csum_block_size > heap->dsk->bitmap_granularity &&
|
||||
((offset % heap->dsk->csum_block_size) || (len % heap->dsk->csum_block_size)));
|
||||
}
|
||||
|
||||
bool heap_write_t::is_compacted(uint64_t compacted_lsn)
|
||||
{
|
||||
return lsn <= compacted_lsn && (flags == (BS_HEAP_SMALL_WRITE|BS_HEAP_STABLE) || flags == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE));
|
||||
return lsn <= compacted_lsn && (entry_type == (BS_HEAP_SMALL_WRITE|BS_HEAP_STABLE) || entry_type == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE));
|
||||
}
|
||||
|
||||
bool heap_write_t::can_be_collapsed(blockstore_heap_t *heap)
|
||||
@@ -87,8 +87,8 @@ bool heap_write_t::can_be_collapsed(blockstore_heap_t *heap)
|
||||
bool heap_write_t::is_allowed_before_compacted(uint64_t compacted_lsn, bool is_last_entry)
|
||||
{
|
||||
return lsn <= compacted_lsn && (is_last_entry
|
||||
? (flags == (BS_HEAP_BIG_WRITE|BS_HEAP_STABLE))
|
||||
: (flags == (BS_HEAP_SMALL_WRITE|BS_HEAP_STABLE) || flags == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE)));
|
||||
? (entry_type == (BS_HEAP_BIG_WRITE|BS_HEAP_STABLE))
|
||||
: (entry_type == (BS_HEAP_SMALL_WRITE|BS_HEAP_STABLE) || entry_type == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE)));
|
||||
}
|
||||
|
||||
uint8_t *heap_write_t::get_ext_bitmap(blockstore_heap_t *heap)
|
||||
@@ -738,7 +738,7 @@ bool blockstore_heap_t::recheck_small_writes(std::function<void(bool is_data, ui
|
||||
if (is_intent)
|
||||
{
|
||||
auto next_wr = wr->next();
|
||||
assert(next_wr && next_wr->flags == (BS_HEAP_BIG_WRITE | (wr->flags & BS_HEAP_STABLE)));
|
||||
assert(next_wr && next_wr->entry_type == (BS_HEAP_BIG_WRITE | (wr->entry_type & BS_HEAP_STABLE)));
|
||||
loc = wr->offset + next_wr->location;
|
||||
}
|
||||
recheck_in_progress++;
|
||||
@@ -1247,8 +1247,8 @@ uint32_t blockstore_heap_t::block_has_compactable(uint8_t *data)
|
||||
region_marker > sizeof(heap_object_t))
|
||||
{
|
||||
heap_write_t *wr = (heap_write_t*)data;
|
||||
if (wr->flags == (BS_HEAP_SMALL_WRITE|BS_HEAP_STABLE) ||
|
||||
wr->flags == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE))
|
||||
if (wr->entry_type == (BS_HEAP_SMALL_WRITE|BS_HEAP_STABLE) ||
|
||||
wr->entry_type == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE))
|
||||
{
|
||||
// May be freed in the future
|
||||
sum += wr->size;
|
||||
@@ -1447,7 +1447,7 @@ bool blockstore_heap_t::mvcc_save_copy(heap_object_t *obj)
|
||||
if (wr->type() == BS_HEAP_BIG_WRITE)
|
||||
{
|
||||
mvcc_data_refs[wr->location] += add_ref;
|
||||
if (wr->flags & BS_HEAP_STABLE)
|
||||
if (wr->entry_type & BS_HEAP_STABLE)
|
||||
{
|
||||
if (!for_obj)
|
||||
{
|
||||
@@ -1491,19 +1491,19 @@ int blockstore_heap_t::update_object(uint32_t block_num, heap_object_t *obj, hea
|
||||
{
|
||||
const auto oid = (object_id){ .inode = obj->inode, .stripe = obj->stripe };
|
||||
// First some validation
|
||||
bool is_overwrite = (wr->flags == (BS_HEAP_BIG_WRITE|BS_HEAP_STABLE) || wr->flags == (BS_HEAP_TOMBSTONE|BS_HEAP_STABLE));
|
||||
bool is_overwrite = (wr->entry_type == (BS_HEAP_BIG_WRITE|BS_HEAP_STABLE) || wr->entry_type == (BS_HEAP_TOMBSTONE|BS_HEAP_STABLE));
|
||||
auto first_wr = obj->get_writes();
|
||||
if (first_wr->type() == BS_HEAP_TOMBSTONE && !is_overwrite)
|
||||
{
|
||||
// Small overwrites are only allowed over live objects
|
||||
return EINVAL;
|
||||
}
|
||||
if (!(first_wr->flags & BS_HEAP_STABLE) && (wr->flags & BS_HEAP_STABLE))
|
||||
if (!(first_wr->entry_type & BS_HEAP_STABLE) && (wr->entry_type & BS_HEAP_STABLE))
|
||||
{
|
||||
// Stable overwrites are not allowed over unstable
|
||||
return EINVAL;
|
||||
}
|
||||
if (wr->flags == BS_HEAP_INTENT_WRITE && (first_wr->flags & BS_HEAP_STABLE))
|
||||
if (wr->entry_type == BS_HEAP_INTENT_WRITE && (first_wr->entry_type & BS_HEAP_STABLE))
|
||||
{
|
||||
// Unstable intent writes over stable are not allowed
|
||||
return EINVAL;
|
||||
@@ -1673,7 +1673,7 @@ int blockstore_heap_t::post_stabilize(object_id oid, uint64_t version, uint32_t
|
||||
uint64_t stab_count = 0;
|
||||
for (; wr; wr = wr->next())
|
||||
{
|
||||
if ((wr->flags & BS_HEAP_STABLE))
|
||||
if ((wr->entry_type & BS_HEAP_STABLE))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -1721,9 +1721,9 @@ int blockstore_heap_t::post_stabilize(object_id oid, uint64_t version, uint32_t
|
||||
uint64_t last_lsn = next_lsn;
|
||||
for (wr = obj->get_writes(); wr; wr = wr->next())
|
||||
{
|
||||
if (!(wr->flags & BS_HEAP_STABLE) && wr->version <= version)
|
||||
if (!(wr->entry_type & BS_HEAP_STABLE) && wr->version <= version)
|
||||
{
|
||||
wr->flags |= BS_HEAP_STABLE;
|
||||
wr->entry_type |= BS_HEAP_STABLE;
|
||||
wr->lsn = last_lsn--;
|
||||
push_inflight_lsn(oid, wr->lsn, wr->needs_compact(this) ? HEAP_INFLIGHT_COMPACTABLE : 0);
|
||||
}
|
||||
@@ -1750,14 +1750,14 @@ int blockstore_heap_t::post_rollback(object_id oid, uint64_t version, uint64_t *
|
||||
// No such version
|
||||
return ENOENT;
|
||||
}
|
||||
if (wr->version == version && (wr->flags & BS_HEAP_STABLE))
|
||||
if (wr->version == version && (wr->entry_type & BS_HEAP_STABLE))
|
||||
{
|
||||
// Already rolled back
|
||||
return 0;
|
||||
}
|
||||
for (; wr && wr->version > version; wr = wr->next())
|
||||
{
|
||||
if (wr->flags & BS_HEAP_STABLE)
|
||||
if (wr->entry_type & BS_HEAP_STABLE)
|
||||
{
|
||||
// Already committed, can't rollback
|
||||
return EBUSY;
|
||||
@@ -1939,7 +1939,7 @@ void blockstore_heap_t::free_object_space(inode_t inode, heap_write_t *from, hea
|
||||
if (wr->type() == BS_HEAP_BIG_WRITE)
|
||||
{
|
||||
deref_data(inode, wr->location, mode != BS_HEAP_FREE_MAIN);
|
||||
if (mode == BS_HEAP_FREE_MVCC && (wr->flags & BS_HEAP_STABLE))
|
||||
if (mode == BS_HEAP_FREE_MVCC && (wr->entry_type & BS_HEAP_STABLE))
|
||||
{
|
||||
// Stop at the last visible version
|
||||
break;
|
||||
@@ -2045,7 +2045,7 @@ int blockstore_heap_t::list_objects(uint32_t pg_num, object_id min_oid, object_i
|
||||
auto first_wr = obj->get_writes();
|
||||
for (auto wr = first_wr; wr; wr = wr->next())
|
||||
{
|
||||
if (wr->flags & BS_HEAP_STABLE)
|
||||
if (wr->entry_type & BS_HEAP_STABLE)
|
||||
{
|
||||
stable_version = wr->version;
|
||||
break;
|
||||
|
||||
@@ -35,19 +35,19 @@ struct __attribute__((__packed__)) heap_write_t
|
||||
// size should have top bit cleared
|
||||
uint16_t size = 0;
|
||||
int16_t next_pos = 0;
|
||||
uint8_t entry_type = 0; // BS_HEAP_*
|
||||
uint64_t lsn = 0;
|
||||
uint64_t version = 0;
|
||||
uint32_t offset = 0;
|
||||
uint32_t len = 0;
|
||||
uint64_t location = 0;
|
||||
uint8_t flags = 0; // 1|2|3 = small|big|tombstone, 4|0 = stable|unstable
|
||||
|
||||
// uint8_t[] external_bitmap
|
||||
// uint8_t[] internal_bitmap
|
||||
// uint32_t[] checksums
|
||||
|
||||
heap_write_t *next();
|
||||
inline uint8_t type() const { return (flags & BS_HEAP_TYPE); }
|
||||
inline uint8_t type() const { return (entry_type & BS_HEAP_TYPE); }
|
||||
uint32_t get_size(blockstore_heap_t *heap);
|
||||
uint32_t get_csum_size(blockstore_heap_t *heap);
|
||||
bool needs_recheck(blockstore_heap_t *heap);
|
||||
|
||||
@@ -136,14 +136,14 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op)
|
||||
(!perfect_csum_update || dsk.csum_block_size <= dsk.bitmap_granularity ||
|
||||
!(op->offset % dsk.csum_block_size) &&
|
||||
!(op->len % dsk.csum_block_size) &&
|
||||
(obj->get_writes()->flags != (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE) ||
|
||||
(obj->get_writes()->entry_type != (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE) ||
|
||||
obj->get_writes()->can_be_collapsed(heap))) &&
|
||||
// One intent-write is allowed even with fsyncs because BIG_WRITE is always counted as fsynced
|
||||
dsk.disable_meta_fsync &&
|
||||
(op->opcode == BS_OP_WRITE_STABLE &&
|
||||
(obj->get_writes()->flags == (BS_HEAP_BIG_WRITE|BS_HEAP_STABLE) ||
|
||||
obj->get_writes()->flags == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE) && dsk.disable_data_fsync) ||
|
||||
op->opcode == BS_OP_WRITE && obj->get_writes()->flags == BS_HEAP_BIG_WRITE))
|
||||
(obj->get_writes()->entry_type == (BS_HEAP_BIG_WRITE|BS_HEAP_STABLE) ||
|
||||
obj->get_writes()->entry_type == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE) && dsk.disable_data_fsync) ||
|
||||
op->opcode == BS_OP_WRITE && obj->get_writes()->entry_type == BS_HEAP_BIG_WRITE))
|
||||
{
|
||||
// Direct intent-write
|
||||
BS_SUBMIT_CHECK_SQES(1);
|
||||
@@ -163,7 +163,7 @@ process_intent:
|
||||
wr->offset = op->offset;
|
||||
wr->len = op->len;
|
||||
wr->location = 0;
|
||||
wr->flags = BS_HEAP_INTENT_WRITE | (op->opcode == BS_OP_WRITE_STABLE ? BS_HEAP_STABLE : 0);
|
||||
wr->entry_type = BS_HEAP_INTENT_WRITE | (op->opcode == BS_OP_WRITE_STABLE ? BS_HEAP_STABLE : 0);
|
||||
if (op->bitmap)
|
||||
memcpy(wr->get_ext_bitmap(heap), op->bitmap, dsk.clean_entry_bitmap_size);
|
||||
heap->calc_checksums(wr, (uint8_t*)op->buf, true);
|
||||
@@ -212,7 +212,7 @@ process_intent:
|
||||
wr->len = op->len;
|
||||
wr->location = loc;
|
||||
PRIV(op)->location = loc;
|
||||
wr->flags = BS_HEAP_SMALL_WRITE | (op->opcode == BS_OP_WRITE_STABLE ? BS_HEAP_STABLE : 0);
|
||||
wr->entry_type = BS_HEAP_SMALL_WRITE | (op->opcode == BS_OP_WRITE_STABLE ? BS_HEAP_STABLE : 0);
|
||||
if (op->bitmap)
|
||||
memcpy(wr->get_ext_bitmap(heap), op->bitmap, dsk.clean_entry_bitmap_size);
|
||||
heap->calc_checksums(wr, (uint8_t*)op->buf, true);
|
||||
@@ -271,7 +271,7 @@ int blockstore_impl_t::make_big_write(blockstore_op_t *op, uint32_t offset, uint
|
||||
wr->offset = offset;
|
||||
wr->len = len;
|
||||
wr->location = PRIV(op)->location;
|
||||
wr->flags = BS_HEAP_BIG_WRITE | (op->opcode == BS_OP_WRITE_STABLE ? BS_HEAP_STABLE : 0);
|
||||
wr->entry_type = BS_HEAP_BIG_WRITE | (op->opcode == BS_OP_WRITE_STABLE ? BS_HEAP_STABLE : 0);
|
||||
if (op->bitmap)
|
||||
memcpy(wr->get_ext_bitmap(heap), op->bitmap, dsk.clean_entry_bitmap_size);
|
||||
memset(wr->get_int_bitmap(heap), 0, dsk.clean_entry_bitmap_size);
|
||||
|
||||
Reference in New Issue
Block a user