From: Yehuda Sadeh Date: Fri, 27 Apr 2012 22:46:49 +0000 (-0700) Subject: filestore: first lock osd mount point, next detect fs type X-Git-Tag: v0.47~86^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f03dc34f7e2fc1707fa00339b917c0d2c93dbdd3;p=ceph.git filestore: first lock osd mount point, next detect fs type 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 --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 7f70f2fe863a..1a64d8cc6aa8 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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) {