]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: Journal no longer requires AioCompletion for IO events
authorJason Dillaman <dillaman@redhat.com>
Mon, 9 May 2016 22:17:49 +0000 (18:17 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 9 Jun 2016 18:08:49 +0000 (14:08 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 82587a31f1d8ba1765f164391796753cf97a1878)

src/librbd/AioImageRequest.cc
src/librbd/Journal.cc
src/librbd/Journal.h
src/test/librbd/journal/test_Replay.cc
src/test/librbd/test_mock_Journal.cc

index 5a1904b8cb30c2c2b30ced365f1cc34a40fb5894..4739b08da931f409d77051db4584a259320cb471 100644 (file)
@@ -318,9 +318,8 @@ uint64_t AioImageWrite::append_journal_event(
   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);
   }
@@ -378,8 +377,7 @@ void AioImageWrite::update_stats(size_t length) {
 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);
@@ -452,7 +450,7 @@ void AioImageFlush::send_request() {
   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,
index ebd1f246eef0c641c55b9bd6942ad2a74b3b7cee..855ea3d2882de365ac6a9703afdc1de03916e60c 100644 (file)
@@ -2,7 +2,6 @@
 // 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"
@@ -802,8 +801,7 @@ void Journal<I>::flush_commit_position(Context *on_finish) {
 }
 
 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) {
@@ -833,13 +831,12 @@ uint64_t Journal<I>::append_write_event(AioCompletion *aio_comp,
     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) {
@@ -847,13 +844,12 @@ uint64_t Journal<I>::append_io_event(AioCompletion *aio_comp,
 
   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,
@@ -875,7 +871,7 @@ uint64_t Journal<I>::append_io_events(AioCompletion *aio_comp,
       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;
index 48fe9a2e00723a91b6e53c300848f2d1428b3c9b..3d36b28b40249f18946a6bdfc76e18a82010ad8b 100644 (file)
@@ -30,7 +30,6 @@ class Journaler;
 
 namespace librbd {
 
-class AioCompletion;
 class AioObjectRequest;
 class ImageCtx;
 
@@ -129,13 +128,11 @@ public:
 
   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);
@@ -176,7 +173,6 @@ private:
 
   struct Event {
     Futures futures;
-    AioCompletion *aio_comp = nullptr;
     AioObjectRequests aio_object_requests;
     Contexts on_safe_contexts;
     ExtentInterval pending_extents;
@@ -186,9 +182,9 @@ private:
 
     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);
       }
@@ -290,8 +286,7 @@ private:
 
   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);
index f7e20f71c5a280359f642b6d3ffe6fe0f7660f70..cbde9ae72bdf66aa813e74347308ed6043a4dba5 100644 (file)
@@ -47,8 +47,8 @@ public:
     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);
     }
   }
 
index 53a6fa8632d05eff550bf00605227e7d04a58aa3..1a912a7abe8a15fb26e75cf65e93dcaf16e01efb 100644 (file)
@@ -9,6 +9,8 @@
 #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"
@@ -296,10 +298,15 @@ public:
 
   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) {
@@ -878,21 +885,21 @@ TEST_F(TestMockJournal, EventCommitError) {
     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);
@@ -917,14 +924,16 @@ TEST_F(TestMockJournal, EventCommitErrorWithPendingWriteback) {
     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;
@@ -933,9 +942,7 @@ TEST_F(TestMockJournal, EventCommitErrorWithPendingWriteback) {
   // 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());