bufferlist bl;
bl.append(m_buf, m_len);
- uint64_t tid = m_image_ctx.journal->append_write_event(m_aio_comp, m_off,
- m_len, bl, requests,
- synchronous);
+ uint64_t tid = m_image_ctx.journal->append_write_event(m_off, m_len, bl,
+ requests, synchronous);
if (m_image_ctx.object_cacher == NULL) {
m_aio_comp->associate_journal_event(tid);
}
uint64_t AioImageDiscard::append_journal_event(
const AioObjectRequests &requests, bool synchronous) {
journal::EventEntry event_entry(journal::AioDiscardEvent(m_off, m_len));
- uint64_t tid = m_image_ctx.journal->append_io_event(m_aio_comp,
- std::move(event_entry),
+ uint64_t tid = m_image_ctx.journal->append_io_event(std::move(event_entry),
requests, m_off, m_len,
synchronous);
m_aio_comp->associate_journal_event(tid);
if (journaling) {
// in-flight ops are flushed prior to closing the journal
uint64_t journal_tid = m_image_ctx.journal->append_io_event(
- m_aio_comp, journal::EventEntry(journal::AioFlushEvent()),
+ journal::EventEntry(journal::AioFlushEvent()),
AioObjectRequests(), 0, 0, false);
C_FlushJournalCommit *ctx = new C_FlushJournalCommit(m_image_ctx,
// vim: ts=8 sw=2 smarttab
#include "librbd/Journal.h"
-#include "librbd/AioCompletion.h"
#include "librbd/AioImageRequestWQ.h"
#include "librbd/AioObjectRequest.h"
#include "librbd/ExclusiveLock.h"
}
template <typename I>
-uint64_t Journal<I>::append_write_event(AioCompletion *aio_comp,
- uint64_t offset, size_t length,
+uint64_t Journal<I>::append_write_event(uint64_t offset, size_t length,
const bufferlist &bl,
const AioObjectRequests &requests,
bool flush_entry) {
bytes_remaining -= event_length;
} while (bytes_remaining > 0);
- return append_io_events(aio_comp, journal::EVENT_TYPE_AIO_WRITE, bufferlists,
- requests, offset, length, flush_entry);
+ return append_io_events(journal::EVENT_TYPE_AIO_WRITE, bufferlists, requests,
+ offset, length, flush_entry);
}
template <typename I>
-uint64_t Journal<I>::append_io_event(AioCompletion *aio_comp,
- journal::EventEntry &&event_entry,
+uint64_t Journal<I>::append_io_event(journal::EventEntry &&event_entry,
const AioObjectRequests &requests,
uint64_t offset, size_t length,
bool flush_entry) {
bufferlist bl;
::encode(event_entry, bl);
- return append_io_events(aio_comp, event_entry.get_event_type(), {bl},
- requests, offset, length, flush_entry);
+ return append_io_events(event_entry.get_event_type(), {bl}, requests, offset,
+ length, flush_entry);
}
template <typename I>
-uint64_t Journal<I>::append_io_events(AioCompletion *aio_comp,
- journal::EventType event_type,
+uint64_t Journal<I>::append_io_events(journal::EventType event_type,
const Bufferlists &bufferlists,
const AioObjectRequests &requests,
uint64_t offset, size_t length,
assert(bl.length() <= m_max_append_size);
futures.push_back(m_journaler->append(m_tag_tid, bl));
}
- m_events[tid] = Event(futures, aio_comp, requests, offset, length);
+ m_events[tid] = Event(futures, requests, offset, length);
}
CephContext *cct = m_image_ctx.cct;
namespace librbd {
-class AioCompletion;
class AioObjectRequest;
class ImageCtx;
void flush_commit_position(Context *on_finish);
- uint64_t append_write_event(AioCompletion *aio_comp,
- uint64_t offset, size_t length,
+ uint64_t append_write_event(uint64_t offset, size_t length,
const bufferlist &bl,
const AioObjectRequests &requests,
bool flush_entry);
- uint64_t append_io_event(AioCompletion *aio_comp,
- journal::EventEntry &&event_entry,
+ uint64_t append_io_event(journal::EventEntry &&event_entry,
const AioObjectRequests &requests,
uint64_t offset, size_t length,
bool flush_entry);
struct Event {
Futures futures;
- AioCompletion *aio_comp = nullptr;
AioObjectRequests aio_object_requests;
Contexts on_safe_contexts;
ExtentInterval pending_extents;
Event() {
}
- Event(const Futures &_futures, AioCompletion *_aio_comp,
- const AioObjectRequests &_requests, uint64_t offset, size_t length)
- : futures(_futures), aio_comp(_aio_comp), aio_object_requests(_requests) {
+ Event(const Futures &_futures, const AioObjectRequests &_requests,
+ uint64_t offset, size_t length)
+ : futures(_futures), aio_object_requests(_requests) {
if (length > 0) {
pending_extents.insert(offset, length);
}
journal::Replay<ImageCtxT> *m_journal_replay;
- uint64_t append_io_events(AioCompletion *aio_comp,
- journal::EventType event_type,
+ uint64_t append_io_events(journal::EventType event_type,
const Bufferlists &bufferlists,
const AioObjectRequests &requests,
uint64_t offset, size_t length, bool flush_entry);
librbd::Journal<>::AioObjectRequests requests;
{
RWLock::RLocker owner_locker(ictx->owner_lock);
- ictx->journal->append_io_event(NULL, std::move(event_entry), requests, 0,
- 0, true);
+ ictx->journal->append_io_event(std::move(event_entry), requests, 0, 0,
+ true);
}
}
#include "common/Mutex.h"
#include "cls/journal/cls_journal_types.h"
#include "journal/Journaler.h"
+#include "librbd/AioCompletion.h"
+#include "librbd/AioObjectRequest.h"
#include "librbd/Journal.h"
#include "librbd/Utils.h"
#include "librbd/journal/Replay.h"
uint64_t when_append_io_event(MockJournalImageCtx &mock_image_ctx,
MockJournal &mock_journal,
- AioCompletion *aio_comp = nullptr) {
+ AioObjectRequest *object_request = nullptr) {
RWLock::RLocker owner_locker(mock_image_ctx.owner_lock);
+ MockJournal::AioObjectRequests object_requests;
+ if (object_request != nullptr) {
+ object_requests.push_back(object_request);
+ }
return mock_journal.append_io_event(
- aio_comp, journal::EventEntry{journal::AioFlushEvent{}}, {}, 0, 0, false);
+ journal::EventEntry{journal::AioFlushEvent{}}, object_requests, 0, 0,
+ false);
}
void save_commit_context(Context *ctx) {
close_journal(mock_journal, mock_journaler);
};
- AioCompletion *comp = new AioCompletion();
- comp->get();
+ C_SaferCond object_request_ctx;
+ AioObjectRemove *object_request = new AioObjectRemove(
+ ictx, "oid", 0, {}, &object_request_ctx);
::journal::MockFuture mock_future;
Context *on_journal_safe;
expect_append_journaler(mock_journaler);
expect_wait_future(mock_future, &on_journal_safe);
- ASSERT_EQ(1U, when_append_io_event(mock_image_ctx, mock_journal, comp));
+ ASSERT_EQ(1U, when_append_io_event(mock_image_ctx, mock_journal,
+ object_request));
// commit the event in the journal w/o waiting writeback
expect_future_committed(mock_journaler);
on_journal_safe->complete(-EINVAL);
- ASSERT_EQ(0, comp->wait_for_complete());
- ASSERT_EQ(-EINVAL, comp->get_return_value());
- comp->put();
+ ASSERT_EQ(-EINVAL, object_request_ctx.wait());
// cache should receive the error after attempting writeback
expect_future_is_valid(mock_future);
close_journal(mock_journal, mock_journaler);
};
- AioCompletion *comp = new AioCompletion();
- comp->get();
+ C_SaferCond object_request_ctx;
+ AioObjectRemove *object_request = new AioObjectRemove(
+ ictx, "oid", 0, {}, &object_request_ctx);
::journal::MockFuture mock_future;
Context *on_journal_safe;
expect_append_journaler(mock_journaler);
expect_wait_future(mock_future, &on_journal_safe);
- ASSERT_EQ(1U, when_append_io_event(mock_image_ctx, mock_journal, comp));
+ ASSERT_EQ(1U, when_append_io_event(mock_image_ctx, mock_journal,
+ object_request));
expect_future_is_valid(mock_future);
C_SaferCond flush_ctx;
// commit the event in the journal w/ waiting cache writeback
expect_future_committed(mock_journaler);
on_journal_safe->complete(-EINVAL);
- ASSERT_EQ(0, comp->wait_for_complete());
- ASSERT_EQ(-EINVAL, comp->get_return_value());
- comp->put();
+ ASSERT_EQ(-EINVAL, object_request_ctx.wait());
// cache should receive the error if waiting
ASSERT_EQ(-EINVAL, flush_ctx.wait());