]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
crimson: use tri_mutex for guarding ObjectContext
authorKefu Chai <kchai@redhat.com>
Mon, 14 Sep 2020 07:23:17 +0000 (15:23 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 15 Sep 2020 08:48:27 +0000 (16:48 +0800)
commitef72fc736d05b1a65b2b61729eaf96eed6f03ea3
tree94e9d9c0c469ba9805b746b660b0bae8fbeb7190
parent111a145371bc503bd8384f937010fe533c865f4a
crimson: use tri_mutex for guarding ObjectContext

before this change, a seastar::shared_mutex, a RWState and a
shared_promise are used for tracking the consumers of ObjectContext.
and all of the consumers are put into writers if the predicate function
evaluates to "false", and is awaken if the predicate function evaluates
to "true" afterwards in a polling loop waiting on the shared_promise,
which is in turn fulfilled once the last consumer of the given category
relinquishes the lock.

this approach has couple issues:

* it is heavy weighted. seastar::shared_mutex already tracks each of
  the waiters' continuation using separate promise<>, and it does try
  to reschedule them once a given consumer releases the last lock.
  so it's like a design of a customized shared_mutex over a
  shared_mutex.
* it is complicated. 3 variables for tracking the different
  consumers of ObjectContext.

in this change,

* `tri_mutex` is introduced as a variant of the original
  `seastar::shared_mutex` to track two different shared users in
  addition to an exclusive user.
* replace `shared_mutex` with `tri_mutex` in `ObjectContext`, to
  simplify the design.
* move recovery_read_marker into `ObjectContext`. assuming all
  pending actions will be added as a waiter for the related
  object context before they acquire the lock.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/CMakeLists.txt
src/crimson/common/tri_mutex.cc [new file with mode: 0644]
src/crimson/common/tri_mutex.h [new file with mode: 0644]
src/crimson/osd/object_context.h