]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/osd_types: convert object_info_t::uses_tmap to a flag 670/head
authorSage Weil <sage@inktank.com>
Tue, 1 Oct 2013 19:24:58 +0000 (12:24 -0700)
committerSage Weil <sage@inktank.com>
Tue, 1 Oct 2013 21:17:59 +0000 (14:17 -0700)
Treat the second encoded bool as bits 9-16 of a (now) 16-bit flags field,
and use bit 9 (what used to be set by the use_tmap bool) as FLAG_USES_TMAP.

No encoding compatibility change.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/ReplicatedPG.cc
src/osd/osd_types.cc
src/osd/osd_types.h

index 1a529919bc3bf170f6d3cebe5f6ac0367538561a..e88c5cc97903227e6b244f26547ad11653e36410 100644 (file)
@@ -3292,7 +3292,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
 
        if (cct->_conf->osd_tmapput_sets_uses_tmap) {
          assert(cct->_conf->osd_auto_upgrade_tmap);
-         oi.uses_tmap = true;
+         oi.set_flag(object_info_t::FLAG_USES_TMAP);
        }
 
        // write it
@@ -3340,7 +3340,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
        }
        set<string> out_set;
 
-       if (oi.uses_tmap && cct->_conf->osd_auto_upgrade_tmap) {
+       if (oi.test_flag(object_info_t::FLAG_USES_TMAP) && cct->_conf->osd_auto_upgrade_tmap) {
          dout(20) << "CEPH_OSD_OP_OMAPGETKEYS: "
                   << " Reading " << oi.soid << " omap from tmap" << dendl;
          map<string, bufferlist> vals;
@@ -3398,7 +3398,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
        }
        map<string, bufferlist> out_set;
 
-       if (oi.uses_tmap && cct->_conf->osd_auto_upgrade_tmap) {
+       if (oi.test_flag(object_info_t::FLAG_USES_TMAP) && cct->_conf->osd_auto_upgrade_tmap) {
          dout(20) << "CEPH_OSD_OP_OMAPGETVALS: "
                   << " Reading " << oi.soid << " omap from tmap" << dendl;
          map<string, bufferlist> vals;
@@ -3449,7 +3449,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
     case CEPH_OSD_OP_OMAPGETHEADER:
       ++ctx->num_read;
       {
-       if (oi.uses_tmap && cct->_conf->osd_auto_upgrade_tmap) {
+       if (oi.test_flag(object_info_t::FLAG_USES_TMAP) && cct->_conf->osd_auto_upgrade_tmap) {
          dout(20) << "CEPH_OSD_OP_OMAPGETHEADER: "
                   << " Reading " << oi.soid << " omap from tmap" << dendl;
          map<string, bufferlist> vals;
@@ -3480,7 +3480,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
          goto fail;
        }
        map<string, bufferlist> out;
-       if (oi.uses_tmap && cct->_conf->osd_auto_upgrade_tmap) {
+       if (oi.test_flag(object_info_t::FLAG_USES_TMAP) && cct->_conf->osd_auto_upgrade_tmap) {
          dout(20) << "CEPH_OSD_OP_OMAPGET: "
                   << " Reading " << oi.soid << " omap from tmap" << dendl;
          map<string, bufferlist> vals;
@@ -3579,7 +3579,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
     case CEPH_OSD_OP_OMAPSETVALS:
       ++ctx->num_write;
       {
-       if (oi.uses_tmap && cct->_conf->osd_auto_upgrade_tmap) {
+       if (oi.test_flag(object_info_t::FLAG_USES_TMAP) && cct->_conf->osd_auto_upgrade_tmap) {
          _copy_up_tmap(ctx);
        }
        if (!obs.exists) {
@@ -3609,7 +3609,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
     case CEPH_OSD_OP_OMAPSETHEADER:
       ++ctx->num_write;
       {
-       if (oi.uses_tmap && cct->_conf->osd_auto_upgrade_tmap) {
+       if (oi.test_flag(object_info_t::FLAG_USES_TMAP) && cct->_conf->osd_auto_upgrade_tmap) {
          _copy_up_tmap(ctx);
        }
        if (!obs.exists) {
@@ -3629,7 +3629,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
          result = -ENOENT;
          break;
        }
-       if (oi.uses_tmap && cct->_conf->osd_auto_upgrade_tmap) {
+       if (oi.test_flag(object_info_t::FLAG_USES_TMAP) && cct->_conf->osd_auto_upgrade_tmap) {
          _copy_up_tmap(ctx);
        }
        t.touch(coll, soid);
@@ -3645,7 +3645,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
          result = -ENOENT;
          break;
        }
-       if (oi.uses_tmap && cct->_conf->osd_auto_upgrade_tmap) {
+       if (oi.test_flag(object_info_t::FLAG_USES_TMAP) && cct->_conf->osd_auto_upgrade_tmap) {
          _copy_up_tmap(ctx);
        }
        t.touch(coll, soid);
@@ -3824,7 +3824,7 @@ int ReplicatedPG::_get_tmap(OpContext *ctx,
 int ReplicatedPG::_copy_up_tmap(OpContext *ctx)
 {
   dout(20) << "copying up tmap for " << ctx->new_obs.oi.soid << dendl;
-  ctx->new_obs.oi.uses_tmap = false;
+  ctx->new_obs.oi.clear_flag(object_info_t::FLAG_USES_TMAP);
   map<string, bufferlist> vals;
   bufferlist header;
   int r = _get_tmap(ctx, &vals, &header);
index e8960584c251b803ee7f2107e408b0f195494bfd..952f0cf75d78a634650239151570c528d0909833 100644 (file)
@@ -2798,7 +2798,6 @@ void object_info_t::copy_user_bits(const object_info_t& other)
   truncate_size = other.truncate_size;
   flags = other.flags;
   category = other.category;
-  uses_tmap = other.uses_tmap;
 }
 
 ps_t object_info_t::legacy_object_locator_to_ps(const object_t &oid, 
@@ -2839,13 +2838,15 @@ void object_info_t::encode(bufferlist& bl) const
     ::encode(snaps, bl);
   ::encode(truncate_seq, bl);
   ::encode(truncate_size, bl);
-  ::encode((__u8)flags, bl);
+  __u8 flags_lo = flags & 0xff;
+  __u8 flags_hi = (flags & 0xff00) >> 8;
+  ::encode(flags_lo, 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. */
   eversion_t user_eversion(0, user_version);
   ::encode(user_eversion, bl);
-  ::encode(uses_tmap, bl);
+  ::encode(flags_hi, bl);
   ::encode(watchers, bl);
   ENCODE_FINISH(bl);
 }
@@ -2884,9 +2885,9 @@ void object_info_t::decode(bufferlist::iterator& bl)
   ::decode(truncate_seq, bl);
   ::decode(truncate_size, bl);
   if (struct_v >= 3) {
-    __u8 f;
-    ::decode(f, bl);
-    flags = (flag_t)f;
+    __u8 lo;
+    ::decode(lo, bl);
+    flags = (flag_t)lo;
   } else {
     flags = (flag_t)0;
   }
@@ -2896,10 +2897,13 @@ void object_info_t::decode(bufferlist::iterator& bl)
     ::decode(user_eversion, bl);
     user_version = user_eversion.version;
   }
-  if (struct_v >= 9)
-    ::decode(uses_tmap, bl);
-  else
-    uses_tmap = true;
+  if (struct_v >= 9) {
+    __u8 hi;
+    ::decode(hi, bl);
+    flags = (flag_t)(flags | ((unsigned)hi << 8));
+  } else {
+    set_flag(FLAG_USES_TMAP);
+  }
   if (struct_v < 10)
     soid.pool = myoloc.pool;
   if (struct_v >= 11) {
index 97a5b2e71f814696d1499c277868d24641a8cb16..9d440e25bde3db740d7b806c2ceb9e68ed9b2837 100644 (file)
@@ -2094,10 +2094,13 @@ struct object_info_t {
   uint64_t size;
   utime_t mtime;
 
-  // note: these are currently encoded into 8 bits; see encode()/decode()
+  // note: these are currently encoded into a total 16 bits; see
+  // encode()/decode() for the weirdness.
   typedef enum {
     FLAG_LOST     = 1<<0,
     FLAG_WHITEOUT = 1<<1,  // object logically does not exist
+    // ...
+    FLAG_USES_TMAP = 1<<8,
   } flag_t;
   flag_t flags;
 
@@ -2108,7 +2111,6 @@ struct object_info_t {
 
 
   map<pair<uint64_t, entity_name_t>, watch_info_t> watchers;
-  bool uses_tmap;
 
   void copy_user_bits(const object_info_t& other);
 
@@ -2142,13 +2144,13 @@ struct object_info_t {
 
   explicit object_info_t()
     : user_version(0), size(0), flags((flag_t)0),
-      truncate_seq(0), truncate_size(0), uses_tmap(false)
+      truncate_seq(0), truncate_size(0)
   {}
 
   object_info_t(const hobject_t& s)
     : soid(s),
       user_version(0), size(0), flags((flag_t)0),
-      truncate_seq(0), truncate_size(0), uses_tmap(false) {}
+      truncate_seq(0), truncate_size(0) {}
 
   object_info_t(bufferlist& bl) {
     decode(bl);