All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vishal Verma <vverma@digitalocean.com>
To: song@kernel.org, linux-raid@vger.kernel.org
Cc: axboe@kernel.dk, rgoldwyn@suse.de,
	Vishal Verma <vverma@digitalocean.com>
Subject: [PATCH v5 1/4] md: add support for REQ_NOWAIT
Date: Wed, 15 Dec 2021 06:09:03 +0000	[thread overview]
Message-ID: <20211215060906.3230-1-vverma@digitalocean.com> (raw)
In-Reply-To: <CAPhsuW7OY+5-F6Vk6z=ngSMXEayz3si=Sdf69r4vexRo202X_Q@mail.gmail.com>

commit 021a24460dc2 ("block: add QUEUE_FLAG_NOWAIT") added support
for checking whether a given bdev supports handling of REQ_NOWAIT or not.
Since then commit 6abc49468eea ("dm: add support for REQ_NOWAIT and enable
it for linear target") added support for REQ_NOWAIT for dm. This uses
a similar approach to incorporate REQ_NOWAIT for md based bios.

This patch was tested using t/io_uring tool within FIO. A nvme drive
was partitioned into 2 partitions and a simple raid 0 configuration
/dev/md0 was created.

md0 : active raid0 nvme4n1p1[1] nvme4n1p2[0]
  937423872 blocks super 1.2 512k chunks

Before patch:

$ ./t/io_uring /dev/md0 -p 0 -a 0 -d 1 -r 100

Running top while the above runs:

$ ps -eL | grep $(pidof io_uring)

38396   38396 pts/2    00:00:00 io_uring
38396   38397 pts/2    00:00:15 io_uring
38396   38398 pts/2    00:00:13 iou-wrk-38397

We can see iou-wrk-38397 io worker thread created which gets created
when io_uring sees that the underlying device (/dev/md0 in this case)
doesn't support nowait.

After patch:

$ ./t/io_uring /dev/md0 -p 0 -a 0 -d 1 -r 100

Running top while the above runs:

$ ps -eL | grep $(pidof io_uring)

38341   38341 pts/2    00:10:22 io_uring
38341   38342 pts/2    00:10:37 io_uring

After running this patch, we don't see any io worker thread
being created which indicated that io_uring saw that the
underlying device does support nowait. This is the exact behaviour
noticed on a dm device which also supports nowait.

For all the other raid personalities except raid0, we would need
to train pieces which involves make_request fn in order for them
to correctly handle REQ_NOWAIT.

Signed-off-by: Vishal Verma <vverma@digitalocean.com>
---
 drivers/md/md.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7fbf6f0ac01b..5b4c28e0e1db 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -419,6 +419,12 @@ void md_handle_request(struct mddev *mddev, struct bio *bio)
 	if (is_suspended(mddev, bio)) {
 		DEFINE_WAIT(__wait);
 		for (;;) {
+			/* Bail out if REQ_NOWAIT is set for the bio */
+			if (bio->bi_opf & REQ_NOWAIT) {
+				rcu_read_unlock();
+				bio_wouldblock_error(bio);
+				return;
+			}
 			prepare_to_wait(&mddev->sb_wait, &__wait,
 					TASK_UNINTERRUPTIBLE);
 			if (!is_suspended(mddev, bio))
@@ -5787,6 +5793,7 @@ int md_run(struct mddev *mddev)
 	int err;
 	struct md_rdev *rdev;
 	struct md_personality *pers;
+	bool nowait = true;
 
 	if (list_empty(&mddev->disks))
 		/* cannot run an array with no devices.. */
@@ -5857,8 +5864,13 @@ int md_run(struct mddev *mddev)
 			}
 		}
 		sysfs_notify_dirent_safe(rdev->sysfs_state);
+		nowait = nowait && blk_queue_nowait(bdev_get_queue(rdev->bdev));
 	}
 
