diff options
author | Josh Durgin <josh.durgin@inktank.com> | 2012-05-16 21:41:27 +0200 |
---|---|---|
committer | Josh Durgin <josh.durgin@inktank.com> | 2012-05-17 02:02:53 +0200 |
commit | 49c6ad44b4efb34ab76cdc0139ef6aac817a4d0c (patch) | |
tree | 10fffeef58483316c9e07d332ef031bcc9a4cddd | |
parent | ObjectCacher: handle write errors (diff) | |
download | ceph-49c6ad44b4efb34ab76cdc0139ef6aac817a4d0c.tar.xz ceph-49c6ad44b4efb34ab76cdc0139ef6aac817a4d0c.zip |
librbd: check for cache flush errors
Return errors from flushing to the caller. Warn
if an error occurs during invalidation, but don't retry,
since the higher level handles these cases, namely:
* rollback (doing this with an image open is asking for trouble)
* shrink (doing this with writes in flight may create extra objects anyway)
* shutdown (qemu flushes before closing the device)
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r-- | src/librbd.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/librbd.cc b/src/librbd.cc index 05ce5407531..7bc0f262264 100644 --- a/src/librbd.cc +++ b/src/librbd.cc @@ -310,8 +310,8 @@ namespace librbd { return r; } - void flush_cache() { - int r; + int flush_cache() { + int r = 0; Mutex mylock("librbd::ImageCtx::flush_cache"); Cond cond; bool done; @@ -328,6 +328,7 @@ namespace librbd { mylock.Unlock(); ldout(cct, 20) << "finished flushing cache" << dendl; } + return r; } void shutdown_cache() { @@ -344,11 +345,14 @@ namespace librbd { cache_lock.Lock(); object_cacher->release_set(object_set); cache_lock.Unlock(); - flush_cache(); + int r = flush_cache(); + if (r) + lderr(cct) << "flush_cache returned " << r << dendl; cache_lock.Lock(); bool unclean = object_cacher->release_set(object_set); cache_lock.Unlock(); - assert(!unclean); + if (unclean) + lderr(cct) << "could not release all objects from cache" << dendl; } }; @@ -1729,7 +1733,7 @@ ssize_t handle_sparse_read(CephContext *cct, /* last hole */ if (buf_left > 0) { - ldout(cct, 0) << "<3>zeroing " << buf_ofs << "~" << buf_left << dendl; + ldout(cct, 10) << "<3>zeroing " << buf_ofs << "~" << buf_left << dendl; r = cb(buf_ofs, buf_left, NULL, arg); if (r < 0) { return r; @@ -1809,14 +1813,13 @@ int _flush(ImageCtx *ictx) int r; // flush any outstanding writes if (ictx->object_cacher) { - ictx->flush_cache(); - r = 0; + r = ictx->flush_cache(); } else { r = ictx->data_ctx.aio_flush(); } if (r) - ldout(cct, 10) << "aio_flush " << ictx << " r = " << r << dendl; + lderr(cct) << "_flush " << ictx << " r = " << r << dendl; return r; } |