diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 537d98760e7..152456e8252 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -560,7 +560,7 @@ public: // -- distributed state -- protected: - // file capabilities FIXME Capability not part of mempool + // file capabilities using cap_map = mempool::mds_co::map; cap_map client_caps; // client -> caps mempool::mds_co::compact_map mds_caps_wanted; // [auth] mds -> caps wanted diff --git a/src/mds/Capability.cc b/src/mds/Capability.cc index 03fcefaa10e..78c531865d8 100644 --- a/src/mds/Capability.cc +++ b/src/mds/Capability.cc @@ -175,9 +175,9 @@ void Capability::dump(Formatter *f) const f->dump_unsigned("pending", _pending); f->open_array_section("revokes"); - for (list::const_iterator p = _revokes.begin(); p != _revokes.end(); ++p) { + for (const auto &r : _revokes) { f->open_object_section("revoke"); - p->dump(f); + r.dump(f); f->close_section(); } f->close_section(); @@ -191,12 +191,18 @@ void Capability::generate_test_instances(list& ls) ls.back()->last_issue_stamp = utime_t(12, 13); ls.back()->_wanted = 14; ls.back()->_pending = 15; - ls.back()->_revokes.push_back(revoke_info()); - ls.back()->_revokes.back().before = 16; - ls.back()->_revokes.back().seq = 17; - ls.back()->_revokes.back().last_issue = 18; - ls.back()->_revokes.push_back(revoke_info()); - ls.back()->_revokes.back().before = 19; - ls.back()->_revokes.back().seq = 20; - ls.back()->_revokes.back().last_issue = 21; + { + auto &r = ls.back()->_revokes.emplace_back(); + r.before = 16; + r.seq = 17; + r.last_issue = 18; + } + { + auto &r = ls.back()->_revokes.emplace_back(); + r.before = 19; + r.seq = 20; + r.last_issue = 21; + } } + +MEMPOOL_DEFINE_OBJECT_FACTORY(Capability, co_cap, mds_co); diff --git a/src/mds/Capability.h b/src/mds/Capability.h index 3543efee849..2934ab9ebd7 100644 --- a/src/mds/Capability.h +++ b/src/mds/Capability.h @@ -16,14 +16,16 @@ #ifndef CEPH_CAPABILITY_H #define CEPH_CAPABILITY_H -#include "include/counter.h" #include "include/buffer_fwd.h" +#include "include/counter.h" +#include "include/mempool.h" #include "include/xlist.h" #include "common/config.h" #include "mdstypes.h" + /* Capability protocol notes. @@ -66,6 +68,8 @@ namespace ceph { class Capability : public Counter { public: + MEMPOOL_CLASS_HELPERS(); + struct Export { int64_t cap_id; int32_t wanted; @@ -138,7 +142,7 @@ public: ceph_seq_t issue(unsigned c) { if (_pending & ~c) { // revoking (and maybe adding) bits. note caps prior to this revocation - _revokes.push_back(revoke_info(_pending, last_sent, last_issue)); + _revokes.emplace_back(_pending, last_sent, last_issue); _pending = c; _issued |= c; } else if (~_pending & c) { @@ -166,8 +170,9 @@ public: } void _calc_issued() { _issued = _pending; - for (list::iterator p = _revokes.begin(); p != _revokes.end(); ++p) - _issued |= p->before; + for (const auto &r : _revokes) { + _issued |= r.before; + } } void confirm_receipt(ceph_seq_t seq, unsigned caps) { if (seq == last_sent) { @@ -345,7 +350,7 @@ private: // - add new caps to _pending // - track revocations in _revokes list __u32 _pending, _issued; - list _revokes; + mempool::mds_co::list _revokes; ceph_seq_t last_sent; ceph_seq_t last_issue;