]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
FileStore: Race condition during object delete is fixed 2509/head 2510/head
authorSomnath Roy <somnath.roy@sandisk.com>
Tue, 16 Sep 2014 00:23:51 +0000 (17:23 -0700)
committerSomnath Roy <somnath.roy@sandisk.com>
Tue, 16 Sep 2014 22:36:06 +0000 (15:36 -0700)
There was a race condition (hence OSD crash) between lfn_unlink
and lfn_open. The reason was FDCache lookup was called without
taking index lock from lfn_open. Lookup will increase reference
count and thus Clear will not be able to delete those FDs. FDs
will be leaked. The assert within FDCache clear was hitting
because of this.

Fixes: #9480
Signed-off-by: Somnath Roy <somnath.roy@sandisk.com>
src/os/FileStore.cc

index e91bda69d37178f73d80518512499e64e45eb456..f22ca6bb25ccd8e3f56914fc441d2c4b2af21280 100644 (file)
@@ -230,23 +230,9 @@ int FileStore::lfn_open(coll_t cid,
           oid.generation == ghobject_t::NO_GEN ));
   assert(outfd);
   int r = 0;
-
   bool need_lock = true;
-  if (!replaying) {
-    *outfd = fdcache.lookup(oid);
-    if (*outfd) {
-      if (!index) {
-        return 0;
-      } else {
-        if (!((*index).index)) {
-          r = get_index(cid, index);
-          return r;
-        }
-      }
-    }
-  }
-
   int flags = O_RDWR;
+
   if (create)
     flags |= O_CREAT;
 
@@ -254,7 +240,6 @@ int FileStore::lfn_open(coll_t cid,
   if (!index) {
     index = &index2;
   }
-
   if (!((*index).index)) {
     r = get_index(cid, index);
   } else {
@@ -266,6 +251,16 @@ int FileStore::lfn_open(coll_t cid,
   if (need_lock) {
     ((*index).index)->access_lock.get_write();
   }
+  if (!replaying) {
+    *outfd = fdcache.lookup(oid);
+    if (*outfd) {
+      if (need_lock) {
+        ((*index).index)->access_lock.put_write();
+      }
+      return 0;
+    }
+  }
+
 
   IndexedPath path2;
   IndexedPath *path = &path2;