From 68f300dda47936e825f00237ed5263be5961cc60 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Fri, 19 Feb 2016 14:25:54 +0800 Subject: [PATCH] os/filestore: fix wrong scope of result code for error cases during mkfs During the mkfs process, if we fail to read and sometimes rewrite the op_seq, the mkfs process is abnormally terminated but we may still return a positive answer to the caller, which is misleading. This patch is provided to solve the above problems by correctly setting 'ret' correspondingly under these cases, which is the final answer to be passed out for caller. Fixes: #14814 Signed-off-by: xie xingguo --- src/os/filestore/FileStore.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index 548b1d926f7..ca6bc81b3a5 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -877,16 +877,17 @@ int FileStore::mkfs() uint64_t initial_seq = 0; int fd = read_op_seq(&initial_seq); if (fd < 0) { + ret = fd; derr << "mkfs: failed to create " << current_op_seq_fn << ": " - << cpp_strerror(fd) << dendl; + << cpp_strerror(ret) << dendl; goto close_fsid_fd; } if (initial_seq == 0) { - int err = write_op_seq(fd, 1); - if (err < 0) { + ret = write_op_seq(fd, 1); + if (ret < 0) { VOID_TEMP_FAILURE_RETRY(::close(fd)); derr << "mkfs: failed to write to " << current_op_seq_fn << ": " - << cpp_strerror(err) << dendl; + << cpp_strerror(ret) << dendl; goto close_fsid_fd; } -- 2.47.3