diff options
author | Sage Weil <sage@inktank.com> | 2013-10-02 22:14:39 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-10-02 22:32:24 -0700 |
commit | a1534b7e66389e56a749402c5c35a1843e56a1ed (patch) | |
tree | 2b39c48e6c32f1c4f696e0e1f619909260710c4d | |
parent | 8148b9088fea5e9e6807cd8d4e2b389f9964b008 (diff) | |
download | ceph-a1534b7e66389e56a749402c5c35a1843e56a1ed.tar.gz |
osd/osd_types: add explicit hash to object_locator_t
Instead of hashing the object name or key, we allow the hash position to be
provided explicitly.
Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r-- | src/osd/osd_types.cc | 11 | ||||
-rw-r--r-- | src/osd/osd_types.h | 22 |
2 files changed, 22 insertions, 11 deletions
diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 778d3b7f609..f123435e7ed 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -56,18 +56,19 @@ void osd_reqid_t::generate_test_instances(list<osd_reqid_t*>& o) void object_locator_t::encode(bufferlist& bl) const { - ENCODE_START(5, 3, bl); + ENCODE_START(6, 3, bl); ::encode(pool, bl); int32_t preferred = -1; // tell old code there is no preferred osd (-1). ::encode(preferred, bl); ::encode(key, bl); ::encode(nspace, bl); + ::encode(hash, bl); ENCODE_FINISH(bl); } void object_locator_t::decode(bufferlist::iterator& p) { - DECODE_START_LEGACY_COMPAT_LEN(5, 3, 3, p); + DECODE_START_LEGACY_COMPAT_LEN(6, 3, 3, p); if (struct_v < 2) { int32_t op; ::decode(op, p); @@ -82,6 +83,10 @@ void object_locator_t::decode(bufferlist::iterator& p) ::decode(key, p); if (struct_v >= 5) ::decode(nspace, p); + if (struct_v >= 6) + ::decode(hash, p); + else + hash = -1; DECODE_FINISH(p); } @@ -90,12 +95,14 @@ void object_locator_t::dump(Formatter *f) const f->dump_int("pool", pool); f->dump_string("key", key); f->dump_string("namespace", nspace); + f->dump_int("hash", hash); } void object_locator_t::generate_test_instances(list<object_locator_t*>& o) { o.push_back(new object_locator_t); o.push_back(new object_locator_t(123)); + o.push_back(new object_locator_t(123, 876)); o.push_back(new object_locator_t(1, "n2")); o.push_back(new object_locator_t(1234, "", "key")); o.push_back(new object_locator_t(12, "n1", "key2")); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index fb71c4f3f41..d31976333f0 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -104,20 +104,23 @@ namespace __gnu_cxx { // a locator constrains the placement of an object. mainly, which pool // does it go in. struct object_locator_t { - int64_t pool; - string key; - string nspace; + int64_t pool; ///< pool id + string key; ///< key string (if non-empty) + string nspace; ///< namespace + int64_t hash; ///< hash position (if >= 0) explicit object_locator_t() - : pool(-1) {} + : pool(-1), hash(-1) {} explicit object_locator_t(int64_t po) - : pool(po) {} + : pool(po), hash(-1) {} + explicit object_locator_t(int64_t po, int64_t ps) + : pool(po), hash(ps) {} explicit object_locator_t(int64_t po, string ns) - : pool(po), nspace(ns) {} + : pool(po), nspace(ns), hash(-1) {} explicit object_locator_t(int64_t po, string ns, string s) - : pool(po), key(s), nspace(ns) {} + : pool(po), key(s), nspace(ns), hash(-1) {} explicit object_locator_t(const hobject_t& soid) - : pool(soid.pool), key(soid.get_key()), nspace(soid.nspace) {} + : pool(soid.pool), key(soid.get_key()), nspace(soid.nspace), hash(-1) {} int64_t get_pool() const { return pool; @@ -127,6 +130,7 @@ struct object_locator_t { pool = -1; key = ""; nspace = ""; + hash = -1; } bool empty() const { @@ -141,7 +145,7 @@ struct object_locator_t { WRITE_CLASS_ENCODER(object_locator_t) inline bool operator==(const object_locator_t& l, const object_locator_t& r) { - return l.pool == r.pool && l.key == r.key && l.nspace == r.nspace; + return l.pool == r.pool && l.key == r.key && l.nspace == r.nspace && l.hash == r.hash; } inline bool operator!=(const object_locator_t& l, const object_locator_t& r) { return !(l == r); |