summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorVishal Verma <vverma@digitalocean.com>2021-12-21 20:06:22 +0000
committerSong Liu <song@kernel.org>2022-01-06 08:37:02 -0800
commitbf2c411bb1cfc45f73eb6c55b5755bcb990063ae (patch)
tree1a9a8189222bbd8f82f0436856c18dc5f6432b63 /drivers/md
parentc9aa889b035fca4598ae985a0f0c76ebbb547ad2 (diff)
downloadlwn-bf2c411bb1cfc45f73eb6c55b5755bcb990063ae.tar.gz
lwn-bf2c411bb1cfc45f73eb6c55b5755bcb990063ae.zip
md: raid456 add nowait support
Returns EAGAIN in case the raid456 driver would block waiting for reshape. Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Vishal Verma <vverma@digitalocean.com> Signed-off-by: Song Liu <song@kernel.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/raid5.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 1240a5c16af8..beb544be9058 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5686,6 +5686,10 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
struct stripe_head *sh;
int stripe_sectors;
+ /* We need to handle this when io_uring supports discard/trim */
+ if (WARN_ON_ONCE(bi->bi_opf & REQ_NOWAIT))
+ return;
+
if (mddev->reshape_position != MaxSector)
/* Skip discard while reshape is happening */
return;
@@ -5819,6 +5823,17 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
last_sector = bio_end_sector(bi);
bi->bi_next = NULL;
+ /* Bail out if conflicts with reshape and REQ_NOWAIT is set */
+ if ((bi->bi_opf & REQ_NOWAIT) &&
+ (conf->reshape_progress != MaxSector) &&
+ (mddev->reshape_backwards
+ ? (logical_sector > conf->reshape_progress && logical_sector <= conf->reshape_safe)
+ : (logical_sector >= conf->reshape_safe && logical_sector < conf->reshape_progress))) {
+ bio_wouldblock_error(bi);
+ if (rw == WRITE)
+ md_write_end(mddev);
+ return true;
+ }
md_account_bio(mddev, &bi);
prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE);
for (; logical_sector < last_sector; logical_sector += RAID5_STRIPE_SECTORS(conf)) {