diff --unified --recursive --text archlinux-linux/drivers/md/raid1.c archlinux-linux-diff/drivers/md/raid1.c --- archlinux-linux/drivers/md/raid1.c 2021-09-24 14:37:15.347771866 +0200 +++ archlinux-linux-diff/drivers/md/raid1.c 2021-09-24 14:40:02.443978319 +0200 @@ -1501,7 +1501,7 @@ * Not if there are too many, or cannot * allocate memory, or a reader on WriteMostly * is waiting for behind writes to flush */ - if (bitmap && + if (bitmap && write_behind && (atomic_read(&bitmap->behind_writes) < mddev->bitmap_info.max_write_behind) && !waitqueue_active(&bitmap->behind_wait)) { diff --unified --recursive --text archlinux-linux/drivers/md/raid1.c archlinux-linux-changed/drivers/md/raid1.c --- archlinux-linux/drivers/md/raid1.c 2021-09-24 15:43:22.842680119 +0200 +++ archlinux-linux-changed/drivers/md/raid1.c 2021-09-24 15:43:59.426142955 +0200 @@ -1329,7 +1329,6 @@ struct raid1_plug_cb *plug = NULL; int first_clone; int max_sectors; - bool write_behind = false; if (mddev_is_clustered(mddev) && md_cluster_ops->area_resyncing(mddev, WRITE, @@ -1383,14 +1382,6 @@ for (i = 0; i < disks; i++) { struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev); - /* - * The write-behind io is only attempted on drives marked as - * write-mostly, which means we could allocate write behind - * bio later. - */ - if (rdev && test_bit(WriteMostly, &rdev->flags)) - write_behind = true; - if (rdev && unlikely(test_bit(Blocked, &rdev->flags))) { atomic_inc(&rdev->nr_pending); blocked_rdev = rdev; @@ -1470,7 +1461,7 @@ * at a time and thus needs a new bio that can fit the whole payload * this bio in page sized chunks. */ - if (write_behind && bitmap) + if (bitmap) max_sectors = min_t(int, max_sectors, BIO_MAX_VECS * (PAGE_SIZE >> 9)); if (max_sectors < bio_sectors(bio)) { @@ -1501,7 +1492,7 @@ * Not if there are too many, or cannot * allocate memory, or a reader on WriteMostly * is waiting for behind writes to flush */ - if (bitmap && + if (bitmap && (atomic_read(&bitmap->behind_writes) < mddev->bitmap_info.max_write_behind) && !waitqueue_active(&bitmap->behind_wait)) {