From 6eca240b26e112641caa7ed31a5ae58e1fefff26 Mon Sep 17 00:00:00 2001 From: John Spray Date: Tue, 31 Mar 2015 14:14:53 +0100 Subject: [PATCH] osdc: implement Objecter::osdmap_pool_full This is for checking whether the global full flag *or* the per-pool full flag is set. Signed-off-by: John Spray --- src/osdc/Objecter.cc | 25 ++++++++++++++++++------- src/osdc/Objecter.h | 8 ++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 93768c0e74b1..0edbbc6e5688 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -2297,13 +2297,7 @@ start: return ret; } -/** - * Any write op which is in progress at the start of this call shall no longer - * be in progress when this call ends. Operations started after the start - * of this call may still be in progress when this call ends. - * - * @return the latest possible epoch in which a cancelled op could have existed - */ + epoch_t Objecter::op_cancel_writes(int r, int64_t pool) { rwlock.get_write(); @@ -2377,6 +2371,23 @@ bool Objecter::osdmap_full_flag() const return _osdmap_full_flag(); } +bool Objecter::osdmap_pool_full(const int64_t pool_id) const +{ + RWLock::RLocker rl(rwlock); + + if (_osdmap_full_flag()) { + return true; + } + + const pg_pool_t *pool = osdmap->get_pg_pool(pool_id); + if (pool == NULL) { + ldout(cct, 4) << __func__ << ": DNE pool " << pool_id << dendl; + return false; + } + + return pool->has_flag(pg_pool_t::FLAG_FULL); +} + /** * Wrapper around osdmap->test_flag for special handling of the FULL flag. */ diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index baf902f4ccca..03c91d739c41 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -1694,6 +1694,14 @@ public: bool osdmap_full_flag() const; + /** + * Test pg_pool_t::FLAG_FULL on a pool + * + * @return true if the pool exists and has the flag set, or + * the global full flag is set, else false + */ + bool osdmap_pool_full(const int64_t pool_id) const; + private: map linger_ops; // we use this just to confirm a cookie is valid before dereferencing the ptr -- 2.47.3