]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd/cache: save full cach path instead of folder 37625/head
authorlixiaoy1 <xiaoyan.li@intel.com>
Sat, 10 Oct 2020 13:38:20 +0000 (09:38 -0400)
committerlixiaoy1 <xiaoyan.li@intel.com>
Sat, 10 Oct 2020 14:24:31 +0000 (10:24 -0400)
Signed-off-by: Li, Xiaoyan <xiaoyan.li@intel.com>
src/librbd/cache/pwl/AbstractWriteLog.cc
src/librbd/cache/pwl/ImageCacheState.cc
src/librbd/cache/pwl/ImageCacheState.h

index a3a0a33fb29160d89e8afe218959798fd83ebf07..f1e5ed702c958b6156bf7c547cabed9f266a9482 100644 (file)
@@ -9,6 +9,7 @@
 #include "common/dout.h"
 #include "common/environment.h"
 #include "common/errno.h"
+#include "common/hostname.h"
 #include "common/WorkQueue.h"
 #include "common/Timer.h"
 #include "common/perf_counters.h"
@@ -487,14 +488,20 @@ void AbstractWriteLog<I>::pwl_init(Context *on_finish, DeferredContexts &later)
   std::lock_guard locker(m_lock);
   ceph_assert(!m_initialized);
   ldout(cct,5) << "image name: " << m_image_ctx.name << " id: " << m_image_ctx.id << dendl;
-  ldout(cct,5) << "pwl_size: " << m_cache_state->size << dendl;
-  std::string pwl_path = m_cache_state->path;
-  ldout(cct,5) << "pwl_path: " << pwl_path << dendl;
 
-  std::string pool_name = m_image_ctx.md_ctx.get_pool_name();
-  std::string log_pool_name = pwl_path + "/rbd-pwl." + pool_name + "." + m_image_ctx.id + ".pool";
-  m_log_pool_name = log_pool_name;
+  if (!m_cache_state->present) {
+    m_cache_state->host = ceph_get_short_hostname();
+    m_cache_state->size = m_image_ctx.config.template get_val<uint64_t>("rbd_rwl_size");
+
+    string path = m_image_ctx.config.template get_val<string>("rbd_rwl_path");
+    std::string pool_name = m_image_ctx.md_ctx.get_pool_name();
+    m_cache_state->path = path + "/rbd-pwl." + pool_name + "." + m_image_ctx.id + ".pool";
+  }
+
+  ldout(cct,5) << "pwl_size: " << m_cache_state->size << dendl;
+  ldout(cct,5) << "pwl_path: " << m_cache_state->path << dendl;
 
+  m_log_pool_name = m_cache_state->path;
   m_log_pool_config_size = max(m_cache_state->size, MIN_POOL_SIZE);
 
   if ((!m_cache_state->present) &&
@@ -509,6 +516,10 @@ void AbstractWriteLog<I>::pwl_init(Context *on_finish, DeferredContexts &later)
     } else {
       ldout(cct, 5) << "Removed the existing pool file." << dendl;
     }
+  } else if ((m_cache_state->present) &&
+             (access(m_log_pool_name.c_str(), F_OK) != 0)) {
+    ldout(cct, 5) << "Can't find the existed pool file " << m_log_pool_name << dendl;
+    on_finish->complete(-errno);
   }
 
   initialize_pool(on_finish, later);
index 5f2ac52f0dd96fd88d4c1c337a9f6a98c0d16727..b36896a6915dcd65cabb43edf85df57de952dc49 100644 (file)
@@ -6,10 +6,10 @@
 #include "librbd/cache/pwl/ImageCacheState.h"
 #include "librbd/ImageCtx.h"
 #include "librbd/Operations.h"
-#include "common/environment.h"
-#include "common/hostname.h"
 #include "common/config_proxy.h"
 #include "common/ceph_json.h"
+#include "common/environment.h"
+#include "common/hostname.h"
 
 #undef dout_subsys
 #define dout_subsys ceph_subsys_rbd_pwl
@@ -38,9 +38,6 @@ ImageCacheState<I>::ImageCacheState(I *image_ctx) : m_image_ctx(image_ctx) {
                             << dendl;
 
   ConfigProxy &config = image_ctx->config;
-  host = ceph_get_short_hostname();
-  path = config.get_val<std::string>("rbd_rwl_path");
-  size = config.get_val<uint64_t>("rbd_rwl_size");
   log_periodic_stats = config.get_val<bool>("rbd_rwl_log_periodic_stats");
 }
 
index 2bdf31ffeed7116ac93ba7d18a453f8b7acdd2d9..bdc8cb080ff65e64dd49742243acf6721a49169a 100644 (file)
@@ -22,12 +22,12 @@ class ImageCacheState {
 private:
   ImageCtxT* m_image_ctx;
 public:
-  bool present = true;
+  bool present = false;
   bool empty = true;
   bool clean = true;
   std::string host;
   std::string path;
-  uint64_t size;
+  uint64_t size = 0;
   bool log_periodic_stats;
 
   ImageCacheState(ImageCtxT* image_ctx);