From 835b12ff6dcd7a08944c3e71eba96bbd4c938710 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Wed, 6 May 2015 16:14:29 +0800 Subject: [PATCH] librbd: fix the image format detection If the detection of the old format fails with reasons other than -ENOENT, we should return with this error. Otherwise, if we continue the new format detection and fail with -ENOENT, the caller will get the missleading failure information. Signed-off-by: Zhiqiang Wang --- src/librbd/internal.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index bb2413632108..809dfee90b75 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -311,12 +311,14 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type, if (old_format) *old_format = true; int r = io_ctx.stat(old_header_name(name), size, NULL); - if (r < 0) { + if (r == -ENOENT) { if (old_format) *old_format = false; r = io_ctx.stat(id_obj_name(name), size, NULL); if (r < 0) return r; + } else if (r < 0) { + return r; } ldout(cct, 20) << "detect format of " << name << " : " -- 2.47.3