]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: --get-journal-fsid
authorSage Weil <sage@newdream.net>
Wed, 30 Nov 2011 22:13:47 +0000 (14:13 -0800)
committerSage Weil <sage@newdream.net>
Mon, 19 Dec 2011 16:15:08 +0000 (08:15 -0800)
Signed-off-by: Sage Weil <sage@newdream.net>
doc/man/8/ceph-osd.rst
src/ceph_osd.cc
src/os/FileJournal.cc
src/os/FileJournal.h
src/osd/OSD.cc
src/osd/OSD.h

index ff2b3e48c657f64fdcb904ebc7659b2c1631a745..bf467988e2dad6cd5ab896696cd4fb368ee6a1c6 100644 (file)
@@ -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
index a12a73367e4998b24eea0065932093fb7359a48b..c9a590443979da68d481e441e07e0bdb1eb89590 100644 (file)
@@ -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);
 
index 9824aed97a55388104ae2ce5feed7e54f374ab7b..63449723d675ec87292ddd3ef96346a1fab02fdd 100644 (file)
@@ -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;
index 08705e28d766efc3f4b3f50bbf493bfd6baede76..88955b2474b61d1ebe5351b71ec53e97c02eedde 100644 (file)
@@ -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();
 
index 99d76df81b6f706324368c71a9f4f611105039e9..80c5321ec1f0c1402e5e59a66a940e4d59a88c9d 100644 (file)
@@ -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)
 
index dd0b86bb15270bd59b1a417d586f39d1d94ef05d..72296e10b6cc8439ed6497308f90a0b5d65b67ad 100644 (file)
@@ -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