]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/cache/pwl: don't crash if cache file removal fails
authorIlya Dryomov <idryomov@gmail.com>
Sun, 10 Apr 2022 14:57:24 +0000 (16:57 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 13 Apr 2022 10:57:45 +0000 (12:57 +0200)
The non-ec overload will throw fs::filesystem_error on any error
(e.g. EPERM due to unprivileged "rbd persistent-cache invalidate"
being brought up against a privileged workload).

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 63197ff7003fa9e595527a7431f9f3f6790f7d57)

src/librbd/cache/pwl/DiscardRequest.cc

index decefafb5277f9bbba4f8cad0ea9aaf7011cfea4..9d4bff26b2cec52f3307b6efaab95591bfc5c1cf 100644 (file)
@@ -68,7 +68,13 @@ void DiscardRequest<I>::delete_image_cache_file() {
   if (m_cache_state->present &&
       !m_cache_state->host.compare(ceph_get_short_hostname()) &&
       fs::exists(m_cache_state->path)) {
-    fs::remove(m_cache_state->path);
+    std::error_code ec;
+    fs::remove(m_cache_state->path, ec);
+    if (ec) {
+      lderr(cct) << "failed to remove persistent cache file: " << ec.message()
+                 << dendl;
+      // not fatal
+    }
   }
 
   remove_image_cache_state();