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) 2010 Greg Farnum <gregf@hq.newdream.net>
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.
15
#include "mds/Dumper.h"
16
#include "osdc/Journaler.h"
17
#include "mds/mdstypes.h"
18
#include "mon/MonClient.h"
24
bool Dumper::ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer,
27
if (dest_type == CEPH_ENTITY_TYPE_MON)
31
if (monc->wait_auth_rotating(10) < 0)
35
*authorizer = monc->auth->build_authorizer(dest_type);
36
return *authorizer != NULL;
41
inodeno_t ino = MDS_INO_LOG_OFFSET + strtol(g_conf.id, 0, 0);
42
unsigned pg_pool = CEPH_METADATA_RULE;
43
osdmap = new OSDMap();
44
objecter = new Objecter(messenger, monc, osdmap, lock, timer);
45
journaler = new Journaler(ino, pg_pool, CEPH_FS_ONDISK_MAGIC,
46
objecter, 0, 0, &timer);
48
objecter->set_client_incarnation(0);
50
messenger->register_entity(entity_name_t::CLIENT());
51
messenger->add_dispatcher_head(this);
52
messenger->start(true);
54
monc->set_want_keys(CEPH_ENTITY_TYPE_MON|CEPH_ENTITY_TYPE_OSD|CEPH_ENTITY_TYPE_MDS);
55
monc->set_messenger(messenger);
61
objecter->wait_for_osd_map();
66
void Dumper::shutdown()
73
void Dumper::dump(const char *dump_file)
77
inodeno_t ino = MDS_INO_LOG_OFFSET + strtol(g_conf.id, 0, 0);;
80
journaler->recover(new C_SafeCond(&lock, &cond, &done));
85
uint64_t start = journaler->get_read_pos();
86
uint64_t end = journaler->get_write_pos();
87
uint64_t len = end-start;
88
cout << "journal is " << start << "~" << len << std::endl;
90
Filer filer(objecter);
92
filer.read(ino, &journaler->get_layout(), CEPH_NOSNAP,
93
start, len, &bl, 0, new C_SafeCond(&lock, &cond, &done));
99
cout << "read " << bl.length() << " bytes" << std::endl;
100
bl.write_file(dump_file);
101
messenger->shutdown();
103
// wait for messenger to finish