]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: delay expiry if LogSegment is ahead of committed oft seq
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 27 Aug 2024 17:50:55 +0000 (13:50 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 25 Sep 2024 19:42:26 +0000 (15:42 -0400)
And remove the misplaced conditional in ::trim_expiring_segments.

This is necessary as the `flush journal` command gets confused by missing a
wait_for_expiry on a LogSegment that is not actually expired.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/MDLog.cc
src/mds/OpenFileTable.cc
src/mds/OpenFileTable.h
src/mds/journal.cc

index 9fba37da51d030f0b5ce3d586670ea20982e3f64..0f33bacbd3e2b5d2d95d053a186523342d1cf2cd 100644 (file)
@@ -856,8 +856,6 @@ void MDLog::_trim_expired_segments(auto& locker, MDSContext* ctx)
   ceph_assert(ceph_mutex_is_locked_by_me(submit_mutex));
   ceph_assert(locker.owns_lock());
 
-  uint64_t const oft_committed_seq = mds->mdcache->open_file_table.get_committed_log_seq();
-
   // trim expired segments?
   bool trimmed = false;
   uint64_t end = 0;
@@ -903,12 +901,6 @@ void MDLog::_trim_expired_segments(auto& locker, MDSContext* ctx)
       break;
     }
 
-    if (!mds_is_shutting_down && ls->seq >= oft_committed_seq) {
-      dout(10) << __func__ << " defer expire for open file table committedseq " << oft_committed_seq
-              << " <= " << ls->seq << "/" << ls->offset << dendl;
-      break;
-    }
-    
     end = seq;
     dout(10) << __func__ << ": maybe expiring " << *ls << dendl;
   }
index 4322b6a8a7d59cabd985c46ff9526c946001d412..811c6aff8ad2894090ab46f5fd7a45d1a5f18199 100644 (file)
@@ -283,6 +283,14 @@ void OpenFileTable::_commit_finish(int r, uint64_t log_seq, MDSContext *fin)
   committed_log_seq = log_seq;
   num_pending_commit--;
 
+  {
+    auto last = waiting_for_commit.upper_bound(log_seq);
+    for (auto it = waiting_for_commit.begin(); it != last; it++) {
+      finish_contexts(g_ceph_context, it->second);
+    }
+    waiting_for_commit.erase(waiting_for_commit.begin(), last);
+  }
+
   if (fin)
     fin->complete(r);
 }
index b18395213f56b5ad3dca81e429b9936c299e785f..a1b62012f79520e48258c5bcae256f0936f6dad9 100644 (file)
@@ -50,6 +50,9 @@ public:
     ceph_assert(!load_done);
     waiting_for_load.push_back(c);
   }
+  void wait_for_commit(uint64_t seq, Context* c) {
+    waiting_for_commit[seq].push_back(c);
+  }
 
   bool prefetch_inodes();
   bool is_prefetched() const { return prefetch_state == DONE; }
@@ -149,6 +152,8 @@ protected:
   std::set<inodeno_t> destroyed_inos_set;
 
   std::unique_ptr<PerfCounters> logger;
+
+  std::map<uint64_t, std::vector<Context*>> waiting_for_commit;
 };
 
 #endif
index 3018ea99fa03544156c7414c39c551eed76768f4..b7fc058692a665f582f2548752e0832f30bdfb2d 100644 (file)
@@ -235,6 +235,14 @@ void LogSegment::try_to_expire(MDSRank *mds, MDSGatherBuilder &gather_bld, int o
     }
   }
 
+  auto const oft_cseq = mds->mdcache->open_file_table.get_committed_log_seq();
+  if (!mds->mdlog->is_capped() && seq >= oft_cseq) {
+    dout(10) << *this << ".try_to_expire"
+             << " defer expire for oft_committed_seq (" << oft_cseq
+             << ") <= seq (" << seq << ")" << dendl;
+    mds->mdcache->open_file_table.wait_for_commit(seq, gather_bld.new_sub());
+  }
+
   ceph_assert(g_conf()->mds_kill_journal_expire_at != 3);
 
   std::map<int64_t, std::vector<CInodeCommitOperations>> ops_vec_map;