From: David Zafman Date: Fri, 17 Feb 2017 01:25:12 +0000 (-0800) Subject: filestore: Account for dirty journal data in statfs X-Git-Tag: v12.0.1~168^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=78adb70c21c6b8e6a9191b76917919b125a9490f;p=ceph.git filestore: Account for dirty journal data in statfs Fixes: http://tracker.ceph.com/issues/16878 Signed-off-by: David Zafman --- diff --git a/src/os/filestore/FileJournal.cc b/src/os/filestore/FileJournal.cc index 0781e2c6955..e660da2265a 100644 --- a/src/os/filestore/FileJournal.cc +++ b/src/os/filestore/FileJournal.cc @@ -2160,3 +2160,15 @@ void FileJournal::corrupt_header_magic( (reinterpret_cast(&h.magic2) - reinterpret_cast(&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; +} diff --git a/src/os/filestore/FileJournal.h b/src/os/filestore/FileJournal.h index c804f354d58..f7b32988101 100644 --- a/src/os/filestore/FileJournal.h +++ b/src/os/filestore/FileJournal.h @@ -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 diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index 48f4ee6f1da..77755157e2b 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -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; } diff --git a/src/os/filestore/Journal.h b/src/os/filestore/Journal.h index eadb2987fa2..7bc09ebfb1a 100644 --- a/src/os/filestore/Journal.h +++ b/src/os/filestore/Journal.h @@ -82,6 +82,8 @@ public: virtual int prepare_entry(vector& tls, bufferlist* tbl) = 0; + virtual off64_t get_journal_size_estimate() { return 0; } + // reads/recovery };