bcachefs: trans->notrace_relock_fail
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 9 Feb 2023 19:48:54 +0000 (14:48 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:50 +0000 (17:09 -0400)
When we unlock in order to submit IO, the next relock event is likely to
fail if submit_bio() blocked - we shouldn't those events in our _fail
stats, since those are expected events and shouldn't cause test
failures.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_locking.c
fs/bcachefs/btree_types.h
fs/bcachefs/io.c

index 7bb7b5ffe001944747215ff6c4feaab54b70c02c..21f12e522360802b0a64b005a8e7dd6e9b82ac7e 100644 (file)
@@ -2854,8 +2854,10 @@ u32 bch2_trans_begin(struct btree_trans *trans)
                bch2_trans_reset_srcu_lock(trans);
 
        trans->last_restarted_ip = _RET_IP_;
-       if (trans->restarted)
+       if (trans->restarted) {
                bch2_btree_path_traverse_all(trans);
+               trans->notrace_relock_fail = false;
+       }
 
        trans->last_begin_time = local_clock();
        return trans->restart_count;
index 56489e7b0ac25ce2d17e8010e1ec698286a9e3e2..cf138cd9d43192ef8122c1e090916abcea5bd0f2 100644 (file)
@@ -473,7 +473,7 @@ bool __bch2_btree_node_relock(struct btree_trans *trans,
                return true;
        }
 fail:
-       if (trace)
+       if (trace && !trans->notrace_relock_fail)
                trace_and_count(trans->c, btree_path_relock_fail, trans, _RET_IP_, path, level);
        return false;
 }
index 5660d076c678c6c80ae948af518561a4c3e582b9..a815cd5a072ed27eed8dc6e1ada5fc264ac4b93d 100644 (file)
@@ -425,6 +425,7 @@ struct btree_trans {
        bool                    memory_allocation_failure:1;
        bool                    journal_transaction_names:1;
        bool                    journal_replay_not_finished:1;
+       bool                    notrace_relock_fail:1;
        enum bch_errcode        restarted:16;
        u32                     restart_count;
        unsigned long           last_restarted_ip;
index bd55c4b41d7cf2b9317927be8292fafbfb094bfc..b57187ce1f653f831581bb778dbfad4950e4fd5c 100644 (file)
@@ -2375,6 +2375,12 @@ get_bio:
                        else
                                submit_bio_wait(&rbio->bio);
                }
+
+               /*
+                * We just submitted IO which may block, we expect relock fail
+                * events and shouldn't count them:
+                */
+               trans->notrace_relock_fail = true;
        } else {
                /* Attempting reconstruct read: */
                if (bch2_ec_read_extent(c, rbio)) {