Skip to content

Commit 8c13ab1

Browse files
Guoqing Jiangliu-song-6
authored andcommitted
md/bitmap: don't set max_write_behind if there is no write mostly device
We shouldn't set it since write behind IO should only happen to write mostly device. Signed-off-by: Guoqing Jiang <[email protected]> Signed-off-by: Song Liu <[email protected]>
1 parent e2daec4 commit 8c13ab1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/md/md-bitmap.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,11 +2469,30 @@ backlog_store(struct mddev *mddev, const char *buf, size_t len)
24692469
{
24702470
unsigned long backlog;
24712471
unsigned long old_mwb = mddev->bitmap_info.max_write_behind;
2472+
struct md_rdev *rdev;
2473+
bool has_write_mostly = false;
24722474
int rv = kstrtoul(buf, 10, &backlog);
24732475
if (rv)
24742476
return rv;
24752477
if (backlog > COUNTER_MAX)
24762478
return -EINVAL;
2479+
2480+
/*
2481+
* Without write mostly device, it doesn't make sense to set
2482+
* backlog for max_write_behind.
2483+
*/
2484+
rdev_for_each(rdev, mddev) {
2485+
if (test_bit(WriteMostly, &rdev->flags)) {
2486+
has_write_mostly = true;
2487+
break;
2488+
}
2489+
}
2490+
if (!has_write_mostly) {
2491+
pr_warn_ratelimited("%s: can't set backlog, no write mostly device available\n",
2492+
mdname(mddev));
2493+
return -EINVAL;
2494+
}
2495+
24772496
mddev->bitmap_info.max_write_behind = backlog;
24782497
if (!backlog && mddev->serial_info_pool) {
24792498
/* serial_info_pool is not needed if backlog is zero */

0 commit comments

Comments
 (0)