diff options
author | Sage Weil <sage@inktank.com> | 2013-10-22 18:02:25 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-10-22 18:07:35 -0700 |
commit | 0e63847bba82e40cd14da9f36b318bb28de55f0e (patch) | |
tree | 512168acfd5f56d76adb392ae6b6a3410132960c | |
parent | bd602c377c691a1b00267973f147a13845adfd05 (diff) | |
download | ceph-0e63847bba82e40cd14da9f36b318bb28de55f0e.tar.gz |
osd/ReplicatedPG: clear whiteout when writing into cache tier
If we have a whiteout object and then write over it, clear the whiteout
flag.
Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r-- | src/osd/ReplicatedPG.cc | 8 | ||||
-rw-r--r-- | src/test/librados/tier.cc | 14 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 0798f5a602b..849a68ac41c 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4202,6 +4202,14 @@ int ReplicatedPG::prepare_transaction(OpContext *ctx) return result; } + // cache: clear whiteout? + if (pool.info.cache_mode == pg_pool_t::CACHEMODE_WRITEBACK) { + if (ctx->user_modify && + ctx->obc->obs.oi.is_whiteout()) { + dout(10) << __func__ << " clearing whiteout on " << soid << dendl; + ctx->new_obs.oi.clear_flag(object_info_t::FLAG_WHITEOUT); + } + } // clone, if necessary make_writeable(ctx); diff --git a/src/test/librados/tier.cc b/src/test/librados/tier.cc index 466827e5e83..a97dc72dd80 100644 --- a/src/test/librados/tier.cc +++ b/src/test/librados/tier.cc @@ -218,6 +218,20 @@ TEST(LibRadosTier, Whiteout) { ASSERT_EQ(-ENOENT, base_ioctx.remove("foo")); + // recreate an object and verify we can read it + { + bufferlist bl; + bl.append("hi there"); + ObjectWriteOperation op; + op.write_full(bl); + ASSERT_EQ(0, base_ioctx.operate("foo", &op)); + } + { + bufferlist bl; + ASSERT_EQ(1, base_ioctx.read("foo", bl, 1, 0)); + ASSERT_EQ('h', bl[0]); + } + // tear down tiers ASSERT_EQ(0, cluster.mon_command( "{\"prefix\": \"osd tier remove-overlay\", \"pool\": \"" + base_pool_name + |