From: Sage Weil Date: Wed, 30 Nov 2011 22:13:47 +0000 (-0800) Subject: osd: --get-journal-fsid X-Git-Tag: v0.40~137^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dc977901c63fda16b4dafa28c7397fff38846f5d;p=ceph.git osd: --get-journal-fsid Signed-off-by: Sage Weil --- diff --git a/doc/man/8/ceph-osd.rst b/doc/man/8/ceph-osd.rst index ff2b3e48c657..bf467988e2da 100644 --- a/doc/man/8/ceph-osd.rst +++ b/doc/man/8/ceph-osd.rst @@ -69,6 +69,21 @@ Options resize the journal or need to otherwise destroy it: this guarantees you won't lose data. +.. option:: --get-cluster-fsid + + Print the cluster fsid (uuid) and exit. + +.. option:: --get-osd-fsid + + Print the OSD's fsid and exit. The OSD's uuid is generated at + --mkfs time and is thus unique to a particular instantiation of + this OSD. + +.. option:: --get-journal-fsid + + Print the journal's uuid. The journal fsid is set to match the OSD + fsid at --mkfs time. + .. option:: -c ceph.conf, --conf=ceph.conf Use *ceph.conf* configuration file instead of the default diff --git a/src/ceph_osd.cc b/src/ceph_osd.cc index a12a73367e49..c9a590443979 100644 --- a/src/ceph_osd.cc +++ b/src/ceph_osd.cc @@ -65,6 +65,7 @@ int main(int argc, const char **argv) bool mkkey = false; bool flushjournal = false; bool convertfilestore = false; + bool get_journal_fsid = false; bool get_osd_fsid = false; bool get_cluster_fsid = false; std::string dump_pg_log; @@ -92,6 +93,8 @@ int main(int argc, const char **argv) get_cluster_fsid = true; } else if (ceph_argparse_flag(args, i, "--get-osd-fsid", (char*)NULL)) { get_osd_fsid = true; + } else if (ceph_argparse_flag(args, i, "--get-journal-fsid", (char*)NULL)) { + get_journal_fsid = true; } else { ++i; } @@ -250,6 +253,13 @@ int main(int argc, const char **argv) cout << osd_fsid << std::endl; exit(0); } + if (get_journal_fsid) { + uuid_d fsid; + int r = OSD::peek_journal_fsid(g_conf->osd_journal, fsid); + if (r == 0) + cout << fsid << std::endl; + exit(r); + } pick_addresses(g_ceph_context); diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index 9824aed97a55..63449723d675 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -394,6 +394,18 @@ done: return ret; } +int FileJournal::peek_fsid(uuid_d& fsid) +{ + int r = _open(false, false); + if (r < 0) + return r; + r = read_header(); + if (r < 0) + return r; + fsid = header.fsid; + return 0; +} + int FileJournal::open(uint64_t fs_op_seq) { dout(2) << "open " << fn << " fsid " << fsid << " fs_op_seq " << fs_op_seq << dendl; diff --git a/src/os/FileJournal.h b/src/os/FileJournal.h index 08705e28d766..88955b2474b6 100644 --- a/src/os/FileJournal.h +++ b/src/os/FileJournal.h @@ -30,24 +30,6 @@ public: /* * journal header */ -#if 0 - struct old_header_t { - __u32 version; - __u32 flags; - uint64_t fsid; - __u32 block_size; - __u32 alignment; - int64_t max_size; // max size of journal ring buffer - int64_t start; // offset of first entry - - old_header_t() : version(1), flags(0), fsid(0), block_size(0), alignment(0), max_size(0), start(0) {} - - void clear() { - start = block_size; - } - } __attribute__((__packed__, aligned(4))); -#endif - struct header_t { uint64_t flags; uuid_d fsid; @@ -83,7 +65,7 @@ public: ::decode(v, bl); if (v < 2) { // normally 0, but concievably 1 // decode old header_t struct (pre v0.40). - bl.advance(4); // skip flags (was unused by old code) + bl.advance(4); // skip __u32 flags (it was unused by any old code) flags = 0; uint64_t tfsid; ::decode(tfsid, bl); @@ -254,6 +236,7 @@ private: int create(); int open(uint64_t fs_op_seq); void close(); + int peek_fsid(uuid_d& fsid); void flush(); diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 99d76df81b6f..80c5321ec1f0 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -35,6 +35,7 @@ #include "common/ceph_argparse.h" #include "os/FileStore.h" +#include "os/FileJournal.h" #include "ReplicatedPG.h" @@ -496,6 +497,13 @@ int OSD::peek_meta(const std::string &dev, std::string& magic, return 0; } +int OSD::peek_journal_fsid(string path, uuid_d& fsid) +{ + FileJournal j(fsid, 0, 0, path.c_str()); + return j.peek_fsid(fsid); +} + + #undef dout_prefix #define dout_prefix _prefix(_dout, whoami, osdmap) diff --git a/src/osd/OSD.h b/src/osd/OSD.h index dd0b86bb1527..72296e10b6cc 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1061,6 +1061,7 @@ private: public: static int peek_meta(const std::string &dev, string& magic, uuid_d& cluster_fsid, uuid_d& osd_fsid, int& whoami); + static int peek_journal_fsid(std::string jpath, uuid_d& fsid); // startup/shutdown