From: Neha Ojha Date: Tue, 9 Oct 2018 22:57:15 +0000 (-0700) Subject: osd/PrimaryLogPG.cc: reassign size only when object size > truncate_size X-Git-Tag: v12.2.10~38^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d41cd7540c11c039584d1df153b421ffb1dd0800;p=ceph.git 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 (cherry picked from commit 76c57810ee2346c392834206331aacb0faaa5b54) --- diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 743d27bc21986..674efddbf0e4c 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -4858,7 +4858,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