summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-09-27 15:50:50 -0700
committerSage Weil <sage@inktank.com>2013-10-01 12:04:42 -0700
commit933fe643b2f9a44850e69282d25ab7832a488dd7 (patch)
treebbfb951d8879df1917a7a9995f08c2be8963ab01
parenta9df335b12a093c31f947d5ca98883de9c2a5cf9 (diff)
downloadceph-933fe643b2f9a44850e69282d25ab7832a488dd7.tar.gz
osd/osd_types: replace bool lost with a flags field
This is more generic. We could also fold uses_tmap flag into here, but the encoding change for that is non-trivial. Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r--src/osd/ReplicatedPG.cc4
-rw-r--r--src/osd/osd_types.cc20
-rw-r--r--src/osd/osd_types.h27
3 files changed, 37 insertions, 14 deletions
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc
index fcaca434ba8..50d10eca863 100644
--- a/src/osd/ReplicatedPG.cc
+++ b/src/osd/ReplicatedPG.cc
@@ -981,7 +981,7 @@ void ReplicatedPG::do_op(OpRequestRef op)
return;
}
- if ((op->may_read()) && (obc->obs.oi.lost)) {
+ if ((op->may_read()) && (obc->obs.oi.is_lost())) {
// This object is lost. Reading from it returns an error.
dout(20) << __func__ << ": object " << obc->obs.oi.soid
<< " is lost" << dendl;
@@ -7108,7 +7108,7 @@ ObjectContextRef ReplicatedPG::mark_object_lost(ObjectStore::Transaction *t,
obc->ondisk_write_lock();
- obc->obs.oi.lost = true;
+ obc->obs.oi.set_flag(object_info_t::FLAG_LOST);
obc->obs.oi.version = info.last_update;
obc->obs.oi.prior_version = version;
diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc
index aa20dc592fa..84ebb393f72 100644
--- a/src/osd/osd_types.cc
+++ b/src/osd/osd_types.cc
@@ -2796,7 +2796,7 @@ void object_info_t::copy_user_bits(const object_info_t& other)
last_reqid = other.last_reqid;
truncate_seq = other.truncate_seq;
truncate_size = other.truncate_size;
- lost = other.lost;
+ flags = other.flags;
category = other.category;
uses_tmap = other.uses_tmap;
}
@@ -2839,7 +2839,7 @@ void object_info_t::encode(bufferlist& bl) const
::encode(snaps, bl);
::encode(truncate_seq, bl);
::encode(truncate_size, bl);
- ::encode(lost, bl);
+ ::encode((__u8)flags, bl);
::encode(old_watchers, bl);
/* shenanigans to avoid breaking backwards compatibility in the disk format.
* When we can, switch this out for simply putting the version_t on disk. */
@@ -2883,10 +2883,13 @@ void object_info_t::decode(bufferlist::iterator& bl)
::decode(snaps, bl);
::decode(truncate_seq, bl);
::decode(truncate_size, bl);
- if (struct_v >= 3)
- ::decode(lost, bl);
- else
- lost = false;
+ if (struct_v >= 3) {
+ __u8 f;
+ ::decode(f, bl);
+ flags = (flag_t)f;
+ } else {
+ flags = (flag_t)0;
+ }
if (struct_v >= 4) {
::decode(old_watchers, bl);
eversion_t user_eversion;
@@ -2924,7 +2927,8 @@ void object_info_t::dump(Formatter *f) const
f->dump_stream("last_reqid") << last_reqid;
f->dump_unsigned("size", size);
f->dump_stream("mtime") << mtime;
- f->dump_unsigned("lost", lost);
+ f->dump_unsigned("lost", (int)is_lost());
+ f->dump_unsigned("flags", (int)flags);
f->dump_stream("wrlock_by") << wrlock_by;
f->open_array_section("snaps");
for (vector<snapid_t>::const_iterator p = snaps.begin(); p != snaps.end(); ++p)
@@ -2960,7 +2964,7 @@ ostream& operator<<(ostream& out, const object_info_t& oi)
out << " wrlock_by=" << oi.wrlock_by;
else
out << " " << oi.snaps;
- if (oi.lost)
+ if (oi.is_lost())
out << " LOST";
out << ")";
return out;
diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h
index 884b8ada8cc..a912d3cf5f0 100644
--- a/src/osd/osd_types.h
+++ b/src/osd/osd_types.h
@@ -2093,7 +2093,12 @@ struct object_info_t {
uint64_t size;
utime_t mtime;
- bool lost;
+
+ // note: these are currently encoded into 8 bits; see encode()/decode()
+ typedef enum {
+ FLAG_LOST = 1<<0,
+ } flag_t;
+ flag_t flags;
osd_reqid_t wrlock_by; // [head]
vector<snapid_t> snaps; // [clone]
@@ -2109,6 +2114,19 @@ struct object_info_t {
static ps_t legacy_object_locator_to_ps(const object_t &oid,
const object_locator_t &loc);
+ bool test_flag(flag_t f) const {
+ return flags & f;
+ }
+ void set_flag(flag_t f) {
+ flags = (flag_t)(flags | f);
+ }
+ void clear_flag(flag_t f) {
+ flags = (flag_t)(flags & ~f);
+ }
+ bool is_lost() const {
+ return test_flag(FLAG_LOST);
+ }
+
void encode(bufferlist& bl) const;
void decode(bufferlist::iterator& bl);
void decode(bufferlist& bl) {
@@ -2119,13 +2137,14 @@ struct object_info_t {
static void generate_test_instances(list<object_info_t*>& o);
explicit object_info_t()
- : user_version(0), size(0), lost(false),
+ : user_version(0), size(0), flags((flag_t)0),
truncate_seq(0), truncate_size(0), uses_tmap(false)
{}
object_info_t(const hobject_t& s)
- : soid(s), user_version(0), size(0),
- lost(false), truncate_seq(0), truncate_size(0), uses_tmap(false) {}
+ : soid(s),
+ user_version(0), size(0), flags((flag_t)0),
+ truncate_seq(0), truncate_size(0), uses_tmap(false) {}
object_info_t(bufferlist& bl) {
decode(bl);