]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
osd/SnapMapper: maintain the prefix_itr between calls to SnapMapper::get_next_objects...
authorGabriel BenHanokh <gbenhano@redhat.com>
Wed, 14 Dec 2022 12:55:19 +0000 (12:55 +0000)
committerGabriel BenHanokh <gbenhano@redhat.com>
Thu, 2 Nov 2023 19:25:16 +0000 (19:25 +0000)
commitabba1a8b2c0829a824ac11c75afa83e40ed230fc
tree09a3cf49efe4f4b8464aad7e05b3be850fbf66b9
parentddd2c61077c566964f6b0aa4835396740fe9c9b3
osd/SnapMapper: maintain the prefix_itr between calls to SnapMapper::get_next_objects_to_trim()
Maintain the prefix_itr between calls to SnapMapper::get_next_objects_to_trim() to prevent searching depleted prefixes.
We got 8 distinct hash prefixes used for searching objects owned by a given PG.
On each call to SnapMapper::get_next_objects_to_trim() we start from the first prefix even after all objects mapped to it were depleted.
This means that we will be searching for 1 non-existing prefix after the first prefix was depleted, 2 after the first two prefixes were depleted... and so on until we will search 7 non-existing prefixes after the first 7 prefixes were depleted.

This is a performance improvement PR only!
It maintains the existing behavior and does not try to fix/change any of the TRIM logic.
I added an extra step after the last object is trimmed doing a full scan of the DB and only if no object was found it will return ENOENT.
This should make the new code no-worse than existing code which returns ENOENT after a full scan found no object.
It should not impact performance in real life snaps as it should only happen once per-snap.

added snap-mapper tests to rados-test-suite
disabled osd_debug_trim_objects when running (SnapMapperTest, prefix_itr) to prevent asserts(as this code does illegal inserts into DELETED snaps)
Code beautifing

Disabled the assert as there is a corner case when we retrieve the last valid object/s in a snap
The prefix_itr is advanced past the last valid value (as we completed a full scan)
If the OSD will call get_next_objects_to_trim() before the retrieved object/s was processed and removed from the SnapMapper DB it won't be found by the next call (as the prefix_itr is invalid).
The object will be found in the second-pass which will seems as if it was added after the trim was started (which is illegal) and will trigger an ASSERT

Signed-off-by: Gabriel BenHanokh <gbenhano@redhat.com>
qa/suites/rados/singleton-nomsgr/all/ceph-snapmapper.yaml [new file with mode: 0644]
qa/tasks/ceph.conf.template
src/common/options/osd.yaml.in
src/osd/SnapMapper.cc
src/osd/SnapMapper.h
src/test/CMakeLists.txt
src/test/test_snap_mapper.cc