1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2014 John Spray <john.spray@inktank.com>
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.
14 #include "MDSUtility.h"
15 #include "RoleSelector.h"
18 #include "mds/mdstypes.h"
19 #include "mds/LogEvent.h"
20 #include "mds/events/EMetaBlob.h"
22 #include "include/rados/librados.hpp"
24 #include "JournalFilter.h"
30 * Command line tool for investigating and repairing filesystems
31 * with damaged metadata logs
33 class JournalTool
: public MDSUtility
36 MDSRoleSelector role_selector
;
37 // Bit hacky, use this `rank` member to control behaviour of the
38 // various main_ functions.
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
);
46 // Shared functionality
47 int recover_journal();
50 int journal_inspect();
51 int journal_export(std::string
const &path
, bool import
, bool force
);
52 int journal_reset(bool hard
);
58 librados::Rados rados
;
59 librados::IoCtx input
;
60 librados::IoCtx output
;
64 // Metadata backing store manipulation
65 int read_lost_found(std::set
<std::string
> &lost
);
67 EMetaBlob
const &metablob
,
69 std::set
<inodeno_t
> *consumed_inos
);
72 int erase_region(JournalScanner
const &jp
, uint64_t const pos
, uint64_t const length
);
74 // Backing store helpers
75 void encode_fullbit_as_inode(
76 const EMetaBlob::fullbit
&fb
,
79 int consume_inos(const std::set
<inodeno_t
> &inos
);
84 rank(0), other_pool(false) {}
85 int main(std::vector
<const char*> &argv
);