~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/mds/Dumper.cc

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum, Clint Byrum, Micah Gersten
  • Date: 2011-02-12 22:50:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110212225026-yyyw4tk0msgql3ul
Tags: 0.24.2-0ubuntu1
[ Clint Byrum <clint@ubuntu.com> ]
* New upstream release. (LP: #658670, LP: #684011)
* debian/patches/fix-mkcephfs.patch: dropped (applied upstream)
* Removed .la files from libceph1-dev, libcrush1-dev and 
  librados1-dev (per Debian policy v3.9.1 10.2).
* debian/control: adding pkg-config as a build dependency
* debian/control: depend on libcrypto++-dev instead of libssl-dev
* debian/watch: added watch file

[ Micah Gersten <micahg@ubuntu.com> ]
* debian/control: add Homepage

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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) 2010 Greg Farnum <gregf@hq.newdream.net>
 
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
 
 
15
#include "mds/Dumper.h"
 
16
#include "osdc/Journaler.h"
 
17
#include "mds/mdstypes.h"
 
18
#include "mon/MonClient.h"
 
19
 
 
20
Dumper::~Dumper()
 
21
{
 
22
}
 
23
 
 
24
bool Dumper::ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer,
 
25
                         bool force_new)
 
26
{
 
27
  if (dest_type == CEPH_ENTITY_TYPE_MON)
 
28
    return true;
 
29
 
 
30
  if (force_new) {
 
31
    if (monc->wait_auth_rotating(10) < 0)
 
32
      return false;
 
33
  }
 
34
 
 
35
  *authorizer = monc->auth->build_authorizer(dest_type);
 
36
  return *authorizer != NULL;
 
37
}
 
38
 
 
39
void Dumper::init() 
 
40
{
 
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);
 
47
 
 
48
  objecter->set_client_incarnation(0);
 
49
 
 
50
  messenger->register_entity(entity_name_t::CLIENT());
 
51
  messenger->add_dispatcher_head(this);
 
52
  messenger->start(true);
 
53
 
 
54
  monc->set_want_keys(CEPH_ENTITY_TYPE_MON|CEPH_ENTITY_TYPE_OSD|CEPH_ENTITY_TYPE_MDS);
 
55
  monc->set_messenger(messenger);
 
56
  monc->init();
 
57
  monc->authenticate();
 
58
 
 
59
  lock.Lock();
 
60
  objecter->init();
 
61
  objecter->wait_for_osd_map();
 
62
  timer.init();
 
63
  lock.Unlock();
 
64
}
 
65
 
 
66
void Dumper::shutdown()
 
67
{
 
68
  lock.Lock();
 
69
  timer.shutdown();
 
70
  lock.Unlock();
 
71
}
 
72
 
 
73
void Dumper::dump(const char *dump_file)
 
74
{
 
75
  bool done = false;
 
76
  Cond cond;
 
77
  inodeno_t ino = MDS_INO_LOG_OFFSET + strtol(g_conf.id, 0, 0);;
 
78
 
 
79
  lock.Lock();
 
80
  journaler->recover(new C_SafeCond(&lock, &cond, &done));
 
81
  while (!done)
 
82
    cond.Wait(lock);
 
83
  lock.Unlock();
 
84
 
 
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;
 
89
 
 
90
  Filer filer(objecter);
 
91
  bufferlist bl;
 
92
  filer.read(ino, &journaler->get_layout(), CEPH_NOSNAP,
 
93
             start, len, &bl, 0, new C_SafeCond(&lock, &cond, &done));
 
94
  lock.Lock();
 
95
  while (!done)
 
96
    cond.Wait(lock);
 
97
  lock.Unlock();
 
98
 
 
99
  cout << "read " << bl.length() << " bytes" << std::endl;
 
100
  bl.write_file(dump_file);
 
101
  messenger->shutdown();
 
102
 
 
103
  // wait for messenger to finish
 
104
  messenger->wait();
 
105
 
 
106
  shutdown();
 
107
}