]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/osd_types: replace bool lost with a flags field
authorSage Weil <sage@inktank.com>
Fri, 27 Sep 2013 22:50:50 +0000 (15:50 -0700)
committerSage Weil <sage@inktank.com>
Tue, 1 Oct 2013 21:17:58 +0000 (14:17 -0700)
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>
src/osd/ReplicatedPG.cc
src/osd/osd_types.cc
src/osd/osd_types.h

index fcaca434ba895ddbc9267ba2628007bc7d0a8f17..50d10eca86378b8837a57934c50b2eb4800832df 100644 (file)
@@ -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;
 
index aa20dc592fa52c85806aa2d949ad78a0529dcc4e..84ebb393f72b5ce554a08af43d2fbc146175847a 100644 (file)
@@ -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;
index 884b8ada8ccb62e727762feb7725d8910b4da468..aa1b08193628cef644fb72eb866837b8126260b1 100644 (file)
@@ -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) == 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);