}
for (auto& p : obc->obs.oi.manifest.chunk_map) {
- if (p.second.flags == chunk_info_t::FLAG_MISSING) {
+ if (p.second.is_missing()) {
const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
const object_locator_t oloc = m->get_object_locator();
promote_object(obc, obc->obs.oi.soid, oloc, op, NULL);
bool all_dirty = true;
for (auto& p : obc->obs.oi.manifest.chunk_map) {
- if (p.second.flags != chunk_info_t::FLAG_DIRTY) {
+ if (!p.second.is_dirty()) {
all_dirty = false;
}
}
map<uint64_t, chunk_info_t>::iterator iter = manifest.chunk_map.find(start_offset);
ceph_assert(iter != manifest.chunk_map.end());
for (;iter != manifest.chunk_map.end(); ++iter) {
- if (iter->second.flags == chunk_info_t::FLAG_DIRTY) {
+ if (iter->second.is_dirty()) {
last_offset = iter->first;
max_copy_size += iter->second.length;
}
iter = manifest.chunk_map.find(start_offset);
for (;iter != manifest.chunk_map.end(); ++iter) {
- if (iter->second.flags != chunk_info_t::FLAG_DIRTY) {
+ if (!iter->second.is_dirty()) {
continue;
}
uint64_t tgt_length = iter->second.length;
obc->obs.oi.manifest.chunk_map.find(last_offset);
ceph_assert(iter != obc->obs.oi.manifest.chunk_map.end());
for (;iter != obc->obs.oi.manifest.chunk_map.end(); ++iter) {
- if (iter->second.flags == chunk_info_t::FLAG_DIRTY && last_offset < iter->first) {
+ if (iter->second.is_dirty() && last_offset < iter->first) {
do_manifest_flush(p->second->op, obc, p->second, iter->first, p->second->blocking);
return;
}
/* requested chunks exist in chunk_map ? */
for (auto &p : obc->obs.oi.manifest.chunk_map) {
if (p.first <= cursor && p.first + p.second.length > cursor) {
- if (p.second.flags != chunk_info_t::FLAG_MISSING) {
+ if (!p.second.is_missing()) {
return false;
}
if (p.second.length >= remain) {
ctx->register_on_commit(
[oi, ctx, this](){
for (auto p : oi.manifest.chunk_map) {
- if (p.second.flags & chunk_info_t::FLAG_HAS_REFERENCE) {
+ if (p.second.has_reference()) {
object_locator_t target_oloc(p.second.oid);
refcount_manifest(ctx->obc, target_oloc, p.second.oid,
SnapContext(), false, NULL, p.first);
}
chunk_info_t chunk_info;
- chunk_info.flags = chunk_info_t::FLAG_MISSING;
+ chunk_info.set_flag(chunk_info_t::FLAG_MISSING);
chunk_info.oid = target;
chunk_info.offset = tgt_offset;
chunk_info.length= src_length;
oi.set_flag(object_info_t::FLAG_MANIFEST);
oi.manifest.type = object_manifest_t::TYPE_CHUNKED;
if (!has_reference && need_reference) {
- oi.manifest.chunk_map[src_offset].flags |=
- chunk_info_t::FLAG_HAS_REFERENCE;
+ oi.manifest.chunk_map[src_offset].set_flag(chunk_info_t::FLAG_HAS_REFERENCE);
}
if (need_reference && pool.info.get_fingerprint_type() != pg_pool_t::TYPE_FINGERPRINT_NONE) {
- oi.manifest.chunk_map[src_offset].flags |= chunk_info_t::FLAG_HAS_FINGERPRINT;
+ oi.manifest.chunk_map[src_offset].set_flag(chunk_info_t::FLAG_HAS_FINGERPRINT);
}
ctx->modify = true;
for (auto &p : oi.manifest.chunk_map) {
if ((p.first <= offset && p.first + p.second.length > offset) ||
(p.first > offset && p.first <= offset + length)) {
- p.second.flags = chunk_info_t::FLAG_DIRTY;
+ p.second.clear_flag(chunk_info_t::FLAG_MISSING);
+ p.second.set_flag(chunk_info_t::FLAG_DIRTY);
}
}
}
<< " length: " << sub_chunk.outdata.length() << dendl;
write_update_size_and_usage(ctx->delta_stats, obs.oi, ctx->modified_ranges,
p.second->cursor.data_offset, sub_chunk.outdata.length());
- obs.oi.manifest.chunk_map[p.second->cursor.data_offset].flags = 0; // clean
+ obs.oi.manifest.chunk_map[p.second->cursor.data_offset].clear_flag(chunk_info_t::FLAG_DIRTY);
+ obs.oi.manifest.chunk_map[p.second->cursor.data_offset].clear_flag(chunk_info_t::FLAG_MISSING);
sub_chunk.outdata.clear();
}
obs.oi.clear_data_digest();
0);
ctx->new_obs.oi.new_object();
for (auto &p : ctx->new_obs.oi.manifest.chunk_map) {
- p.second.flags = chunk_info_t::FLAG_MISSING;
+ p.second.clear_flag(chunk_info_t::FLAG_DIRTY);
+ p.second.set_flag(chunk_info_t::FLAG_MISSING);
}
} else {
for (auto &p : ctx->new_obs.oi.manifest.chunk_map) {
- if (p.second.flags == chunk_info_t::FLAG_DIRTY) {
+ if (p.second.is_dirty()) {
dout(20) << __func__ << " offset: " << p.second.offset
<< " length: " << p.second.length << dendl;
- p.second.flags = 0; // CLEAN
+ p.second.clear_flag(chunk_info_t::FLAG_DIRTY);
+ p.second.clear_flag(chunk_info_t::FLAG_MISSING); // CLEAN
}
}
}
}
struct chunk_info_t {
- enum {
+ typedef enum {
FLAG_DIRTY = 1,
FLAG_MISSING = 2,
FLAG_HAS_REFERENCE = 4,
FLAG_HAS_FINGERPRINT = 8,
- };
+ } cflag_t;
uint32_t offset;
uint32_t length;
hobject_t oid;
- uint32_t flags; // FLAG_*
+ cflag_t flags; // FLAG_*
- chunk_info_t() : offset(0), length(0), flags(0) { }
+ chunk_info_t() : offset(0), length(0), flags((cflag_t)0) { }
static string get_flag_string(uint64_t flags) {
string r;
return r.substr(1);
return r;
}
+ bool test_flag(cflag_t f) const {
+ return (flags & f) == f;
+ }
+ void set_flag(cflag_t f) {
+ flags = (cflag_t)(flags | f);
+ }
+ void set_flags(cflag_t f) {
+ flags = f;
+ }
+ void clear_flag(cflag_t f) {
+ flags = (cflag_t)(flags & ~f);
+ }
+ void clear_flags() {
+ flags = (cflag_t)0;
+ }
+ bool is_dirty() const {
+ return test_flag(FLAG_DIRTY);
+ }
+ bool is_missing() const {
+ return test_flag(FLAG_MISSING);
+ }
+ bool has_reference() const {
+ return test_flag(FLAG_HAS_REFERENCE);
+ }
+ bool has_fingerprint() const {
+ return test_flag(FLAG_HAS_FINGERPRINT);
+ }
void encode(bufferlist &bl) const;
void decode(bufferlist::const_iterator &bl);
void dump(Formatter *f) const;