From aed074401d2834a5b04edd1b7f6b4f36336f6293 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 17 Mar 2014 15:37:44 -0700 Subject: [PATCH] os/FileJournal: return errors on make_writeable() if reopen fails This is why #7738 is resulting in a crash instead of an error. Signed-off-by: Sage Weil --- src/os/FileJournal.cc | 12 ++++++++---- src/os/FileJournal.h | 2 +- src/os/Journal.h | 2 +- src/os/JournalingObjectStore.cc | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index 3a344fa71015..54c03719e978 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -75,8 +75,8 @@ int FileJournal::_open(bool forwrite, bool create) fd = TEMP_FAILURE_RETRY(::open(fn.c_str(), flags, 0644)); if (fd < 0) { int err = errno; - dout(2) << "FileJournal::_open: unable to open journal: open() failed: " - << cpp_strerror(err) << dendl; + dout(2) << "FileJournal::_open unable to open journal " + << fn << ": " << cpp_strerror(err) << dendl; return -err; } @@ -1576,9 +1576,12 @@ void FileJournal::put_throttle(uint64_t ops, uint64_t bytes) } } -void FileJournal::make_writeable() +int FileJournal::make_writeable() { - _open(true); + dout(10) << __func__ << dendl; + int r = _open(true); + if (r < 0) + return r; if (read_pos > 0) write_pos = read_pos; @@ -1588,6 +1591,7 @@ void FileJournal::make_writeable() must_write_header = true; start_writer(); + return 0; } void FileJournal::wrap_read_bl( diff --git a/src/os/FileJournal.h b/src/os/FileJournal.h index c69fc54c2820..dbb1181bc8ed 100644 --- a/src/os/FileJournal.h +++ b/src/os/FileJournal.h @@ -400,7 +400,7 @@ private: bool is_writeable() { return read_pos == 0; } - void make_writeable(); + int make_writeable(); // writes void commit_start(uint64_t seq); diff --git a/src/os/Journal.h b/src/os/Journal.h index 1d413bb4c531..4f8658fb418f 100644 --- a/src/os/Journal.h +++ b/src/os/Journal.h @@ -56,7 +56,7 @@ public: // writes virtual bool is_writeable() = 0; - virtual void make_writeable() = 0; + virtual int make_writeable() = 0; virtual void submit_entry(uint64_t seq, bufferlist& e, int alignment, Context *oncommit, TrackedOpRef osd_op = TrackedOpRef()) = 0; diff --git a/src/os/JournalingObjectStore.cc b/src/os/JournalingObjectStore.cc index e662580ac42b..402fa3cc9757 100644 --- a/src/os/JournalingObjectStore.cc +++ b/src/os/JournalingObjectStore.cc @@ -98,7 +98,9 @@ int JournalingObjectStore::journal_replay(uint64_t fs_op_seq) submit_manager.set_op_seq(op_seq); // done reading, make writeable. - journal->make_writeable(); + err = journal->make_writeable(); + if (err < 0) + return err; return count; } -- 2.47.3