]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: handle read_op_seq errors
authorSage Weil <sage.weil@dreamhost.com>
Fri, 4 Feb 2011 22:27:10 +0000 (14:27 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Fri, 4 Feb 2011 22:27:18 +0000 (14:27 -0800)
Fixes: #775
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/os/FileStore.cc

index 1f20f22ac452db74dc3865a8b5a625148c1ffc0c..86980a35b6ba57fbdfb8964731283824c56a58ee 100644 (file)
@@ -1068,7 +1068,7 @@ int FileStore::read_op_seq(const char *fn, uint64_t *seq)
 {
   int op_fd = ::open(current_op_seq_fn.c_str(), O_CREAT|O_RDWR, 0644);
   if (op_fd < 0)
-    return op_fd;
+    return -errno;
 
   char s[40];
   int l = ::read(op_fd, s, sizeof(s));
@@ -1076,9 +1076,11 @@ int FileStore::read_op_seq(const char *fn, uint64_t *seq)
     s[l] = 0;
     *seq = atoll(s);
   } else {
-    char buf[80];
+    int err = errno;
     dout(0) << "error reading " << current_op_seq_fn << ": "
-     << strerror_r(errno, buf, sizeof(buf)) << dendl;
+     << cpp_strerror(err) << dendl;
+    ::close(op_fd);
+    return -err;
   }
 
   return op_fd;
@@ -1223,6 +1225,7 @@ int FileStore::mount()
 
       if (cp != curr_seq) {
         int fd = read_op_seq(current_op_seq_fn.c_str(), &curr_seq);
+       assert(fd >= 0);
         /* we'll use the higher version from now on */
         curr_seq = cp;
         write_op_seq(fd, curr_seq);