From: Jianpeng Ma Date: Mon, 9 Mar 2015 06:23:23 +0000 (+0800) Subject: librbd: Add a paramter:purge_on_error in ImageCtx::invalidate_cache(). X-Git-Tag: v0.94.4~25^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F5767%2Fhead;p=ceph.git librbd: Add a paramter:purge_on_error in ImageCtx::invalidate_cache(). 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 (cherry picked from commit 35def5c81f7fc83d55d18320e4860c6a63d4c7f5) Conflicts: src/librbd/ImageCtx.cc : trivial resolution --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index ebdd184616b..0f5d46a56f4 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -683,14 +683,26 @@ public: flush_async_operations(); RWLock::RLocker owner_locker(owner_lock); - 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) { diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index 1022474e8a5..238b0ab6bd8 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -195,7 +195,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();