]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
FileStore: fix double close
authorSamuel Just <samuel.just@dreamhost.com>
Tue, 1 Feb 2011 21:48:39 +0000 (13:48 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 1 Feb 2011 19:02:15 +0000 (11:02 -0800)
curr_fd is already closed if cp == cur_seq.  This second close
occasionally ended up closing another thread's fd.  The next open would
tend to grab that fd in op_fd or current_fd which would then get closed
by the other thread leaving op_fd or current_fd pointing to some random
file (or a closed descriptor).

Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
src/os/FileStore.cc

index 5f30683836c852ca7026a9707c7e7a765d8fc409..f55ca4a69dc652d115930de310d2eb9c78a52b31 100644 (file)
@@ -1132,7 +1132,8 @@ int FileStore::mount()
 
       int curr_fd = read_op_seq(current_op_seq_fn.c_str(), &curr_seq);
       assert(curr_fd >= 0);
-      close(curr_fd);
+      ::close(curr_fd);
+      curr_fd = -1;
       dout(10) << "*** curr_seq=" << curr_seq << " cp=" << cp << dendl;
      
       if (cp != curr_seq && !g_conf.osd_use_stale_snap) { 
@@ -1189,14 +1190,13 @@ int FileStore::mount()
       dout(10) << "mount rolled back to consistent snap " << cp << dendl;
       snaps.pop_back();
 
-      assert(curr_fd >= 0);
       if (cp != curr_seq) {
         curr_fd = read_op_seq(current_op_seq_fn.c_str(), &curr_seq);
         /* we'll use the higher version from now on */
         curr_seq = cp;
         write_op_seq(curr_fd, curr_seq);
+       ::close(curr_fd);
       }
-      close(curr_fd);
     }
   }