Thread (7 messages) 7 messages, 5 authors, 2023-09-26

Re: fstrim on raid1 LV with writemostly PV leads to system freeze

From: Kirill Kirilenko <hidden>
Date: 2023-09-25 23:59:08
Also in: dm-devel

Possibly related (same subject, not in this thread)

On 25.09.2023 05:58 +0300, Yu Kuai wrote:
quoted hunk ↗ jump to hunk
Roman and Kirill, can you test the following patch?

Thanks,
Kuai
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 4b30a1742162..4963f864ef99 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1345,6 +1345,7 @@ static void raid1_write_request(struct mddev
*mddev, struct bio *bio,
        int first_clone;
        int max_sectors;
        bool write_behind = false;
+       bool is_discard = (bio_op(bio) == REQ_OP_DISCARD);

        if (mddev_is_clustered(mddev) &&
             md_cluster_ops->area_resyncing(mddev, WRITE,
@@ -1405,7 +1406,7 @@ static void raid1_write_request(struct mddev
*mddev, struct bio *bio,
                 * write-mostly, which means we could allocate write
behind
                 * bio later.
                 */
-               if (rdev && test_bit(WriteMostly, &rdev->flags))
+               if (!is_discard && rdev && test_bit(WriteMostly,
&rdev->flags))
                        write_behind = true;

                if (rdev && unlikely(test_bit(Blocked, &rdev->flags))) {
Thank you. I can confirm, that your patch eliminates freezes during
'fstrim' execution. Tested on kernel 6.5.0.
Still 'fstrim' takes more than 2 minutes, but I believe it's normal to a
file system with 1M+ inodes.

Probably I'm wrong here, but to me this doesn't look like a solution,
more like a masking the real problem.
Even with TRIM operations split in 1MB pieces, I don't expect kernel to
freeze.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help