From f2646130ae145fb86cfc0333d15aa850a55c5cae Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 30 Oct 2025 14:39:39 -0700 Subject: [PATCH] Don't leak alloc blocks on srch compact error scoutfs_alloc_prepare_commit() is badly named. All it really does is put the references to the two dirty alloc list blocks in the allocator. It must allways be called if allocation was attempted, but it's easier to require that it always be paired with _alloc_init(). If the srch compaction worker in the client sees an error it will send the error back to the server without writing its dirty blocks. In avoiding the write it also avoided putting the two block references, leading to leaked blocks. We've been seeing rare messages with leaked blocks in tests. Signed-off-by: Zach Brown --- kmod/src/srch.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kmod/src/srch.c b/kmod/src/srch.c index 54d437a9..e1b5fb90 100644 --- a/kmod/src/srch.c +++ b/kmod/src/srch.c @@ -2276,12 +2276,11 @@ static void scoutfs_srch_compact_worker(struct work_struct *work) } else { ret = -EINVAL; } - if (ret < 0) - goto commit; - ret = scoutfs_alloc_prepare_commit(sb, &alloc, &wri) ?: + scoutfs_alloc_prepare_commit(sb, &alloc, &wri); + if (ret == 0) scoutfs_block_writer_write(sb, &wri); -commit: + /* the server won't use our partial compact if _ERROR is set */ sc->meta_avail = alloc.avail; sc->meta_freed = alloc.freed;