From: xie xingguo Date: Fri, 19 Feb 2016 06:25:54 +0000 (+0800) Subject: os/filestore: fix wrong scope of result code for error cases during mkfs X-Git-Tag: v10.1.0~247^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F7704%2Fhead;p=ceph.git 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 --- 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; }