diff options
author | Xuehan Xu <xuxuehan@360.cn> | 2018-07-03 10:08:26 +0200 |
---|---|---|
committer | Xuehan Xu <xuxuehan@360.cn> | 2018-08-09 09:33:11 +0200 |
commit | 5582faef0767bb2de32cb9eeeffdbca7d4323747 (patch) | |
tree | 9f05d234e9172cbfdcf8c6379bec1eeb06ec1d8e /src/mds | |
parent | Merge pull request #22776 from tchaikov/wip-thread-setaffinity (diff) | |
download | ceph-5582faef0767bb2de32cb9eeeffdbca7d4323747.tar.xz ceph-5582faef0767bb2de32cb9eeeffdbca7d4323747.zip |
cephfs-journal-tool: enable purge_queue journal's event commands
Resolves: http://tracker.ceph.com/issues/24604
Signed-off-by: Xuehan Xu <xuxuehan@360.cn>
Diffstat (limited to 'src/mds')
-rw-r--r-- | src/mds/PurgeQueue.cc | 31 | ||||
-rw-r--r-- | src/mds/PurgeQueue.h | 31 | ||||
-rw-r--r-- | src/mds/StrayManager.cc | 2 |
3 files changed, 61 insertions, 3 deletions
diff --git a/src/mds/PurgeQueue.cc b/src/mds/PurgeQueue.cc index 0c1a722d3c4..c84dd9007b7 100644 --- a/src/mds/PurgeQueue.cc +++ b/src/mds/PurgeQueue.cc @@ -28,9 +28,16 @@ static ostream& _prefix(std::ostream *_dout, mds_rank_t rank) { return *_dout << "mds." << rank << ".purge_queue "; } +const std::map<std::string, PurgeItem::Action> PurgeItem::actions = { + {"NONE", PurgeItem::NONE}, + {"PURGE_FILE", PurgeItem::PURGE_FILE}, + {"TRUNCATE_FILE", PurgeItem::TRUNCATE_FILE}, + {"PURGE_DIR", PurgeItem::PURGE_DIR} +}; + void PurgeItem::encode(bufferlist &bl) const { - ENCODE_START(1, 1, bl); + ENCODE_START(2, 1, bl); encode((uint8_t)action, bl); encode(ino, bl); encode(size, bl); @@ -38,12 +45,17 @@ void PurgeItem::encode(bufferlist &bl) const encode(old_pools, bl); encode(snapc, bl); encode(fragtree, bl); + encode(stamp, bl); + uint8_t static const pad = 0xff; + for (unsigned int i = 0; i<pad_size; i++) { + encode(pad, bl); + } ENCODE_FINISH(bl); } void PurgeItem::decode(bufferlist::const_iterator &p) { - DECODE_START(1, p); + DECODE_START(2, p); decode((uint8_t&)action, p); decode(ino, p); decode(size, p); @@ -51,6 +63,9 @@ void PurgeItem::decode(bufferlist::const_iterator &p) decode(old_pools, p); decode(snapc, p); decode(fragtree, p); + if (struct_v >= 2) { + decode(stamp, p); + } DECODE_FINISH(p); } @@ -651,3 +666,15 @@ bool PurgeQueue::drain( return false; } +std::string PurgeItem::get_type_str() const +{ + switch(action) { + case PurgeItem::NONE: return "NONE"; + case PurgeItem::PURGE_FILE: return "PURGE_FILE"; + case PurgeItem::PURGE_DIR: return "PURGE_DIR"; + case PurgeItem::TRUNCATE_FILE: return "TRUNCATE_FILE"; + default: + return "UNKNOWN"; + } +} + diff --git a/src/mds/PurgeQueue.h b/src/mds/PurgeQueue.h index 4c4de89fa43..bcee0b2fe84 100644 --- a/src/mds/PurgeQueue.h +++ b/src/mds/PurgeQueue.h @@ -36,6 +36,11 @@ public: PURGE_DIR }; + utime_t stamp; + //None PurgeItem serves as NoOp for splicing out journal entries; + //so there has to be a "pad_size" to specify the size of journal + //space to be spliced. + uint32_t pad_size; Action action; inodeno_t ino; uint64_t size; @@ -45,11 +50,35 @@ public: fragtree_t fragtree; PurgeItem() - : action(NONE), ino(0), size(0) + : pad_size(0), action(NONE), ino(0), size(0) {} void encode(bufferlist &bl) const; void decode(bufferlist::const_iterator &p); + + static Action str_to_type(std::string_view str) { + return PurgeItem::actions.at(std::string(str)); + } + + void dump(Formatter *f) const + { + f->dump_int("action", action); + f->dump_int("ino", ino); + f->dump_int("size", size); + f->open_object_section("layout"); + layout.dump(f); + f->close_section(); + f->open_object_section("SnapContext"); + snapc.dump(f); + f->close_section(); + f->open_object_section("fragtree"); + fragtree.dump(f); + f->close_section(); + } + + std::string get_type_str() const; +private: + static const std::map<std::string, PurgeItem::Action> actions; }; WRITE_CLASS_ENCODER(PurgeItem) diff --git a/src/mds/StrayManager.cc b/src/mds/StrayManager.cc index a310fb34f27..897b96cd129 100644 --- a/src/mds/StrayManager.cc +++ b/src/mds/StrayManager.cc @@ -98,6 +98,7 @@ void StrayManager::purge(CDentry *dn) PurgeItem item; item.ino = in->inode.ino; + item.stamp = ceph_clock_now(); if (in->is_dir()) { item.action = PurgeItem::PURGE_DIR; item.fragtree = in->dirfragtree; @@ -733,6 +734,7 @@ void StrayManager::truncate(CDentry *dn) item.layout = in->inode.layout; item.snapc = *snapc; item.size = to; + item.stamp = ceph_clock_now(); purge_queue.push(item, new C_IO_PurgeStrayPurged( this, dn, true)); |