Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
ceph
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
certo
ceph
Commits
35e71378
Commit
35e71378
authored
Jan 29, 2023
by
Vladimir Bashkirtsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed patches
parent
6315acaf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
755 deletions
+17
-755
ceph-15.2.15-arm32_fix_tests.patch
ceph-15.2.15-arm32_fix_tests.patch
+17
-17
ceph-15.2.15-fix_librbd_duplicate.patch
ceph-15.2.15-fix_librbd_duplicate.patch
+0
-738
No files found.
ceph-15.2.15-arm32_fix_tests.patch
View file @
35e71378
diff -uNr ceph-15.2.15/src/test/librados_test_stub/TestIoCtxImpl.h ceph-15.2.15-arm32_fix_tests/src/test/librados_test_stub/TestIoCtxImpl.h
--- ceph-15.2.15/src/test/librados_test_stub/TestIoCtxImpl.h 2021-10-21 00:49:57.000000000 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librados_test_stub/TestIoCtxImpl.h 2023-01-2
5 14:24:54.990418287
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librados_test_stub/TestIoCtxImpl.h 2023-01-2
9 19:37:45.275166620
+1030
@@ -197,6 +197,9 @@
};
...
...
@@ -13,7 +13,7 @@ diff -uNr ceph-15.2.15/src/test/librados_test_stub/TestIoCtxImpl.h ceph-15.2.15-
std::string m_namespace_name;
diff -uNr ceph-15.2.15/src/test/librbd/CMakeLists.txt ceph-15.2.15-arm32_fix_tests/src/test/librbd/CMakeLists.txt
--- ceph-15.2.15/src/test/librbd/CMakeLists.txt 2021-10-21 00:49:57.000000000 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/CMakeLists.txt 2023-01-2
5 18:48:17.206236731
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/CMakeLists.txt 2023-01-2
9 19:37:45.275166620
+1030
@@ -15,6 +15,10 @@
test_DeepCopy.cc
test_Groups.cc
...
...
@@ -27,7 +27,7 @@ diff -uNr ceph-15.2.15/src/test/librbd/CMakeLists.txt ceph-15.2.15-arm32_fix_tes
test_Operations.cc
diff -uNr ceph-15.2.15/src/test/librbd/test_DeepCopy.cc ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_DeepCopy.cc
--- ceph-15.2.15/src/test/librbd/test_DeepCopy.cc 2021-10-21 00:49:57.000000000 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_DeepCopy.cc 2023-01-2
5 14:24:54.99141829
0 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_DeepCopy.cc 2023-01-2
9 19:37:45.27516662
0 +1030
@@ -362,14 +362,14 @@
size = initial_size = m_src_ictx->get_image_size(CEPH_NOSNAP);
}
...
...
@@ -47,7 +47,7 @@ diff -uNr ceph-15.2.15/src/test/librbd/test_DeepCopy.cc ceph-15.2.15-arm32_fix_t
std::stringstream ss(c);
diff -uNr ceph-15.2.15/src/test/librbd/test_main.cc ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_main.cc
--- ceph-15.2.15/src/test/librbd/test_main.cc 2021-10-21 00:49:57.000000000 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_main.cc 2023-01-2
5 14:24:54.99141829
0 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_main.cc 2023-01-2
9 19:37:45.27516662
0 +1030
@@ -18,6 +18,7 @@
extern void register_test_journal_entries();
extern void register_test_journal_replay();
...
...
@@ -66,7 +66,7 @@ diff -uNr ceph-15.2.15/src/test/librbd/test_main.cc ceph-15.2.15-arm32_fix_tests
register_test_object_map();
diff -uNr ceph-15.2.15/src/test/librbd/test_MigrationAbort.cc ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationAbort.cc
--- ceph-15.2.15/src/test/librbd/test_MigrationAbort.cc 1970-01-01 09:30:00.000000000 +0930
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationAbort.cc 2023-01-2
5 14:35:54.107146312
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationAbort.cc 2023-01-2
9 19:37:45.276166623
+1030
@@ -0,0 +1,472 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
...
...
@@ -542,7 +542,7 @@ diff -uNr ceph-15.2.15/src/test/librbd/test_MigrationAbort.cc ceph-15.2.15-arm32
+}
diff -uNr ceph-15.2.15/src/test/librbd/test_Migration.cc ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_Migration.cc
--- ceph-15.2.15/src/test/librbd/test_Migration.cc 2021-10-21 00:49:57.000000000 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_Migration.cc 2023-01-2
5 18:46:31.518954521
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_Migration.cc 2023-01-2
9 19:37:45.276166623
+1030
@@ -427,94 +427,6 @@
close_image(child_ictx);
}
...
...
@@ -1043,7 +1043,7 @@ diff -uNr ceph-15.2.15/src/test/librbd/test_Migration.cc ceph-15.2.15-arm32_fix_
-}
diff -uNr ceph-15.2.15/src/test/librbd/test_MigrationClone.cc ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationClone.cc
--- ceph-15.2.15/src/test/librbd/test_MigrationClone.cc 1970-01-01 09:30:00.000000000 +0930
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationClone.cc 2023-01-2
5 14:59:39.76892836
3 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationClone.cc 2023-01-2
9 19:37:45.27616662
3 +1030
@@ -0,0 +1,635 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
...
...
@@ -1682,7 +1682,7 @@ diff -uNr ceph-15.2.15/src/test/librbd/test_MigrationClone.cc ceph-15.2.15-arm32
+}
diff -uNr ceph-15.2.15/src/test/librbd/test_MigrationSnaps.cc ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationSnaps.cc
--- ceph-15.2.15/src/test/librbd/test_MigrationSnaps.cc 1970-01-01 09:30:00.000000000 +0930
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationSnaps.cc 2023-01-2
5 18:47:57.635184472
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationSnaps.cc 2023-01-2
9 19:37:45.276166623
+1030
@@ -0,0 +1,584 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
...
...
@@ -2270,7 +2270,7 @@ diff -uNr ceph-15.2.15/src/test/librbd/test_MigrationSnaps.cc ceph-15.2.15-arm32
+}
diff -uNr ceph-15.2.15/src/test/librbd/test_MigrationStress.cc ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationStress.cc
--- ceph-15.2.15/src/test/librbd/test_MigrationStress.cc 1970-01-01 09:30:00.000000000 +0930
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationStress.cc 2023-01-2
5 14:24:54.991418290
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/librbd/test_MigrationStress.cc 2023-01-2
9 19:37:45.277166625
+1030
@@ -0,0 +1,456 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
...
...
@@ -2730,7 +2730,7 @@ diff -uNr ceph-15.2.15/src/test/librbd/test_MigrationStress.cc ceph-15.2.15-arm3
+}
diff -uNr ceph-15.2.15/src/test/objectstore/Allocator_test.cc ceph-15.2.15-arm32_fix_tests/src/test/objectstore/Allocator_test.cc
--- ceph-15.2.15/src/test/objectstore/Allocator_test.cc 2021-10-21 00:49:57.000000000 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/objectstore/Allocator_test.cc 2023-01-2
6 00:23:10.562677288
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/objectstore/Allocator_test.cc 2023-01-2
9 19:37:45.277166625
+1030
@@ -543,7 +543,7 @@
init_alloc(size, block);
...
...
@@ -2742,7 +2742,7 @@ diff -uNr ceph-15.2.15/src/test/objectstore/Allocator_test.cc ceph-15.2.15-arm32
diff -uNr ceph-15.2.15/src/test/objectstore/test_bdev.cc ceph-15.2.15-arm32_fix_tests/src/test/objectstore/test_bdev.cc
--- ceph-15.2.15/src/test/objectstore/test_bdev.cc 2021-10-21 00:49:57.000000000 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/objectstore/test_bdev.cc 2023-01-2
5 22:43:12.070916570
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/objectstore/test_bdev.cc 2023-01-2
9 19:37:45.277166625
+1030
@@ -54,8 +54,8 @@
BlockDevice::create(g_ceph_context, bdev.path, NULL, NULL,
[](void* handle, void* aio) {}, NULL));
...
...
@@ -2755,8 +2755,8 @@ diff -uNr ceph-15.2.15/src/test/objectstore/test_bdev.cc ceph-15.2.15-arm32_fix_
bl.append(s);
}
diff -uNr ceph-15.2.15/src/test/objectstore/test_bluefs.cc ceph-15.2.15-arm32_fix_tests/src/test/objectstore/test_bluefs.cc
--- ceph-15.2.15/src/test/objectstore/test_bluefs.cc 202
1-10-21 00:49:57.000000000
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/objectstore/test_bluefs.cc 2023-01-2
6 00:27:04.688305206
+1030
--- ceph-15.2.15/src/test/objectstore/test_bluefs.cc 202
3-01-29 19:40:48.944658003
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/objectstore/test_bluefs.cc 2023-01-2
9 19:39:27.042438884
+1030
@@ -237,8 +237,8 @@
}
...
...
@@ -2776,13 +2776,13 @@ diff -uNr ceph-15.2.15/src/test/objectstore/test_bluefs.cc ceph-15.2.15-arm32_fi
+ for (unsigned i = 0; i < 1*512*1048576ull / sizeof(buf); ++i) {
h->append(buf, sizeof(buf));
total_written += sizeof(buf);
fs.fsync(h);
}
fs.fsync(h);
- for (unsigned i = 0; i < 2*1024*1048576ull / sizeof(buf); ++i) {
+ for (unsigned i = 0; i < 1*256*1048576ull / sizeof(buf); ++i) {
h->append(buf, sizeof(buf));
total_written += sizeof(buf);
}
fs.fsync(h);
@@ -278,7 +278,7 @@
bufferlist bl;
BlueFS::FileReaderBuffer readbuf(10485760);
...
...
@@ -2816,7 +2816,7 @@ diff -uNr ceph-15.2.15/src/test/objectstore/test_bluefs.cc ceph-15.2.15-arm32_fi
diff -uNr ceph-15.2.15/src/test/rgw/CMakeLists.txt ceph-15.2.15-arm32_fix_tests/src/test/rgw/CMakeLists.txt
--- ceph-15.2.15/src/test/rgw/CMakeLists.txt 2021-10-21 00:49:57.000000000 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/rgw/CMakeLists.txt 2023-01-2
5 23:35:42.840260592
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/rgw/CMakeLists.txt 2023-01-2
9 19:37:45.277166625
+1030
@@ -27,6 +27,7 @@
test_rgw_compression.cc
$<TARGET_OBJECTS:unit-main>)
...
...
@@ -2827,7 +2827,7 @@ diff -uNr ceph-15.2.15/src/test/rgw/CMakeLists.txt ceph-15.2.15-arm32_fix_tests/
# unitttest_http_manager
diff -uNr ceph-15.2.15/src/test/test_mempool.cc ceph-15.2.15-arm32_fix_tests/src/test/test_mempool.cc
--- ceph-15.2.15/src/test/test_mempool.cc 2021-10-21 00:49:57.000000000 +1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/test_mempool.cc 2023-01-2
6 00:05:47.183905764
+1030
+++ ceph-15.2.15-arm32_fix_tests/src/test/test_mempool.cc 2023-01-2
9 19:37:45.277166625
+1030
@@ -405,7 +405,7 @@
TEST(mempool, check_shard_select)
...
...
ceph-15.2.15-fix_librbd_duplicate.patch
View file @
35e71378
...
...
@@ -10,741 +10,3 @@ diff -uNr ceph-15.2.15/src/librbd/image/OpenRequest.cc ceph-15.2.15-fix_librbd_d
#include "librbd/image/CloseRequest.h"
#include "librbd/image/RefreshRequest.h"
#include "librbd/image/SetSnapRequest.h"
diff -uNr ceph-15.2.15/src/librbd/image/OpenRequest.cc.orig ceph-15.2.15-fix_librbd_duplicate/src/librbd/image/OpenRequest.cc.orig
--- ceph-15.2.15/src/librbd/image/OpenRequest.cc.orig 1970-01-01 09:30:00.000000000 +0930
+++ ceph-15.2.15-fix_librbd_duplicate/src/librbd/image/OpenRequest.cc.orig 2021-10-21 00:49:57.000000000 +1030
@@ -0,0 +1,734 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "librbd/image/OpenRequest.h"
+#include "common/dout.h"
+#include "common/errno.h"
+#include "cls/rbd/cls_rbd_client.h"
+#include "librbd/ConfigWatcher.h"
+#include "librbd/ImageCtx.h"
+#include "librbd/Utils.h"
+#include "librbd/cache/ObjectCacherObjectDispatch.h"
+#include "librbd/cache/WriteAroundObjectDispatch.h"
+#include "librbd/cache/ParentCacheObjectDispatch.cc"
+#include "librbd/image/CloseRequest.h"
+#include "librbd/image/RefreshRequest.h"
+#include "librbd/image/SetSnapRequest.h"
+#include "librbd/io/SimpleSchedulerObjectDispatch.h"
+#include <boost/algorithm/string/predicate.hpp>
+#include "include/ceph_assert.h"
+
+#define dout_subsys ceph_subsys_rbd
+#undef dout_prefix
+#define dout_prefix *_dout << "librbd::image::OpenRequest: "
+
+namespace librbd {
+namespace image {
+
+using util::create_context_callback;
+using util::create_rados_callback;
+
+template <typename I>
+OpenRequest<I>::OpenRequest(I *image_ctx, uint64_t flags,
+ Context *on_finish)
+ : m_image_ctx(image_ctx),
+ m_skip_open_parent_image(flags & OPEN_FLAG_SKIP_OPEN_PARENT),
+ m_on_finish(on_finish), m_error_result(0) {
+ if ((flags & OPEN_FLAG_OLD_FORMAT) != 0) {
+ m_image_ctx->old_format = true;
+ }
+ if ((flags & OPEN_FLAG_IGNORE_MIGRATING) != 0) {
+ m_image_ctx->ignore_migrating = true;
+ }
+}
+
+template <typename I>
+void OpenRequest<I>::send() {
+ if (m_image_ctx->old_format) {
+ send_v1_detect_header();
+ } else {
+ send_v2_detect_header();
+ }
+}
+
+template <typename I>
+void OpenRequest<I>::send_v1_detect_header() {
+ librados::ObjectReadOperation op;
+ op.stat(NULL, NULL, NULL);
+
+ using klass = OpenRequest<I>;
+ librados::AioCompletion *comp =
+ create_rados_callback<klass, &klass::handle_v1_detect_header>(this);
+ m_out_bl.clear();
+ m_image_ctx->md_ctx.aio_operate(util::old_header_name(m_image_ctx->name),
+ comp, &op, &m_out_bl);
+ comp->release();
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_v1_detect_header(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ if (*result < 0) {
+ if (*result != -ENOENT) {
+ lderr(cct) << "failed to stat image header: " << cpp_strerror(*result)
+ << dendl;
+ }
+ send_close_image(*result);
+ } else {
+ ldout(cct, 1) << "RBD image format 1 is deprecated. "
+ << "Please copy this image to image format 2." << dendl;
+
+ m_image_ctx->old_format = true;
+ m_image_ctx->header_oid = util::old_header_name(m_image_ctx->name);
+ m_image_ctx->apply_metadata({}, true);
+
+ send_refresh();
+ }
+ return nullptr;
+}
+
+template <typename I>
+void OpenRequest<I>::send_v2_detect_header() {
+ if (m_image_ctx->id.empty()) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ librados::ObjectReadOperation op;
+ op.stat(NULL, NULL, NULL);
+
+ using klass = OpenRequest<I>;
+ librados::AioCompletion *comp =
+ create_rados_callback<klass, &klass::handle_v2_detect_header>(this);
+ m_out_bl.clear();
+ m_image_ctx->md_ctx.aio_operate(util::id_obj_name(m_image_ctx->name),
+ comp, &op, &m_out_bl);
+ comp->release();
+ } else {
+ send_v2_get_name();
+ }
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_v2_detect_header(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ if (*result == -ENOENT) {
+ send_v1_detect_header();
+ } else if (*result < 0) {
+ lderr(cct) << "failed to stat v2 image header: " << cpp_strerror(*result)
+ << dendl;
+ send_close_image(*result);
+ } else {
+ m_image_ctx->old_format = false;
+ send_v2_get_id();
+ }
+ return nullptr;
+}
+
+template <typename I>
+void OpenRequest<I>::send_v2_get_id() {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ librados::ObjectReadOperation op;
+ cls_client::get_id_start(&op);
+
+ using klass = OpenRequest<I>;
+ librados::AioCompletion *comp =
+ create_rados_callback<klass, &klass::handle_v2_get_id>(this);
+ m_out_bl.clear();
+ m_image_ctx->md_ctx.aio_operate(util::id_obj_name(m_image_ctx->name),
+ comp, &op, &m_out_bl);
+ comp->release();
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_v2_get_id(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ if (*result == 0) {
+ auto it = m_out_bl.cbegin();
+ *result = cls_client::get_id_finish(&it, &m_image_ctx->id);
+ }
+ if (*result < 0) {
+ lderr(cct) << "failed to retrieve image id: " << cpp_strerror(*result)
+ << dendl;
+ send_close_image(*result);
+ } else {
+ send_v2_get_initial_metadata();
+ }
+ return nullptr;
+}
+
+template <typename I>
+void OpenRequest<I>::send_v2_get_name() {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ librados::ObjectReadOperation op;
+ cls_client::dir_get_name_start(&op, m_image_ctx->id);
+
+ using klass = OpenRequest<I>;
+ librados::AioCompletion *comp = create_rados_callback<
+ klass, &klass::handle_v2_get_name>(this);
+ m_out_bl.clear();
+ m_image_ctx->md_ctx.aio_operate(RBD_DIRECTORY, comp, &op, &m_out_bl);
+ comp->release();
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_v2_get_name(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ if (*result == 0) {
+ auto it = m_out_bl.cbegin();
+ *result = cls_client::dir_get_name_finish(&it, &m_image_ctx->name);
+ }
+ if (*result < 0 && *result != -ENOENT) {
+ lderr(cct) << "failed to retrieve name: "
+ << cpp_strerror(*result) << dendl;
+ send_close_image(*result);
+ } else if (*result == -ENOENT) {
+ // image does not exist in directory, look in the trash bin
+ ldout(cct, 10) << "image id " << m_image_ctx->id << " does not exist in "
+ << "rbd directory, searching in rbd trash..." << dendl;
+ send_v2_get_name_from_trash();
+ } else {
+ send_v2_get_initial_metadata();
+ }
+ return nullptr;
+}
+
+template <typename I>
+void OpenRequest<I>::send_v2_get_name_from_trash() {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ librados::ObjectReadOperation op;
+ cls_client::trash_get_start(&op, m_image_ctx->id);
+
+ using klass = OpenRequest<I>;
+ librados::AioCompletion *comp = create_rados_callback<
+ klass, &klass::handle_v2_get_name_from_trash>(this);
+ m_out_bl.clear();
+ m_image_ctx->md_ctx.aio_operate(RBD_TRASH, comp, &op, &m_out_bl);
+ comp->release();
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_v2_get_name_from_trash(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ cls::rbd::TrashImageSpec trash_spec;
+ if (*result == 0) {
+ auto it = m_out_bl.cbegin();
+ *result = cls_client::trash_get_finish(&it, &trash_spec);
+ m_image_ctx->name = trash_spec.name;
+ }
+ if (*result < 0) {
+ if (*result == -EOPNOTSUPP) {
+ *result = -ENOENT;
+ }
+ if (*result == -ENOENT) {
+ ldout(cct, 5) << "failed to retrieve name for image id "
+ << m_image_ctx->id << dendl;
+ } else {
+ lderr(cct) << "failed to retrieve name from trash: "
+ << cpp_strerror(*result) << dendl;
+ }
+ send_close_image(*result);
+ } else {
+ send_v2_get_initial_metadata();
+ }
+
+ return nullptr;
+}
+
+template <typename I>
+void OpenRequest<I>::send_v2_get_initial_metadata() {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ m_image_ctx->old_format = false;
+ m_image_ctx->header_oid = util::header_name(m_image_ctx->id);
+
+ librados::ObjectReadOperation op;
+ cls_client::get_size_start(&op, CEPH_NOSNAP);
+ cls_client::get_object_prefix_start(&op);
+ cls_client::get_features_start(&op, true);
+
+ using klass = OpenRequest<I>;
+ librados::AioCompletion *comp = create_rados_callback<
+ klass, &klass::handle_v2_get_initial_metadata>(this);
+ m_out_bl.clear();
+ m_image_ctx->md_ctx.aio_operate(m_image_ctx->header_oid, comp, &op,
+ &m_out_bl);
+ comp->release();
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_v2_get_initial_metadata(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ auto it = m_out_bl.cbegin();
+ if (*result >= 0) {
+ uint64_t size;
+ *result = cls_client::get_size_finish(&it, &size, &m_image_ctx->order);
+ }
+
+ if (*result >= 0) {
+ *result = cls_client::get_object_prefix_finish(&it,
+ &m_image_ctx->object_prefix);
+ }
+
+ if (*result >= 0) {
+ uint64_t incompatible_features;
+ *result = cls_client::get_features_finish(&it, &m_image_ctx->features,
+ &incompatible_features);
+ }
+
+ if (*result < 0) {
+ lderr(cct) << "failed to retrieve initial metadata: "
+ << cpp_strerror(*result) << dendl;
+ send_close_image(*result);
+ return nullptr;
+ }
+
+ if (m_image_ctx->test_features(RBD_FEATURE_STRIPINGV2)) {
+ send_v2_get_stripe_unit_count();
+ } else {
+ send_v2_get_create_timestamp();
+ }
+
+ return nullptr;
+}
+
+template <typename I>
+void OpenRequest<I>::send_v2_get_stripe_unit_count() {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ librados::ObjectReadOperation op;
+ cls_client::get_stripe_unit_count_start(&op);
+
+ using klass = OpenRequest<I>;
+ librados::AioCompletion *comp = create_rados_callback<
+ klass, &klass::handle_v2_get_stripe_unit_count>(this);
+ m_out_bl.clear();
+ m_image_ctx->md_ctx.aio_operate(m_image_ctx->header_oid, comp, &op,
+ &m_out_bl);
+ comp->release();
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_v2_get_stripe_unit_count(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ if (*result == 0) {
+ auto it = m_out_bl.cbegin();
+ *result = cls_client::get_stripe_unit_count_finish(
+ &it, &m_image_ctx->stripe_unit, &m_image_ctx->stripe_count);
+ }
+
+ if (*result == -ENOEXEC || *result == -EINVAL) {
+ *result = 0;
+ }
+
+ if (*result < 0) {
+ lderr(cct) << "failed to read striping metadata: " << cpp_strerror(*result)
+ << dendl;
+ send_close_image(*result);
+ return nullptr;
+ }
+
+ send_v2_get_create_timestamp();
+ return nullptr;
+}
+
+template <typename I>
+void OpenRequest<I>::send_v2_get_create_timestamp() {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ librados::ObjectReadOperation op;
+ cls_client::get_create_timestamp_start(&op);
+
+ using klass = OpenRequest<I>;
+ librados::AioCompletion *comp = create_rados_callback<
+ klass, &klass::handle_v2_get_create_timestamp>(this);
+ m_out_bl.clear();
+ m_image_ctx->md_ctx.aio_operate(m_image_ctx->header_oid, comp, &op,
+ &m_out_bl);
+ comp->release();
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_v2_get_create_timestamp(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << ": r=" << *result << dendl;
+
+ if (*result == 0) {
+ auto it = m_out_bl.cbegin();
+ *result = cls_client::get_create_timestamp_finish(&it,
+ &m_image_ctx->create_timestamp);
+ }
+ if (*result < 0 && *result != -EOPNOTSUPP) {
+ lderr(cct) << "failed to retrieve create_timestamp: "
+ << cpp_strerror(*result)
+ << dendl;
+ send_close_image(*result);
+ return nullptr;
+ }
+
+ send_v2_get_access_modify_timestamp();
+ return nullptr;
+}
+
+template <typename I>
+void OpenRequest<I>::send_v2_get_access_modify_timestamp() {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ librados::ObjectReadOperation op;
+ cls_client::get_access_timestamp_start(&op);
+ cls_client::get_modify_timestamp_start(&op);
+ //TODO: merge w/ create timestamp query after luminous EOLed
+
+ using klass = OpenRequest<I>;
+ librados::AioCompletion *comp = create_rados_callback<
+ klass, &klass::handle_v2_get_access_modify_timestamp>(this);
+ m_out_bl.clear();
+ m_image_ctx->md_ctx.aio_operate(m_image_ctx->header_oid, comp, &op,
+ &m_out_bl);
+ comp->release();
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_v2_get_access_modify_timestamp(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << ": r=" << *result << dendl;
+
+ if (*result == 0) {
+ auto it = m_out_bl.cbegin();
+ *result = cls_client::get_access_timestamp_finish(&it,
+ &m_image_ctx->access_timestamp);
+ if (*result == 0)
+ *result = cls_client::get_modify_timestamp_finish(&it,
+ &m_image_ctx->modify_timestamp);
+ }
+ if (*result < 0 && *result != -EOPNOTSUPP) {
+ lderr(cct) << "failed to retrieve access/modify_timestamp: "
+ << cpp_strerror(*result)
+ << dendl;
+ send_close_image(*result);
+ return nullptr;
+ }
+
+ send_v2_get_data_pool();
+ return nullptr;
+}
+
+template <typename I>
+void OpenRequest<I>::send_v2_get_data_pool() {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ librados::ObjectReadOperation op;
+ cls_client::get_data_pool_start(&op);
+
+ using klass = OpenRequest<I>;
+ librados::AioCompletion *comp = create_rados_callback<
+ klass, &klass::handle_v2_get_data_pool>(this);
+ m_out_bl.clear();
+ m_image_ctx->md_ctx.aio_operate(m_image_ctx->header_oid, comp, &op,
+ &m_out_bl);
+ comp->release();
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_v2_get_data_pool(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << ": r=" << *result << dendl;
+
+ int64_t data_pool_id = -1;
+ if (*result == 0) {
+ auto it = m_out_bl.cbegin();
+ *result = cls_client::get_data_pool_finish(&it, &data_pool_id);
+ } else if (*result == -EOPNOTSUPP) {
+ *result = 0;
+ }
+
+ if (*result < 0) {
+ lderr(cct) << "failed to read data pool: " << cpp_strerror(*result)
+ << dendl;
+ send_close_image(*result);
+ return nullptr;
+ }
+
+ if (data_pool_id != -1) {
+ *result = util::create_ioctx(m_image_ctx->md_ctx, "data pool", data_pool_id,
+ {}, &m_image_ctx->data_ctx);
+ if (*result < 0) {
+ if (*result != -ENOENT) {
+ send_close_image(*result);
+ return nullptr;
+ }
+ m_image_ctx->data_ctx.close();
+ } else {
+ m_image_ctx->data_ctx.set_namespace(m_image_ctx->md_ctx.get_namespace());
+ }
+ } else {
+ data_pool_id = m_image_ctx->md_ctx.get_id();
+ }
+
+ m_image_ctx->init_layout(data_pool_id);
+ send_refresh();
+ return nullptr;
+}
+
+template <typename I>
+void OpenRequest<I>::send_refresh() {
+ m_image_ctx->init();
+
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ m_image_ctx->config_watcher = ConfigWatcher<I>::create(*m_image_ctx);
+ m_image_ctx->config_watcher->init();
+
+ using klass = OpenRequest<I>;
+ RefreshRequest<I> *req = RefreshRequest<I>::create(
+ *m_image_ctx, false, m_skip_open_parent_image,
+ create_context_callback<klass, &klass::handle_refresh>(this));
+ req->send();
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_refresh(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ if (*result < 0) {
+ lderr(cct) << "failed to refresh image: " << cpp_strerror(*result)
+ << dendl;
+ send_close_image(*result);
+ return nullptr;
+ }
+
+ return send_parent_cache(result);
+}
+
+template <typename I>
+Context* OpenRequest<I>::send_parent_cache(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ bool parent_cache_enabled = m_image_ctx->config.template get_val<bool>(
+ "rbd_parent_cache_enabled");
+
+ if (m_image_ctx->child == nullptr || !parent_cache_enabled ||
+ !m_image_ctx->data_ctx.is_valid()) {
+ return send_init_cache(result);
+ }
+
+ auto parent_cache = cache::ParentCacheObjectDispatch<I>::create(m_image_ctx);
+ using klass = OpenRequest<I>;
+ Context *ctx = create_context_callback<
+ klass, &klass::handle_parent_cache>(this);
+
+ parent_cache->init(ctx);
+ return nullptr;
+}
+
+template <typename I>
+Context* OpenRequest<I>::handle_parent_cache(int* result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ if (*result < 0) {
+ lderr(cct) << "failed to parent cache " << dendl;
+ send_close_image(*result);
+ return nullptr;
+ }
+
+ return send_init_cache(result);
+}
+
+template <typename I>
+Context *OpenRequest<I>::send_init_cache(int *result) {
+ if (!m_image_ctx->cache || m_image_ctx->child != nullptr ||
+ !m_image_ctx->data_ctx.is_valid()) {
+ return send_register_watch(result);
+ }
+
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ size_t max_dirty = m_image_ctx->config.template get_val<Option::size_t>(
+ "rbd_cache_max_dirty");
+ auto writethrough_until_flush = m_image_ctx->config.template get_val<bool>(
+ "rbd_cache_writethrough_until_flush");
+ auto cache_policy = m_image_ctx->config.template get_val<std::string>(
+ "rbd_cache_policy");
+ if (cache_policy == "writearound") {
+ auto cache = cache::WriteAroundObjectDispatch<I>::create(
+ m_image_ctx, max_dirty, writethrough_until_flush);
+ cache->init();
+
+ m_image_ctx->readahead.set_max_readahead_size(0);
+ } else if (cache_policy == "writethrough" || cache_policy == "writeback") {
+ if (cache_policy == "writethrough") {
+ max_dirty = 0;
+ }
+
+ auto cache = cache::ObjectCacherObjectDispatch<I>::create(
+ m_image_ctx, max_dirty, writethrough_until_flush);
+ cache->init();
+
+ // readahead requires the object cacher cache
+ m_image_ctx->readahead.set_trigger_requests(
+ m_image_ctx->config.template get_val<uint64_t>("rbd_readahead_trigger_requests"));
+ m_image_ctx->readahead.set_max_readahead_size(
+ m_image_ctx->config.template get_val<Option::size_t>("rbd_readahead_max_bytes"));
+ }
+ return send_register_watch(result);
+}
+
+template <typename I>
+Context *OpenRequest<I>::send_register_watch(int *result) {
+ if ((m_image_ctx->read_only_flags & IMAGE_READ_ONLY_FLAG_USER) != 0U) {
+ return send_set_snap(result);
+ }
+
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ using klass = OpenRequest<I>;
+ Context *ctx = create_context_callback<
+ klass, &klass::handle_register_watch>(this);
+ m_image_ctx->register_watch(ctx);
+ return nullptr;
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_register_watch(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << ": r=" << *result << dendl;
+
+ if (*result == -EPERM) {
+ ldout(cct, 5) << "user does not have write permission" << dendl;
+ send_close_image(*result);
+ return nullptr;
+ } else if (*result < 0) {
+ lderr(cct) << "failed to register watch: " << cpp_strerror(*result)
+ << dendl;
+ send_close_image(*result);
+ return nullptr;
+ }
+
+ return send_set_snap(result);
+}
+
+template <typename I>
+Context *OpenRequest<I>::send_set_snap(int *result) {
+ if (m_image_ctx->snap_name.empty() &&
+ m_image_ctx->open_snap_id == CEPH_NOSNAP) {
+ *result = 0;
+ return finalize(*result);
+ }
+
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ uint64_t snap_id = CEPH_NOSNAP;
+ std::swap(m_image_ctx->open_snap_id, snap_id);
+ if (snap_id == CEPH_NOSNAP) {
+ std::shared_lock image_locker{m_image_ctx->image_lock};
+ snap_id = m_image_ctx->get_snap_id(m_image_ctx->snap_namespace,
+ m_image_ctx->snap_name);
+ }
+ if (snap_id == CEPH_NOSNAP) {
+ lderr(cct) << "failed to find snapshot " << m_image_ctx->snap_name << dendl;
+ send_close_image(-ENOENT);
+ return nullptr;
+ }
+
+ using klass = OpenRequest<I>;
+ SetSnapRequest<I> *req = SetSnapRequest<I>::create(
+ *m_image_ctx, snap_id,
+ create_context_callback<klass, &klass::handle_set_snap>(this));
+ req->send();
+ return nullptr;
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_set_snap(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ if (*result < 0) {
+ lderr(cct) << "failed to set image snapshot: " << cpp_strerror(*result)
+ << dendl;
+ send_close_image(*result);
+ return nullptr;
+ }
+
+ return finalize(*result);
+}
+
+template <typename I>
+Context *OpenRequest<I>::finalize(int r) {
+ if (r == 0) {
+ auto io_scheduler_cfg =
+ m_image_ctx->config.template get_val<std::string>("rbd_io_scheduler");
+
+ if (io_scheduler_cfg == "simple" && !m_image_ctx->read_only) {
+ auto io_scheduler =
+ io::SimpleSchedulerObjectDispatch<I>::create(m_image_ctx);
+ io_scheduler->init();
+ }
+ }
+
+ return m_on_finish;
+}
+
+template <typename I>
+void OpenRequest<I>::send_close_image(int error_result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ m_error_result = error_result;
+
+ using klass = OpenRequest<I>;
+ Context *ctx = create_context_callback<klass, &klass::handle_close_image>(
+ this);
+ CloseRequest<I> *req = CloseRequest<I>::create(m_image_ctx, ctx);
+ req->send();
+}
+
+template <typename I>
+Context *OpenRequest<I>::handle_close_image(int *result) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << __func__ << ": r=" << *result << dendl;
+
+ if (*result < 0) {
+ lderr(cct) << "failed to close image: " << cpp_strerror(*result) << dendl;
+ }
+ if (m_error_result < 0) {
+ *result = m_error_result;
+ }
+ return m_on_finish;
+}
+
+} // namespace image
+} // namespace librbd
+
+template class librbd::image::OpenRequest<librbd::ImageCtx>;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment