Skip to content

Commit

Permalink
librbd: move IO-related classes to new io namespace
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
  • Loading branch information
Jason Dillaman committed Feb 20, 2017
1 parent 3c0af07 commit de95d86
Show file tree
Hide file tree
Showing 67 changed files with 1,054 additions and 973 deletions.
26 changes: 13 additions & 13 deletions src/librbd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ add_library(rbd_types STATIC
WatchNotifyTypes.cc)

set(librbd_internal_srcs
AioCompletion.cc
AioImageRequest.cc
AioImageRequestWQ.cc
AioObjectRequest.cc
AsyncObjectThrottle.cc
AsyncOperation.cc
AsyncRequest.cc
CopyupRequest.cc
DiffIterate.cc
ExclusiveLock.cc
Group.cc
Expand All @@ -30,14 +25,6 @@ set(librbd_internal_srcs
cache/ImageWriteback.cc
cache/PassthroughImageCache.cc
Watcher.cc
watcher/Types.cc
watcher/RewatchRequest.cc
managed_lock/AcquireRequest.cc
managed_lock/BreakRequest.cc
managed_lock/GetLockerRequest.cc
managed_lock/ReleaseRequest.cc
managed_lock/ReacquireRequest.cc
managed_lock/Utils.cc
exclusive_lock/AutomaticPolicy.cc
exclusive_lock/PreAcquireRequest.cc
exclusive_lock/PostAcquireRequest.cc
Expand All @@ -51,13 +38,24 @@ set(librbd_internal_srcs
image/SetFlagsRequest.cc
image/SetSnapRequest.cc
image_watcher/NotifyLockOwner.cc
io/AioCompletion.cc
io/CopyupRequest.cc
io/ImageRequest.cc
io/ImageRequestWQ.cc
io/ObjectRequest.cc
journal/RemoveRequest.cc
journal/CreateRequest.cc
journal/OpenRequest.cc
journal/PromoteRequest.cc
journal/Replay.cc
journal/StandardPolicy.cc
journal/Utils.cc
managed_lock/AcquireRequest.cc
managed_lock/BreakRequest.cc
managed_lock/GetLockerRequest.cc
managed_lock/ReacquireRequest.cc
managed_lock/ReleaseRequest.cc
managed_lock/Utils.cc
mirror/DisableRequest.cc
mirror/EnableRequest.cc
object_map/CreateRequest.cc
Expand Down Expand Up @@ -91,6 +89,8 @@ set(librbd_internal_srcs
operation/SnapshotUnprotectRequest.cc
operation/SnapshotLimitRequest.cc
operation/TrimRequest.cc
watcher/RewatchRequest.cc
watcher/Types.cc
${CMAKE_SOURCE_DIR}/src/common/ContextCompletion.cc)

add_library(rbd_api STATIC librbd.cc)
Expand Down
22 changes: 11 additions & 11 deletions src/librbd/ExclusiveLock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// vim: ts=8 sw=2 smarttab

#include "librbd/ExclusiveLock.h"
#include "librbd/AioImageRequestWQ.h"
#include "librbd/ImageWatcher.h"
#include "librbd/ImageState.h"
#include "librbd/exclusive_lock/PreAcquireRequest.h"
#include "librbd/exclusive_lock/PostAcquireRequest.h"
#include "librbd/exclusive_lock/PreReleaseRequest.h"
#include "librbd/io/ImageRequestWQ.h"
#include "librbd/Utils.h"
#include "common/Mutex.h"
#include "common/dout.h"
Expand Down Expand Up @@ -83,8 +83,8 @@ void ExclusiveLock<I>::init(uint64_t features, Context *on_init) {
ML<I>::set_state_initializing();
}

m_image_ctx.aio_work_queue->block_writes(new C_InitComplete(this, features,
on_init));
m_image_ctx.io_work_queue->block_writes(new C_InitComplete(this, features,
on_init));
}

template <typename I>
Expand Down Expand Up @@ -116,7 +116,7 @@ void ExclusiveLock<I>::handle_init_complete(uint64_t features) {
ldout(m_image_ctx.cct, 10) << "features=" << features << dendl;

if ((features & RBD_FEATURE_JOURNALING) != 0) {
m_image_ctx.aio_work_queue->set_require_lock_on_read();
m_image_ctx.io_work_queue->set_require_lock_on_read();
}

Mutex::Locker locker(ML<I>::m_lock);
Expand All @@ -129,11 +129,11 @@ void ExclusiveLock<I>::shutdown_handler(int r, Context *on_finish) {

{
RWLock::WLocker owner_locker(m_image_ctx.owner_lock);
m_image_ctx.aio_work_queue->clear_require_lock_on_read();
m_image_ctx.io_work_queue->clear_require_lock_on_read();
m_image_ctx.exclusive_lock = nullptr;
}

m_image_ctx.aio_work_queue->unblock_writes();
m_image_ctx.io_work_queue->unblock_writes();
m_image_ctx.image_watcher->flush(on_finish);
}

Expand Down Expand Up @@ -237,8 +237,8 @@ void ExclusiveLock<I>::handle_post_acquired_lock(int r) {

if (r >= 0) {
m_image_ctx.image_watcher->notify_acquired_lock();
m_image_ctx.aio_work_queue->clear_require_lock_on_read();
m_image_ctx.aio_work_queue->unblock_writes();
m_image_ctx.io_work_queue->clear_require_lock_on_read();
m_image_ctx.io_work_queue->unblock_writes();
}

on_finish->complete(r);
Expand Down Expand Up @@ -270,7 +270,7 @@ void ExclusiveLock<I>::post_release_lock_handler(bool shutting_down, int r,

if (r >= 0) {
m_image_ctx.image_watcher->notify_released_lock();
if (m_image_ctx.aio_work_queue->is_lock_request_needed()) {
if (m_image_ctx.io_work_queue->is_lock_request_needed()) {
// if we have blocked IO -- re-request the lock
RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
ML<I>::acquire_lock(nullptr);
Expand All @@ -279,12 +279,12 @@ void ExclusiveLock<I>::post_release_lock_handler(bool shutting_down, int r,
} else {
{
RWLock::WLocker owner_locker(m_image_ctx.owner_lock);
m_image_ctx.aio_work_queue->clear_require_lock_on_read();
m_image_ctx.io_work_queue->clear_require_lock_on_read();
m_image_ctx.exclusive_lock = nullptr;
}

if (r >= 0) {
m_image_ctx.aio_work_queue->unblock_writes();
m_image_ctx.io_work_queue->unblock_writes();
}

m_image_ctx.image_watcher->notify_released_lock();
Expand Down
2 changes: 1 addition & 1 deletion src/librbd/Group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

#include "common/errno.h"

#include "librbd/AioCompletion.h"
#include "librbd/Group.h"
#include "librbd/ImageState.h"
#include "librbd/Utils.h"
#include "librbd/io/AioCompletion.h"

#define dout_subsys ceph_subsys_rbd
#undef dout_prefix
Expand Down
11 changes: 10 additions & 1 deletion src/librbd/Group.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#ifndef CEPH_LIBRBD_GROUP_H
#define CEPH_LIBRBD_GROUP_H

#include "include/rados/librados.hpp"
#include "include/rbd/librbd.hpp"
#include <string>
#include <vector>

namespace librbd {

struct ImageCtx;

// Consistency groups functions
int group_create(librados::IoCtx& io_ctx, const char *imgname);
int group_remove(librados::IoCtx& io_ctx, const char *group_name);
Expand All @@ -16,6 +24,7 @@ int group_image_remove(librados::IoCtx& group_ioctx, const char *group_name,
int group_image_list(librados::IoCtx& group_ioctx, const char *group_name,
std::vector<group_image_status_t> *images);
int image_get_group(ImageCtx *ictx, group_spec_t *group_spec);
}

} // namespace librbd

#endif // CEPH_LIBRBD_GROUP_H
22 changes: 11 additions & 11 deletions src/librbd/ImageCtx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
#include "common/WorkQueue.h"
#include "common/Timer.h"

#include "librbd/AioImageRequestWQ.h"
#include "librbd/AioCompletion.h"
#include "librbd/AsyncOperation.h"
#include "librbd/AsyncRequest.h"
#include "librbd/ExclusiveLock.h"
#include "librbd/exclusive_lock/AutomaticPolicy.h"
#include "librbd/exclusive_lock/StandardPolicy.h"
#include "librbd/internal.h"
#include "librbd/ImageCtx.h"
#include "librbd/ImageState.h"
#include "librbd/ImageWatcher.h"
#include "librbd/Journal.h"
#include "librbd/journal/StandardPolicy.h"
#include "librbd/LibrbdAdminSocketHook.h"
#include "librbd/ObjectMap.h"
#include "librbd/Operations.h"
#include "librbd/operation/ResizeRequest.h"
#include "librbd/Utils.h"
#include "librbd/LibrbdWriteback.h"
#include "librbd/exclusive_lock/AutomaticPolicy.h"
#include "librbd/exclusive_lock/StandardPolicy.h"
#include "librbd/io/AioCompletion.h"
#include "librbd/io/ImageRequestWQ.h"
#include "librbd/journal/StandardPolicy.h"

#include "osdc/Striper.h"
#include <boost/bind.hpp>
Expand Down Expand Up @@ -189,7 +189,7 @@ struct C_InvalidateCache : public Context {
state(new ImageState<>(this)),
operations(new Operations<>(*this)),
exclusive_lock(nullptr), object_map(nullptr),
aio_work_queue(nullptr), op_work_queue(nullptr),
io_work_queue(nullptr), op_work_queue(nullptr),
asok_hook(nullptr)
{
md_ctx.dup(p);
Expand All @@ -200,9 +200,9 @@ struct C_InvalidateCache : public Context {
memset(&header, 0, sizeof(header));

ThreadPool *thread_pool_singleton = get_thread_pool_instance(cct);
aio_work_queue = new AioImageRequestWQ(this, "librbd::aio_work_queue",
cct->_conf->rbd_op_thread_timeout,
thread_pool_singleton);
io_work_queue = new io::ImageRequestWQ(
this, "librbd::io_work_queue", cct->_conf->rbd_op_thread_timeout,
thread_pool_singleton);
op_work_queue = new ContextWQ("librbd::op_work_queue",
cct->_conf->rbd_op_thread_timeout,
thread_pool_singleton);
Expand Down Expand Up @@ -242,12 +242,12 @@ struct C_InvalidateCache : public Context {
md_ctx.aio_flush();
data_ctx.aio_flush();
op_work_queue->drain();
aio_work_queue->drain();
io_work_queue->drain();

delete journal_policy;
delete exclusive_lock_policy;
delete op_work_queue;
delete aio_work_queue;
delete io_work_queue;
delete operations;
delete state;
}
Expand Down
14 changes: 8 additions & 6 deletions src/librbd/ImageCtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ class SafeTimer;

namespace librbd {

class AioCompletion;
class AioImageRequestWQ;
class AsyncOperation;
class CopyupRequest;
template <typename> class ExclusiveLock;
template <typename> class ImageState;
template <typename> class ImageWatcher;
Expand All @@ -53,6 +50,11 @@ namespace librbd {

namespace cache { struct ImageCache; }
namespace exclusive_lock { struct Policy; }
namespace io {
class AioCompletion;
class ImageRequestWQ;
class CopyupRequest;
}
namespace journal { struct Policy; }

namespace operation {
Expand Down Expand Up @@ -136,7 +138,7 @@ namespace librbd {
Readahead readahead;
uint64_t total_bytes_read;

std::map<uint64_t, CopyupRequest*> copyup_list;
std::map<uint64_t, io::CopyupRequest*> copyup_list;

xlist<AsyncOperation*> async_ops;
xlist<AsyncRequest<>*> async_requests;
Expand All @@ -150,8 +152,8 @@ namespace librbd {

xlist<operation::ResizeRequest<ImageCtx>*> resize_reqs;

AioImageRequestWQ *aio_work_queue;
xlist<AioCompletion*> completed_reqs;
io::ImageRequestWQ *io_work_queue;
xlist<io::AioCompletion*> completed_reqs;
EventSocket event_socket;

ContextWQ *op_work_queue;
Expand Down
2 changes: 1 addition & 1 deletion src/librbd/ImageWatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// vim: ts=8 sw=2 smarttab

#include "librbd/ImageWatcher.h"
#include "librbd/AioCompletion.h"
#include "librbd/ExclusiveLock.h"
#include "librbd/ImageCtx.h"
#include "librbd/ImageState.h"
Expand All @@ -12,6 +11,7 @@
#include "librbd/Utils.h"
#include "librbd/exclusive_lock/Policy.h"
#include "librbd/image_watcher/NotifyLockOwner.h"
#include "librbd/io/AioCompletion.h"
#include "include/encoding.h"
#include "common/errno.h"
#include "common/WorkQueue.h"
Expand Down
22 changes: 11 additions & 11 deletions src/librbd/Journal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
// vim: ts=8 sw=2 smarttab

#include "librbd/Journal.h"
#include "librbd/AioImageRequestWQ.h"
#include "librbd/AioObjectRequest.h"
#include "librbd/ExclusiveLock.h"
#include "librbd/ImageCtx.h"
#include "librbd/journal/OpenRequest.h"
#include "librbd/journal/PromoteRequest.h"
#include "librbd/journal/Replay.h"
#include "cls/journal/cls_journal_types.h"
#include "journal/Journaler.h"
#include "journal/Policy.h"
Expand All @@ -19,8 +14,13 @@
#include "common/Timer.h"
#include "common/WorkQueue.h"
#include "include/rados/librados.hpp"
#include "librbd/journal/RemoveRequest.h"
#include "librbd/io/ImageRequestWQ.h"
#include "librbd/io/ObjectRequest.h"
#include "librbd/journal/CreateRequest.h"
#include "librbd/journal/OpenRequest.h"
#include "librbd/journal/PromoteRequest.h"
#include "librbd/journal/RemoveRequest.h"
#include "librbd/journal/Replay.h"

#include <boost/scope_exit.hpp>
#include <utility>
Expand Down Expand Up @@ -828,7 +828,7 @@ void Journal<I>::flush_commit_position(Context *on_finish) {
template <typename I>
uint64_t Journal<I>::append_write_event(uint64_t offset, size_t length,
const bufferlist &bl,
const AioObjectRequests &requests,
const IOObjectRequests &requests,
bool flush_entry) {
assert(m_max_append_size > journal::AioWriteEvent::get_fixed_size());
uint64_t max_write_data_size =
Expand Down Expand Up @@ -861,7 +861,7 @@ uint64_t Journal<I>::append_write_event(uint64_t offset, size_t length,

template <typename I>
uint64_t Journal<I>::append_io_event(journal::EventEntry &&event_entry,
const AioObjectRequests &requests,
const IOObjectRequests &requests,
uint64_t offset, size_t length,
bool flush_entry) {
bufferlist bl;
Expand All @@ -874,7 +874,7 @@ uint64_t Journal<I>::append_io_event(journal::EventEntry &&event_entry,
template <typename I>
uint64_t Journal<I>::append_io_events(journal::EventType event_type,
const Bufferlists &bufferlists,
const AioObjectRequests &requests,
const IOObjectRequests &requests,
uint64_t offset, size_t length,
bool flush_entry) {
assert(!bufferlists.empty());
Expand Down Expand Up @@ -1547,7 +1547,7 @@ void Journal<I>::handle_io_event_safe(int r, uint64_t tid) {
<< "failed to commit IO event: " << cpp_strerror(r) << dendl;
}

AioObjectRequests aio_object_requests;
IOObjectRequests aio_object_requests;
Contexts on_safe_contexts;
{
Mutex::Locker event_locker(m_event_lock);
Expand Down Expand Up @@ -1576,7 +1576,7 @@ void Journal<I>::handle_io_event_safe(int r, uint64_t tid) {

ldout(cct, 20) << this << " " << __func__ << ": "
<< "completing tid=" << tid << dendl;
for (AioObjectRequests::iterator it = aio_object_requests.begin();
for (IOObjectRequests::iterator it = aio_object_requests.begin();
it != aio_object_requests.end(); ++it) {
if (r < 0) {
// don't send aio requests if the journal fails -- bubble error up
Expand Down

0 comments on commit de95d86

Please sign in to comment.