template <typename I>
void AioImageRequest<I>::send() {
I &image_ctx = this->m_image_ctx;
- assert(image_ctx.owner_lock.is_locked());
assert(m_aio_comp->is_initialized(get_aio_type()));
assert(m_aio_comp->is_started() ^ (get_aio_type() == AIO_TYPE_FLUSH));
ldout(cct, 20) << __func__ << ": ictx=" << &m_image_ctx << ", "
<< "req=" << req << dendl;
- {
- RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
- req->send();
- }
+ req->send();
finish_queued_op(req);
if (req->is_write_op()) {
}
if (writes_blocked) {
- RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
m_image_ctx.flush(new C_BlockedWrites(this));
}
}
}
void AioImageRequestWQ::finish_in_flight_op() {
+ Context *on_shutdown;
{
RWLock::RLocker locker(m_lock);
if (m_in_flight_ops.dec() > 0 || !m_shutdown) {
return;
}
+ on_shutdown = m_on_shutdown;
}
CephContext *cct = m_image_ctx.cct;
ldout(cct, 5) << __func__ << ": completing shut down" << dendl;
- RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
- assert(m_on_shutdown != nullptr);
- m_image_ctx.flush(m_on_shutdown);
+ assert(on_shutdown != nullptr);
+ m_image_ctx.flush(on_shutdown);
}
bool AioImageRequestWQ::is_lock_required() const {
}
static inline bool is_copy_on_read(ImageCtx *ictx, librados::snap_t snap_id) {
- assert(ictx->owner_lock.is_locked());
assert(ictx->snap_lock.is_locked());
return (ictx->clone_copy_on_read &&
!ictx->read_only && snap_id == CEPH_NOSNAP &&
// This is the step to read from parent
if (!m_tried_parent && r == -ENOENT) {
{
- RWLock::RLocker owner_locker(image_ctx->owner_lock);
RWLock::RLocker snap_locker(image_ctx->snap_lock);
RWLock::RLocker parent_locker(image_ctx->parent_lock);
if (image_ctx->parent == NULL) {
{
ImageCtx *image_ctx = this->m_ictx;
{
- RWLock::RLocker owner_locker(image_ctx->owner_lock);
RWLock::RLocker snap_locker(image_ctx->snap_lock);
RWLock::RLocker parent_locker(image_ctx->parent_lock);
if (!this->compute_parent_extents() ||
<< " parent completion " << parent_completion
<< " extents " << parent_extents
<< dendl;
- RWLock::RLocker owner_locker(image_ctx->parent->owner_lock);
AioImageRequest<>::aio_read(image_ctx->parent, parent_completion,
parent_extents, NULL, &m_read_data, 0);
}
}
void AbstractAioObjectWrite::send() {
- assert(m_ictx->owner_lock.is_locked());
ldout(m_ictx->cct, 20) << "send " << get_write_type() << " " << this <<" "
<< m_oid << " " << m_object_off << "~"
<< m_object_len << dendl;
}
void AbstractAioObjectWrite::send_pre() {
- assert(m_ictx->owner_lock.is_locked());
-
bool write = false;
{
RWLock::RLocker snap_lock(m_ictx->snap_lock);
}
bool AbstractAioObjectWrite::send_post() {
- RWLock::RLocker owner_locker(m_ictx->owner_lock);
RWLock::RLocker snap_locker(m_ictx->snap_lock);
if (m_ictx->object_map == nullptr || !post_object_map_update()) {
return true;
}
virtual int send() {
- assert(m_image_ctx.owner_lock.is_locked());
uint64_t snap_id = m_snap_ids[m_snap_id_idx];
if (snap_id == CEPH_NOSNAP) {
RWLock::RLocker snap_locker(m_image_ctx.snap_lock);
<< ", oid " << m_oid
<< ", extents " << m_image_extents
<< dendl;
- RWLock::RLocker owner_locker(m_ictx->parent->owner_lock);
AioImageRequest<>::aio_read(m_ictx->parent, comp, m_image_extents, NULL,
&m_copyup_data, 0);
}
bool CopyupRequest::send_object_map() {
{
- RWLock::RLocker owner_locker(m_ictx->owner_lock);
RWLock::RLocker snap_locker(m_ictx->snap_lock);
if (m_ictx->object_map != nullptr) {
bool copy_on_read = m_pending_requests.empty();
}
virtual void finish(int r) {
// successful cache flush indicates all IO is now safe
- assert(image_ctx->owner_lock.is_locked());
image_ctx->flush_cache(on_safe);
}
};
}
void ImageCtx::flush_cache(Context *onfinish) {
- assert(owner_lock.is_locked());
cache_lock.Lock();
object_cacher->flush_set(object_set, onfinish);
cache_lock.Unlock();
return;
}
- RWLock::RLocker owner_locker(owner_lock);
cache_lock.Lock();
object_cacher->release_set(object_set);
cache_lock.Unlock();
// ensure no locks are held when flush is complete
on_safe = util::create_async_context_callback(*this, on_safe);
- assert(owner_lock.is_locked());
if (object_cacher != NULL) {
// flush cache after completing all in-flight AIO ops
on_safe = new C_FlushCache(this, on_safe);
const bufferlist &bl,
const AioObjectRequests &requests,
bool flush_entry) {
- assert(m_image_ctx.owner_lock.is_locked());
-
assert(m_max_append_size > journal::AioWriteEvent::get_fixed_size());
uint64_t max_write_data_size =
m_max_append_size - journal::AioWriteEvent::get_fixed_size();
const AioObjectRequests &requests,
uint64_t offset, size_t length,
bool flush_entry) {
- assert(m_image_ctx.owner_lock.is_locked());
-
bufferlist bl;
::encode(event_entry, bl);
return append_io_events(event_entry.get_event_type(), {bl}, requests, offset,
const AioObjectRequests &requests,
uint64_t offset, size_t length,
bool flush_entry) {
- assert(m_image_ctx.owner_lock.is_locked());
assert(!bufferlists.empty());
Futures futures;
(*it)->complete(r);
} else {
// send any waiting aio requests now that journal entry is safe
- RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
(*it)->send();
}
}
*/
class C_ReadRequest : public Context {
public:
- C_ReadRequest(CephContext *cct, Context *c, RWLock *owner_lock,
- Mutex *cache_lock)
- : m_cct(cct), m_ctx(c), m_owner_lock(owner_lock),
- m_cache_lock(cache_lock) {
+ C_ReadRequest(CephContext *cct, Context *c, Mutex *cache_lock)
+ : m_cct(cct), m_ctx(c), m_cache_lock(cache_lock) {
}
virtual void finish(int r) {
ldout(m_cct, 20) << "aio_cb completing " << dendl;
{
- RWLock::RLocker owner_locker(*m_owner_lock);
Mutex::Locker cache_locker(*m_cache_lock);
m_ctx->complete(r);
}
private:
CephContext *m_cct;
Context *m_ctx;
- RWLock *m_owner_lock;
Mutex *m_cache_lock;
};
ldout(cct, 20) << this << " C_WriteJournalCommit: "
<< "journal committed: sending write request" << dendl;
- RWLock::RLocker owner_locker(image_ctx->owner_lock);
assert(image_ctx->exclusive_lock->is_lock_owner());
request_sent = true;
__u32 trunc_seq, int op_flags, Context *onfinish)
{
// on completion, take the mutex and then call onfinish.
- Context *req = new C_ReadRequest(m_ictx->cct, onfinish, &m_ictx->owner_lock,
- &m_lock);
+ Context *req = new C_ReadRequest(m_ictx->cct, onfinish, &m_lock);
{
RWLock::RLocker snap_locker(m_ictx->snap_lock);
__u32 trunc_seq, ceph_tid_t journal_tid,
Context *oncommit)
{
- assert(m_ictx->owner_lock.is_locked());
uint64_t object_no = oid_to_object_no(oid.name, m_ictx->object_prefix);
write_result_d *result = new write_result_d(oid.name, oncommit);
<< "journal_tid=" << original_journal_tid << ", "
<< "new_journal_tid=" << new_journal_tid << dendl;
- assert(m_ictx->owner_lock.is_locked());
uint64_t object_no = oid_to_object_no(oid.name, m_ictx->object_prefix);
// all IO operations are flushed prior to closing the journal
}
}
- void LibrbdWriteback::get_client_lock() {
- m_ictx->owner_lock.get_read();
- }
-
- void LibrbdWriteback::put_client_lock() {
- m_ictx->owner_lock.put_read();
- }
-
void LibrbdWriteback::complete_writes(const std::string& oid)
{
assert(m_lock.is_locked());
uint64_t len, ceph_tid_t original_journal_tid,
ceph_tid_t new_journal_tid);
- virtual void get_client_lock();
- virtual void put_client_lock();
-
struct write_result_d {
bool done;
int ret;
{
assert(m_image_ctx.snap_lock.is_locked());
assert((m_image_ctx.features & RBD_FEATURE_OBJECT_MAP) != 0);
- assert(m_image_ctx.owner_lock.is_locked());
assert(m_image_ctx.image_watcher != NULL);
assert(m_image_ctx.exclusive_lock == nullptr ||
m_image_ctx.exclusive_lock->is_lock_owner());