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

« back to all changes in this revision

Viewing changes to src/ceph_osd.cc

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
using namespace std;
24
24
 
25
25
#include "osd/OSD.h"
 
26
#include "os/FileStore.h"
 
27
#include "mon/MonClient.h"
26
28
#include "include/ceph_features.h"
27
29
 
28
30
#include "common/config.h"
29
31
 
30
32
#include "mon/MonMap.h"
31
 
#include "mon/MonClient.h"
32
33
 
33
34
 
34
35
#include "msg/Messenger.h"
45
46
 
46
47
#include "perfglue/heap_profiler.h"
47
48
 
 
49
#include "include/assert.h"
 
50
 
48
51
#define dout_subsys ceph_subsys_osd
49
52
 
50
53
OSD *osd = NULL;
185
188
      derr << "Unable to get a Ceph keyring." << dendl;
186
189
      return 1;
187
190
    }
 
191
 
188
192
    EntityName ename(g_conf->name);
189
193
    EntityAuth eauth;
190
 
    eauth.key.create(g_ceph_context, CEPH_CRYPTO_AES);
191
 
    keyring->add(ename, eauth);
192
 
    bufferlist bl;
193
 
    keyring->encode_plaintext(bl);
194
 
    int r = bl.write_file(g_conf->keyring.c_str(), 0600);
195
 
    if (r)
196
 
      derr << TEXT_RED << " ** ERROR: writing new keyring to " << g_conf->keyring
197
 
           << ": " << cpp_strerror(r) << TEXT_NORMAL << dendl;
198
 
    else
199
 
      derr << "created new key in keyring " << g_conf->keyring << dendl;
 
194
 
 
195
    int ret = keyring->load(g_ceph_context, g_conf->keyring);
 
196
    if (ret == 0 &&
 
197
        keyring->get_auth(ename, eauth)) {
 
198
      derr << "already have key in keyring " << g_conf->keyring << dendl;
 
199
    } else {
 
200
      eauth.key.create(g_ceph_context, CEPH_CRYPTO_AES);
 
201
      keyring->add(ename, eauth);
 
202
      bufferlist bl;
 
203
      keyring->encode_plaintext(bl);
 
204
      int r = bl.write_file(g_conf->keyring.c_str(), 0600);
 
205
      if (r)
 
206
        derr << TEXT_RED << " ** ERROR: writing new keyring to " << g_conf->keyring
 
207
             << ": " << cpp_strerror(r) << TEXT_NORMAL << dendl;
 
208
      else
 
209
        derr << "created new key in keyring " << g_conf->keyring << dendl;
 
210
    }
200
211
  }
201
212
  if (mkfs || mkkey)
202
213
    exit(0);
251
262
           << ": " << cpp_strerror(-err) << TEXT_NORMAL << dendl;
252
263
      exit(1);
253
264
    }
 
265
    exit(0);
254
266
  }
255
267
  
256
268
  string magic;
381
393
  if (r < 0)
382
394
    exit(1);
383
395
 
 
396
 
384
397
  // Set up crypto, daemonize, etc.
385
 
  // Leave stderr open in case we need to report errors.
386
 
  global_init_daemonize(g_ceph_context, CINIT_FLAG_NO_CLOSE_STDERR);
 
398
  global_init_daemonize(g_ceph_context, 0);
387
399
  common_init_finish(g_ceph_context);
388
400
 
389
 
  int err = OSD::convertfs(g_conf->osd_data, g_conf->osd_journal);
390
 
  if (err < 0) {
391
 
    derr << TEXT_RED << " ** ERROR: error converting store " << g_conf->osd_data
392
 
         << ": " << cpp_strerror(-err) << TEXT_NORMAL << dendl;
393
 
    exit(1);
 
401
  if (g_conf->filestore_update_to >= (int)FileStore::on_disk_version) {
 
402
    int err = OSD::convertfs(g_conf->osd_data, g_conf->osd_journal);
 
403
    if (err < 0) {
 
404
      derr << TEXT_RED << " ** ERROR: error converting store " << g_conf->osd_data
 
405
           << ": " << cpp_strerror(-err) << TEXT_NORMAL << dendl;
 
406
      exit(1);
 
407
    }
394
408
  }
395
409
 
396
410
  MonClient mc(g_ceph_context);
402
416
                messenger_hbclient, messenger_hbserver,
403
417
                &mc,
404
418
                g_conf->osd_data, g_conf->osd_journal);
405
 
  err = osd->pre_init();
 
419
 
 
420
  int err = osd->pre_init();
406
421
  if (err < 0) {
407
422
    derr << TEXT_RED << " ** ERROR: osd pre_init failed: " << cpp_strerror(-err)
408
423
         << TEXT_NORMAL << dendl;