]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: write-around cache should honor FUA op flag
authorJason Dillaman <dillaman@redhat.com>
Fri, 12 Apr 2019 15:07:31 +0000 (11:07 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 12 Apr 2019 15:07:31 +0000 (11:07 -0400)
If force unit access is specified, the cache should be bypassed just
like other non-optimized IO through the cache.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/cache/WriteAroundObjectDispatch.cc
src/librbd/cache/WriteAroundObjectDispatch.h
src/test/librbd/cache/test_mock_WriteAroundObjectDispatch.cc

index 38a81fe53976e294ad2e4407fb39706122962056..1952d1af3e429bc40d6b819b93bba70f0450a8ff 100644 (file)
@@ -73,7 +73,7 @@ bool WriteAroundObjectDispatch<I>::discard(
   ldout(cct, 20) << "object_no=" << object_no << " " << object_off << "~"
                  << object_len << dendl;
 
-  return dispatch_io(object_no, object_off, object_len, dispatch_result,
+  return dispatch_io(object_no, object_off, object_len, 0, dispatch_result,
                      on_finish, on_dispatched);
 }
 
@@ -88,8 +88,8 @@ bool WriteAroundObjectDispatch<I>::write(
   ldout(cct, 20) << "object_no=" << object_no << " " << object_off << "~"
                  << data.length() << dendl;
 
-  return dispatch_io(object_no, object_off, data.length(), dispatch_result,
-                     on_finish, on_dispatched);
+  return dispatch_io(object_no, object_off, data.length(), op_flags,
+                     dispatch_result, on_finish, on_dispatched);
 }
 
 template <typename I>
@@ -104,7 +104,7 @@ bool WriteAroundObjectDispatch<I>::write_same(
   ldout(cct, 20) << "object_no=" << object_no << " " << object_off << "~"
                  << object_len << dendl;
 
-  return dispatch_io(object_no, object_off, object_len, dispatch_result,
+  return dispatch_io(object_no, object_off, object_len, 0, dispatch_result,
                      on_finish, on_dispatched);
 }
 
@@ -194,7 +194,7 @@ bool WriteAroundObjectDispatch<I>::dispatch_unoptimized_io(
 template <typename I>
 bool WriteAroundObjectDispatch<I>::dispatch_io(
     uint64_t object_no, uint64_t object_off, uint64_t object_len,
-    io::DispatchResult* dispatch_result, Context** on_finish,
+    int op_flags, io::DispatchResult* dispatch_result, Context** on_finish,
     Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
 
@@ -205,6 +205,13 @@ bool WriteAroundObjectDispatch<I>::dispatch_io(
     return false;
   }
 
+  if ((op_flags & LIBRADOS_OP_FLAG_FADVISE_FUA) != 0) {
+    // force unit access flag is set -- disable write-around
+    m_lock.Unlock();
+    return dispatch_unoptimized_io(object_no, object_off, object_len,
+                                   dispatch_result, on_dispatched);
+  }
+
   auto tid = ++m_last_tid;
   auto ctx = util::create_async_context_callback(*m_image_ctx, *on_finish);
 
index bafde05a36ac72cb02eeecfedf4c892c117b8d0a..b9909b9db8fec87edd67dc1dee938f09ace53813 100644 (file)
@@ -168,8 +168,9 @@ private:
                                io::DispatchResult* dispatch_result,
                                Context* on_dispatched);
   bool dispatch_io(uint64_t object_no, uint64_t object_off,
-                   uint64_t object_len, io::DispatchResult* dispatch_result,
-                   Context** on_finish, Context* on_dispatch);
+                   uint64_t object_len, int op_flags,
+                   io::DispatchResult* dispatch_result, Context** on_finish,
+                   Context* on_dispatch);
 
   bool block_overlapping_io(InFlightObjectExtents* in_flight_object_extents,
                             uint64_t object_off, uint64_t object_len);
index 1fa346f7211b3a7939581bd9f692f378f1191d26..611109fcc47a4bd35109454e51132a051cc24808 100644 (file)
@@ -632,5 +632,28 @@ TEST_F(TestMockCacheWriteAroundObjectDispatch, UnoptimizedIOBlockedIO) {
   finish_ctx_ptr2->complete(0);
 }
 
+TEST_F(TestMockCacheWriteAroundObjectDispatch, FUA) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockTestImageCtx mock_image_ctx(*ictx);
+  MockWriteAroundObjectDispatch object_dispatch(&mock_image_ctx, 16384, false);
+
+  InSequence seq;
+
+  bufferlist data;
+  data.append(std::string(4096, '1'));
+
+  io::DispatchResult dispatch_result;
+  MockContext finish_ctx;
+  MockContext dispatch_ctx;
+  Context* finish_ctx_ptr = &finish_ctx;
+  ASSERT_FALSE(object_dispatch.write("oid", 0, 0, std::move(data), {},
+                                     LIBRADOS_OP_FLAG_FADVISE_FUA, {},
+                                     nullptr, nullptr, &dispatch_result,
+                                     &finish_ctx_ptr, &dispatch_ctx));
+  ASSERT_EQ(finish_ctx_ptr, &finish_ctx);
+}
+
 } // namespace cache
 } // namespace librbd