]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
automake cleanup: moving hobject from os to common
authorRoald J. van Loon <roaldvanloon@gmail.com>
Sat, 7 Sep 2013 13:16:27 +0000 (15:16 +0200)
committerRoald J. van Loon <roaldvanloon@gmail.com>
Sat, 7 Sep 2013 20:41:10 +0000 (22:41 +0200)
This file is used by libcommon, so lets put it in src/common instead of
src/os.

Signed-off-by: Roald J. van Loon <roaldvanloon@gmail.com>
src/Makefile.am
src/common/hobject.cc [new file with mode: 0644]
src/common/hobject.h [new file with mode: 0644]
src/os/FDCache.h
src/os/WBThrottle.h
src/os/hobject.cc [deleted file]
src/os/hobject.h [deleted file]
src/osd/SnapMapper.h
src/osd/osd_types.h
src/test/encoding/types.h

index cf08504a76d1ca5a097004a16033f66409224756..9380a8ed8cf894f1e27712e4b03218d659779beb 100644 (file)
@@ -1594,7 +1594,7 @@ libcommon_files = \
        msg/Pipe.cc \
        msg/SimpleMessenger.cc \
        msg/msg_types.cc \
-       os/hobject.cc \
+       common/hobject.cc \
        osd/OSDMap.cc \
        osd/osd_types.cc \
        mds/MDSMap.cc \
@@ -2240,7 +2240,7 @@ noinst_HEADERS = \
        os/btrfs_ioctl.h\
        os/ZFS.h\
        os/chain_xattr.h\
-       os/hobject.h \
+       common/hobject.h \
        os/CollectionIndex.h\
         os/FileJournal.h\
         os/FileStore.h\
