Thread (34 messages) 34 messages, 5 authors, 2021-12-14

[RFC PATCH v4 4/4] md: raid456 add nowait support

flat view
STALE1766d

From: Vishal Verma <hidden>
Date: 2021-11-10 18:15:12
Subsystem: software raid (multiple disks) support, the rest · Maintainers: Song Liu, Yu Kuai, Linus Torvalds

Returns EAGAIN in case the raid456 driver would block
waiting for situations like:

  - Reshape operation,
  - Discard operation.

Signed-off-by: Vishal Verma <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help