From: Sage Weil Date: Mon, 17 Mar 2014 22:37:44 +0000 (-0700) Subject: os/FileJournal: return errors on make_writeable() if reopen fails X-Git-Tag: v0.67.8~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1f80bbdf45439c7224ed52e4956973fc6d007848;p=ceph.git 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 (cherry picked from commit aed074401d2834a5b04edd1b7f6b4f36336f6293) --- diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index 4a2af08dd4c0..2c9e73265c90 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -74,8 +74,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; } @@ -1596,9 +1596,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; @@ -1608,6 +1611,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; }