Merge pull request #9364 from H3C/H3C

osd: sparse_read offset may not be zero for ecpool

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2016-06-11 18:06:24 +08:00 committed by GitHub
commit 9db46b0cb5

View File

@ -4053,14 +4053,15 @@ struct FillInVerifyExtent : public Context {
struct ToSparseReadResult : public Context {
bufferlist& data_bl;
uint64_t data_offset;
ceph_le64& len;
ToSparseReadResult(bufferlist& bl, ceph_le64& len):
data_bl(bl), len(len) {}
ToSparseReadResult(bufferlist& bl, uint64_t offset, ceph_le64& len):
data_bl(bl), data_offset(offset),len(len) {}
void finish(int r) {
if (r < 0) return;
len = r;
bufferlist outdata;
map<uint64_t, uint64_t> extents = {{0, r}};
map<uint64_t, uint64_t> extents = {{data_offset, r}};
::encode(extents, outdata);
::encode_destructively(data_bl, outdata);
data_bl.swap(outdata);
@ -4324,7 +4325,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
ctx->pending_async_reads.push_back(
make_pair(
boost::make_tuple(op.extent.offset, op.extent.length, op.flags),
make_pair(&osd_op.outdata, new ToSparseReadResult(osd_op.outdata,
make_pair(&osd_op.outdata, new ToSparseReadResult(osd_op.outdata, op.extent.offset,
op.extent.length))));
dout(10) << " async_read (was sparse_read) noted for " << soid << dendl;
} else {