[PATCH] md/raid5: allow discard with llbitmap
Yu Kuai <[email protected]>
| Newsgroups | gmane.linux.raid,gmane.linux.kernel |
|---|---|
| Message-ID | <[email protected]> |
From: Yu Kuai <[email protected]> Raid5 disables discard unless devices_handle_discard_safely is set because lower devices that do not return zeroes after discard can leave a discarded stripe inconsistent. A later partial write can then reconstruct bad data if a member fails. The legacy bitmap needs this restriction because it only records write-intent dirty ranges. It cannot distinguish discarded data from valid data, so discard can make data inconsistent after later partial writes and failures. llbitmap records discarded ranges as unwritten. Raid5 already consults llbitmap state to force RCW or lazy recovery before using parity for unwritten data. Therefore non-zeroing discard is safe with llbitmap while the existing full-stripe granularity and lower-device discard-size checks still apply. Signed-off-by: Yu Kuai <[email protected]> --- drivers/md/raid5.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index debf35342ae0..4e9a758a8cc9 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -7829,11 +7829,12 @@ static int raid5_set_limits(struct mddev *mddev) * We only allow DISCARD if the sysadmin has confirmed that only safe * devices are in use by setting a module parameter. A better idea * might be to turn DISCARD into WRITE_ZEROES requests, as that is * required to be safe. */ - if (!devices_handle_discard_safely || + if ((!devices_handle_discard_safely && + mddev->bitmap_id != ID_LLBITMAP) || lim.max_discard_sectors < (stripe >> 9) || lim.discard_granularity < stripe) lim.max_hw_discard_sectors = 0; /* -- 2.51.0