Skip to content

Commit 5d979e7

Browse files
Ravi Nagarjun AkellaRavi Nagarjun Akella
authored andcommitted
No need to set zeroes for lbas not in use.
1 parent aff3e95 commit 5d979e7

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/lib/volume/tests/test_volume_io.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ class VolumeIOImpl {
147147
if(auto it = m_lba_data.find(lba); it != m_lba_data.end()) {
148148
data_pattern = it->second;
149149
test_common::HBTestHelper::validate_data_buf(buf, m_vol_ptr->info()->page_size, data_pattern);
150-
} else {
151-
test_common::HBTestHelper::validate_zeros(buf, m_vol_ptr->info()->page_size);
152150
}
153151

154152
LOGDEBUG("Verify data lba={} pattern expected={} actual={}", lba, data_pattern, *r_cast< uint64_t* >(read_blob.bytes()));

src/lib/volume_mgr.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,16 @@ VolumeManager::NullAsyncResult HomeBlocksImpl::read(const VolumePtr& vol, const
274274
for (uint32_t i = 0, blk_count = 0, start_idx = 0; i < out_vector.size(); ++i, ++cur_lba) {
275275
auto const& [key, value] = out_vector[i];
276276
// cur_lba is used to keep track of the holes
277-
// fill the read buffer with zeroes for the holes
277+
// move the read buffer by the size of the holes
278278
if(cur_lba != key.key()) {
279279
if(blk_count > 0) {
280280
// submit the read for the previous blkids
281281
submit_read_to_backend(read_buf, futs, out_vector[start_idx], blk_count, vol, req->part_of_batch);
282282
start_idx = i;
283283
blk_count = 0;
284284
}
285-
auto fill_size = (key.key() - cur_lba) * vol->rd()->get_blk_size();
286-
std::memset(read_buf, 0, fill_size);
287-
read_buf += fill_size;
285+
auto offset = (key.key() - cur_lba) * vol->rd()->get_blk_size();
286+
read_buf += offset;
288287
cur_lba = key.key();
289288
}
290289

@@ -310,10 +309,6 @@ VolumeManager::NullAsyncResult HomeBlocksImpl::read(const VolumePtr& vol, const
310309
submit_read_to_backend(read_buf, futs, out_vector[start_idx], 1, vol, req->part_of_batch);
311310
}
312311
}
313-
// fill the holes at the end of the read buffer
314-
if(cur_lba != req->end_lba() + 1) {
315-
std::memset(read_buf, 0, (req->end_lba() - cur_lba + 1) * vol->rd()->get_blk_size());
316-
}
317312

318313
return out_vector.empty() ? folly::Unit() :
319314
folly::collectAllUnsafe(futs).thenValue([out_vector = std::move(out_vector), buf = req->buffer

0 commit comments

Comments
 (0)