diff --git a/src/common/hobject.cc b/src/common/hobject.cc
new file mode 100644 (file)
index 0000000..d627369
--- /dev/null
@@ -0,0 +1,193 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "include/types.h"
+#include "hobject.h"
+#include "common/Formatter.h"
+
+static void append_escaped(const string &in, string *out)
+{
+  for (string::const_iterator i = in.begin(); i != in.end(); ++i) {
+    if (*i == '%') {
+      out->push_back('%');
+      out->push_back('p');
+    } else if (*i == '.') {
+      out->push_back('%');
+      out->push_back('e');
+    } else if (*i == '_') {
+      out->push_back('%');
+      out->push_back('u');
+    } else {
+      out->push_back(*i);
+    }
+  }
+}
+
+set<string> hobject_t::get_prefixes(
+  uint32_t bits,
+  uint32_t mask,
+  int64_t pool)
+{
+  uint32_t len = bits;
+  while (len % 4 /* nibbles */) len++;
+
+  set<uint32_t> from;
+  if (bits < 32)
+    from.insert(mask & ~((uint32_t)(~0) << bits));
+  else if (bits == 32)
+    from.insert(mask);
+  else
+    assert(0);
+
+
+  set<uint32_t> to;
+  for (uint32_t i = bits; i < len; ++i) {
+    for (set<uint32_t>::iterator j = from.begin();
+        j != from.end();
+        ++j) {
+      to.insert(*j | (1 << i));
+      to.insert(*j);
+    }
+    to.swap(from);
+    to.clear();
+  }
+
+  char buf[20];
+  char *t = buf;
+  uint64_t poolid(pool);
+  t += snprintf(t, sizeof(buf), "%.*llX", 16, (long long unsigned)poolid);
+  *(t++) = '.';
+  string poolstr(buf, t - buf);
+  set<string> ret;
+  for (set<uint32_t>::iterator i = from.begin();
+       i != from.end();
+       ++i) {
+    uint32_t revhash(hobject_t::_reverse_nibbles(*i));
+    snprintf(buf, sizeof(buf), "%.*X", (int)(sizeof(revhash))*2, revhash);
+    ret.insert(poolstr + string(buf, len/4));
+  }
+  return ret;
+}
+
+string hobject_t::to_str() const
+{
+  string out;
+
+  char snap_with_hash[1000];
+  char *t = snap_with_hash;
+  char *end = t + sizeof(snap_with_hash);
+
+  uint64_t poolid(pool);
+  t += snprintf(t, end - t, "%.*llX", 16, (long long unsigned)poolid);
+
+  uint32_t revhash(get_filestore_key_u32());
+  t += snprintf(t, end - t, ".%.*X", 8, revhash);
+
+  if (snap == CEPH_NOSNAP)
+    t += snprintf(t, end - t, ".head");
+  else if (snap == CEPH_SNAPDIR)
+    t += snprintf(t, end - t, ".snapdir");
+  else
+    t += snprintf(t, end - t, ".%llx", (long long unsigned)snap);
+
+  out += string(snap_with_hash);
+
+  out.push_back('.');
+  append_escaped(oid.name, &out);
+  out.push_back('.');
+  append_escaped(get_key(), &out);
+  out.push_back('.');
+  append_escaped(nspace, &out);
+
+  return out;
+}
+
+void hobject_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(4, 3, bl);
+  ::encode(key, bl);
+  ::encode(oid, bl);
+  ::encode(snap, bl);
+  ::encode(hash, bl);
+  ::encode(max, bl);
+  ::encode(nspace, bl);
+  ::encode(pool, bl);
+  ENCODE_FINISH(bl);
+}
+
+void hobject_t::decode(bufferlist::iterator& bl)
+{
+  DECODE_START_LEGACY_COMPAT_LEN(4, 3, 3, bl);
+  if (struct_v >= 1)
+    ::decode(key, bl);
+  ::decode(oid, bl);
+  ::decode(snap, bl);
+  ::decode(hash, bl);
+  if (struct_v >= 2)
+    ::decode(max, bl);
+  else
+    max = false;
+  if (struct_v >= 4) {
+    ::decode(nspace, bl);
+    ::decode(pool, bl);
+  }
+  DECODE_FINISH(bl);
+}
+
+void hobject_t::decode(json_spirit::Value& v)
+{
+  using namespace json_spirit;
+  Object& o = v.get_obj();
+  for (Object::size_type i=0; i<o.size(); i++) {
+    Pair& p = o[i];
+    if (p.name_ == "oid")
+      oid.name = p.value_.get_str();
+    else if (p.name_ == "key")
+      key = p.value_.get_str();
+    else if (p.name_ == "snapid")
+      snap = p.value_.get_uint64();
+    else if (p.name_ == "hash")
+      hash = p.value_.get_int();
+    else if (p.name_ == "max")
+      max = p.value_.get_int();
+    else if (p.name_ == "pool")
+      pool = p.value_.get_int();
+    else if (p.name_ == "namespace")
+      nspace = p.value_.get_str();
+  }
+}
+
+void hobject_t::dump(Formatter *f) const
+{
+  f->dump_string("oid", oid.name);
+  f->dump_string("key", key);
+  f->dump_int("snapid", snap);
+  f->dump_int("hash", hash);
+  f->dump_int("max", (int)max);
+  f->dump_int("pool", pool);
+  f->dump_string("namespace", nspace);
+}
+
+void hobject_t::generate_test_instances(list<hobject_t*>& o)
+{
+  o.push_back(new hobject_t);
+  o.push_back(new hobject_t);
+  o.back()->max = true;
+  o.push_back(new hobject_t(object_t("oname"), string(), 1, 234, -1, ""));
+  o.push_back(new hobject_t(object_t("oname2"), string("okey"), CEPH_NOSNAP,
+       67, 0, "n1"));
+  o.push_back(new hobject_t(object_t("oname3"), string("oname3"),
+       CEPH_SNAPDIR, 910, 1, "n2"));
+}
+
+ostream& operator<<(ostream& out, const hobject_t& o)
+{
+  if (o.is_max())
+    return out << "MAX";
+  out << std::hex << o.hash << std::dec;
+  if (o.get_key().length())
+    out << "." << o.get_key();
+  out << "/" << o.oid << "/" << o.snap;
+  out << "/" << o.nspace << "/" << o.pool;
+  return out;
+}
diff --git a/src/common/hobject.h b/src/common/hobject.h
new file mode 100644 (file)
index 0000000..633e471
--- /dev/null
@@ -0,0 +1,182 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software 
+ * Foundation.  See file COPYING.
+ * 
+ */
+
+#ifndef __CEPH_OS_HOBJECT_H
+#define __CEPH_OS_HOBJECT_H
+
+#include <string.h>
+#include "include/types.h"
+#include "include/object.h"
+#include "include/cmp.h"
+
+#include "json_spirit/json_spirit_value.h"
+#include "include/assert.h"   // spirit clobbers it!
+
+typedef uint64_t filestore_hobject_key_t;
+
+namespace ceph {
+  class Formatter;
+}
+
+struct hobject_t {
+  object_t oid;
+  snapid_t snap;
+  uint32_t hash;
+private:
+  bool max;
+public:
+  int64_t pool;
+  string nspace;
+
+private:
+  string key;
+
+public:
+  const string &get_key() const {
+    return key;
+  }
+
+  string to_str() const;
+
+  static bool match_hash(uint32_t to_check, uint32_t bits, uint32_t match) {
+    return (match & ~((~0)<<bits)) == (to_check & ~((~0)<<bits));
+  }
+  bool match(uint32_t bits, uint32_t match) const {
+    return match_hash(hash, bits, match);
+  }
+  
+  hobject_t() : snap(0), hash(0), max(false), pool(-1) {}
+
+  hobject_t(object_t oid, const string& key, snapid_t snap, uint64_t hash,
+           int64_t pool, string nspace) :
+    oid(oid), snap(snap), hash(hash), max(false),
+    pool(pool), nspace(nspace),
+    key(oid.name == key ? string() : key) {}
+
+  hobject_t(const sobject_t &soid, const string &key, uint32_t hash,
+           int64_t pool, string nspace) :
+    oid(soid.oid), snap(soid.snap), hash(hash), max(false),
+    pool(pool), nspace(nspace),
+    key(soid.oid.name == key ? string() : key) {}
+
+  /// @return min hobject_t ret s.t. ret.hash == this->hash
+  hobject_t get_boundary() const {
+    if (is_max())
+      return *this;
+    hobject_t ret;
+    ret.hash = hash;
+    return ret;
+  }
+
+  /* Do not use when a particular hash function is needed */
+  explicit hobject_t(const sobject_t &o) :
+    oid(o.oid), snap(o.snap), max(false), pool(-1) {
+    hash = __gnu_cxx::hash<sobject_t>()(o);
+  }
+
+  // maximum sorted value.
+  static hobject_t get_max() {
+    hobject_t h;
+    h.max = true;
+    return h;
+  }
+  bool is_max() const {
+    return max;
+  }
+
+  static uint32_t _reverse_nibbles(uint32_t retval) {
+    // reverse nibbles
+    retval = ((retval & 0x0f0f0f0f) << 4) | ((retval & 0xf0f0f0f0) >> 4);
+    retval = ((retval & 0x00ff00ff) << 8) | ((retval & 0xff00ff00) >> 8);
+    retval = ((retval & 0x0000ffff) << 16) | ((retval & 0xffff0000) >> 16);
+    return retval;
+  }
+
+  /**
+   * Returns set S of strings such that for any object
+   * h where h.match(bits, mask), there is some string
+   * s \in S such that s is a prefix of h.to_str().
+   * Furthermore, for any s \in S, s is a prefix of
+   * h.str() implies that h.match(bits, mask).
+   */
+  static set<string> get_prefixes(
+    uint32_t bits,
+    uint32_t mask,
+    int64_t pool);
+
+  filestore_hobject_key_t get_filestore_key_u32() const {
+    assert(!max);
+    return _reverse_nibbles(hash);
+  }
+  filestore_hobject_key_t get_filestore_key() const {
+    if (max)
+      return 0x100000000ull;
+    else
+      return get_filestore_key_u32();
+  }
+
+  const string& get_effective_key() const {
+    if (key.length())
+      return key;
+    return oid.name;
+  }
+
+  void swap(hobject_t &o) {
+    hobject_t temp(o);
+    o = (*this);
+    (*this) = temp;
+  }
+
+  string get_namespace() const {
+    return nspace;
+  }
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& bl);
+  void decode(json_spirit::Value& v);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<hobject_t*>& o);
+  friend bool operator<(const hobject_t&, const hobject_t&);
+  friend bool operator>(const hobject_t&, const hobject_t&);
+  friend bool operator<=(const hobject_t&, const hobject_t&);
+  friend bool operator>=(const hobject_t&, const hobject_t&);
+  friend bool operator==(const hobject_t&, const hobject_t&);
+  friend bool operator!=(const hobject_t&, const hobject_t&);
+};
+WRITE_CLASS_ENCODER(hobject_t)
+
+namespace __gnu_cxx {
+  template<> struct hash<hobject_t> {
+    size_t operator()(const hobject_t &r) const {
+      static hash<object_t> H;
+      static rjhash<uint64_t> I;
+      return H(r.oid) ^ I(r.snap);
+    }
+  };
+}
+
+ostream& operator<<(ostream& out, const hobject_t& o);
+
+WRITE_EQ_OPERATORS_7(hobject_t, oid, get_key(), snap, hash, max, pool, nspace)
+// sort hobject_t's by <max, get_filestore_key(hash), key, oid, snapid>
+WRITE_CMP_OPERATORS_7(hobject_t,
+                     max,
+                     get_filestore_key(),
+                     nspace,
+                     pool,
+                     get_effective_key(),
+                     oid,
+                     snap)
+
+#endif
index f0f40e7bbf41b9f8fb481c7bce097a47024c6ca8..00e632f3e0f28ecf08dcfc3ab77e2e506eed1ce0 100644 (file)
@@ -18,7 +18,7 @@
 #include <memory>
 #include <errno.h>
 #include <cstdio>
