diff options
author | Josh Durgin <josh.durgin@inktank.com> | 2013-08-12 19:17:09 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-08-18 11:35:59 -0700 |
commit | 6cf05375abea26d2645e3301c9082c64ddf31a55 (patch) | |
tree | 8871573880184ef93ca7b159486c427aef6ab44d | |
parent | 6a37a62b6f794026b82b88630519ec2cde4f20d6 (diff) | |
download | ceph-6cf05375abea26d2645e3301c9082c64ddf31a55.tar.gz |
librados: fix locking for AioCompletionImpl refcounting
Add an already-locked helper so that C_Aio{Safe,Complete} can
increment the reference count when their caller holds the
lock. C_AioCompleteAndSafe's caller is not holding the lock, so call
regular get() to ensure no racing updates can occur.
This eliminates all direct manipulations of AioCompletionImpl->ref,
and makes the necessary locking clear.
The only place C_AioCompleteAndSafe is used is in handling
aio_flush_async(). This could cause a missing completion.
Refs: #5919
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
Tested-by: Oliver Francke <Oliver.Francke@filoo.de>
(cherry picked from commit 7a52e2ff5025754f3040eff3fc52d4893cafc389)
-rw-r--r-- | src/librados/AioCompletionImpl.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/librados/AioCompletionImpl.h b/src/librados/AioCompletionImpl.h index b3e1e8a16e2..8d6c5a542b0 100644 --- a/src/librados/AioCompletionImpl.h +++ b/src/librados/AioCompletionImpl.h @@ -134,10 +134,14 @@ struct librados::AioCompletionImpl { void get() { lock.Lock(); - assert(ref > 0); - ref++; + _get(); lock.Unlock(); } + void _get() { + assert(lock.is_locked()); + assert(ref > 0); + ++ref; + } void release() { lock.Lock(); assert(!released); @@ -162,7 +166,7 @@ struct C_AioComplete : public Context { AioCompletionImpl *c; C_AioComplete(AioCompletionImpl *cc) : c(cc) { - c->ref++; + c->_get(); } void finish(int r) { @@ -181,7 +185,7 @@ struct C_AioSafe : public Context { AioCompletionImpl *c; C_AioSafe(AioCompletionImpl *cc) : c(cc) { - c->ref++; + c->_get(); } void finish(int r) { @@ -208,7 +212,7 @@ struct C_AioCompleteAndSafe : public Context { AioCompletionImpl *c; C_AioCompleteAndSafe(AioCompletionImpl *cc) : c(cc) { - c->ref++; + c->get(); } void finish(int r) { |