]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/journal: close open segment and reset soft state in close()
authorSamuel Just <sjust@redhat.com>
Wed, 28 Apr 2021 07:22:16 +0000 (00:22 -0700)
committerSamuel Just <sjust@redhat.com>
Fri, 7 May 2021 07:36:44 +0000 (00:36 -0700)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/journal.h

index d2cfe1383f5905bb9dc1360754f2e97bde1188eb..6804a47ca65f25bcbc5eb731f36e172ab7d1c4a7 100644 (file)
@@ -159,7 +159,22 @@ public:
    */
   using close_ertr = crimson::errorator<
     crimson::ct_error::input_output_error>;
-  close_ertr::future<> close() { return close_ertr::now(); }
+  close_ertr::future<> close() {
+    return (
+      current_journal_segment ?
+      current_journal_segment->close() :
+      Segment::close_ertr::now()
+    ).handle_error(
+      close_ertr::pass_further{},
+      crimson::ct_error::assert_all{
+       "Error during Journal::close()"
+      }
+    ).finally([this] {
+      current_journal_segment.reset();
+      reset_soft_state();
+      return close_ertr::now();
+    });
+  }
 
   /**
    * submit_record
@@ -256,6 +271,13 @@ private:
 
   WritePipeline *write_pipeline = nullptr;
 
+  void reset_soft_state() {
+    next_journal_segment_seq = 0;
+    current_segment_nonce = 0;
+    written_to = 0;
+    committed_to = 0;
+  }
+
   /// prepare segment for writes, writes out segment header
   using initialize_segment_ertr = crimson::errorator<
     crimson::ct_error::input_output_error>;