-#include "hobject.h"
+#include "common/hobject.h"
 #include "common/Mutex.h"
 #include "common/Cond.h"
 #include "common/shared_cache.hpp"
index 070de08e1230bd8cebef5b84b9c6164d1df80824..d480a6b751c52e2c5f970e967303f78b18b5b2ee 100644 (file)
@@ -20,7 +20,7 @@
 #include <tr1/memory>
 #include "include/buffer.h"
 #include "common/Formatter.h"
-#include "os/hobject.h"
+#include "common/hobject.h"
 #include "include/interval_set.h"
 #include "FDCache.h"
 #include "common/Thread.h"
diff --git a/src/os/hobject.cc b/src/os/hobject.cc
deleted file mode 100644 (file)
index d627369..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#include "include/types.h"
-#include "hobject.h"
-#include "common/Formatter.h"
-
-static void append_escaped(const string &in, string *out)
-{
-  for (string::const_iterator i = in.begin(); i != in.end(); ++i) {
-    if (*i == '%') {
-      out->push_back('%');
-      out->push_back('p');
-    } else if (*i == '.') {
-      out->push_back('%');
-      out->push_back('e');
-    } else if (*i == '_') {
-      out->push_back('%');
-      out->push_back('u');
-    } else {
-      out->push_back(*i);
-    }
-  }
-}
-
-set<string> hobject_t::get_prefixes(
-  uint32_t bits,
-  uint32_t mask,
-  int64_t pool)
-{
-  uint32_t len = bits;
-  while (len % 4 /* nibbles */) len++;
-
-  set<uint32_t> from;
-  if (bits < 32)
-    from.insert(mask & ~((uint32_t)(~0) << bits));
-  else if (bits == 32)
-    from.insert(mask);
-  else
-    assert(0);
-
-
-  set<uint32_t> to;
-  for (uint32_t i = bits; i < len; ++i) {
-    for (set<uint32_t>::iterator j = from.begin();
-        j != from.end();
-        ++j) {
-      to.insert(*j | (1 << i));
-      to.insert(*j);
-    }
-    to.swap(from);
-    to.clear();
-  }
-
-  char buf[20];
-  char *t = buf;
-  uint64_t poolid(pool);
-  t += snprintf(t, sizeof(buf), "%.*llX", 16, (long long unsigned)poolid);
-  *(t++) = '.';
-  string poolstr(buf, t - buf);
-  set<string> ret;
-  for (set<uint32_t>::iterator i = from.begin();
-       i != from.end();
-       ++i) {
-    uint32_t revhash(hobject_t::_reverse_nibbles(*i));
-    snprintf(buf, sizeof(buf), "%.*X", (int)(sizeof(revhash))*2, revhash);
-    ret.insert(poolstr + string(buf, len/4));
-  }
-  return ret;
-}
-
-string hobject_t::to_str() const
-{
-  string out;
-
-  char snap_with_hash[1000];
-  char *t = snap_with_hash;
-  char *end = t + sizeof(snap_with_hash);
-
-  uint64_t poolid(pool);
-  t += snprintf(t, end - t, "%.*llX", 16, (long long unsigned)poolid);
-
-  uint32_t revhash(get_filestore_key_u32());
-  t += snprintf(t, end - t, ".%.*X", 8, revhash);
-
-  if (snap == CEPH_NOSNAP)
-    t += snprintf(t, end - t, ".head");
-  else if (snap == CEPH_SNAPDIR)
-    t += snprintf(t, end - t, ".snapdir");
-  else
-    t += snprintf(t, end - t, ".%llx", (long long unsigned)snap);
-
-  out += string(snap_with_hash);
-
-  out.push_back('.');
-  append_escaped(oid.name, &out);
-  out.push_back('.');
-  append_escaped(get_key(), &out);
-  out.push_back('.');
-  append_escaped(nspace, &out);
-
-  return out;
-}
-
-void hobject_t::encode(bufferlist& bl) const
-{
-  ENCODE_START(4, 3, bl);
-  ::encode(key, bl);
-  ::encode(oid, bl);
-  ::encode(snap, bl);
-  ::encode(hash, bl);
-  ::encode(max, bl);
-  ::encode(nspace, bl);
-  ::encode(pool, bl);
-  ENCODE_FINISH(bl);
-}
-
-void hobject_t::decode(bufferlist::iterator& bl)
-{
-  DECODE_START_LEGACY_COMPAT_LEN(4, 3, 3, bl);
-  if (struct_v >= 1)
-    ::decode(key, bl);
-  ::decode(oid, bl);
-  ::decode(snap, bl);
-  ::decode(hash, bl);
-  if (struct_v >= 2)
-    ::decode(max, bl);
-  else
-    max = false;
-  if (struct_v >= 4) {
-    ::decode(nspace, bl);
-    ::decode(pool, bl);
-  }
-  DECODE_FINISH(bl);
-}
-
-void hobject_t::decode(json_spirit::Value& v)
-{
-  using namespace json_spirit;
-  Object& o = v.get_obj();
-  for (Object::size_type i=0; i<o.size(); i++) {
-    Pair& p = o[i];
-    if (p.name_ == "oid")
-      oid.name = p.value_.get_str();
-    else if (p.name_ == "key")
-      key = p.value_.get_str();
-    else if (p.name_ == "snapid")
-      snap = p.value_.get_uint64();
-    else if (p.name_ == "hash")
-      hash = p.value_.get_int();
-    else if (p.name_ == "max")
-      max = p.value_.get_int();
-    else if (p.name_ == "pool")
-      pool = p.value_.get_int();
-    else if (p.name_ == "namespace")
-      nspace = p.value_.get_str();
-  }
-}
-
-void hobject_t::dump(Formatter *f) const
-{
-  f->dump_string("oid", oid.name);
-  f->dump_string("key", key);
-  f->dump_int("snapid", snap);
-  f->dump_int("hash", hash);
-  f->dump_int("max", (int)max);
-  f->dump_int("pool", pool);
-  f->dump_string("namespace", nspace);
-}
-
-void hobject_t::generate_test_instances(list<hobject_t*>& o)
-{
-  o.push_back(new hobject_t);
-  o.push_back(new hobject_t);
-  o.back()->max = true;
-  o.push_back(new hobject_t(object_t("oname"), string(), 1, 234, -1, ""));
-  o.push_back(new hobject_t(object_t("oname2"), string("okey"), CEPH_NOSNAP,
-       67, 0, "n1"));
-  o.push_back(new hobject_t(object_t("oname3"), string("oname3"),
-       CEPH_SNAPDIR, 910, 1, "n2"));
-}
-
-ostream& operator<<(ostream& out, const hobject_t& o)
-{
-  if (o.is_max())
-    return out << "MAX";
-  out << std::hex << o.hash << std::dec;
-  if (o.get_key().length())
-    out << "." << o.get_key();
-  out << "/" << o.oid << "/" << o.snap;
-  out << "/" << o.nspace << "/" << o.pool;
-  return out;
-}
diff --git a/src/os/hobject.h b/src/os/hobject.h
deleted file mode 100644 (file)
index 633e471..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
- * Foundation.  See file COPYING.
- * 
- */
-
-#ifndef __CEPH_OS_HOBJECT_H
-#define __CEPH_OS_HOBJECT_H
-
-#include <string.h>
-#include "include/types.h"
-#include "include/object.h"
-#include "include/cmp.h"
-
-#include "json_spirit/json_spirit_value.h"
-#include "include/assert.h"   // spirit clobbers it!
-
-typedef uint64_t filestore_hobject_key_t;
-
-namespace ceph {
-  class Formatter;
-}
-
-struct hobject_t {
-  object_t oid;
-  snapid_t snap;
-  uint32_t hash;
-private:
-  bool max;
-public:
-  int64_t pool;
-  string nspace;
-
-private:
-  string key;
-
-public:
-  const string &get_key() const {
-    return key;
-  }
-
-  string to_str() const;
-
-  static bool match_hash(uint32_t to_check, uint32_t bits, uint32_t match) {
-    return (match & ~((~0)<<bits)) == (to_check & ~((~0)<<bits));
-  }
-  bool match(uint32_t bits, uint32_t match) const {
-    return match_hash(hash, bits, match);
-  }
-  
-  hobject_t() : snap(0), hash(0), max(false), pool(-1) {}
-
-  hobject_t(object_t oid, const string& key, snapid_t snap, uint64_t hash,
-           int64_t pool, string nspace) :
-    oid(oid), snap(snap), hash(hash), max(false),
-    pool(pool), nspace(nspace),
-    key(oid.name == key ? string() : key) {}
-
-  hobject_t(const sobject_t &soid, const string &key, uint32_t hash,
-           int64_t pool, string nspace) :
-    oid(soid.oid), snap(soid.snap), hash(hash), max(false),
-    pool(pool), nspace(nspace),
-    key(soid.oid.name == key ? string() : key) {}
-
-  /// @return min hobject_t ret s.t. ret.hash == this->hash
-  hobject_t get_boundary() const {
-    if (is_max())
-      return *this;
-    hobject_t ret;
-    ret.hash = hash;
-    return ret;
-  }
-
-  /* Do not use when a particular hash function is needed */
-  explicit hobject_t(const sobject_t &o) :
-    oid(o.oid), snap(o.snap), max(false), pool(-1) {
-    hash = __gnu_cxx::hash<sobject_t>()(o);
-  }
-
-  // maximum sorted value.
-  static hobject_t get_max() {
-    hobject_t h;
-    h.max = true;
-    return h;
-  }
-  bool is_max() const {
-    return max;
-  }
-
-  static uint32_t _reverse_nibbles(uint32_t retval) {
-    // reverse nibbles
-    retval = ((retval & 0x0f0f0f0f) << 4) | ((retval & 0xf0f0f0f0) >> 4);
-    retval = ((retval & 0x00ff00ff) << 8) | ((retval & 0xff00ff00) >> 8);
-    retval = ((retval & 0x0000ffff) << 16) | ((retval & 0xffff0000) >> 16);
-    return retval;
-  }
-
-  /**
-   * Returns set S of strings such that for any object
-   * h where h.match(bits, mask), there is some string
-   * s \in S such that s is a prefix of h.to_str().
-   * Furthermore, for any s \in S, s is a prefix of
-   * h.str() implies that h.match(bits, mask).
-   */
-  static set<string> get_prefixes(
-    uint32_t bits,
-    uint32_t mask,
-    int64_t pool);
-
-  filestore_hobject_key_t get_filestore_key_u32() const {
-    assert(!max);
-    return _reverse_nibbles(hash);
-  }
-  filestore_hobject_key_t get_filestore_key() const {
-    if (max)
-      return 0x100000000ull;
-    else
-      return get_filestore_key_u32();
-  }
-
-  const string& get_effective_key() const {
-    if (key.length())
-      return key;
-    return oid.name;
-  }
-
-  void swap(hobject_t &o) {
-    hobject_t temp(o);
-    o = (*this);
-    (*this) = temp;
-  }
-
-  string get_namespace() const {
-    return nspace;
-  }
-
-  void encode(bufferlist& bl) const;
-  void decode(bufferlist::iterator& bl);
-  void decode(json_spirit::Value& v);
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<hobject_t*>& o);
-  friend bool operator<(const hobject_t&, const hobject_t&);
-  friend bool operator>(const hobject_t&, const hobject_t&);
-  friend bool operator<=(const hobject_t&, const hobject_t&);
-  friend bool operator>=(const hobject_t&, const hobject_t&);
-  friend bool operator==(const hobject_t&, const hobject_t&);
-  friend bool operator!=(const hobject_t&, const hobject_t&);
-};
-WRITE_CLASS_ENCODER(hobject_t)
-
-namespace __gnu_cxx {
-  template<> struct hash<hobject_t> {
-    size_t operator()(const hobject_t &r) const {
-      static hash<object_t> H;
-      static rjhash<uint64_t> I;
-      return H(r.oid) ^ I(r.snap);
-    }
-  };
-}
-
-ostream& operator<<(ostream& out, const hobject_t& o);
-
-WRITE_EQ_OPERATORS_7(hobject_t, oid, get_key(), snap, hash, max, pool, nspace)
-// sort hobject_t's by <max, get_filestore_key(hash), key, oid, snapid>
-WRITE_CMP_OPERATORS_7(hobject_t,
-                     max,
-                     get_filestore_key(),
-                     nspace,
-                     pool,
-                     get_effective_key(),
-                     oid,
-                     snap)
-
-#endif
index 560cc43497f6e0a9bbb5602ccbda1277e05dbd26..f0d0baa219082e9cee97f2fc8ff960252a6c5db6 100644 (file)
@@ -21,7 +21,7 @@
 #include <string.h>
 
 #include "common/map_cacher.hpp"
-#include "os/hobject.h"
+#include "common/hobject.h"
 #include "include/buffer.h"
 #include "include/encoding.h"
 #include "include/object.h"
index 312eb81e3fd0f8db945422359443e0df3c2e4ea5..da139b853b16e567e87b6d93fcd3e3884772e39e 100644 (file)
@@ -26,7 +26,7 @@
 #include "include/interval_set.h"
 #include "common/snap_types.h"
 #include "common/Formatter.h"
-#include "os/hobject.h"
+#include "common/hobject.h"
 #include "Watch.h"
 
 #define CEPH_OSD_ONDISK_MAGIC "ceph osd volume v026"
index a6f7cfb7883dfe92d21040ae94d9be3e299758d5..514c76fc1a89c2b51b54448ad57ccc86a6dbf41c 100644 (file)
@@ -75,7 +75,7 @@ TYPE(ObjectStore::Transaction)
 #include "os/SequencerPosition.h"
 TYPE(SequencerPosition)
 
-#include "os/hobject.h"
+#include "common/hobject.h"
 TYPE(hobject_t)
 
 #include "mon/AuthMonitor.h"