]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/filestore: fix wrong scope of result code for error cases during mkfs 7704/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 19 Feb 2016 06:25:54 +0000 (14:25 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 19 Feb 2016 06:45:20 +0000 (14:45 +0800)
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 <xie.xingguo@zte.com.cn>
src/os/filestore/FileStore.cc

index 548b1d926f75b2285bd5708c9e0ce9e45d7fe23c..ca6bc81b3a53127b59ac2efcd9cfebc1374ad496 100644 (file)
@@ -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;
       }