]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
common: fix races when visiting a TrackedOp. 22877/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 5 Jul 2018 12:39:31 +0000 (14:39 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 10 Jul 2018 16:12:39 +0000 (18:12 +0200)
commit871cbf0f6114c301acc749ae184dbbac32baacf2
tree2907b33b1584c7ac63913d1c9071de23d95b5204
parent5864722eae1a37aeb5fe21ca2545e7471789ed64
common: fix races when visiting a TrackedOp.

Before the commit following race can happen:
  ```
  A           : OpTracker::visit_ops_in_flight(..., callable leaking TrackedOpRef outside)
  A           : Mutex::Locker::Locker(sdata->ops_in_flight_lock_sharded)
  A with lock : (nref > 0) == true

  B           : TrackedOp::put(), nref := 0 // updating the counter is done without the lock
  B           : OpTracker::unregister_inflight_op()
  B           : Mutex::Locker::Locker(sdata->ops_in_flight_lock_sharded)

  A with lock : visit() -> TrackedOp::get(), nref := 1
  A with lock : Mutex::Locker::~Locker()

  B with lock : boost::intrusive::list::iterator_to(op)
  B with lock : boost::intrusive::list::erase(iter)
  B with lock : Mutex::Locker::~Locker()

  A           : TrackedOp::put(), nref := 0
  A           : OpTracker::unregister_inflight_op()
  A           : Mutex::Locker::Locker(sdata->ops_in_flight_lock_sharded)
  A with lock : boost::intrusive::list::iterator_to(op) // oops as op doesn't belong to the list anymore
  ```

Fixes: https://tracker.ceph.com/issues/24664
Related-To: https://tracker.ceph.com/issues/24037
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/common/TrackedOp.cc
src/common/TrackedOp.h