cleanerd: apply missing fix for swapped segment count reduction

In 'nilfs_cleanerd_reduce_nsegs_per_step()', the logic to halve the
number of segments to clean was swapped between the manual mode and
the daemon mode.  When 'running' is 2 (manual mode), it incorrectly
reduced 'nsegs_per_step' instead of 'mm_nsegs_per_step', and vice
versa for the daemon mode.

Correct this so that the variable corresponding to the current mode is
properly updated when retrying.

This patch applies a fix originally proposed for v2.2.7 but missed.
Here is the original proposal:

    Bugfix for nilfs-utils-2.2.7 reduce_ncleansegs_for_retry()

    I think I've found a bug in nilfs-utils 2.2.7 when the number of
    segments to clean per pass is halfed in respons to a memory
    shortage. if cleanerd->running == 2 it is a manual run, and thus
    it should be mm_ncleansegs that is reduced.

    /Tommy

[ ryusuke: reflected changes to variable names ]
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
This commit is contained in:
Tommy Pettersson 2026-01-25 14:07:23 +09:00 committed by Ryusuke Konishi
parent 4115aebf9f
commit 77377af5b2

View File

@ -600,11 +600,11 @@ static void
nilfs_cleanerd_reduce_nsegs_per_step(struct nilfs_cleanerd *cleanerd)
{
if (cleanerd->running == 2) {
if (cleanerd->nsegs_per_step > 1)
cleanerd->nsegs_per_step >>= 1;
} else {
if (cleanerd->mm_nsegs_per_step > 1)
cleanerd->mm_nsegs_per_step >>= 1;
} else {
if (cleanerd->nsegs_per_step > 1)
cleanerd->nsegs_per_step >>= 1;
}
}