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: v14.1.0~135^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3892b81303bcc35056ca06371651e13b7a4c4f2a;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 --- diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index 2b391e956d346..9b0db2e4f4732 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -2509,7 +2509,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(); @@ -2578,7 +2582,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, @@ -2593,7 +2601,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; @@ -2601,7 +2609,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(); @@ -2651,7 +2663,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 a35577877d0c4..2451ae8c70520 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 121ba7bc6a91f..ba2ed13166238 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(); #if defined(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);