]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/cache/pwl: rename persistent cache key
authorYin Congmin <congmin.yin@intel.com>
Wed, 22 Dec 2021 07:07:11 +0000 (15:07 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 13 Apr 2022 10:57:45 +0000 (12:57 +0200)
librbd "internal" metadata keys was change to ".rbd" prefix. Change
peristent cache to ".rbd" too.
And the name of  persistent cache key is IMAGE_CACHE_STATE. Since
this key is planned to be used outside the pwl directory, it seems
more appropriate to change it to a clear name as PERSISTENT_CACHE_STATE.

Signed-off-by: Yin Congmin <congmin.yin@intel.com>
(cherry picked from commit bd66fdda910f02ffe91bb026f82a85f28a6ff225)

src/librbd/cache/Types.h
src/librbd/cache/pwl/ImageCacheState.cc
src/librbd/cache/pwl/ShutdownRequest.cc
src/tools/rbd/action/Status.cc

index b791d590873732dc6d85858318a8896315d9ffab..43dcd758f0b2b3770611cadbde0b38bf59709a75 100644 (file)
@@ -20,7 +20,7 @@ enum ImageCacheType {
 
 typedef std::list<Context *> Contexts;
 
-const std::string IMAGE_CACHE_STATE = ".librbd/image_cache_state";
+const std::string PERSISTENT_CACHE_STATE = ".rbd_persistent_cache_state";
 
 } // namespace cache
 } // namespace librbd
index 1dd81e6480c9b39f33875fc44ab0b4f538779d9b..fe6e1087d05205df6ea0472f51f8f0474d82f40d 100644 (file)
@@ -85,7 +85,7 @@ void ImageCacheState<I>::write_image_cache_state(Context *on_finish) {
 
   ldout(m_image_ctx->cct, 20) << __func__ << " Store state: "
                               << image_state_json << dendl;
-  m_plugin_api.execute_image_metadata_set(m_image_ctx, IMAGE_CACHE_STATE,
+  m_plugin_api.execute_image_metadata_set(m_image_ctx, PERSISTENT_CACHE_STATE,
                                           image_state_json, on_finish);
 }
 
@@ -94,7 +94,7 @@ void ImageCacheState<I>::clear_image_cache_state(Context *on_finish) {
   std::shared_lock owner_lock{m_image_ctx->owner_lock};
   ldout(m_image_ctx->cct, 20) << __func__ << " Remove state: " << dendl;
   m_plugin_api.execute_image_metadata_remove(
-    m_image_ctx, IMAGE_CACHE_STATE, on_finish);
+    m_image_ctx, PERSISTENT_CACHE_STATE, on_finish);
 }
 
 template <typename I>
@@ -107,7 +107,7 @@ ImageCacheState<I>* ImageCacheState<I>::create_image_cache_state(
   bool dirty_cache = plugin_api.test_image_features(image_ctx, RBD_FEATURE_DIRTY_CACHE);
   if (dirty_cache) {
     cls_client::metadata_get(&image_ctx->md_ctx, image_ctx->header_oid,
-                             IMAGE_CACHE_STATE, &cache_state_str);
+                             PERSISTENT_CACHE_STATE, &cache_state_str);
   }
 
   ldout(image_ctx->cct, 20) << "image_cache_state: " << cache_state_str << dendl;
@@ -155,7 +155,7 @@ ImageCacheState<I>* ImageCacheState<I>::get_image_cache_state(
   ImageCacheState<I>* cache_state = nullptr;
   string cache_state_str;
   cls_client::metadata_get(&image_ctx->md_ctx, image_ctx->header_oid,
-                          IMAGE_CACHE_STATE, &cache_state_str);
+                          PERSISTENT_CACHE_STATE, &cache_state_str);
   if (!cache_state_str.empty()) {
     // ignore errors, best effort
     cache_state = new ImageCacheState<I>(image_ctx, plugin_api);
index 4475712dd6bb755272e1b235e894208477362749..e022328ba70e9bf1516088c94191bb8f2e4f68cb 100644 (file)
@@ -132,7 +132,7 @@ void ShutdownRequest<I>::send_remove_image_cache_state() {
   Context *ctx = create_context_callback<klass, &klass::handle_remove_image_cache_state>(
     this);
   std::shared_lock owner_lock{m_image_ctx.owner_lock};
-  m_plugin_api.execute_image_metadata_remove(&m_image_ctx, IMAGE_CACHE_STATE, ctx);
+  m_plugin_api.execute_image_metadata_remove(&m_image_ctx, PERSISTENT_CACHE_STATE, ctx);
 }
 
 template <typename I>
index 4cc01c628213adabec547b0d29b138a8b98dca36..958a686c4167854d530d16c0985ed72b2a2a022f 100644 (file)
@@ -9,6 +9,7 @@
 #include "tools/rbd/Utils.h"
 #include "include/rbd_types.h"
 #include "include/stringify.h"
+#include "librbd/cache/Types.h"
 #include <iostream>
 #include <boost/program_options.hpp>
 
@@ -19,12 +20,6 @@ namespace status {
 namespace at = argument_types;
 namespace po = boost::program_options;
 
-namespace {
-
-const std::string IMAGE_CACHE_STATE = ".librbd/image_cache_state";
-
-} // anonymous namespace
-
 static int do_show_status(librados::IoCtx& io_ctx, const std::string &image_name,
                           librbd::Image &image, Formatter *f)
 {
@@ -133,7 +128,7 @@ static int do_show_status(librados::IoCtx& io_ctx, const std::string &image_name
   } cache_state;
   std::string cache_str;
   if (features & RBD_FEATURE_DIRTY_CACHE) {
-    r = image.metadata_get(IMAGE_CACHE_STATE, &cache_str);
+    r = image.metadata_get(librbd::cache::PERSISTENT_CACHE_STATE, &cache_str);
     if (r < 0) {
       std::cerr << "rbd: getting persistent cache state failed: " << cpp_strerror(r)
                 << std::endl;