From 3e366ceb221e799757bace2cf962b9ca677fb604 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 31 Aug 2017 18:42:18 -0400 Subject: [PATCH] osd/PrimaryLogPG: do_op: move and strength LIST_SNAPs vs snapdir check Verify that *only* the LIST_SNAPS op uses an oid with snapdir set. Signed-off-by: Sage Weil --- src/osd/PrimaryLogPG.cc | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 5a16ee039c23f..516a25d1b20aa 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -2082,6 +2082,25 @@ void PrimaryLogPG::do_op(OpRequestRef& op) hobject_t missing_oid; const hobject_t& oid = m->get_hobj(); + // make sure LIST_SNAPS is on CEPH_SNAPDIR and nothing else + for (vector::iterator p = m->ops.begin(); p != m->ops.end(); ++p) { + OSDOp& osd_op = *p; + + if (osd_op.op.op == CEPH_OSD_OP_LIST_SNAPS) { + if (m->get_snapid() != CEPH_SNAPDIR) { + dout(10) << "LIST_SNAPS with incorrect context" << dendl; + osd->reply_op_error(op, -EINVAL); + return; + } + } else { + if (m->get_snapid() == CEPH_SNAPDIR) { + dout(10) << "non-LIST_SNAPS on snapdir" << dendl; + osd->reply_op_error(op, -EINVAL); + return; + } + } + } + // io blocked on obc? if (!m->has_flag(CEPH_OSD_FLAG_FLUSH) && maybe_await_blocked_head(oid, op)) { @@ -2197,18 +2216,6 @@ void PrimaryLogPG::do_op(OpRequestRef& op) dout(25) << __func__ << " oi " << obc->obs.oi << dendl; - for (vector::iterator p = m->ops.begin(); p != m->ops.end(); ++p) { - OSDOp& osd_op = *p; - - // make sure LIST_SNAPS is on CEPH_SNAPDIR and nothing else - if (osd_op.op.op == CEPH_OSD_OP_LIST_SNAPS && - m->get_snapid() != CEPH_SNAPDIR) { - dout(10) << "LIST_SNAPS with incorrect context" << dendl; - osd->reply_op_error(op, -EINVAL); - return; - } - } - OpContext *ctx = new OpContext(op, m->get_reqid(), &m->ops, obc, this); if (!obc->obs.exists) -- 2.39.5