]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/cephfs/JournalTool.h
update sources to v12.1.0
[ceph.git] / ceph / src / tools / cephfs / JournalTool.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2014 John Spray <john.spray@inktank.com>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 */
13
14 #include "MDSUtility.h"
15 #include "RoleSelector.h"
16 #include <vector>
17
18 #include "mds/mdstypes.h"
19 #include "mds/LogEvent.h"
20 #include "mds/events/EMetaBlob.h"
21
22 #include "include/rados/librados.hpp"
23
24 #include "JournalFilter.h"
25
26 class JournalScanner;
27
28
29 /**
30 * Command line tool for investigating and repairing filesystems
31 * with damaged metadata logs
32 */
33 class JournalTool : public MDSUtility
34 {
35 private:
36 MDSRoleSelector role_selector;
37 // Bit hacky, use this `rank` member to control behaviour of the
38 // various main_ functions.
39 mds_rank_t rank;
40
41 // Entry points
42 int main_journal(std::vector<const char*> &argv);
43 int main_header(std::vector<const char*> &argv);
44 int main_event(std::vector<const char*> &argv);
45
46 // Shared functionality
47 int recover_journal();
48
49 // Journal operations
50 int journal_inspect();
51 int journal_export(std::string const &path, bool import);
52 int journal_reset(bool hard);
53
54 // Header operations
55 int header_set();
56
57 // I/O handles
58 librados::Rados rados;
59 librados::IoCtx input;
60 librados::IoCtx output;
61
62 bool other_pool;
63
64 // Metadata backing store manipulation
65 int read_lost_found(std::set<std::string> &lost);
66 int recover_dentries(
67 EMetaBlob const &metablob,
68 bool const dry_run,
69 std::set<inodeno_t> *consumed_inos);
70
71 // Splicing
72 int erase_region(JournalScanner const &jp, uint64_t const pos, uint64_t const length);
73
74 // Backing store helpers
75 void encode_fullbit_as_inode(
76 const EMetaBlob::fullbit &fb,
77 const bool bare,
78 bufferlist *out_bl);
79 int consume_inos(const std::set<inodeno_t> &inos);
80
81 public:
82 void usage();
83 JournalTool() :
84 rank(0), other_pool(false) {}
85 int main(std::vector<const char*> &argv);
86 };
87