dm-delay: fix max_delay calculations
authorBenjamin Marzinski <bmarzins@redhat.com>
Mon, 6 May 2024 21:55:44 +0000 (17:55 -0400)
committerMike Snitzer <snitzer@kernel.org>
Thu, 9 May 2024 13:10:58 +0000 (09:10 -0400)
delay_ctr() pointlessly compared max_delay in cases where multiple delay
classes were initialized identically. Also, when write delays were
configured different than read delays, delay_ctr() never compared their
value against max_delay. Fix these issues.

Fixes: 70bbeb29fab0 ("dm delay: for short delays, use kthread instead of timers and wq")
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-delay.c

index 4ba12d53699499b02a930f8e0be9f536ac555000..2ac43d1f1b92c3774b1ea5aa1cc837e50266852d 100644 (file)
@@ -242,19 +242,18 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
                ret = delay_class_ctr(ti, &dc->flush, argv);
                if (ret)
                        goto bad;
-               max_delay = max(max_delay, dc->write.delay);
-               max_delay = max(max_delay, dc->flush.delay);
                goto out;
        }
 
        ret = delay_class_ctr(ti, &dc->write, argv + 3);
        if (ret)
                goto bad;
+       max_delay = max(max_delay, dc->write.delay);
+
        if (argc == 6) {
                ret = delay_class_ctr(ti, &dc->flush, argv + 3);
                if (ret)
                        goto bad;
-               max_delay = max(max_delay, dc->flush.delay);
                goto out;
        }