]> 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)
committerNathan Cutler <ncutler@suse.com>
Tue, 18 Jul 2017 20:12:57 +0000 (22:12 +0200)
Fixes: http://tracker.ceph.com/issues/16878
Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit 78adb70c21c6b8e6a9191b76917919b125a9490f)

src/os/filestore/FileJournal.cc
src/os/filestore/FileJournal.h
src/os/filestore/FileStore.cc
src/os/filestore/Journal.h

index f11e419a944b91ad00517dffad4acb5d4fa4bc87..d71af3f6cf73a55efaed015d0b85c3b61e75f7d8 100644 (file)
@@ -2157,3 +2157,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 1d3d6fb5d3248744151e41c2c4a0991b93f5e283..d14024d9cadfa4e279addd405b3d18b4e07d4fc5 100644 (file)
@@ -471,6 +471,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 461e1025fb460cd4858cbcefb380c201446df3cb..7e69a17d2a81ee0ae71bb20bc754e91fbf48c1ed 100644 (file)
@@ -714,6 +714,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 ca30da4794feb0748b14f1c9d9ff133e3a4c2a9e..067a14cc6463175c4fcf07e63bf8dbfb5f4a0ea1 100644 (file)
@@ -81,6 +81,8 @@ public:
 
   virtual int prepare_entry(vector<ObjectStore::Transaction>& tls, bufferlist* tbl) = 0;
 
+  virtual off64_t get_journal_size_estimate() { return 0; }
+
   // reads/recovery
 
 };