2007-10-17 23:34:54 +00:00
|
|
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
|
|
|
// vim: ts=8 sw=2 smarttab
|
|
|
|
/*
|
|
|
|
* Ceph - scalable distributed file system
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
|
|
|
|
*
|
|
|
|
* This is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software
|
|
|
|
* Foundation. See file COPYING.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
|
|
|
2011-05-06 16:26:59 +00:00
|
|
|
#include "osd/OSD.h"
|
|
|
|
|
2011-02-22 16:38:45 +00:00
|
|
|
#include "common/config.h"
|
2007-10-17 23:34:54 +00:00
|
|
|
|
|
|
|
#include "mon/MonMap.h"
|
2008-03-10 05:32:16 +00:00
|
|
|
#include "mon/MonClient.h"
|
2007-10-17 23:34:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "msg/SimpleMessenger.h"
|
|
|
|
|
|
|
|
#include "common/Timer.h"
|
2011-06-17 03:15:24 +00:00
|
|
|
#include "global/global_init.h"
|
2011-02-20 17:18:03 +00:00
|
|
|
#include "common/ceph_argparse.h"
|
2007-10-17 23:34:54 +00:00
|
|
|
|
2009-04-28 18:02:55 +00:00
|
|
|
#include "include/color.h"
|
2010-12-16 18:53:58 +00:00
|
|
|
#include "common/errno.h"
|
2009-04-28 18:02:55 +00:00
|
|
|
|
2011-03-02 22:13:38 +00:00
|
|
|
#include "perfglue/heap_profiler.h"
|
|
|
|
|
2008-03-11 01:36:50 +00:00
|
|
|
void usage()
|
|
|
|
{
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << "usage: cosd -i osdid [--osd-data=path] [--osd-journal=path] "
|
2011-08-30 22:34:18 +00:00
|
|
|
<< "[--mkfs] [--mkjournal] [--convert-filestore]" << dendl;
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << " --debug_osd N set debug level (e.g. 10)" << dendl;
|
2009-03-10 22:22:52 +00:00
|
|
|
generic_server_usage();
|
2008-03-11 01:36:50 +00:00
|
|
|
}
|
|
|
|
|
2008-01-01 22:04:31 +00:00
|
|
|
int main(int argc, const char **argv)
|
2007-10-17 23:34:54 +00:00
|
|
|
{
|
2009-03-12 23:08:13 +00:00
|
|
|
DEFINE_CONF_VARS(usage);
|
2008-01-01 22:04:31 +00:00
|
|
|
vector<const char*> args;
|
2007-10-17 23:34:54 +00:00
|
|
|
argv_to_vec(argc, argv, args);
|
2008-11-05 22:54:13 +00:00
|
|
|
env_to_vec(args);
|
2009-10-01 20:54:21 +00:00
|
|
|
vector<const char *>::iterator args_iter;
|
|
|
|
|
2011-06-17 03:15:24 +00:00
|
|
|
global_init(args, CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_DAEMON, 0);
|
2011-03-02 22:13:38 +00:00
|
|
|
ceph_heap_profiler_init();
|
2007-10-17 23:34:54 +00:00
|
|
|
|
|
|
|
// osd specific args
|
2009-11-18 18:49:38 +00:00
|
|
|
bool mkfs = false;
|
|
|
|
bool mkjournal = false;
|
2011-05-18 01:46:38 +00:00
|
|
|
bool mkkey = false;
|
2010-05-20 17:58:56 +00:00
|
|
|
bool flushjournal = false;
|
2011-08-30 22:34:18 +00:00
|
|
|
bool convertfilestore = false;
|
2010-06-09 05:34:57 +00:00
|
|
|
char *dump_pg_log = 0;
|
2009-03-12 23:08:13 +00:00
|
|
|
FOR_EACH_ARG(args) {
|
2011-03-28 23:10:33 +00:00
|
|
|
if (CEPH_ARGPARSE_EQ("mkfs", '\0')) {
|
2009-11-18 18:49:38 +00:00
|
|
|
mkfs = true;
|
2011-03-28 23:10:33 +00:00
|
|
|
} else if (CEPH_ARGPARSE_EQ("mkjournal", '\0')) {
|
2009-11-18 18:49:38 +00:00
|
|
|
mkjournal = true;
|
2011-05-18 01:46:38 +00:00
|
|
|
} else if (CEPH_ARGPARSE_EQ("mkkey", '\0')) {
|
|
|
|
mkkey = true;
|
2011-03-28 23:10:33 +00:00
|
|
|
} else if (CEPH_ARGPARSE_EQ("flush-journal", '\0')) {
|
2010-05-20 17:58:56 +00:00
|
|
|
flushjournal = true;
|
2011-08-30 22:34:18 +00:00
|
|
|
} else if (CEPH_ARGPARSE_EQ("convert-filestore", '\0')) {
|
|
|
|
convertfilestore = true;
|
2011-03-28 23:10:33 +00:00
|
|
|
} else if (CEPH_ARGPARSE_EQ("dump-pg-log", '\0')) {
|
|
|
|
CEPH_ARGPARSE_SET_ARG_VAL(&dump_pg_log, OPT_STR);
|
2009-03-12 23:08:13 +00:00
|
|
|
} else {
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << "unrecognized arg " << args[i] << dendl;
|
2011-03-28 23:10:33 +00:00
|
|
|
usage();
|
2007-10-17 23:34:54 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-11 21:58:58 +00:00
|
|
|
|
2010-06-09 05:34:57 +00:00
|
|
|
if (dump_pg_log) {
|
2011-06-21 19:28:16 +00:00
|
|
|
common_init_finish(g_ceph_context);
|
2010-06-09 05:34:57 +00:00
|
|
|
bufferlist bl;
|
2011-06-10 21:30:17 +00:00
|
|
|
std::string error;
|
|
|
|
int r = bl.read_file(dump_pg_log, &error);
|
2010-06-09 05:34:57 +00:00
|
|
|
if (r >= 0) {
|
|
|
|
PG::Log::Entry e;
|
|
|
|
bufferlist::iterator p = bl.begin();
|
|
|
|
while (!p.end()) {
|
|
|
|
uint64_t pos = p.get_off();
|
|
|
|
try {
|
|
|
|
::decode(e, p);
|
|
|
|
}
|
2010-10-04 17:47:30 +00:00
|
|
|
catch (const buffer::error &e) {
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << "failed to decode LogEntry at offset " << pos << dendl;
|
2010-06-09 05:34:57 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << pos << ":\t" << e << dendl;
|
2010-06-09 05:34:57 +00:00
|
|
|
}
|
2010-12-16 18:53:58 +00:00
|
|
|
} else {
|
2011-06-10 21:30:17 +00:00
|
|
|
derr << "unable to open " << dump_pg_log << ": " << error << dendl;
|
2010-12-16 18:53:58 +00:00
|
|
|
}
|
2010-06-09 05:34:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-11 21:58:58 +00:00
|
|
|
// whoami
|
|
|
|
char *end;
|
2011-06-07 17:38:54 +00:00
|
|
|
const char *id = g_conf->name.get_id().c_str();
|
2011-03-07 13:23:43 +00:00
|
|
|
int whoami = strtol(id, &end, 10);
|
|
|
|
if (*end || end == id || whoami < 0) {
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << "must specify '-i #' where # is the osd number" << dendl;
|
2008-03-11 01:36:50 +00:00
|
|
|
usage();
|
2007-10-17 23:34:54 +00:00
|
|
|
}
|
|
|
|
|
2011-06-07 17:38:54 +00:00
|
|
|
if (g_conf->osd_data.empty()) {
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << "must specify '--osd-data=foo' data path" << dendl;
|
2008-03-11 01:36:50 +00:00
|
|
|
usage();
|
|
|
|
}
|
2008-01-25 20:04:31 +00:00
|
|
|
|
2008-03-11 01:36:50 +00:00
|
|
|
if (mkfs) {
|
2011-06-21 19:28:16 +00:00
|
|
|
common_init_finish(g_ceph_context);
|
|
|
|
MonClient mc(g_ceph_context);
|
2011-05-20 23:35:52 +00:00
|
|
|
if (mc.build_initial_monmap() < 0)
|
|
|
|
return -1;
|
2010-02-12 00:18:54 +00:00
|
|
|
if (mc.get_monmap_privately() < 0)
|
|
|
|
return -1;
|
|
|
|
|
2011-06-07 17:38:54 +00:00
|
|
|
int err = OSD::mkfs(g_conf->osd_data, g_conf->osd_journal, mc.monmap.fsid, whoami);
|
2008-03-11 01:36:50 +00:00
|
|
|
if (err < 0) {
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << TEXT_RED << " ** ERROR: error creating empty object store in "
|
2011-06-07 17:38:54 +00:00
|
|
|
<< g_conf->osd_data << ": " << cpp_strerror(-err) << TEXT_NORMAL << dendl;
|
2008-03-11 01:36:50 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2011-06-07 17:38:54 +00:00
|
|
|
derr << "created object store " << g_conf->osd_data;
|
|
|
|
if (!g_conf->osd_journal.empty())
|
|
|
|
*_dout << " journal " << g_conf->osd_journal;
|
2010-12-16 18:53:58 +00:00
|
|
|
*_dout << " for osd" << whoami << " fsid " << mc.monmap.fsid << dendl;
|
2008-03-11 01:36:50 +00:00
|
|
|
}
|
2011-05-18 01:46:38 +00:00
|
|
|
if (mkkey) {
|
2011-06-21 19:28:16 +00:00
|
|
|
common_init_finish(g_ceph_context);
|
2011-06-02 22:50:22 +00:00
|
|
|
KeyRing *keyring = KeyRing::create_empty();
|
|
|
|
if (!keyring) {
|
|
|
|
derr << "Unable to get a Ceph keyring." << dendl;
|
|
|
|
return 1;
|
|
|
|
}
|
2011-06-07 17:38:54 +00:00
|
|
|
EntityName ename(g_conf->name);
|
2011-05-18 01:46:38 +00:00
|
|
|
EntityAuth eauth;
|
2011-06-21 19:28:16 +00:00
|
|
|
eauth.key.create(g_ceph_context, CEPH_CRYPTO_AES);
|
2011-06-02 22:50:22 +00:00
|
|
|
keyring->add(ename, eauth);
|
2011-05-18 01:46:38 +00:00
|
|
|
bufferlist bl;
|
2011-06-02 22:50:22 +00:00
|
|
|
keyring->encode_plaintext(bl);
|
2011-06-07 17:38:54 +00:00
|
|
|
int r = bl.write_file(g_conf->keyring.c_str(), 0600);
|
2011-05-18 01:46:38 +00:00
|
|
|
if (r)
|
2011-06-07 17:38:54 +00:00
|
|
|
derr << TEXT_RED << " ** ERROR: writing new keyring to " << g_conf->keyring
|
2011-05-18 01:46:38 +00:00
|
|
|
<< ": " << cpp_strerror(r) << TEXT_NORMAL << dendl;
|
|
|
|
else
|
2011-06-07 17:38:54 +00:00
|
|
|
derr << "created new key in keyring " << g_conf->keyring << dendl;
|
2011-05-18 01:46:38 +00:00
|
|
|
}
|
|
|
|
if (mkfs || mkkey)
|
|
|
|
exit(0);
|
2010-05-20 17:58:56 +00:00
|
|
|
if (mkjournal) {
|
2011-06-21 19:28:16 +00:00
|
|
|
common_init_finish(g_ceph_context);
|
2011-06-07 17:38:54 +00:00
|
|
|
int err = OSD::mkjournal(g_conf->osd_data, g_conf->osd_journal);
|
2010-05-20 17:58:56 +00:00
|
|
|
if (err < 0) {
|
2011-06-07 17:38:54 +00:00
|
|
|
derr << TEXT_RED << " ** ERROR: error creating fresh journal " << g_conf->osd_journal
|
|
|
|
<< " for object store " << g_conf->osd_data
|
2011-03-21 18:55:38 +00:00
|
|
|
<< ": " << cpp_strerror(-err) << TEXT_NORMAL << dendl;
|
2010-05-20 17:58:56 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2011-06-07 17:38:54 +00:00
|
|
|
derr << "created new journal " << g_conf->osd_journal
|
|
|
|
<< " for object store " << g_conf->osd_data << dendl;
|
2010-05-20 17:58:56 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
if (flushjournal) {
|
2011-06-21 19:28:16 +00:00
|
|
|
common_init_finish(g_ceph_context);
|
2011-06-07 17:38:54 +00:00
|
|
|
int err = OSD::flushjournal(g_conf->osd_data, g_conf->osd_journal);
|
2010-05-20 17:58:56 +00:00
|
|
|
if (err < 0) {
|
2011-06-07 17:38:54 +00:00
|
|
|
derr << TEXT_RED << " ** ERROR: error flushing journal " << g_conf->osd_journal
|
|
|
|
<< " for object store " << g_conf->osd_data
|
2011-03-21 18:55:38 +00:00
|
|
|
<< ": " << cpp_strerror(-err) << TEXT_NORMAL << dendl;
|
2010-05-20 17:58:56 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2011-06-07 17:38:54 +00:00
|
|
|
derr << "flushed journal " << g_conf->osd_journal
|
|
|
|
<< " for object store " << g_conf->osd_data
|
2010-12-16 18:53:58 +00:00
|
|
|
<< dendl;
|
2010-05-20 17:58:56 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
2011-08-30 22:34:18 +00:00
|
|
|
|
|
|
|
int err = OSD::convertfs(g_conf->osd_data, g_conf->osd_journal);
|
|
|
|
if (err < 0) {
|
|
|
|
derr << TEXT_RED << " ** ERROR: error converting store " << g_conf->osd_data
|
|
|
|
<< ": " << cpp_strerror(-err) << TEXT_NORMAL << dendl;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (convertfilestore) {
|
|
|
|
derr << "Converted Filestore " << g_conf->osd_data << dendl;
|
|
|
|
exit(0);
|
|
|
|
}
|
2010-05-20 17:58:56 +00:00
|
|
|
|
2010-04-28 20:45:55 +00:00
|
|
|
string magic;
|
2009-03-11 21:58:58 +00:00
|
|
|
ceph_fsid_t fsid;
|
|
|
|
int w;
|
2011-06-07 17:38:54 +00:00
|
|
|
int r = OSD::peek_meta(g_conf->osd_data, magic, fsid, w);
|
2009-03-11 21:58:58 +00:00
|
|
|
if (r < 0) {
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << TEXT_RED << " ** ERROR: unable to open OSD superblock on "
|
2011-06-07 17:38:54 +00:00
|
|
|
<< g_conf->osd_data << ": " << cpp_strerror(-r)
|
2010-12-16 18:53:58 +00:00
|
|
|
<< TEXT_NORMAL << dendl;
|
|
|
|
if (r == -ENOTSUP) {
|
|
|
|
derr << TEXT_RED << " ** please verify that underlying storage "
|
|
|
|
<< "supports xattrs" << TEXT_NORMAL << dendl;
|
|
|
|
}
|
2009-03-11 21:58:58 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (w != whoami) {
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << "OSD id " << w << " != my id " << whoami << dendl;
|
2009-03-11 21:58:58 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (strcmp(magic.c_str(), CEPH_OSD_ONDISK_MAGIC)) {
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << "OSD magic " << magic << " != my " << CEPH_OSD_ONDISK_MAGIC
|
|
|
|
<< dendl;
|
2009-03-11 21:58:58 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2009-12-04 22:37:28 +00:00
|
|
|
|
2011-06-29 17:54:15 +00:00
|
|
|
if (g_conf->public_addr.is_blank_ip() && !g_conf->cluster_addr.is_blank_ip()) {
|
2011-06-21 16:51:22 +00:00
|
|
|
derr << TEXT_YELLOW
|
|
|
|
<< " ** WARNING: specified cluster addr but not public addr; we recommend **\n"
|
|
|
|
<< " ** you specify neither or both. **"
|
|
|
|
<< TEXT_NORMAL << dendl;
|
2010-07-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
|
2011-06-21 19:28:16 +00:00
|
|
|
SimpleMessenger *client_messenger = new SimpleMessenger(g_ceph_context);
|
|
|
|
SimpleMessenger *cluster_messenger = new SimpleMessenger(g_ceph_context);
|
2011-08-04 20:35:57 +00:00
|
|
|
SimpleMessenger *messenger_hbin = new SimpleMessenger(g_ceph_context);
|
|
|
|
SimpleMessenger *messenger_hbout = new SimpleMessenger(g_ceph_context);
|
2010-07-08 22:12:14 +00:00
|
|
|
|
2011-06-07 17:38:54 +00:00
|
|
|
client_messenger->bind(g_conf->public_addr, getpid());
|
|
|
|
cluster_messenger->bind(g_conf->cluster_addr, getpid());
|
2010-11-22 04:48:49 +00:00
|
|
|
|
2011-03-29 23:23:55 +00:00
|
|
|
// hb should bind to same ip as cluster_addr (if specified)
|
2011-06-07 17:38:54 +00:00
|
|
|
entity_addr_t hb_addr = g_conf->cluster_addr;
|
2011-06-29 17:54:15 +00:00
|
|
|
if (!hb_addr.is_blank_ip())
|
2010-07-08 22:12:14 +00:00
|
|
|
hb_addr.set_port(0);
|
2011-08-04 20:35:57 +00:00
|
|
|
messenger_hbout->bind(hb_addr, getpid());
|
2008-01-26 17:33:13 +00:00
|
|
|
|
2011-02-24 08:20:06 +00:00
|
|
|
cout << "starting osd" << whoami
|
2010-07-08 22:12:14 +00:00
|
|
|
<< " at " << client_messenger->get_ms_addr()
|
2011-06-07 17:38:54 +00:00
|
|
|
<< " osd_data " << g_conf->osd_data
|
|
|
|
<< " " << ((g_conf->osd_journal.empty()) ?
|
|
|
|
"(no journal)" : g_conf->osd_journal)
|
2011-02-24 08:20:06 +00:00
|
|
|
<< std::endl;
|
2008-01-26 17:33:13 +00:00
|
|
|
|
2010-07-08 22:12:14 +00:00
|
|
|
client_messenger->register_entity(entity_name_t::OSD(whoami));
|
2010-11-22 03:59:43 +00:00
|
|
|
cluster_messenger->register_entity(entity_name_t::OSD(whoami));
|
2011-08-04 20:35:57 +00:00
|
|
|
messenger_hbin->register_entity(entity_name_t::OSD(whoami));
|
|
|
|
messenger_hbout->register_entity(entity_name_t::OSD(whoami));
|
2007-10-17 23:34:54 +00:00
|
|
|
|
2011-06-07 17:38:54 +00:00
|
|
|
Throttle client_throttler(g_conf->osd_client_message_size_cap);
|
2010-06-04 19:04:08 +00:00
|
|
|
|
2010-07-02 16:19:11 +00:00
|
|
|
uint64_t supported =
|
|
|
|
CEPH_FEATURE_UID |
|
2011-08-27 16:57:13 +00:00
|
|
|
CEPH_FEATURE_NOSRCADDR |
|
|
|
|
CEPH_FEATURE_PGID64;
|
2010-11-22 03:59:43 +00:00
|
|
|
|
2010-07-08 22:12:14 +00:00
|
|
|
client_messenger->set_default_policy(SimpleMessenger::Policy::stateless_server(supported, 0));
|
|
|
|
client_messenger->set_policy(entity_name_t::TYPE_CLIENT,
|
2010-11-22 03:59:43 +00:00
|
|
|
SimpleMessenger::Policy::stateless_server(supported, 0));
|
2010-07-08 22:12:14 +00:00
|
|
|
client_messenger->set_policy_throttler(entity_name_t::TYPE_CLIENT, &client_throttler);
|
2010-07-30 16:23:46 +00:00
|
|
|
client_messenger->set_policy(entity_name_t::TYPE_MON,
|
|
|
|
SimpleMessenger::Policy::client(supported,
|
2011-08-27 16:57:13 +00:00
|
|
|
CEPH_FEATURE_UID |
|
|
|
|
CEPH_FEATURE_PGID64));
|
2010-11-22 03:59:43 +00:00
|
|
|
//try to poison pill any OSD connections on the wrong address
|
|
|
|
client_messenger->set_policy(entity_name_t::TYPE_OSD,
|
|
|
|
SimpleMessenger::Policy::stateless_server(0,0));
|
|
|
|
|
|
|
|
cluster_messenger->set_default_policy(SimpleMessenger::Policy::stateless_server(0, 0));
|
|
|
|
cluster_messenger->set_policy(entity_name_t::TYPE_MON, SimpleMessenger::Policy::client(0,0));
|
|
|
|
cluster_messenger->set_policy(entity_name_t::TYPE_OSD,
|
2011-08-27 16:57:13 +00:00
|
|
|
SimpleMessenger::Policy::lossless_peer(supported,
|
|
|
|
CEPH_FEATURE_UID |
|
|
|
|
CEPH_FEATURE_PGID64));
|
2010-11-22 03:59:43 +00:00
|
|
|
cluster_messenger->set_policy(entity_name_t::TYPE_CLIENT,
|
|
|
|
SimpleMessenger::Policy::stateless_server(0, 0));
|
|
|
|
|
2011-05-20 23:35:52 +00:00
|
|
|
// Set up crypto, daemonize, etc.
|
|
|
|
// Leave stderr open in case we need to report errors.
|
2011-06-21 19:28:16 +00:00
|
|
|
global_init_daemonize(g_ceph_context, CINIT_FLAG_NO_CLOSE_STDERR);
|
|
|
|
common_init_finish(g_ceph_context);
|
|
|
|
MonClient mc(g_ceph_context);
|
2011-05-20 23:35:52 +00:00
|
|
|
if (mc.build_initial_monmap() < 0)
|
|
|
|
return -1;
|
2011-06-21 19:28:16 +00:00
|
|
|
global_init_chdir(g_ceph_context);
|
2010-02-12 19:20:30 +00:00
|
|
|
|
2011-08-04 20:35:57 +00:00
|
|
|
OSD *osd = new OSD(whoami, cluster_messenger, client_messenger,
|
|
|
|
messenger_hbin, messenger_hbout,
|
|
|
|
&mc,
|
2011-06-07 17:38:54 +00:00
|
|
|
g_conf->osd_data, g_conf->osd_journal);
|
2011-08-30 22:34:18 +00:00
|
|
|
err = osd->pre_init();
|
2010-02-12 19:20:30 +00:00
|
|
|
if (err < 0) {
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << TEXT_RED << " ** ERROR: initializing osd failed: " << cpp_strerror(-err)
|
|
|
|
<< TEXT_NORMAL << dendl;
|
2010-02-12 19:20:30 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-05-20 23:35:52 +00:00
|
|
|
// Now close the standard file descriptors
|
2011-06-21 19:28:16 +00:00
|
|
|
global_init_shutdown_stderr(g_ceph_context);
|
2011-05-20 23:35:52 +00:00
|
|
|
|
2011-04-29 18:29:42 +00:00
|
|
|
client_messenger->start();
|
2011-08-04 20:35:57 +00:00
|
|
|
messenger_hbin->start_with_nonce(getpid());
|
|
|
|
messenger_hbout->start();
|
2011-04-29 18:29:42 +00:00
|
|
|
cluster_messenger->start();
|
2008-11-13 18:40:11 +00:00
|
|
|
|
2007-10-17 23:34:54 +00:00
|
|
|
// start osd
|
2011-02-03 14:07:26 +00:00
|
|
|
err = osd->init();
|
|
|
|
if (err < 0) {
|
2010-12-16 18:53:58 +00:00
|
|
|
derr << TEXT_RED << " ** ERROR: initializing osd failed: " << cpp_strerror(-err)
|
|
|
|
<< TEXT_NORMAL << dendl;
|
2009-02-12 23:05:12 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2007-10-17 23:34:54 +00:00
|
|
|
|
2010-07-08 22:12:14 +00:00
|
|
|
client_messenger->wait();
|
2011-08-04 20:35:57 +00:00
|
|
|
messenger_hbin->wait();
|
|
|
|
messenger_hbout->wait();
|
2010-11-22 03:59:43 +00:00
|
|
|
cluster_messenger->wait();
|
|
|
|
|
2007-10-17 23:34:54 +00:00
|
|
|
// done
|
|
|
|
delete osd;
|
2010-07-08 22:12:14 +00:00
|
|
|
client_messenger->destroy();
|
2011-08-04 20:35:57 +00:00
|
|
|
messenger_hbin->destroy();
|
|
|
|
messenger_hbout->destroy();
|
2010-11-22 03:59:43 +00:00
|
|
|
cluster_messenger->destroy();
|
2010-07-02 15:44:58 +00:00
|
|
|
|
2008-11-04 22:50:21 +00:00
|
|
|
// cd on exit, so that gmon.out (if any) goes into a separate directory for each node.
|
|
|
|
char s[20];
|
2010-01-15 00:07:39 +00:00
|
|
|
snprintf(s, sizeof(s), "gmon/%d", getpid());
|
2011-02-03 18:15:34 +00:00
|
|
|
if ((mkdir(s, 0755) == 0) && (chdir(s) == 0)) {
|
|
|
|
dout(0) << "cosd: gmon.out should be in " << s << dendl;
|
|
|
|
}
|
2008-11-04 22:50:21 +00:00
|
|
|
|
2007-10-17 23:34:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|