From: Yan, Zheng Date: Sun, 16 Feb 2014 14:14:50 +0000 (+0800) Subject: ReplicatedPG: return no data if read size is trimmed to zero X-Git-Tag: v0.78~170^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1251%2Fhead;p=ceph.git ReplicatedPG: return no data if read size is trimmed to zero OSD should return no data if the read size is trimmed to zero by the truncate_seq/truncate_size check. We can't rely on ObjectStore::read() to do that because it reads the entire object when the 'len' parameter is zero. Fixes: #7371 Signed-off-by: Yan, Zheng --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 826a7e9d39c..8de7e03249c 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -2829,22 +2829,25 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops) case CEPH_OSD_OP_READ: ++ctx->num_read; { + uint64_t trim = (uint64_t)-1; __u32 seq = oi.truncate_seq; // are we beyond truncate_size? if ( (seq < op.extent.truncate_seq) && (op.extent.offset + op.extent.length > op.extent.truncate_size) ) { // truncated portion of the read - unsigned from = MAX(op.extent.offset, op.extent.truncate_size); // also end of data - unsigned to = op.extent.offset + op.extent.length; - unsigned trim = to-from; + uint64_t from = MAX(op.extent.offset, op.extent.truncate_size); // also end of data + uint64_t to = op.extent.offset + op.extent.length; + trim = to - from; op.extent.length = op.extent.length - trim; } // read into a buffer bufferlist bl; - if (pool.info.ec_pool()) { + if (trim != (uint64_t)-1 && op.extent.length == 0) { + // read size was trimmed to zero + } else if (pool.info.ec_pool()) { ctx->pending_async_reads.push_back( make_pair( make_pair(op.extent.offset, op.extent.length),