[Devel] [PATCH vz10] dm-ploop: fix inverted nr_deltas check disabling construction-time prealloc
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Mon Jun 15 16:19:17 MSK 2026
Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
On 6/4/26 11:25, Konstantin Khorenko wrote:
> The read-only guard added to ploop_ctr() also accidentally negated the
> existing nr_deltas clause:
>
> - if (ploop->nr_deltas > 0)
> + if (!ploop_is_ro(ploop) && !(ploop->nr_deltas > 0))
> ploop_should_prealloc(ploop);
>
> At this point ploop->nr_deltas is always >= 1 (ploop_add_deltas_stack()
> just above returns -EINVAL for argc < 1 and otherwise sets nr_deltas =
> argc, and ploop_ctr() rejects argc <= 0 earlier), so "nr_deltas > 0" is
> always true and "!(nr_deltas > 0)" is always false. The whole condition
> is therefore always false and ploop_should_prealloc() is never called -
> for writable devices too, contrary to the commit's intent ("skip prealloc
> for read-only, keep it for RW").
>
> Drop the spurious inner negation so prealloc is enabled for RW devices
> with deltas and skipped only for read-only ones. (Runtime allocation-path
> prealloc was unaffected; this only restores eager construction-time
> preallocation.)
>
> Fixes: f268061806e5 ("dm-ploop: dont preallocate clusters for read only table")
> https://virtuozzo.atlassian.net/browse/VSTOR-132310
> Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
> ---
> drivers/md/dm-ploop-target.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
> index af0925712194..0de0e84d440d 100644
> --- a/drivers/md/dm-ploop-target.c
> +++ b/drivers/md/dm-ploop-target.c
> @@ -635,7 +635,7 @@ static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
> ti->num_discard_bios = 1;
> ti->discards_supported = true;
>
> - if (!ploop_is_ro(ploop) && !(ploop->nr_deltas > 0))
> + if (!ploop_is_ro(ploop) && ploop->nr_deltas > 0)
> ploop_should_prealloc(ploop);
>
> return 0;
--
Best regards, Pavel Tikhomirov
Senior Software Developer, Virtuozzo.
More information about the Devel
mailing list