Skip to content

Commit 9e55a22

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md/raid1: don't split discard io for write behind
Currently, discad io is treated the same as normal write io, and for write behind case, io size is limited to: BIO_MAX_VECS * (PAGE_SIZE >> 9) For 0.5KB sector size and 4KB PAGE_SIZE, this is just 1MB. For consequence, if 'WriteMostly' is set to one of the underlying disks, then diskcard io will be splited into 1MB and it will take a long time for the diskcard to finish. Fix this problem by disable write behind for discard io. Reported-by: Roman Mamedov <rm@romanrm.net> Closes: https://lore.kernel.org/all/6a1165f7-c792-c054-b8f0-1ad4f7b8ae01@ultracoder.org/ Reported-and-tested-by: Kirill Kirilenko <kirill@ultracoder.org> Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20231007112105.407449-1-yukuai1@huaweicloud.com
1 parent 09f894a commit 9e55a22

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/md/raid1.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
13451345
int first_clone;
13461346
int max_sectors;
13471347
bool write_behind = false;
1348+
bool is_discard = (bio_op(bio) == REQ_OP_DISCARD);
13481349

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

14111412
if (rdev && unlikely(test_bit(Blocked, &rdev->flags))) {

0 commit comments

Comments
 (0)