From 542820d065b9f670e651b71561b7e8d0b53a7f71 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 31 Mar 2015 13:49:35 -0700 Subject: [PATCH] ceph-osd: add --check-wants-journal, --check-allows-journal Completes OSD side of #9580 Signed-off-by: Sage Weil --- src/ceph_osd.cc | 53 +++++++++++++++++++++++++++++++++--------- src/os/FileStore.h | 10 +++++++- src/os/KeyValueStore.h | 10 +++++++- src/os/MemStore.h | 10 +++++++- src/os/ObjectStore.h | 11 +++------ 5 files changed, 72 insertions(+), 22 deletions(-) diff --git a/src/ceph_osd.cc b/src/ceph_osd.cc index a589ee7356d1f..d893aebd052a0 100644 --- a/src/ceph_osd.cc +++ b/src/ceph_osd.cc @@ -70,6 +70,12 @@ void usage() << " run any pending upgrade operations\n" << " --flush-journal flush all data out of journal\n" << " --mkjournal initialize a new journal\n" + << " --check-wants-journal\n" + << " check whether a journal is desired\n" + << " --check-allows-journal\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)" << std::endl; generic_server_usage(); @@ -108,6 +114,9 @@ int main(int argc, const char **argv) // osd specific args bool mkfs = false; bool mkjournal = false; + bool check_wants_journal = false; + bool check_allows_journal = false; + bool check_needs_journal = false; bool mkkey = false; bool flushjournal = false; bool dump_journal = false; @@ -115,7 +124,6 @@ int main(int argc, const char **argv) bool get_journal_fsid = false; bool get_osd_fsid = false; bool get_cluster_fsid = false; - bool check_need_journal = false; std::string dump_pg_log; std::string val; @@ -129,6 +137,12 @@ int main(int argc, const char **argv) mkfs = true; } else if (ceph_argparse_flag(args, i, "--mkjournal", (char*)NULL)) { mkjournal = true; + } else if (ceph_argparse_flag(args, i, "--check-allows-journal", (char*)NULL)) { + check_allows_journal = true; + } else if (ceph_argparse_flag(args, i, "--check-wants-journal", (char*)NULL)) { + check_wants_journal = true; + } else if (ceph_argparse_flag(args, i, "--check-needs-journal", (char*)NULL)) { + check_needs_journal = true; } else if (ceph_argparse_flag(args, i, "--mkkey", (char*)NULL)) { mkkey = true; } else if (ceph_argparse_flag(args, i, "--flush-journal", (char*)NULL)) { @@ -145,8 +159,6 @@ 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_flag(args, i, "--check-needs-journal", (char*)NULL)) { - check_need_journal = true; } else { ++i; } @@ -268,6 +280,33 @@ int main(int argc, const char **argv) << " for object store " << g_conf->osd_data << dendl; exit(0); } + if (check_wants_journal) { + if (store->wants_journal()) { + cout << "yes" << std::endl; + exit(0); + } else { + cout << "no" << std::endl; + exit(1); + } + } + if (check_allows_journal) { + if (store->allows_journal()) { + cout << "yes" << std::endl; + exit(0); + } else { + cout << "no" << std::endl; + exit(1); + } + } + if (check_needs_journal) { + if (store->needs_journal()) { + cout << "yes" << std::endl; + exit(0); + } else { + cout << "no" << std::endl; + exit(1); + } + } if (flushjournal) { common_init_finish(g_ceph_context); int err = store->mount(); @@ -326,14 +365,6 @@ int main(int argc, const char **argv) exit(r); } - if (check_need_journal) { - if (store->need_journal()) - cout << "yes" << std::endl; - else - cout << "no" << std::endl; - exit(0); - } - string magic; uuid_d cluster_fsid, osd_fsid; int w; diff --git a/src/os/FileStore.h b/src/os/FileStore.h index bdd6761cf77db..4f6a69f1af1f3 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -96,7 +96,6 @@ public: return target_version; } - bool need_journal() { return true; } int peek_journal_fsid(uuid_d *fsid); struct FSPerfTracker { @@ -423,6 +422,15 @@ public: } int mkfs(); int mkjournal(); + bool wants_journal() { + return true; + } + bool allows_journal() { + return true; + } + bool needs_journal() { + return false; + } int write_version_stamp(); int version_stamp_is_valid(uint32_t *version); diff --git a/src/os/KeyValueStore.h b/src/os/KeyValueStore.h index ef3085fa0d95b..376a37097ce39 100644 --- a/src/os/KeyValueStore.h +++ b/src/os/KeyValueStore.h @@ -484,7 +484,6 @@ class KeyValueStore : public ObjectStore, uint32_t get_target_version() { return target_version; } - bool need_journal() { return false; }; int peek_journal_fsid(uuid_d *id) { *id = fsid; return 0; @@ -501,6 +500,15 @@ class KeyValueStore : public ObjectStore, } int mkfs(); int mkjournal() {return 0;} + bool wants_journal() { + return false; + } + bool allows_journal() { + return false; + } + bool needs_journal() { + return false; + } /** ** set_allow_sharded_objects() diff --git a/src/os/MemStore.h b/src/os/MemStore.h index 4459a6a267401..d6cb51a866483 100644 --- a/src/os/MemStore.h +++ b/src/os/MemStore.h @@ -245,7 +245,6 @@ public: sharded(false) {} ~MemStore() { } - bool need_journal() { return false; }; int peek_journal_fsid(uuid_d *fsid); bool test_mount_in_use() { @@ -266,6 +265,15 @@ public: int mkjournal() { return 0; } + bool wants_journal() { + return false; + } + bool allows_journal() { + return false; + } + bool needs_journal() { + return false; + } bool sharded; void set_allow_sharded_objects() { diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index dd703743dcd4f..5fbc869785ef8 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -1761,6 +1761,9 @@ public: virtual unsigned get_max_attr_name_length() = 0; virtual int mkfs() = 0; // wipe virtual int mkjournal() = 0; // journal only + virtual bool needs_journal() = 0; //< requires a journal + virtual bool wants_journal() = 0; //< prefers a journal + virtual bool allows_journal() = 0; //< allows a journal virtual void set_allow_sharded_objects() = 0; virtual bool get_allow_sharded_objects() = 0; @@ -1768,14 +1771,6 @@ public: virtual void collect_metadata(map *pm) { } - /** - * check whether need journal device - * - * It's not constant for backend store. FileStore could have journaless mode - * and KeyValueStore could have journal device for special backend. - */ - virtual bool need_journal() = 0; - /** * check the journal uuid/fsid, without opening */ -- 2.39.5