From a1eb380c3d5254f9f1fe34b4629e51d77fe010c1 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 24 Sep 2015 19:27:16 -0400 Subject: [PATCH] osd/ReplicatedPG: fix ENOSPC checking 1. We need to return ENOSPC *before* we apply our side-effects to the obc cache in finish_ctx(). 2. Consider object count changes too, not just bytes. 3. Consider cluster full flag, not just the pool flag. 4. Reply only if FULL_TRY; silently drop ops that were sent despite the full flag. Fixes: #13098 Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 51279ba52615..51ba2a339a5b 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -2703,13 +2703,6 @@ 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); - return; - } - bool successful_write = !ctx->op_t->empty() && op->may_write() && result >= 0; // prepare the reply ctx->reply = new MOSDOpReply(m, 0, get_osdmap()->get_epoch(), 0, @@ -6136,6 +6129,27 @@ int ReplicatedPG::prepare_transaction(OpContext *ctx) return result; } + // check for full + if ((ctx->delta_stats.num_bytes > 0 || + ctx->delta_stats.num_objects > 0) && // FIXME: keys? + (pool.info.has_flag(pg_pool_t::FLAG_FULL) || + get_osdmap()->test_flag(CEPH_OSDMAP_FULL))) { + MOSDOp *m = static_cast(ctx->op->get_req()); + if (ctx->reqid.name.is_mds() || // FIXME: ignore MDS for now + m->has_flag(CEPH_OSD_FLAG_FULL_FORCE)) { + dout(20) << __func__ << " full, but proceeding due to FULL_FORCE or MDS" + << dendl; + } else if (m->has_flag(CEPH_OSD_FLAG_FULL_TRY)) { + // they tried, they failed. + dout(20) << __func__ << " full, replying to FULL_TRY op" << dendl; + return -ENOSPC; + } else { + // drop request + dout(20) << __func__ << " full, dropping request (bad client)" << dendl; + return -EAGAIN; + } + } + // clone, if necessary if (soid.snap == CEPH_NOSNAP) make_writeable(ctx); -- 2.47.3