From 1645baf65d14b50813dc8846cf66ecd5b62d4f50 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Piotr=20Da=C5=82ek?= Date: Tue, 18 Apr 2017 16:12:04 +0200 Subject: [PATCH] ReplicatedPG: use new fiemap interface MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reduce memory allocator load during sparse reads and recovery by not encoding sparse file extents from map into bufferlist, then back again into map. Signed-off-by: Piotr Dałek --- src/osd/PrimaryLogPG.cc | 7 ++----- src/osd/ReplicatedBackend.cc | 18 +++++++----------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 71846caabf8..f5e164d770b 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -4429,18 +4429,15 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) } } else { // read into a buffer - bufferlist bl; + map m; uint32_t total_read = 0; int r = osd->store->fiemap(ch, ghobject_t(soid, ghobject_t::NO_GEN, info.pgid.shard), - op.extent.offset, op.extent.length, bl); + op.extent.offset, op.extent.length, m); if (r < 0) { result = r; break; } - map m; - bufferlist::iterator iter = bl.begin(); - ::decode(m, iter); map::iterator miter; bufferlist data_bl; uint64_t last = op.extent.offset; diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 1364cc62770..2b6ca917a47 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -1981,21 +1981,17 @@ int ReplicatedBackend::build_push_op(const ObjectRecoveryInfo &recovery_info, if (available > 0) { if (!recovery_info.copy_subset.empty()) { interval_set copy_subset = recovery_info.copy_subset; - bufferlist bl; + map m; int r = store->fiemap(ch, ghobject_t(recovery_info.soid), 0, - copy_subset.range_end(), bl); + copy_subset.range_end(), m); if (r >= 0) { - interval_set fiemap_included; - map m; - bufferlist::iterator iter = bl.begin(); - ::decode(m, iter); - map::iterator miter; - for (miter = m.begin(); miter != m.end(); ++miter) { - fiemap_included.insert(miter->first, miter->second); - } - + interval_set fiemap_included(m); copy_subset.intersection_of(fiemap_included); + } else { + // intersection of copy_subset and empty interval_set would be empty anyway + copy_subset.clear(); } + out_op->data_included.span_of(copy_subset, progress.data_recovered_to, available); if (out_op->data_included.empty()) // zero filled section, skip to end! -- 2.39.5