]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: make set_chunk as ReadOperation
authormyoungwon oh <ohmyoungwon@gmail.com>
Thu, 2 Jul 2020 13:03:41 +0000 (22:03 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Tue, 18 Aug 2020 12:19:20 +0000 (21:19 +0900)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsumg.com>
src/include/rados.h
src/include/rados/librados.hpp
src/librados/librados_cxx.cc
src/osd/PrimaryLogPG.cc
src/test/librados/tier_cxx.cc
src/test/osd/RadosModel.h
src/tools/rados/rados.cc

index 1921ae1c9e0c7d4b4fcf34e502cb49e51011ac12..faaa50b737b54447b65fd333d7054a88203cbad7 100644 (file)
@@ -323,7 +323,7 @@ extern const char *ceph_osd_state_name(int s);
                                                                            \
        /* Extensible */                                                    \
        f(SET_REDIRECT, __CEPH_OSD_OP(WR, DATA, 39),    "set-redirect")     \
-       f(SET_CHUNK,    __CEPH_OSD_OP(WR, DATA, 40),    "set-chunk")        \
+       f(SET_CHUNK,    __CEPH_OSD_OP(CACHE, DATA, 40), "set-chunk")        \
        f(TIER_PROMOTE, __CEPH_OSD_OP(WR, DATA, 41),    "tier-promote")     \
        f(UNSET_MANIFEST, __CEPH_OSD_OP(WR, DATA, 42),  "unset-manifest")   \
        f(TIER_FLUSH, __CEPH_OSD_OP(CACHE, DATA, 43),   "tier-flush")       \
index 7b81fc8bdbc95fc51015b0db5bfb17fa9a6ac600..668e21418260bf63d62438c7819fe973e8401ff6 100644 (file)
@@ -516,12 +516,9 @@ inline namespace v14_2_0 {
      */
     void set_redirect(const std::string& tgt_obj, const IoCtx& tgt_ioctx,
                      uint64_t tgt_version, int flag = 0);
-    void set_chunk(uint64_t src_offset, uint64_t src_length, const IoCtx& tgt_ioctx,
-                   std::string tgt_oid, uint64_t tgt_offset, int flag = 0);
     void tier_promote();
     void unset_manifest();
 
-
     friend class IoCtx;
   };
 
@@ -735,6 +732,22 @@ inline namespace v14_2_0 {
      */
     void cache_evict();
 
+    /**
+     * Extensible tier
+     *
+     * set_chunk: make a chunk pointing a part of the source object at the target 
+     *                   object
+     *
+     * @param src_offset [in] source offset to indicate the start position of 
+     *                                 a chunk in the source object
+     * @param src_length [in] source length to set the length of the chunk
+     * @param tgt_oid    [in] target object's id to set a chunk
+     * @param tgt_offset [in] the start position of the target object
+     * @param flag       [in] flag for the source object
+     *
+     */
+    void set_chunk(uint64_t src_offset, uint64_t src_length, const IoCtx& tgt_ioctx,
+                   std::string tgt_oid, uint64_t tgt_offset, int flag = 0);
     /**
      * flush a manifest tier object to backing tier; will block racing
      * updates.
@@ -1340,6 +1353,7 @@ inline namespace v14_2_0 {
     friend class Rados; // Only Rados can use our private constructor to create IoCtxes.
     friend class libradosstriper::RadosStriper; // Striper needs to see our IoCtxImpl
     friend class ObjectWriteOperation;  // copy_from needs to see our IoCtxImpl
+    friend class ObjectReadOperation;  // set_chunk needs to see our IoCtxImpl
 
     IoCtxImpl *io_ctx_impl;
   };
index 57642cc61b005c00bbbe82a0c02faa367737cc68..de0f9a7ed310a9b8c9cb94d2870c7d10e60cefa9 100644 (file)
@@ -649,7 +649,7 @@ void librados::ObjectWriteOperation::set_redirect(const std::string& tgt_obj,
                          tgt_ioctx.io_ctx_impl->oloc, tgt_version, flag);
 }
 
-void librados::ObjectWriteOperation::set_chunk(uint64_t src_offset,
+void librados::ObjectReadOperation::set_chunk(uint64_t src_offset,
                                               uint64_t src_length,
                                               const IoCtx& tgt_ioctx,
                                               string tgt_oid,
index 2907fd11ccb608d2acc7d82ac49629037a78742c..18e7f2ca3ac9b9ebcfdb8c2eacd7ad412eb4466b 100644 (file)
@@ -7018,7 +7018,6 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
            goto fail;
          }
        }
-
         if (!oi.manifest.is_chunked()) {
           oi.manifest.clear();
         }
index d15ddb5fefe04e3a130b9afa149fea8d283f7f8a..4f3e8a687b3cdfcb45a5e3964befe99111936b0b 100644 (file)
@@ -3010,13 +3010,14 @@ TEST_F(LibRadosTwoPoolsPP, SetChunkRead) {
 
   // set_chunk
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     int len = strlen("hi there");
     for (int i = 0; i < len; i+=2) {
       op.set_chunk(i, 2, cache_ioctx, "bar", i);
     }
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
@@ -3106,10 +3107,11 @@ TEST_F(LibRadosTwoPoolsPP, ManifestPromoteRead) {
   }
   // set-chunk
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(0, 2, cache_ioctx, "bar-chunk", 0);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
@@ -3204,10 +3206,11 @@ TEST_F(LibRadosTwoPoolsPP, ManifestRefRead) {
   }
   // set-chunk
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(0, 2, cache_ioctx, "bar-chunk", 0, CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
@@ -3294,10 +3297,11 @@ TEST_F(LibRadosTwoPoolsPP, ManifestUnset) {
   }
   // set-chunk
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(0, 2, cache_ioctx, "bar-chunk", 0, CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
@@ -3433,24 +3437,26 @@ TEST_F(LibRadosTwoPoolsPP, ManifestDedupRefRead) {
 
   // set-chunk (dedup)
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     int len = strlen("hi there");
     op.set_chunk(0, len, cache_ioctx, "bar-chunk", 0, 
                CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo-dedup", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo-dedup", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
   }
   // set-chunk (dedup)
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     int len = strlen("hi there");
     op.set_chunk(0, len, cache_ioctx, "bar", 0, 
                CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
@@ -3548,20 +3554,22 @@ TEST_F(LibRadosTwoPoolsPP, ManifestFlushRead) {
 
   // set-chunk
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(0, 2, cache_ioctx, "bar-chunk", 0);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
   }
   // set-chunk
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(2, 2, cache_ioctx, "bar-chunk", 2);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
@@ -3636,22 +3644,24 @@ TEST_F(LibRadosTwoPoolsPP, ManifestSnapRefcount) {
 
   // set-chunk (dedup)
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(2, 2, cache_ioctx, "bar", 0,
        CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
   }
   // set-chunk (dedup)
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(6, 2, cache_ioctx, "bar", 0,
        CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
@@ -4003,33 +4013,36 @@ TEST_F(LibRadosTwoPoolsPP, ManifestSnapRefcount2) {
 
   // set-chunk (dedup)
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(2, 2, cache_ioctx, "bar", 0,
        CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
   }
   // set-chunk (dedup)
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(6, 2, cache_ioctx, "bar", 0,
        CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
   }
   // set-chunk (dedup)
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(8, 2, cache_ioctx, "bar", 0,
        CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
@@ -4241,22 +4254,24 @@ TEST_F(LibRadosTwoPoolsPP, ManifestFlushSnap) {
 
   // set-chunk (dedup)
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(2, 2, cache_ioctx, "bar", 0,
        CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
   }
   // set-chunk (dedup)
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(6, 2, cache_ioctx, "bar", 0,
        CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
@@ -7170,10 +7185,11 @@ TEST_F(LibRadosTwoPoolsECPP, SetChunkRead) {
 
   // set_chunk
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(0, 8, cache_ioctx, "bar", 0);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
@@ -7258,10 +7274,11 @@ TEST_F(LibRadosTwoPoolsECPP, ManifestPromoteRead) {
   }
   // set-chunk
   {
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     op.set_chunk(0, 10, cache_ioctx, "bar-chunk", 0);
     librados::AioCompletion *completion = cluster.aio_create_completion();
-    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op));
+    ASSERT_EQ(0, ioctx.aio_operate("foo-chunk", completion, &op,
+             librados::OPERATION_IGNORE_CACHE, NULL));
     completion->wait_for_complete();
     ASSERT_EQ(0, completion->get_return_value());
     completion->release();
index 734ca3e3765eeb0db81772fccdf53feeaea0a6c3..f9ed443671516620f8eb26948155045f12a4c111 100644 (file)
@@ -2296,7 +2296,7 @@ class SetChunkOp : public TestOp {
 public:
   string oid, oid_tgt, tgt_pool_name;
   ObjectDesc src_value, tgt_value;
-  librados::ObjectWriteOperation op;
+  librados::ObjectReadOperation op;
   librados::ObjectReadOperation rd_op;
   librados::AioCompletion *comp;
   std::shared_ptr<int> in_use;
@@ -2350,7 +2350,7 @@ public:
     comp = context->rados.aio_create_completion((void*) cb_arg,
                                                &write_callback);
     context->io_ctx.aio_operate(context->prefix+oid, comp, &op,
-                               librados::OPERATION_ORDER_READS_WRITES);
+                               librados::OPERATION_ORDER_READS_WRITES, NULL);
   }
 
   void _finish(CallbackInfo *info) override
index f967288dd68a2f856e9ce10451ec6fd9c5f50ffe..b21f264167dc88c42788a55760ea25b0047611ea 100644 (file)
@@ -3739,13 +3739,13 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
 
     IoCtx target_ctx;
     ret = rados.ioctx_create(target, target_ctx);
-    ObjectWriteOperation op;
+    ObjectReadOperation op;
     if (with_reference) {
       op.set_chunk(offset, length, target_ctx, tgt_oid, tgt_offset, CEPH_OSD_OP_FLAG_WITH_REFERENCE);
     } else {
       op.set_chunk(offset, length, target_ctx, tgt_oid, tgt_offset);
     }
-    ret = io_ctx.operate(nargs[1], &op);
+    ret = io_ctx.operate(nargs[1], &op, NULL);
     if (ret < 0) {
       cerr << "error set-chunk " << pool_name << "/" << nargs[1] << " " << " offset " << offset
            << " length " << length << " target_pool " << target