From: Sage Weil Date: Mon, 11 Feb 2019 17:11:22 +0000 (-0600) Subject: os/filestore: ceph_abort() on fsync(2) or fdatasync(2) failure X-Git-Tag: v12.2.12~51^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4a9f0fd93476503aec7c220eaa9cfa74cde888e3;p=ceph.git os/filestore: ceph_abort() on fsync(2) or fdatasync(2) failure If we get an error from f[data]sync that is always a fatal error. Fixes: http://tracker.ceph.com/issues/38258 Signed-off-by: Sage Weil (cherry picked from commit 3892b81303bcc35056ca06371651e13b7a4c4f2a) Conflicts: src/os/filestore/FileStore.cc - encode trivial resolution src/os/filestore/WBThrottle.cc - trivial resolution --- diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index dd3d1045e2b..1cdea367702 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -2387,7 +2387,11 @@ void FileStore::_set_global_replay_guard(const coll_t& cid, } // and make sure our xattr is durable. - ::fsync(fd); + r = ::fsync(fd); + if (r < 0) { + derr << __func__ << " fsync failed: " << cpp_strerror(errno) << dendl; + ceph_abort(); + } _inject_failure(); @@ -2456,7 +2460,11 @@ void FileStore::_set_replay_guard(int fd, _inject_failure(); // first make sure the previous operation commits - ::fsync(fd); + int r = ::fsync(fd); + if (r < 0) { + derr << __func__ << " fsync failed: " << cpp_strerror(errno) << dendl; + ceph_abort(); + } if (!in_progress) { // sync object_map too. even if this object has a header or keys, @@ -2471,7 +2479,7 @@ void FileStore::_set_replay_guard(int fd, bufferlist v(40); ::encode(spos, v); ::encode(in_progress, v); - int r = chain_fsetxattr( + r = chain_fsetxattr( fd, REPLAY_GUARD_XATTR, v.c_str(), v.length()); if (r < 0) { derr << "fsetxattr " << REPLAY_GUARD_XATTR << " got " << cpp_strerror(r) << dendl; @@ -2479,7 +2487,11 @@ void FileStore::_set_replay_guard(int fd, } // and make sure our xattr is durable. - ::fsync(fd); + r = ::fsync(fd); + if (r < 0) { + derr << __func__ << " fsync failed: " << cpp_strerror(errno) << dendl; + ceph_abort(); + } _inject_failure(); @@ -2529,7 +2541,11 @@ void FileStore::_close_replay_guard(int fd, const SequencerPosition& spos, } // and make sure our xattr is durable. - ::fsync(fd); + r = ::fsync(fd); + if (r < 0) { + derr << __func__ << " fsync failed: " << cpp_strerror(errno) << dendl; + ceph_abort(); + } _inject_failure(); diff --git a/src/os/filestore/LFNIndex.cc b/src/os/filestore/LFNIndex.cc index 2befe38d5dd..bbdb76e30cb 100644 --- a/src/os/filestore/LFNIndex.cc +++ b/src/os/filestore/LFNIndex.cc @@ -29,6 +29,7 @@ #include "common/debug.h" #include "include/buffer.h" #include "common/ceph_crypto.h" +#include "common/errno.h" #include "include/compat.h" #include "chain_xattr.h" @@ -176,10 +177,11 @@ int LFNIndex::fsync_dir(const vector &path) maybe_inject_failure(); int r = ::fsync(fd); maybe_inject_failure(); - if (r < 0) - return -errno; - else - return 0; + if (r < 0) { + derr << __func__ << " fsync failed: " << cpp_strerror(errno) << dendl; + ceph_abort(); + } + return 0; } int LFNIndex::link_object(const vector &from, diff --git a/src/os/filestore/WBThrottle.cc b/src/os/filestore/WBThrottle.cc index 8930cd95a18..6819c85e2fb 100644 --- a/src/os/filestore/WBThrottle.cc +++ b/src/os/filestore/WBThrottle.cc @@ -5,6 +5,7 @@ #include "os/filestore/WBThrottle.h" #include "common/perf_counters.h" +#include "common/errno.h" WBThrottle::WBThrottle(CephContext *cct) : cur_ios(0), cur_size(0), @@ -166,10 +167,14 @@ void *WBThrottle::entry() logger->inc(l_wbthrottle_inodes_wb); lock.Unlock(); #ifdef HAVE_FDATASYNC - ::fdatasync(**wb.get<1>()); + int r = ::fdatasync(**wb.get<1>()); #else - ::fsync(**wb.get<1>()); + int r = ::fsync(**wb.get<1>()); #endif + if (r < 0) { + lderr(cct) << "WBThrottle fsync failed: " << cpp_strerror(errno) << dendl; + ceph_abort(); + } #ifdef HAVE_POSIX_FADVISE if (cct->_conf->filestore_fadvise && wb.get<2>().nocache) { int fa_r = posix_fadvise(**wb.get<1>(), 0, 0, POSIX_FADV_DONTNEED);