From 4b777db20be4d9bf1f622194ef2a2f997376b0c1 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 14 Aug 2025 18:26:53 +0100 Subject: [PATCH] accounting: Fix stats (speed=0 and eta=nil) when starting jobs via rc Before this change we used the current context to start the average loop. This means that if the context came from the rc the average loop would be cancelled at the end of the rc request leading the speed not being measured. This uses the background context for the accounting loop so it doesn't get cancelled when its parent gets cancelled. --- fs/accounting/stats.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go index a14c59c55..64f160953 100644 --- a/fs/accounting/stats.go +++ b/fs/accounting/stats.go @@ -368,7 +368,7 @@ func (s *StatsInfo) averageLoop(ctx context.Context) { // Call with the mutex held func (s *StatsInfo) _startAverageLoop() { if !s.average.started { - ctx, cancel := context.WithCancel(s.ctx) + ctx, cancel := context.WithCancel(context.Background()) s.average.cancel = cancel s.average.started = true s.average.stopped.Add(1)