]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: Add a paramter:purge_on_error in ImageCtx::invalidate_cache(). 3625/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Mon, 9 Mar 2015 06:23:23 +0000 (14:23 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Mon, 9 Mar 2015 06:23:23 +0000 (14:23 +0800)
If bh_write met error, it will try again. For closing image, if met this
issue, it will trigger a assert:
>>2015-02-03 15:22:49.198292 7ff62d537800 -1 osdc/ObjectCacher.cc: In
function 'ObjectCacher::~ObjectCacher()' thread 7ff62d537800 time
>>2015-02-03 15:22:49.195927osdc/ObjectCacher.cc: 551: FAILED
>>assert(i->empty())

Now add purge_on_error, when shutdown_cache it set true.
In ImageCtx::invalidate_cache, if met error and purge_on_error is true,
purge the dirty bh.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h

index befb452ea45945bbc114a79b5c0b7dc9e2783197..9f4b006a3747daf720e62651f38f4af2645db688 100644 (file)
@@ -616,14 +616,26 @@ namespace librbd {
 
   void ImageCtx::shutdown_cache() {
     flush_async_operations();
-    invalidate_cache();
+    invalidate_cache(true);
     object_cacher->stop();
   }
 
-  int ImageCtx::invalidate_cache() {
+  int ImageCtx::invalidate_cache(bool purge_on_error) {
+    int result;
     C_SaferCond ctx;
     invalidate_cache(&ctx);
-    return ctx.wait();
+    result = ctx.wait();
+
+    if (result && purge_on_error) {
+      cache_lock.Lock();
+      if (object_cacher != NULL) {
+       lderr(cct) << "invalidate cache met error " << cpp_strerror(result) << " !Purging cache..." << dendl;
+       object_cacher->purge_set(object_set);
+      }
+      cache_lock.Unlock();
+    }
+
+    return result;
   }
 
   void ImageCtx::invalidate_cache(Context *on_finish) {
index 21ae7a051866d6e6ea963e99e36926a11e950e2b..b805199179c090acfc5c27d26d06e96af3ebdc46 100644 (file)
@@ -187,7 +187,7 @@ namespace librbd {
     void flush_cache_aio(Context *onfinish);
     int flush_cache();
     void shutdown_cache();
-    int invalidate_cache();
+    int invalidate_cache(bool purge_on_error=false);
     void invalidate_cache(Context *on_finish);
     void invalidate_cache_completion(int r, Context *on_finish);
     void clear_nonexistence_cache();