From 083fdbf86c336878b00487b4422fd936d484855a Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 30 Nov 2015 12:36:13 -0500 Subject: [PATCH] librbd: check for presence of journal before attempting to remove Fixes: #13912 Signed-off-by: Jason Dillaman --- src/librbd/Journal.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/librbd/Journal.cc b/src/librbd/Journal.cc index d83438c60235..797349e8bb53 100644 --- a/src/librbd/Journal.cc +++ b/src/librbd/Journal.cc @@ -119,10 +119,19 @@ int Journal::remove(librados::IoCtx &io_ctx, const std::string &image_id) { // TODO configurable commit flush interval ::journal::Journaler journaler(io_ctx, image_id, "", 5); + bool journal_exists; + int r = journaler.exists(&journal_exists); + if (r < 0) { + lderr(cct) << "failed to stat journal header: " << cpp_strerror(r) << dendl; + return r; + } else if (!journal_exists) { + return 0; + } + C_SaferCond cond; journaler.init(&cond); - int r = cond.wait(); + r = cond.wait(); if (r == -ENOENT) { return 0; } else if (r < 0) { -- 2.47.3