]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: Account for dirty journal data in statfs
authorDavid Zafman <dzafman@redhat.com>
Fri, 17 Feb 2017 01:25:12 +0000 (17:25 -0800)
committerDavid Zafman <dzafman@redhat.com>
Mon, 27 Feb 2017 15:53:56 +0000 (07:53 -0800)
Fixes: http://tracker.ceph.com/issues/16878
Signed-off-by: David Zafman <dzafman@redhat.com>
src/os/filestore/FileJournal.cc
src/os/filestore/FileJournal.h
src/os/filestore/FileStore.cc
src/os/filestore/Journal.h

index 0781e2c6955f994cf91462aa2a7895abc0237950..e660da2265a3e6ac27d79b80affaaf52f13f05de 100644 (file)
@@ -2160,3 +2160,15 @@ void FileJournal::corrupt_header_magic(
     (reinterpret_cast<char*>(&h.magic2) - reinterpret_cast<char*>(&h));
   corrupt(wfd, corrupt_at);
 }
+
+off64_t FileJournal::get_journal_size_estimate()
+{
+  off64_t size, start = header.start;
+  if (write_pos < start) {
+    size = (max_size - start) + write_pos;
+  } else {
+    size = write_pos - start;
+  }
+  dout(20) << __func__ << " journal size=" << size << dendl;
+  return size;
+}
index c804f354d58fa468b6a69174f850fce877bfd1f2..f7b329881015ba5b379f9f8cd8bf9679125f06f9 100644 (file)
@@ -472,6 +472,8 @@ private:
 
   void set_wait_on_full(bool b) { wait_on_full = b; }
 
+  off64_t get_journal_size_estimate();
+
   // reads
 
   /// Result code for read_entry
index 48f4ee6f1dace0cf6ce9ac9722cdb2fd9013212d..77755157e2b2f00c0f3e19356368d34faf68fe15 100644 (file)
@@ -718,6 +718,14 @@ int FileStore::statfs(struct store_statfs_t *buf0)
   }
   buf0->total = buf.f_blocks * buf.f_bsize;
   buf0->available = buf.f_bavail * buf.f_bsize;
+  // Adjust for writes pending in the journal
+  if (journal) {
+    uint64_t estimate = journal->get_journal_size_estimate();
+    if (buf0->available > estimate)
+      buf0->available -= estimate;
+    else
+      buf0->available = 0;
+  }
   return 0;
 }
 
index eadb2987fa26a4d1d3b688e622e37236d15587d5..7bc09ebfb1a42725ca5e21f186e016e8002c816f 100644 (file)
@@ -82,6 +82,8 @@ public:
 
   virtual int prepare_entry(vector<ObjectStore::Transaction>& tls, bufferlist* tbl) = 0;
 
+  virtual off64_t get_journal_size_estimate() { return 0; }
+
   // reads/recovery
 
 };