]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PrimaryLogPG: do_op: move and strength LIST_SNAPs vs snapdir check
authorSage Weil <sage@redhat.com>
Thu, 31 Aug 2017 22:42:18 +0000 (18:42 -0400)
committerSage Weil <sage@redhat.com>
Mon, 11 Sep 2017 14:13:34 +0000 (09:13 -0500)
Verify that *only* the LIST_SNAPS op uses an oid with snapdir set.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/PrimaryLogPG.cc

index 5a16ee039c23fc6313090730bd0884c2e4d726d9..516a25d1b20aa63e2c0998311cf39d5a9a6f70ac 100644 (file)
@@ -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<OSDOp>::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<OSDOp>::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)