]> git.hungrycats.org Git - bees/commitdiff
context: log when LOGICAL_INO returns 0 refs
authorZygo Blaxell <bees@furryterror.org>
Mon, 8 May 2023 12:09:08 +0000 (08:09 -0400)
committerZygo Blaxell <bees@furryterror.org>
Thu, 6 Jul 2023 16:54:33 +0000 (12:54 -0400)
There was a bug in kernel 6.3 where LOGICAL_INO with IGNORE_OFFSET
sometimes fails to ignore the offset.  That bug is now fixed, but
LOGICAL_INO still returns 0 refs much more often than seems appropriate.

This is most likely because bees frequently deletes extents while there
is still work waiting for them in Task queues.  In this case, LOGICAL_INO
correctly returns an empty list, because every reference to some extent
is deleted, but the new extent tree with that extent removed is not yet
committed in btrfs.

Add a DEBUG-level log message and an event counter to track these events.
In the absence of a kernel bug, the debug message may indicate CPU time
was wasted performing a search whose outcome could have been predicted.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
docs/event-counters.md
src/bees-context.cc

index f74cbdc29ed25db5984fda1cb828a20e0af1814c..3821455e34555a1364914182809c868dc685e67c 100644 (file)
@@ -296,6 +296,7 @@ resolve
 
 The `resolve` event group consists of operations related to translating a btrfs virtual block address (i.e. physical block address) to a `(root, inode, offset)` tuple (i.e. locating and opening the file containing a matching block).  `resolve` is the top level, `chase` and `adjust` are the lower two levels.
 
+ * `resolve_empty`: The `LOGICAL_INO` ioctl returned successfully with an empty reference list (0 items).
  * `resolve_fail`: The `LOGICAL_INO` ioctl returned an error.
  * `resolve_large`: The `LOGICAL_INO` ioctl returned more than 2730 results (the limit of the v1 ioctl).
  * `resolve_ms`: Total time spent in the `LOGICAL_INO` ioctl (i.e. wallclock time, not kernel CPU time).
index 73e2b646b0a9b3598a96fbfb4aba6187c3d89336..36cccc9c718d80e278db908bd50525e1979579db 100644 (file)
@@ -821,6 +821,10 @@ BeesContext::resolve_addr_uncached(BeesAddress addr)
 
        // Avoid performance problems - pretend resolve failed if there are too many refs
        const size_t rv_count = log_ino.m_iors.size();
+       if (!rv_count) {
+               BEESLOGDEBUG("LOGICAL_INO returned 0 refs at " << to_hex(addr));
+               BEESCOUNT(resolve_empty);
+       }
        if (rv_count < BEES_MAX_EXTENT_REF_COUNT) {
                rv.m_biors = vector<BtrfsInodeOffsetRoot>(log_ino.m_iors.begin(), log_ino.m_iors.end());
        } else {