From ba0a7c4027d6c9a4e4b66aeef8e18813bc21111a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 10 Jun 2016 09:24:10 -0400 Subject: [PATCH] os/bluestore: cache: define 'empty' buffer This is a buffer with no data. It's a placeholder that is there to be used by cache replacement algorithms like 2Q and MQ that needs history for trimmed buffers. Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 5d103748efaec..d160f66caea07 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -111,14 +111,14 @@ public: /// cached buffer struct Buffer { enum { - STATE_UNDEF = 0, - STATE_CLEAN, - STATE_WRITING, + STATE_EMPTY, ///< empty buffer -- used for cache history + STATE_CLEAN, ///< clean data that is up to date + STATE_WRITING, ///< data that is being written (io not yet complete) STATE_READING, }; static const char *get_state_name(int s) { switch (s) { - case STATE_UNDEF: return "undef"; + case STATE_EMPTY: return "empty"; case STATE_CLEAN: return "clean"; case STATE_WRITING: return "writing"; case STATE_READING: return "reading"; @@ -154,6 +154,9 @@ public: : space(space), state(s), flags(f), seq(q), offset(o), length(b.length()), data(b) {} + bool is_empty() const { + return state == STATE_EMPTY; + } bool is_clean() const { return state == STATE_CLEAN; } -- 2.39.5