From 972e9a5a004822b5dfe50283ce2f61e688be4d84 Mon Sep 17 00:00:00 2001 From: Henry Chang Date: Thu, 23 Apr 2015 12:23:46 +0800 Subject: [PATCH] FileJournal: fix check_for_full The condition to test if journal is passing half full mark is incorrect. Consider the following simplified case: Assume header.max_size = 100 and journal has 48 bytes already. 1st write (10 bytes): max=100, room=52, size=10 --> condition not satisfied 2nd write (4 bytes): max=100, room=42, size=4 --> condition not satisfied It passed the half full mark without triggering filestore commit. Signed-off-by: Henry Chang --- src/os/FileJournal.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index c6bb6f2c0755..e629cde22802 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -751,8 +751,8 @@ int FileJournal::check_for_full(uint64_t seq, off64_t pos, off64_t size) << " top " << get_top() << dendl; if (do_sync_cond) { - if (room < (header.max_size >> 1) && - room + size > (header.max_size >> 1)) { + if (room >= (header.max_size >> 1) && + room - size < (header.max_size >> 1)) { dout(10) << " passing half full mark, triggering commit" << dendl; do_sync_cond->SloppySignal(); // initiate a real commit so we can trim } -- 2.47.3