From 07f7bd69425ed2c6b2a97bbf0034232a56fed046 Mon Sep 17 00:00:00 2001 From: Neha Ojha Date: Wed, 26 Sep 2018 16:31:44 -0700 Subject: [PATCH 1/2] osd: print offset and length to track trimtrunc Signed-off-by: Neha Ojha --- src/osd/ECBackend.cc | 4 ++++ src/osd/PrimaryLogPG.cc | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc index b69112c2b5c..45af62c2152 100644 --- a/src/osd/ECBackend.cc +++ b/src/osd/ECBackend.cc @@ -2200,6 +2200,10 @@ void ECBackend::objects_read_async( auto range = got.second.get_containing_range(offset, length); ceph_assert(range.first != range.second); ceph_assert(range.first.get_off() <= offset); + ldpp_dout(dpp, 30) << "offset: " << offset << dendl; + ldpp_dout(dpp, 30) << "range offset: " << range.first.get_off() << dendl; + ldpp_dout(dpp, 30) << "length: " << length << dendl; + ldpp_dout(dpp, 30) << "range length: " << range.first.get_len() << dendl; ceph_assert( (offset + length) <= (range.first.get_off() + range.first.get_len())); diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 14aa42c13cd..b016071a4e0 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -5435,6 +5435,11 @@ int PrimaryLogPG::do_read(OpContext *ctx, OSDOp& osd_op) { uint64_t size = oi.size; bool trimmed_read = false; + dout(30) << __func__ << " oi.size: " << oi.size << dendl; + dout(30) << __func__ << " oi.truncate_seq: " << oi.truncate_seq << dendl; + dout(30) << __func__ << " op.extent.truncate_seq: " << op.extent.truncate_seq << dendl; + dout(30) << __func__ << " op.extent.truncate_size: " << op.extent.truncate_size << dendl; + // are we beyond truncate_size? if ( (seq < op.extent.truncate_seq) && (op.extent.offset + op.extent.length > op.extent.truncate_size) ) @@ -5451,6 +5456,8 @@ int PrimaryLogPG::do_read(OpContext *ctx, OSDOp& osd_op) { trimmed_read = true; } + dout(30) << __func__ << "op.extent.length is now " << op.extent.length << dendl; + // read into a buffer int result = 0; if (trimmed_read && op.extent.length == 0) { From 76c57810ee2346c392834206331aacb0faaa5b54 Mon Sep 17 00:00:00 2001 From: Neha Ojha Date: Tue, 9 Oct 2018 15:57:15 -0700 Subject: [PATCH 2/2] osd/PrimaryLogPG.cc: reassign size only when object size > truncate_size Before setting size equal to op.extent.truncate_size, we need to check if the size of the object is greater than the truncate_size. We do not need to set size to op.extent.truncate_size, in the case where the size of the object is less than op.extent.truncate_size. Without this change, we were always setting size = op.extent.truncate_size, when (seq < op.extent.truncate_seq) and (op.extent.offset + op.extent.length > op.extent.truncate_size), were both true. This ended up in: 1. overestimating the size of the object 2. not considering the correct size of the object, for the later checks, which calculate op.extent.length for the read ops 3. causing crashes when trying to read more data than what was present Fixes: http://tracker.ceph.com/issues/21931 Fixes: http://tracker.ceph.com/issues/22330 Signed-off-by: Neha Ojha --- src/osd/PrimaryLogPG.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index b016071a4e0..0080223f3b7 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -5442,7 +5442,8 @@ int PrimaryLogPG::do_read(OpContext *ctx, OSDOp& osd_op) { // are we beyond truncate_size? if ( (seq < op.extent.truncate_seq) && - (op.extent.offset + op.extent.length > op.extent.truncate_size) ) + (op.extent.offset + op.extent.length > op.extent.truncate_size) && + (size > op.extent.truncate_size) ) size = op.extent.truncate_size; if (op.extent.length == 0) //length is zero mean read the whole object