From: Sage Weil Date: Thu, 9 Jan 2014 22:49:52 +0000 (-0800) Subject: osd/ReplicatedPG: always return ENOENT on deleted snap X-Git-Tag: v0.77~22^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=10547e6713ef2268e2f5985adf3c5712f57445c1;p=ceph.git osd/ReplicatedPG: always return ENOENT on deleted snap 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 --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 3d4531a69f152..d834a3a12bd45 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -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) { diff --git a/src/test/librados/snapshots.cc b/src/test/librados/snapshots.cc index fc83cf1f81ea7..d2bbe74d72540 100644 --- a/src/test/librados/snapshots.cc +++ b/src/test/librados/snapshots.cc @@ -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)));