]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: correct storage of multiple damaged dentries in DamageTable
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 23 Aug 2022 00:35:52 +0000 (20:35 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Mon, 12 Sep 2022 00:39:52 +0000 (20:39 -0400)
Fixes: c9cfaef104e9aaefad55583d7e54f8b4665904b3
Fixes: https://tracker.ceph.com/issues/57249
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/DamageTable.cc

index 150ad5764825712d592e0ac98220d121dfa57a0e..22802079d85d4879b64bfdf71d3cbc4167b9cf69 100644 (file)
@@ -147,12 +147,11 @@ bool DamageTable::notify_dentry(
     return true;
   }
 
-  auto key = DirFragIdent(ino, frag);
-  if (dentries.count(key) == 0) {
-    DamageEntryRef entry = std::make_shared<DentryDamage>(
-        ino, frag, dname, snap_id);
+  auto& df_dentries = dentries[DirFragIdent(ino, frag)];
+  if (auto [it, inserted] = df_dentries.try_emplace(DentryIdent(dname, snap_id)); inserted) {
+    auto entry = std::make_shared<DentryDamage>(ino, frag, dname, snap_id);
     entry->path = path;
-    dentries[key][DentryIdent(dname, snap_id)] = entry;
+    it->second = entry;
     by_id[entry->id] = std::move(entry);
   }
 
@@ -175,11 +174,10 @@ bool DamageTable::notify_dirfrag(inodeno_t ino, frag_t frag,
     return true;
   }
 
-  auto key = DirFragIdent(ino, frag);
-  if (dirfrags.count(key) == 0) {
+  if (auto [it, inserted] = dirfrags.try_emplace(DirFragIdent(ino, frag)); inserted) {
     DamageEntryRef entry = std::make_shared<DirFragDamage>(ino, frag);
     entry->path = path;
-    dirfrags[key] = entry;
+    it->second = entry;
     by_id[entry->id] = std::move(entry);
   }
 
@@ -192,10 +190,10 @@ bool DamageTable::notify_remote_damaged(inodeno_t ino, std::string_view path)
     return true;
   }
 
-  if (remotes.count(ino) == 0) {
+  if (auto [it, inserted] = remotes.try_emplace(ino); inserted) {
     auto entry = std::make_shared<BacktraceDamage>(ino);
     entry->path = path;
-    remotes[ino] = entry;
+    it->second = entry;
     by_id[entry->id] = std::move(entry);
   }