+	/* Set the NOWAIT flags if all underlying devices support it */
+	if (nowait)
+		blk_queue_flag_set(QUEUE_FLAG_NOWAIT, mddev->queue);
+
 	if (!bioset_initialized(&mddev->bio_set)) {
 		err = bioset_init(&mddev->bio_set, BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
 		if (err)
@@ -7002,6 +7014,15 @@ static int hot_add_disk(struct mddev *mddev, dev_t dev)
 	set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags);
 	if (!mddev->thread)
 		md_update_sb(mddev, 1);
+	/*
+	 * If the new disk does not support REQ_NOWAIT,
+	 * disable on the whole MD.
+	 */
+	if (!blk_queue_nowait(bdev_get_queue(rdev->bdev))) {
+		pr_info("%s: Disabling nowait because %s does not support nowait\n",
+			mdname(mddev), bdevname(rdev->bdev, b));
+		blk_queue_flag_clear(QUEUE_FLAG_NOWAIT, mddev->queue);
+	}
 	/*
 	 * Kick recovery, maybe this spare has to be added to the
 	 * array immediately.
-- 
2.17.1


  parent reply	other threads:[~2021-12-15  6:09 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 21:51 [PATCH] md: add support for REQ_NOWAIT Vishal Verma
2021-11-02  3:41 ` Li Feng
2021-11-02  5:01 ` Song Liu
2021-11-02 14:40   ` [PATCH v2] " Vishal Verma
2021-11-02 15:31     ` Jens Axboe
2021-11-02 18:35     ` Song Liu
2021-11-04  4:51       ` [PATCH v3 2/2] md: raid1 add nowait support Vishal Verma
2021-11-04  4:51         ` [PATCH v3 1/2] md: add support for REQ_NOWAIT Vishal Verma
2021-11-06 15:38           ` Guoqing Jiang
2021-11-07  0:16             ` Vishal Verma
2021-11-08 22:17           ` Song Liu
2021-11-08 22:36             ` Vishal Verma
2021-11-06 15:24         ` [PATCH v3 2/2] md: raid1 add nowait support Guoqing Jiang
2021-11-07  0:18           ` Vishal Verma
2021-11-08 22:32         ` Song Liu
2021-11-08 22:39           ` Vishal Verma
2021-11-09 20:59             ` Vishal Verma
2021-11-10 17:02               ` Song Liu
2021-11-10 17:04                 ` Vishal Verma
2021-11-10 18:14           ` [RFC PATCH v4 1/4] md: add support for REQ_NOWAIT Vishal Verma
2021-11-10 18:14             ` [RFC PATCH v4 2/4] md: raid1 add nowait support Vishal Verma
2021-11-10 18:14             ` [RFC PATCH v4 3/4] md: raid10 " Vishal Verma
2021-12-14  0:32               ` Song Liu
2021-12-14 15:27                 ` Vishal Verma
2021-11-10 18:14             ` [RFC PATCH v4 4/4] md: raid456 " Vishal Verma
2021-11-11 21:42               ` Song Liu
     [not found]                 ` <f8c2a2bc-a885-8254-2b39-fc0c969ac70d@digitalocean.com>
2021-11-19  4:07                   ` Song Liu
2021-11-19  4:20                     ` Vishal Verma
2021-12-09 16:53                     ` Vishal Verma
2021-12-09 16:59                       ` Song Liu
2021-12-09 17:01                         ` Vishal Verma
2021-12-10  2:16               ` Song Liu
2021-12-10  7:18                 ` Song Liu
2021-12-10 18:26                 ` Vishal Verma
2021-12-13  5:56                   ` Song Liu
2021-12-13 22:43                     ` Vishal Verma
2021-12-13 23:35                       ` Jens Axboe
     [not found]                         ` <78d5f029-791e-6d3f-4871-263ec6b5c09b@digitalocean.com>
2021-12-14  1:11                           ` Song Liu
2021-12-14  1:12                             ` Vishal Verma
2021-12-14 15:30                               ` Vishal Verma
2021-12-14 17:08                                 ` Song Liu
2021-12-14 18:09                                   ` Vishal Verma
2021-12-15  6:09                                   ` Vishal Verma [this message]
2021-12-15  6:09                                     ` [PATCH v5 2/4] md: raid1 " Vishal Verma
2021-12-15 20:33                                       ` Song Liu
2021-12-15 22:20                                         ` Vishal Verma
2021-12-21 20:06                                           ` [PATCH v6 1/4] md: add support for REQ_NOWAIT Vishal Verma
2021-12-21 20:06                                             ` [PATCH v6 2/4] md: raid1 add nowait support Vishal Verma
2021-12-21 20:06                                             ` [PATCH v6 3/4] md: raid10 " Vishal Verma
2021-12-22 23:58                                               ` Song Liu
2021-12-23  1:47                                               ` Song Liu
2021-12-21 20:06                                             ` [PATCH v6 4/4] md: raid456 " Vishal Verma
2021-12-21 22:02                                               ` John Stoffel
2021-12-25  2:14                                               ` Song Liu
     [not found]                                                 ` <aadc6d52-bc6e-527a-3b9c-0be225f9b727@digitalocean.com>
2021-12-25 22:13                                                   ` Vishal Verma
2021-12-26  0:07                                                     ` Song Liu
2021-12-26  4:02                                                       ` Vishal Verma
2021-12-26 21:20                                                         ` Vishal Verma
2021-12-22 16:06                                             ` [PATCH v6 1/4] md: add support for REQ_NOWAIT Jens Axboe
2021-12-23  1:22                                             ` Song Liu
2021-12-23  2:57                                             ` Song Liu
2021-12-23  3:08                                               ` Vishal Verma
2022-01-02  0:11                                               ` Song Liu
2022-01-02  2:08                                                 ` Vishal Verma
2021-12-23  8:36                                             ` Christoph Hellwig
2021-12-15  6:09                                     ` [PATCH v5 3/4] md: raid10 add nowait support Vishal Verma
2021-12-15 20:42                                       ` Song Liu
2021-12-15 22:20                                         ` Vishal Verma
2021-12-16  0:30                                           ` Vishal Verma
2021-12-16 16:40                                             ` Vishal Verma
2021-12-16 16:42                                             ` Jens Axboe
2021-12-16 16:45                                               ` Vishal Verma
2021-12-16 18:49                                                 ` Jens Axboe
2021-12-16 19:40                                                   ` Vishal Verma
2021-12-16 20:18                                                     ` Song Liu
2021-12-16 20:37                                                       ` Vishal Verma
2021-12-16 23:50                                                         ` Song Liu
     [not found]                                                           ` <bd90d6e6-adb4-2696-3110-fad0b1ee00dc@digitalocean.com>
2021-12-21  8:13                                                             ` Song Liu
2021-12-21 15:29                                                               ` Vishal Verma
2021-12-21 15:59                                                                 ` Jens Axboe
2021-12-21 16:26                                                                   ` Vishal Verma
2021-12-16 18:14                                               ` Vishal Verma
2021-12-15  6:09                                     ` [PATCH v5 4/4] md: raid456 " Vishal Verma
2021-12-15 20:02                                     ` [PATCH v5 1/4] md: add support for REQ_NOWAIT Song Liu
2021-12-14  0:36                       ` [RFC PATCH v4 4/4] md: raid456 add nowait support Song Liu
2021-12-13 23:50             ` [RFC PATCH v4 1/4] md: add support for REQ_NOWAIT Song Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211215060906.3230-1-vverma@digitalocean.com \
    --to=vverma@digitalocean.com \
    --cc=axboe@kernel.dk \
    --cc=linux-raid@vger.kernel.org \
    --cc=rgoldwyn@suse.de \
    --cc=song@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.