From 2817ffcf4e57f92551b86388681fc0fe70c386ec Mon Sep 17 00:00:00 2001 From: Alexey Sheplyakov Date: Wed, 16 Dec 2015 15:31:52 +0300 Subject: [PATCH] Check for full before changing the cached obc ReplicatedPG::prepare_transaction(): check if the pool is full before updating the cached ObjectContext to avoid the discrepancy between the cached and the actual object size (and other metadata). While at it improve the check itself: consider cluster full flag, not just the pool full flag, also consider object count changes too, not just bytes. Based on commit a1eb380c3d5254f9f1fe34b4629e51d77fe010c1 Fixes: #13335 Signed-off-by: Alexey Sheplyakov --- src/osd/ReplicatedPG.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 835fc2fceb22..fb701c484e46 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -2288,10 +2288,8 @@ void ReplicatedPG::execute_ctx(OpContext *ctx) return; } - // check for full - if (ctx->delta_stats.num_bytes > 0 && - pool.info.has_flag(pg_pool_t::FLAG_FULL)) { - reply_ctx(ctx, -ENOSPC); + if (result == -ENOSPC) { + reply_ctx(ctx, result); return; } @@ -5674,6 +5672,15 @@ int ReplicatedPG::prepare_transaction(OpContext *ctx) return result; } + // check for full + if ((ctx->delta_stats.num_bytes > 0 || + ctx->delta_stats.num_objects > 0) && + (pool.info.has_flag(pg_pool_t::FLAG_FULL) || + get_osdmap()->test_flag(CEPH_OSDMAP_FULL))) { + dout(20) << __func__ << ": full, returning -ENOSPC" << dendl; + return -ENOSPC; + } + // clone, if necessary if (soid.snap == CEPH_NOSNAP) make_writeable(ctx); -- 2.47.3