Repository navigation
common: fix races when visiting a TrackedOp. - #22877
Conversation
6198545 to
4caa945
Compare
|
The alternative patch I'm not satisfied with is: rzarzynski@6e98f7c. |
There was a problem hiding this comment.
Instead of this mess of changes to unregister_inflight_op(), can we just move everything from if (!tracking_enabled) into the caller? There is only one caller, and having this inside the function makes its name misleading (it's not just unregistering but conditionally either deleting or reregistering elsewhere). I find it very unsettling to have a ref to the object (ri at the top) and also detach+delete.
There was a problem hiding this comment.
Yeah, having delete and the re-registration part is uncomfortable at best even without the extra complexity of Ref. I'm going to make a small clean-up in a separated commit for the sake of backportability.
|
I'm not sure I understand the race. I thought it was between the visitor and the nref changing from 1 -> 0 -> 1, but the visitor holds the shard lock the whole time. So, it could see an op that when from 1 -> 0 and hasn't been deregistered yet, and skip it--that's fine. But I don't see a problem with going from 0 -> 1 because it would have already been removed from the shard's list... |
|
@liewegas: I considered following nasty scenario: |
3bb87f2 to
21f0496
Compare
|
@liewegas: just squashed. |
in /a/sage-2018-07-10_00:40:55-rados-wip-sage3-testing-2018-07-09-1727-distro-basic-smithi/2759788 |
There was a problem hiding this comment.
There is a race between the load() and --nref in the new else clause. Need to recheck in a loop.
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 <[email protected]>
21f0496 to
871cbf0
Compare
gregsfortytwo
left a comment
There was a problem hiding this comment.
Reviewed-by: Greg Farnum [email protected]
* refs/pull/22877/head: common: fix races when visiting a TrackedOp. Reviewed-by: Brad Hubbard <[email protected]> Reviewed-by: Sage Weil <[email protected]> Reviewed-by: Gregory Farnum <[email protected]> Reviewed-by: Greg Farnum <[email protected]>
Performance comparisonAll tests have been conducted on the On average for 4 KiB and 64 KiB randreads respectively: The reference point: 910f3aeThe merge point: 360211e |
Fixes: https://tracker.ceph.com/issues/24664
Related-To: https://tracker.ceph.com/issues/24037
Signed-off-by: Radoslaw Zarzynski [email protected]