]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: always return ENOENT on deleted snap
authorSage Weil <sage@inktank.com>
Thu, 9 Jan 2014 22:49:52 +0000 (14:49 -0800)
committerSage Weil <sage@inktank.com>
Tue, 14 Jan 2014 00:19:49 +0000 (16:19 -0800)
Previously, if a snap was deleted but the clone was there and we hadn't
trimmed it yet, we would still return the data.  Instead, return ENOENT
unconditionally (even it's not removed yet).  This makes the behavior from
the client perspective more predictable and conistent.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/ReplicatedPG.cc
src/test/librados/snapshots.cc

index 3d4531a69f152b7d016fc6aaf6998651edd7f109..d834a3a12bd45c3aa712db2121d63d2296479a32 100644 (file)
@@ -6370,6 +6370,11 @@ int ReplicatedPG::find_object_context(const hobject_t& oid,
   }
 
   // we want a snap
+  if (pool.info.is_removed_snap(oid.snap)) {
+    dout(10) << __func__ << " snap " << oid.snap << " is removed" << dendl;
+    return -ENOENT;
+  }
+
   SnapSetContext *ssc = get_snapset_context(oid.oid, oid.get_key(), oid.hash,
                                            can_create, oid.get_namespace());
   if (!ssc) {
index fc83cf1f81ea7789086ca946e949d27d5736ddf7..d2bbe74d725404ab2087fa05ed442712a7d8e3c8 100644 (file)
@@ -212,8 +212,11 @@ TEST(LibRadosSnapshots, SelfManagedSnapTest) {
   char buf2[sizeof(buf)];
   memset(buf2, 0xdd, sizeof(buf2));
   ASSERT_EQ((int)sizeof(buf2), rados_write(ioctx, "foo", buf2, sizeof(buf2), 0));
-  rados_ioctx_snap_set_read(ioctx, my_snaps[1]);
+  rados_ioctx_snap_set_read(ioctx, my_snaps[1]-1);
   char buf3[sizeof(buf)];
+  ASSERT_EQ(-ENOENT, rados_read(ioctx, "foo", buf3, sizeof(buf3), 0));
+
+  rados_ioctx_snap_set_read(ioctx, my_snaps[1]);
   ASSERT_EQ((int)sizeof(buf3), rados_read(ioctx, "foo", buf3, sizeof(buf3), 0));
   ASSERT_EQ(0, memcmp(buf3, buf, sizeof(buf)));