]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: make block device fsid probing generic
authorSage Weil <sage@redhat.com>
Tue, 1 Dec 2015 22:16:11 +0000 (17:16 -0500)
committerSage Weil <sage@redhat.com>
Tue, 1 Dec 2015 22:16:11 +0000 (17:16 -0500)
Currently the option name and invocation assume that the block device
is a journal (and FileStore journal, managed by FileJournal).  Rework
the interface so that we can probe any block device and other ObjectStore
implementations will have a chance to identify the device (and return the
osd fsid).

Switch to a static method while we are at it so we avoid instantiating
each backend.

Note that only FileStore is probed at the moment; that will change soon!

Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph-disk
src/ceph_osd.cc
src/os/FileStore.cc
src/os/FileStore.h
src/os/KeyValueStore.h
src/os/MemStore.cc
src/os/MemStore.h
src/os/ObjectStore.cc
src/os/ObjectStore.h

index 7f4a00988f314d3633d55f7fb3b240e6768f5e72..0a91fa99ec4ddab7d56818aadbb230998d366bcd 100755 (executable)
@@ -2870,9 +2870,7 @@ def get_journal_osd_uuid(path):
         out = _check_output(
             args=[
                 'ceph-osd',
-                '-i', '0',   # this is ignored
-                '--get-journal-uuid',
-                '--osd-journal',
+                '--get-device-fsid',
                 path,
                 ],
             close_fds=True,
index 7a429ff6bd4f5f1e2355740d75da4ed1c516e24f..aad4307d2e50d0b269c616e0a0225f523e77aebd 100644 (file)
@@ -71,8 +71,8 @@ void handle_osd_signal(int signum)
 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"
@@ -85,7 +85,9 @@ void usage()
        << "                    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();
@@ -130,9 +132,11 @@ int main(int argc, const char **argv)
   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;
@@ -168,6 +172,9 @@ int main(int argc, const char **argv)
       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;
     }
@@ -177,6 +184,22 @@ int main(int argc, const char **argv)
     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;
@@ -365,14 +388,6 @@ int main(int argc, const char **argv)
     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;
index 4134c0d4b81d8d2059e843084a5256c7175e0e6e..24653164ff312b83b754f0ee4d03d2457d1113ea 100644 (file)
@@ -123,13 +123,12 @@ static CompatSet get_fs_supported_compat_set() {
   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);
 }
 
index 883167821c282be6a6b492d9228cafb88da38f68..be5e668b8ebf3be5e3f97c1d95d914ded119fcb8 100644 (file)
@@ -96,7 +96,7 @@ public:
     return target_version;
   }
 
-  int peek_journal_fsid(uuid_d *fsid);
+  static int get_block_device_fsid(const string& path, uuid_d *fsid);
 
   struct FSPerfTracker {
     PerfCounters::avg_tracker<uint64_t> os_commit_latency;
index 4307901e5150c27d9d3314cce56498881f09e361..914ce1dff3e4cbc70bf19f3b79e57c8fba307c9d 100644 (file)
@@ -494,10 +494,6 @@ class KeyValueStore : public ObjectStore,
   uint32_t get_target_version() {
     return target_version;
   }
-  int peek_journal_fsid(uuid_d *id) {
-    *id = fsid;
-    return 0;
-  }
 
   int write_version_stamp();
   int mount();
index 080f731e1a8f40cc9b40629839993a5248f40ac6..678b16d2138fb99e215abbdf1a416e82fc86f6f6 100644 (file)
@@ -41,12 +41,6 @@ bool operator>(const MemStore::CollectionRef& l,
 }
 
 
-int MemStore::peek_journal_fsid(uuid_d *fsid)
-{
-  *fsid = uuid_d();
-  return 0;
-}
-
 int MemStore::mount()
 {
   int r = _load();
index efaa2cf8141c26a71dcd6c47dc2743bc7eb40593..fc047c09ad9d6c310439646a180bc86ce8647078 100644 (file)
@@ -348,8 +348,6 @@ public:
       sharded(false) {}
   ~MemStore() { }
 
-  int peek_journal_fsid(uuid_d *fsid);
-
   bool test_mount_in_use() {
     return false;
   }
index aa62fbda691d4f6d6012b081eee9f5644b94c5e4..e47a94cc4279ab8d9d29ac34716273ae7267a755 100644 (file)
@@ -85,6 +85,20 @@ ObjectStore *ObjectStore::create(CephContext *cct,
   return NULL;
 }
 
+int ObjectStore::probe_block_device_fsid(
+  const string& path,
+  uuid_d *fsid)
+{
+  int r;
+
+  // okay, try FileStore (journal).
+  r = FileStore::get_block_device_fsid(path, fsid);
+  if (r == 0)
+    return r;
+
+  return -EINVAL;
+}
+
 int ObjectStore::write_meta(const std::string& key,
                            const std::string& value)
 {
index 3b00ac73ebe8fefb3fe455e78a5068f3a0fadb69..8f2b749ae677a9e7fcbbfd0150c753d381101cc6 100644 (file)
@@ -114,6 +114,16 @@ public:
                             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;
 
   /**
@@ -1826,11 +1836,6 @@ public:
 
   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
    *