summaryrefslogtreecommitdiffstats
path: root/src/mds
diff options
context:
space:
mode:
authorXuehan Xu <xuxuehan@360.cn>2018-07-03 10:08:26 +0200
committerXuehan Xu <xuxuehan@360.cn>2018-08-04 03:58:28 +0200
commit8ebfa93982a95d6ccc66faa2a828b9386af45238 (patch)
treeacd1adfb0051b94ad1a6b87794129a112ec86b24 /src/mds
parentMerge pull request #22776 from tchaikov/wip-thread-setaffinity (diff)
downloadceph-8ebfa93982a95d6ccc66faa2a828b9386af45238.tar.xz
ceph-8ebfa93982a95d6ccc66faa2a828b9386af45238.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.cc28
-rw-r--r--src/mds/PurgeQueue.h31
2 files changed, 58 insertions, 1 deletions
diff --git a/src/mds/PurgeQueue.cc b/src/mds/PurgeQueue.cc
index 0c1a722d3c4..a656257f23a 100644
--- a/src/mds/PurgeQueue.cc
+++ b/src/mds/PurgeQueue.cc
@@ -28,9 +28,22 @@ static ostream& _prefix(std::ostream *_dout, mds_rank_t rank) {
return *_dout << "mds." << rank << ".purge_queue ";
}
+const std::map<std::string_view, 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(stamp, bl);
+ encode(pad_size, bl);
+ uint8_t static const pad = 0xff;
+ for (unsigned int i = 0; i<pad_size; i++) {
+ encode(pad, bl);
+ }
encode((uint8_t)action, bl);
encode(ino, bl);
encode(size, bl);
@@ -44,6 +57,9 @@ void PurgeItem::encode(bufferlist &bl) const
void PurgeItem::decode(bufferlist::const_iterator &p)
{
DECODE_START(1, p);
+ decode(stamp, p);
+ decode(pad_size, p);
+ p.advance(pad_size);
decode((uint8_t&)action, p);
decode(ino, p);
decode(size, p);
@@ -651,3 +667,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..fe3330bdf69 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)
+ : stamp(ceph_clock_now()), 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(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_view, PurgeItem::Action> actions;
};
WRITE_CLASS_ENCODER(PurgeItem)