]> git.hungrycats.org Git - bees/commitdiff
bees: post-kernel-5.7 toxic extent handling
authorZygo Blaxell <bees@furryterror.org>
Fri, 28 May 2021 06:13:33 +0000 (02:13 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sun, 1 Dec 2024 05:17:52 +0000 (00:17 -0500)
Toxic extents are mostly gone in kernel 5.7 and later.  Increase the
timeout for toxic extent handling to reduce false positives, and remove
persistenly stored toxic hashes from the hash table.

Toxic hashes are still stored nonpersistently to help mitigate problems
due to any remaining kernel bugs.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees-hash.cc
src/bees.h

index 60e60e70c31634a182ae41cca3c8a1425ee2893b..91b669d39918098787b4a921d6722d517b576153 100644 (file)
@@ -452,6 +452,34 @@ BeesHashTable::fetch_missing_extent_by_index(uint64_t extent_index)
                        readahead(m_fd, dirty_extent_offset + dirty_extent_size, dirty_extent_size);
                }
        });
+
+       Cell *cell     = m_extent_ptr[extent_index    ].p_buckets[0].p_cells;
+       Cell *cell_end = m_extent_ptr[extent_index + 1].p_buckets[0].p_cells;
+       size_t toxic_cleared_count = 0;
+       set<BeesHashTable::Cell> seen_it(cell, cell_end);
+       while (cell < cell_end) {
+               if (cell->e_addr & BeesAddress::c_toxic_mask) {
+                       ++toxic_cleared_count;
+                       cell->e_addr &= ~BeesAddress::c_toxic_mask;
+                       // Clearing the toxic bit might mean we now have a duplicate.
+                       // This could be due to a race between two
+                       // inserts, one finds the extent toxic while the
+                       // other does not.  That's arguably a bug elsewhere,
+                       // but we should rewrite the whole extent lookup/insert
+                       // loop, not spend time fixing code that will be
+                       // thrown out later anyway.
+                       // If there is a cell that is identical to this one
+                       // except for the toxic bit, then we don't need this one.
+                       if (seen_it.count(*cell)) {
+                               cell->e_addr = 0;
+                               cell->e_hash = 0;
+                       }
+               }
+               ++cell;
+       }
+       if (toxic_cleared_count) {
+               BEESLOGDEBUG("Cleared " << toxic_cleared_count << " hashes while fetching hash table extent " << extent_index);
+       }
 }
 
 void
index 870e2be059dcb69ef9d6e76bebd1cec0f4371029..ea811163520b1e293f87d5b506effe77e04dbf94 100644 (file)
@@ -93,7 +93,7 @@ const double BEES_DEFAULT_THREAD_FACTOR = 1.0;
 const double BEES_TOO_LONG = 5.0;
 
 // Avoid any extent where LOGICAL_INO takes this much kernel CPU time
-const double BEES_TOXIC_SYS_DURATION = 0.1;
+const double BEES_TOXIC_SYS_DURATION = 5.0;
 
 // Maximum number of refs to a single extent before we have other problems
 // If we have more than 10K refs to an extent, adding another will save 0.01% space