]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: handle no-op write with snapshot case 3552/head
authorLoic Dachary <ldachary@redhat.com>
Fri, 30 Jan 2015 17:49:16 +0000 (18:49 +0100)
committerLoic Dachary <ldachary@redhat.com>
Mon, 2 Feb 2015 23:58:17 +0000 (00:58 +0100)
If we have a transaction that does something to the object but it !exists
both before and after, we will continue through the write path.  If the
snapdir object already exists, and we try to create it again, we will
leak a snapdir obc.

Fix is to not recreate the snapdir if it already exists.

Fixes: #10262
Signed-off-by: Sage Weil <sage@redhat.com>
Signed-off-by: Loic Dachary <ldachary@redhat.com>
(cherry picked from commit 02fae9fc54c10b5a932102bac43f32199d4cb612)

    Conflicts:
        src/osd/ReplicatedPG.cc
        src/test/librados/snapshots.cc

src/osd/ReplicatedPG.cc

index 2603d628aefe803ea4345c5f519e4712ac487d1e..7bf90680debe8a2b561239cf50d473c6a698e487 100644 (file)
@@ -3813,7 +3813,8 @@ int ReplicatedPG::prepare_transaction(OpContext *ctx)
        assert(ctx->snapset_obc->registered);
       }
     }
-  } else if (ctx->new_snapset.clones.size()) {
+  } else if (ctx->new_snapset.clones.size() &&
+            (!ctx->snapset_obc || !ctx->snapset_obc->obs.exists)) {
     // save snapset on _snap
     hobject_t snapoid(soid.oid, soid.get_key(), CEPH_SNAPDIR, soid.hash,
                      info.pgid.pool(), soid.get_namespace());
@@ -3822,7 +3823,8 @@ int ReplicatedPG::prepare_transaction(OpContext *ctx)
     ctx->log.push_back(pg_log_entry_t(pg_log_entry_t::MODIFY, snapoid, ctx->at_version, old_version,
                                  osd_reqid_t(), ctx->mtime));
 
-    ctx->snapset_obc = get_object_context(snapoid, true);
+    if (!ctx->snapset_obc)
+      ctx->snapset_obc = get_object_context(snapoid, true);
     ctx->snapset_obc->obs.exists = true;
     ctx->snapset_obc->obs.oi.version = ctx->at_version;
     ctx->snapset_obc->obs.oi.last_reqid = ctx->reqid;