]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ReplicatedPG: return no data if read size is trimmed to zero 1251/head
authorYan, Zheng <zheng.z.yan@intel.com>
Sun, 16 Feb 2014 14:14:50 +0000 (22:14 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Sun, 16 Feb 2014 14:36:09 +0000 (22:36 +0800)
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 <zheng.z.yan@intel.com>
src/osd/ReplicatedPG.cc

index 826a7e9d39c24ca9eb10ec9336759c2e0cac8dd9..8de7e03249cd0396461758c13ba90e6698a1c7c7 100644 (file)
@@ -2829,22 +2829,25 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& 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),