]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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; | |
f64942e4 AA |
40 | // when set, generate per rank dump file path |
41 | bool all_ranks = false; | |
11fdf7f2 TL |
42 | |
43 | std::string type; | |
f64942e4 | 44 | |
7c673cae FG |
45 | // Entry points |
46 | int main_journal(std::vector<const char*> &argv); | |
47 | int main_header(std::vector<const char*> &argv); | |
48 | int main_event(std::vector<const char*> &argv); | |
49 | ||
50 | // Shared functionality | |
51 | int recover_journal(); | |
52 | ||
53 | // Journal operations | |
54 | int journal_inspect(); | |
91327a77 | 55 | int journal_export(std::string const &path, bool import, bool force); |
7c673cae FG |
56 | int journal_reset(bool hard); |
57 | ||
58 | // Header operations | |
59 | int header_set(); | |
60 | ||
61 | // I/O handles | |
62 | librados::Rados rados; | |
63 | librados::IoCtx input; | |
64 | librados::IoCtx output; | |
65 | ||
66 | bool other_pool; | |
67 | ||
68 | // Metadata backing store manipulation | |
69 | int read_lost_found(std::set<std::string> &lost); | |
31f18b77 | 70 | int recover_dentries( |
7c673cae FG |
71 | EMetaBlob const &metablob, |
72 | bool const dry_run, | |
73 | std::set<inodeno_t> *consumed_inos); | |
7c673cae FG |
74 | |
75 | // Splicing | |
76 | int erase_region(JournalScanner const &jp, uint64_t const pos, uint64_t const length); | |
77 | ||
78 | // Backing store helpers | |
79 | void encode_fullbit_as_inode( | |
80 | const EMetaBlob::fullbit &fb, | |
81 | const bool bare, | |
82 | bufferlist *out_bl); | |
83 | int consume_inos(const std::set<inodeno_t> &inos); | |
84 | ||
11fdf7f2 TL |
85 | //validate type |
86 | int validate_type(const std::string &type); | |
87 | ||
f64942e4 AA |
88 | // generate output file path for dump/export |
89 | std::string gen_dump_file_path(const std::string &prefix); | |
90 | ||
91 | // check if an operation (mode, command) is safe to be | |
92 | // executed on all ranks. | |
93 | bool can_execute_for_all_ranks(const std::string &mode, | |
94 | const std::string &command); | |
7c673cae | 95 | public: |
11fdf7f2 | 96 | static void usage(); |
7c673cae FG |
97 | JournalTool() : |
98 | rank(0), other_pool(false) {} | |
99 | int main(std::vector<const char*> &argv); | |
100 | }; | |
101 |