]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: first lock osd mount point, next detect fs type
authorYehuda Sadeh <yehuda.sadeh@dreamhost.com>
Fri, 27 Apr 2012 22:46:49 +0000 (15:46 -0700)
committerYehuda Sadeh <yehuda.sadeh@dreamhost.com>
Fri, 27 Apr 2012 22:46:49 +0000 (15:46 -0700)
Fixes #2353. Problem was that there were (at least) two osd processes
that were racing for the fs detection, which triggered some errors
in the btrfs create/remove snapshot.

Signed-off-by: Yehuda Sadeh <yehuda.sadeh@dreamhost.com>
src/os/FileStore.cc

index 7f70f2fe863a4a41a82336ad6423d8f6406c8bcc..1a64d8cc6aa80ec3ad063abd7241c253914c0791 100644 (file)
@@ -1637,17 +1637,42 @@ int FileStore::mount()
     goto done;
   }
 
+  // get fsid
+  snprintf(buf, sizeof(buf), "%s/fsid", basedir.c_str());
+  fsid_fd = ::open(buf, O_RDWR, 0644);
+  if (fsid_fd < 0) {
+    ret = -errno;
+    derr << "FileStore::mount: error opening '" << buf << "': "
+        << cpp_strerror(ret) << dendl;
+    goto done;
+  }
+
+  ret = read_fsid(fsid_fd);
+  if (ret < 0) {
+    derr << "FileStore::mount: error reading fsid_fd: " << cpp_strerror(ret)
+        << dendl;
+    goto close_fsid_fd;
+  }
+
+  if (lock_fsid() < 0) {
+    derr << "FileStore::mount: lock_fsid failed" << dendl;
+    ret = -EBUSY;
+    goto close_fsid_fd;
+  }
+
+  dout(10) << "mount fsid is " << fsid << dendl;
+
   // test for btrfs, xattrs, etc.
   ret = _detect_fs();
   if (ret)
-    goto done;
+    goto close_fsid_fd;
 
   uint32_t version_stamp;
   ret = version_stamp_is_valid(&version_stamp);
   if (ret < 0) {
     derr << "FileStore::mount : error in version_stamp_is_valid: "
         << cpp_strerror(ret) << dendl;
-    goto done;
+    goto close_fsid_fd;
   } else if (ret == 0) {
     if (m_filestore_update_collections) {
       derr << "FileStore::mount : stale version stamp detected: "
@@ -1662,35 +1687,10 @@ int FileStore::mount()
           << ". Please run the FileStore update script before starting the "
           << "OSD."
           << dendl;
-      goto done;
+      goto close_fsid_fd;
     }
   }
 
-  // get fsid
-  snprintf(buf, sizeof(buf), "%s/fsid", basedir.c_str());
-  fsid_fd = ::open(buf, O_RDWR, 0644);
-  if (fsid_fd < 0) {
-    ret = -errno;
-    derr << "FileStore::mount: error opening '" << buf << "': "
-        << cpp_strerror(ret) << dendl;
-    goto done;
-  }
-
-  ret = read_fsid(fsid_fd);
-  if (ret < 0) {
-    derr << "FileStore::mount: error reading fsid_fd: " << cpp_strerror(ret)
-        << dendl;
-    goto close_fsid_fd;
-  }
-
-  if (lock_fsid() < 0) {
-    derr << "FileStore::mount: lock_fsid failed" << dendl;
-    ret = -EBUSY;
-    goto close_fsid_fd;
-  }
-
-  dout(10) << "mount fsid is " << fsid << dendl;
-
   // open some dir handles
   basedir_fd = ::open(basedir.c_str(), O_RDONLY);
   if (basedir_fd < 0) {