Merge remote-tracking branch 'origin/hammer'

This commit is contained in:
Josh Durgin 2015-02-03 10:28:50 +01:00
commit 352ad94842
4 changed files with 31 additions and 27 deletions

View File

@ -259,8 +259,6 @@ namespace librbd {
m_state = LIBRBD_AIO_WRITE_GUARD; m_state = LIBRBD_AIO_WRITE_GUARD;
m_write.assert_exists(); m_write.assert_exists();
ldout(m_ictx->cct, 20) << __func__ << " guarding write" << dendl; ldout(m_ictx->cct, 20) << __func__ << " guarding write" << dendl;
} else {
m_state = LIBRBD_AIO_WRITE_FLAT;
} }
} }
@ -480,6 +478,7 @@ namespace librbd {
ldout(m_ictx->cct, 20) << "send_write " << this << " " << m_oid << " " ldout(m_ictx->cct, 20) << "send_write " << this << " " << m_oid << " "
<< m_object_off << "~" << m_object_len << dendl; << m_object_off << "~" << m_object_len << dendl;
m_state = LIBRBD_AIO_WRITE_FLAT;
guard_write(); guard_write();
add_write_ops(&m_write); add_write_ops(&m_write);
assert(m_write.size() != 0); assert(m_write.size() != 0);

View File

@ -131,13 +131,22 @@ bool ImageWatcher::has_pending_aio_operations() {
} }
void ImageWatcher::flush_aio_operations() { void ImageWatcher::flush_aio_operations() {
C_SaferCond *ctx = new C_SaferCond();
flush_aio_operations(ctx);
ctx->wait();
}
void ImageWatcher::flush_aio_operations(Context *ctx) {
Mutex::Locker l(m_aio_request_lock); Mutex::Locker l(m_aio_request_lock);
while (m_retrying_aio_requests || !m_aio_requests.empty()) { if (!m_retrying_aio_requests && m_aio_requests.empty()) {
ldout(m_image_ctx.cct, 20) << "flushing aio operations: " ctx->complete(0);
<< "retrying=" << m_retrying_aio_requests << "," return;
<< "count=" << m_aio_requests.size() << dendl;
m_aio_request_cond.Wait(m_aio_request_lock);
} }
ldout(m_image_ctx.cct, 20) << "pending flush: " << ctx << " "
<< "retrying=" << m_retrying_aio_requests << ", "
<< "count=" << m_aio_requests.size() << dendl;
m_aio_flush_contexts.push_back(ctx);
} }
int ImageWatcher::try_lock() { int ImageWatcher::try_lock() {
@ -545,23 +554,13 @@ void ImageWatcher::retry_aio_requests() {
Mutex::Locker l(m_aio_request_lock); Mutex::Locker l(m_aio_request_lock);
m_retrying_aio_requests = false; m_retrying_aio_requests = false;
m_aio_request_cond.Signal(); while (!m_aio_flush_contexts.empty()) {
} Context *flush_ctx = m_aio_flush_contexts.front();
m_aio_flush_contexts.pop_front();
void ImageWatcher::cancel_aio_requests(int result) { ldout(m_image_ctx.cct, 20) << "completed flush: " << flush_ctx << dendl;
Mutex::Locker l(m_aio_request_lock); flush_ctx->complete(0);
for (std::vector<AioRequest>::iterator iter = m_aio_requests.begin();
iter != m_aio_requests.end(); ++iter) {
AioCompletion *c = iter->second;
c->get();
c->lock.Lock();
c->rval = result;
c->lock.Unlock();
c->finish_adding_requests(m_image_ctx.cct);
c->put();
} }
m_aio_requests.clear();
m_aio_request_cond.Signal();
} }
void ImageWatcher::cancel_async_requests(int result) { void ImageWatcher::cancel_async_requests(int result) {

View File

@ -3,9 +3,9 @@
#ifndef CEPH_LIBRBD_IMAGE_WATCHER_H #ifndef CEPH_LIBRBD_IMAGE_WATCHER_H
#define CEPH_LIBRBD_IMAGE_WATCHER_H #define CEPH_LIBRBD_IMAGE_WATCHER_H
#include "common/Cond.h"
#include "common/Mutex.h" #include "common/Mutex.h"
#include "common/RWLock.h" #include "common/RWLock.h"
#include "include/Context.h"
#include "include/rados/librados.hpp" #include "include/rados/librados.hpp"
#include "include/rbd/librbd.hpp" #include "include/rbd/librbd.hpp"
#include <set> #include <set>
@ -16,7 +16,6 @@
#include "include/assert.h" #include "include/assert.h"
class entity_name_t; class entity_name_t;
class Context;
class Finisher; class Finisher;
class SafeTimer; class SafeTimer;
@ -60,6 +59,7 @@ namespace librbd {
bool has_pending_aio_operations(); bool has_pending_aio_operations();
void flush_aio_operations(); void flush_aio_operations();
void flush_aio_operations(Context *ctx);
int try_lock(); int try_lock();
int request_lock(const boost::function<int(AioCompletion*)>& restart_op, int request_lock(const boost::function<int(AioCompletion*)>& restart_op,
@ -170,7 +170,7 @@ namespace librbd {
std::set<RemoteAsyncRequest> m_async_progress; std::set<RemoteAsyncRequest> m_async_progress;
Mutex m_aio_request_lock; Mutex m_aio_request_lock;
Cond m_aio_request_cond; std::list<Context *> m_aio_flush_contexts;
std::vector<AioRequest> m_aio_requests; std::vector<AioRequest> m_aio_requests;
bool m_retrying_aio_requests; bool m_retrying_aio_requests;
Context *m_retry_aio_context; Context *m_retry_aio_context;
@ -191,7 +191,6 @@ namespace librbd {
void finalize_retry_aio_requests(); void finalize_retry_aio_requests();
void retry_aio_requests(); void retry_aio_requests();
void cancel_aio_requests(int result);
void cancel_async_requests(int result); void cancel_async_requests(int result);
uint64_t encode_async_request(bufferlist &bl); uint64_t encode_async_request(bufferlist &bl);

View File

@ -3103,9 +3103,16 @@ reprotect_and_return_err:
ictx->user_flushed(); ictx->user_flushed();
c->get(); c->get();
c->add_request();
c->init_time(ictx, AIO_TYPE_FLUSH); c->init_time(ictx, AIO_TYPE_FLUSH);
if (ictx->image_watcher != NULL) {
C_AioWrite *flush_ctx = new C_AioWrite(cct, c);
c->add_request();
ictx->image_watcher->flush_aio_operations(flush_ctx);
}
C_AioWrite *req_comp = new C_AioWrite(cct, c); C_AioWrite *req_comp = new C_AioWrite(cct, c);
c->add_request();
if (ictx->object_cacher) { if (ictx->object_cacher) {
ictx->flush_cache_aio(req_comp); ictx->flush_cache_aio(req_comp);
} else { } else {