]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
librbd/cache/pwl: avoid inconsistencies in ImageCacheState
authorIlya Dryomov <idryomov@gmail.com>
Thu, 7 Apr 2022 16:49:46 +0000 (18:49 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 11 Apr 2022 06:26:47 +0000 (08:26 +0200)
commit016882925a63f4f03a9c445d008b2325d479bc30
tree1d765fefed4f29444dcbcbae2870f993b6162e1e
parent7678ee2490965a8a73c02a47283adaa5036dbcab
librbd/cache/pwl: avoid inconsistencies in ImageCacheState

When empty and/or clean bools are updated in I/O handling code paths,
ImageCacheState becomes inconistent for a short while: e.g. with clean
transitioned to true, dirty_bytes counter could still be positive
because the counters are updated only in periodic_stats().  Move to
updating the counters in update_image_cache_state(Context*) to avoid
this.

update_image_cache_state(Context*) now requires m_lock -- most call
sites already hold it anyway.  The only problematic call site was
AbstractWriteLog::shut_down() callback chain: perf_stop() needed to
be moved to the very end since perf counters must be alive now for
update_image_cache_state() to work.

Don't override expect_op_work_queue() in unit tests: completing
context in the same thread now results in a deadlock on m_lock in
all test cases that call AbstractWriteLog::init().

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/librbd/cache/pwl/AbstractWriteLog.cc
src/test/librbd/cache/pwl/test_mock_ReplicatedWriteLog.cc
src/test/librbd/cache/pwl/test_mock_SSDWriteLog.cc