Skip to content

Commit

Permalink
librbd/object_map: allow intermediate snaps to be skipped on diff-ite…
Browse files Browse the repository at this point in the history
…rate

In case of diff-iterate against the beginning of time, the result
depends only on the end version.  Loading and processing object maps
or intermediate snapshots is redundant and can be skipped.

This optimization is made possible by commit be507aa ("librbd:
diff-iterate shouldn't ever report "new hole" against a hole") and, to
a lesser extent, the previous commit.

Getting FastDiffInvalid, LoadObjectMapError and ObjectMapTooSmall to
pass required tweaking not just expectations, but also start/end snap
ids and thus also the meaning of these tests.  This is addressed in the
next commit.

Fixes: https://tracker.ceph.com/issues/63341
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
  • Loading branch information
idryomov committed Jan 20, 2024
1 parent 19c7c4a commit 23c675f
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 91 deletions.
21 changes: 12 additions & 9 deletions src/librbd/object_map/DiffRequest.cc
Expand Up @@ -38,16 +38,19 @@ void DiffRequest<I>::send() {

m_object_diff_state->clear();

// collect all the snap ids in the provided range (inclusive)
if (m_snap_id_start != 0) {
m_snap_ids.insert(m_snap_id_start);
}

// collect all the snap ids in the provided range (inclusive) unless
// this is diff-iterate against the beginning of time, in which case
// only the end version matters
std::shared_lock image_locker{m_image_ctx->image_lock};
auto snap_info_it = m_image_ctx->snap_info.upper_bound(m_snap_id_start);
auto snap_info_it_end = m_image_ctx->snap_info.lower_bound(m_snap_id_end);
for (; snap_info_it != snap_info_it_end; ++snap_info_it) {
m_snap_ids.insert(snap_info_it->first);
if (!m_diff_iterate_range || m_snap_id_start != 0) {
if (m_snap_id_start != 0) {
m_snap_ids.insert(m_snap_id_start);
}
auto snap_info_it = m_image_ctx->snap_info.upper_bound(m_snap_id_start);
auto snap_info_it_end = m_image_ctx->snap_info.lower_bound(m_snap_id_end);
for (; snap_info_it != snap_info_it_end; ++snap_info_it) {
m_snap_ids.insert(snap_info_it->first);
}
}
m_snap_ids.insert(m_snap_id_end);

Expand Down

0 comments on commit 23c675f

Please sign in to comment.