Returns EAGAIN in case the raid456 driver would block waiting for situations like: - Reshape operation, - Discard operation. Signed-off-by: Vishal Verma <vverma@xxxxxxxxxxxxxxxx> --- drivers/md/raid5.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 9c1a5877cf9f..fa64ee315241 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -5710,6 +5710,11 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi) int d; again: sh = raid5_get_active_stripe(conf, logical_sector, 0, 0, 0); + /* Bail out if REQ_NOWAIT is set */ + if (bi->bi_opf & REQ_NOWAIT) { + bio_wouldblock_error(bi); + return; + } prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE); set_bit(R5_Overlap, &sh->dev[sh->pd_idx].flags); @@ -5820,6 +5825,15 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi) bi->bi_next = NULL; md_account_bio(mddev, &bi); + /* Bail out if REQ_NOWAIT is set */ + if (bi->bi_opf & REQ_NOWAIT && + conf->reshape_progress != MaxSector && + mddev->reshape_backwards + ? logical_sector < conf->reshape_safe + : logical_sector >= conf->reshape_safe) { + bio_wouldblock_error(bi); + return true; + } prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE); for (; logical_sector < last_sector; logical_sector += RAID5_STRIPE_SECTORS(conf)) { int previous; -- 2.17.1