]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: pass a stream to flush_cache commands for more verbosity
authorMohamad Gebai <mgebai@suse.com>
Mon, 1 Oct 2018 14:46:15 +0000 (10:46 -0400)
committerMohamad Gebai <mgebai@suse.com>
Wed, 10 Oct 2018 15:45:51 +0000 (11:45 -0400)
Signed-off-by: Mohamad Gebai <mgebai@suse.com>
src/os/ObjectStore.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/filestore/FileStore.cc
src/os/filestore/FileStore.h
src/osd/OSD.cc

index 65b52f5346955d9bdd4941232d19ed9e9bc03897..8a737e733d6580e5d2a881b1981f4930083a0b24 100644 (file)
@@ -1479,7 +1479,7 @@ public:
 
   virtual void get_db_statistics(Formatter *f) { }
   virtual void generate_db_histogram(Formatter *f) { }
-  virtual int flush_cache() { return 0; }
+  virtual int flush_cache(ostream *os = NULL) { return 0; }
   virtual void dump_perf_counters(Formatter *f) {}
   virtual int get_cache_obj_count() {
     return -1;
index 8ae5567650ccc82d54587f8b0252891a9f197b5d..4dd49cf2d928643e34861d00a11f5c69eb020417 100644 (file)
@@ -12554,7 +12554,7 @@ void BlueStore::_flush_cache()
 // We use a best-effort policy instead, e.g.,
 // we don't care if there are still some pinned onodes/data in the cache
 // after this command is completed.
-int BlueStore::flush_cache()
+int BlueStore::flush_cache(ostream *os)
 {
   dout(10) << __func__ << dendl;
   for (auto i : cache_shards) {
index 9fc3ebef74390b3f731dac23101dc0bfbbd8d17e..8a4b759eb7c8af4ae345c71e10a974160c8d783b 100644 (file)
@@ -2356,7 +2356,7 @@ public:
   void get_db_statistics(Formatter *f) override;
   void generate_db_histogram(Formatter *f) override;
   void _flush_cache();
-  int flush_cache() override;
+  int flush_cache(ostream *os = NULL) override;
   void dump_perf_counters(Formatter *f) override {
     f->open_object_section("perf_counters");
     logger->dump_formatted(f, false);
index 5e116d864af3f3cbb969854b8ad91c2beea05159..00f8a56226e9afff30d385021c14511a6c1c8ca3 100644 (file)
@@ -1413,22 +1413,28 @@ int FileStore::version_stamp_is_valid(uint32_t *version)
     return 0;
 }
 
-int FileStore::flush_cache()
+int FileStore::flush_cache(ostream *os)
 {
   string drop_caches_file = "/proc/sys/vm/drop_caches";
-  int drop_caches_fd = ::open(drop_caches_file.c_str(), O_WRONLY), ret = 0;
+  int drop_caches_fd = ::open(drop_caches_file.c_str(), O_WRONLY|O_CLOEXEC), ret = 0;
   char buf[2] = "3";
-  int len = strlen(buf);
+  size_t len = strlen(buf);
 
   if (drop_caches_fd < 0) {
     ret = -errno;
     derr << __FUNC__ << ": failed to open " << drop_caches_file << ": " << cpp_strerror(ret) << dendl;
+    if (os) {
+      *os << "FileStore flush_cache: failed to open " << drop_caches_file << ": " << cpp_strerror(ret);
+    }
     return ret;
   }
 
   if (::write(drop_caches_fd, buf, len) < 0) {
     ret = -errno;
     derr << __FUNC__ << ": failed to write to " << drop_caches_file << ": " << cpp_strerror(ret) << dendl;
+    if (os) {
+      *os << "FileStore flush_cache: failed to write to " << drop_caches_file << ": " << cpp_strerror(ret);
+    }
     goto out;
   }
 
index e9e5ce603f74dd5008b94981015769d36719bd25..b1c73af0723175358ca0df53fb82d13545275abd 100644 (file)
@@ -504,7 +504,7 @@ public:
     f->close_section();
   }
 
-  int flush_cache() override;
+  int flush_cache(ostream *os = NULL) override;
   int write_version_stamp();
   int version_stamp_is_valid(uint32_t *version);
   int update_version_stamp();
index 647a93537c2a86481d118d179aeadc63e12d09d1..3eb2140d335356f458e099d6cfd9af61eacf2d68 100644 (file)
@@ -2397,7 +2397,7 @@ will start to track new ops received afterwards.";
   } else if (admin_command == "calc_objectstore_db_histogram") {
     store->generate_db_histogram(f);
   } else if (admin_command == "flush_store_cache") {
-    store->flush_cache();
+    store->flush_cache(&ss);
   } else if (admin_command == "dump_pgstate_history") {
     f->open_object_section("pgstate_history");
     vector<PGRef> pgs;
@@ -6020,8 +6020,8 @@ COMMAND("compact",
 COMMAND("smart name=devid,type=CephString,req=False",
         "runs smartctl on this osd devices.  ",
         "osd", "rw", "cli,rest")
-COMMAND("clear_cache",
-        "Clear OSD caches",
+COMMAND("drop cache",
+        "Drop all OSD caches",
         "osd", "rw", "cli,rest")
 COMMAND("get_cache_object_count",
         "Get OSD caches object count",
@@ -6502,11 +6502,11 @@ int OSD::_do_command(
     probe_smart(devid, ds);
   }
 
-  else if (prefix == "clear_cache") {
+  else if (prefix == "drop cache") {
     dout(20) << "clearing all caches" << dendl;
     // Clear the objectstore's cache - onode and buffer for Bluestore,
     // system's pagecache for Filestore
-    r = store->flush_cache();
+    r = store->flush_cache(&ss);
     if (r < 0) {
       ds << "Error flushing objectstore cache: " << cpp_strerror(r);
       goto out;