]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ReplicatedPG: disallow trans which atomically create and remove an object
authorSamuel Just <sam.just@inktank.com>
Mon, 17 Mar 2014 19:30:52 +0000 (12:30 -0700)
committerSamuel Just <sam.just@inktank.com>
Mon, 17 Mar 2014 22:33:56 +0000 (15:33 -0700)
There are a few problems with such a transaction:
1) We don't really have a way to represent it in the log
2) How does it affect snaps?
3) In finish_ctx, it means we cannot assume that if we are saving snaps
on a snapdir we must be creating the snapdir.

For now, we'll just disallow such a transaction.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/ReplicatedPG.cc

index 160f0d654cf0c9cc2a46a79b7113d19fb52f9ca4..352bf0bd84d1c6137b0ed67f7232fb67a24c8ebd 100644 (file)
@@ -4944,6 +4944,12 @@ int ReplicatedPG::prepare_transaction(OpContext *ctx)
     return result;
   }
 
+  if (!ctx->new_obs.exists && !ctx->obs->exists) {
+    // We can't really represent in the log an operation which atomically
+    // creates and removes an object
+    return -EINVAL;
+  }
+
   // cache: clear whiteout?
   if (pool.info.cache_mode == pg_pool_t::CACHEMODE_WRITEBACK) {
     if (ctx->user_modify &&
@@ -5012,6 +5018,9 @@ void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type)
        }
       }
     } else if (ctx->new_snapset.clones.size()) {
+      // see do_op, if !new_obs.exist && !obs->exists, we returned EINVAL already
+      assert(ctx->obs->exists);
+
       // save snapset on _snap
       hobject_t snapoid(soid.oid, soid.get_key(), CEPH_SNAPDIR, soid.hash,
                        info.pgid.pool(), soid.get_namespace());