From 6f8a81d2ef160d2aa9cae9fe9b5f2316605278ce Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Fri, 20 Jun 2025 15:08:44 -0700 Subject: [PATCH] Avoid trigger munching of block_remove_stale trigger. It's entirely likely that the trigger here is munched by a read on a dirty block from any unrelated or background read. Avoid that by putting the trigger at the end of the condition list. Now that the order is swapped, we have to avoid a null deref in block_is_dirty(bp) here, as well. Signed-off-by: Auke Kok --- kmod/src/block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kmod/src/block.c b/kmod/src/block.c index 9eaba500..e44a98a7 100644 --- a/kmod/src/block.c +++ b/kmod/src/block.c @@ -712,8 +712,8 @@ retry: ret = 0; out: - if ((ret == -ESTALE || scoutfs_trigger(sb, BLOCK_REMOVE_STALE)) && - !retried && !block_is_dirty(bp)) { + if (!retried && !IS_ERR_OR_NULL(bp) && !block_is_dirty(bp) && + (ret == -ESTALE || scoutfs_trigger(sb, BLOCK_REMOVE_STALE))) { retried = true; scoutfs_inc_counter(sb, block_cache_remove_stale); block_remove(sb, bp);