From 2955b3da4e2c472c18b45e81eba791f8ccd58061 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Tue, 30 Sep 2014 13:45:10 +0800 Subject: [PATCH] ObjectStore: Add "need_journal" interface to make aware of journal device Impl feature #9580 Signed-off-by: Haomai Wang --- src/ceph_osd.cc | 11 +++++++++++ src/os/FileStore.h | 1 + src/os/KeyValueStore.h | 1 + src/os/MemStore.h | 1 + src/os/ObjectStore.h | 8 ++++++++ 5 files changed, 22 insertions(+) diff --git a/src/ceph_osd.cc b/src/ceph_osd.cc index 1ee236468ad..d4734d225eb 100644 --- a/src/ceph_osd.cc +++ b/src/ceph_osd.cc @@ -107,6 +107,7 @@ 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; @@ -136,6 +137,8 @@ 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; } @@ -308,6 +311,14 @@ int main(int argc, const char **argv) exit(r); } + if (check_need_journal) { + if (store->check_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 f6ed7bb4b71..2486a80e59a 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -96,6 +96,7 @@ public: return target_version; } + bool need_journal() { return true; } int peek_journal_fsid(uuid_d *fsid); struct FSPerfTracker { diff --git a/src/os/KeyValueStore.h b/src/os/KeyValueStore.h index 9ed47c70f41..86cd7aec69d 100644 --- a/src/os/KeyValueStore.h +++ b/src/os/KeyValueStore.h @@ -484,6 +484,7 @@ 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; diff --git a/src/os/MemStore.h b/src/os/MemStore.h index dbdc7f7be0e..fa16b07ef0b 100644 --- a/src/os/MemStore.h +++ b/src/os/MemStore.h @@ -242,6 +242,7 @@ public: return 1; } + bool need_journal() { return false; }; int peek_journal_fsid(uuid_d *fsid); bool test_mount_in_use() { diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 20f925bc66b..1043547a1c2 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -1248,6 +1248,14 @@ public: */ virtual uint32_t get_target_version() = 0; + /** + * 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 */