void usage()
{
cout << "usage: ceph-osd -i <osdid>\n"
- << " --osd-data=path data directory\n"
- << " --osd-journal=path\n"
+ << " --osd-data PATH data directory\n"
+ << " --osd-journal PATH\n"
<< " journal file or block device\n"
<< " --mkfs create a [new] data directory\n"
<< " --convert-filestore\n"
<< " check whether a journal is allowed\n"
<< " --check-needs-journal\n"
<< " check whether a journal is required\n"
- << " --debug_osd N set debug level (e.g. 10)"
+ << " --debug_osd <N> set debug level (e.g. 10)"
+ << " --get-device-fsid PATH\n"
+ << " get OSD fsid for the given block device\n"
<< std::endl;
generic_server_usage();
cout.flush();
bool flushjournal = false;
bool dump_journal = false;
bool convertfilestore = false;
- bool get_journal_fsid = false;
bool get_osd_fsid = false;
bool get_cluster_fsid = false;
+ bool get_journal_fsid = false;
+ bool get_device_fsid = false;
+ string device_path;
std::string dump_pg_log;
std::string val;
get_osd_fsid = true;
} else if (ceph_argparse_flag(args, i, "--get-journal-fsid", "--get-journal-uuid", (char*)NULL)) {
get_journal_fsid = true;
+ } else if (ceph_argparse_witharg(args, i, &device_path,
+ "--get-device-fsid", (char*)NULL)) {
+ get_device_fsid = true;
} else {
++i;
}
usage();
}
+ if (get_journal_fsid) {
+ device_path = g_conf->osd_journal;
+ get_device_fsid = true;
+ }
+ if (get_device_fsid) {
+ uuid_d uuid;
+ int r = ObjectStore::probe_block_device_fsid(device_path, &uuid);
+ if (r < 0) {
+ cerr << "failed to get device fsid for " << device_path
+ << ": " << cpp_strerror(r) << std::endl;
+ exit(1);
+ }
+ cout << uuid << std::endl;
+ return 0;
+ }
+
if (!dump_pg_log.empty()) {
common_init_finish(g_ceph_context);
bufferlist bl;
exit(0);
}
- if (get_journal_fsid) {
- uuid_d fsid;
- int r = store->peek_journal_fsid(&fsid);
- if (r == 0)
- cout << fsid << std::endl;
- exit(r);
- }
-
string magic;
uuid_d cluster_fsid, osd_fsid;
int w;
return compat;
}
-
-int FileStore::peek_journal_fsid(uuid_d *fsid)
+int FileStore::get_block_device_fsid(const string& path, uuid_d *fsid)
{
// make sure we don't try to use aio or direct_io (and get annoying
// error messages from failing to do so); performance implications
// should be irrelevant for this use
- FileJournal j(*fsid, 0, 0, journalpath.c_str(), false, false);
+ FileJournal j(*fsid, 0, 0, path.c_str(), false, false);
return j.peek_fsid(*fsid);
}
const string& journal,
osflagbits_t flags = 0);
+ /**
+ * probe a block device to learn the uuid of the owning OSD
+ *
+ * @param cct cct
+ * @param path path to device
+ * @param fsid [out] osd uuid
+ */
+ static int probe_block_device_fsid(const string& path,
+ uuid_d *fsid);
+
Logger *logger;
/**
virtual void collect_metadata(map<string,string> *pm) { }
- /**
- * check the journal uuid/fsid, without opening
- */
- virtual int peek_journal_fsid(uuid_d *fsid) = 0;
-
/**
* write_meta - write a simple configuration key out-of-band
*