From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: linux-block@vger.kernel.org
Cc: axboe@kernel.dk, shli@kernel.org, Goldwyn Rodrigues <rgoldwyn@suse.com>
Subject: [PATCH 2/9] md: Add nowait support to md
Date: Wed, 4 Oct 2017 08:55:04 -0500 [thread overview]
Message-ID: <20171004135511.26110-3-rgoldwyn@suse.de> (raw)
In-Reply-To: <20171004135511.26110-1-rgoldwyn@suse.de>
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
Set queue flags to QUEUE_FLAG_NOWAIT to indicate REQ_NOWAIT
will be handled. If any of the underlying devices do not support
NOWAIT feature, we do not set the flag.
If the device is suspended, it returns -EWOULDBLOCK.
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
drivers/md/md.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0ff1bbf6c90e..7325f8be36b4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -237,6 +237,19 @@ EXPORT_SYMBOL_GPL(md_new_event);
static LIST_HEAD(all_mddevs);
static DEFINE_SPINLOCK(all_mddevs_lock);
+static bool is_suspended(struct mddev *mddev, struct bio *bio)
+{
+ /* We can serve READ requests when device is suspended */
+ if (bio_data_dir(bio) == READ)
+ return false;
+
+ if (mddev->suspended)
+ return true;
+
+ return (mddev->suspend_lo < bio_end_sector(bio) &&
+ mddev->suspend_hi > bio->bi_iter.bi_sector);
+}
+
/*
* iterates through all used mddevs in the system.
* We take care to grab the all_mddevs_lock whenever navigating
@@ -316,6 +329,11 @@ static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio)
bio_endio(bio);
return BLK_QC_T_NONE;
}
+ /* Bail out if we would have to wait for suspended device */
+ if ((bio->bi_opf & REQ_NOWAIT) && is_suspended(mddev, bio)) {
+ bio_wouldblock_error(bio);
+ return BLK_QC_T_NONE;
+ }
/*
* save the sectors now since our bio can
@@ -5404,6 +5422,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.. */
@@ -5470,8 +5489,15 @@ int md_run(struct mddev *mddev)
}
}
sysfs_notify_dirent_safe(rdev->sysfs_state);
+ if (!blk_queue_supports_nowait(rdev->bdev->bd_queue))
+ nowait = false;
}
+ /* Set the NOWAIT flags if all underlying devices support it */
+ if (nowait)
+ queue_flag_set_unlocked(QUEUE_FLAG_NOWAIT, mddev->queue);
+
+
if (mddev->bio_set == NULL) {
mddev->bio_set = bioset_create(BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
if (!mddev->bio_set)
@@ -6554,6 +6580,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 whole MD */
+ if (!blk_queue_supports_nowait(rdev->bdev->bd_queue)) {
+ pr_info("%s: Disabling nowait because %s does not support nowait\n",
+ mdname(mddev), bdevname(rdev->bdev,b));
+ queue_flag_clear_unlocked(QUEUE_FLAG_NOWAIT, mddev->queue);
+ }
+
/*
* Kick recovery, maybe this spare has to be added to the
* array immediately.
--
2.14.2
next prev parent reply other threads:[~2017-10-04 13:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 13:55 [PATCH v2 0/9] Nowait support for stacked block devices Goldwyn Rodrigues
2017-10-04 13:55 ` [PATCH 1/9] QUEUE_FLAG_NOWAIT to indicate device supports nowait Goldwyn Rodrigues
2017-10-04 13:55 ` Goldwyn Rodrigues [this message]
2017-10-04 13:55 ` [PATCH 3/9] md: raid1 nowait support Goldwyn Rodrigues
2017-10-04 13:55 ` [PATCH 4/9] md: raid10 " Goldwyn Rodrigues
2017-10-04 13:55 ` [PATCH 5/9] md: raid5 " Goldwyn Rodrigues
2017-10-04 13:55 ` [PATCH 6/9] dm: add " Goldwyn Rodrigues
2017-10-04 13:55 ` [PATCH 7/9] dm: Add nowait support to raid1 Goldwyn Rodrigues
2017-10-04 13:55 ` [PATCH 8/9] dm: Add nowait support to dm-delay Goldwyn Rodrigues
2017-10-04 13:55 ` [PATCH 9/9] dm-mpath: Add nowait support Goldwyn Rodrigues
2017-10-05 17:19 ` [PATCH v2 0/9] Nowait support for stacked block devices Shaohua Li
2017-10-06 12:01 ` Goldwyn Rodrigues
2017-10-10 22:36 ` Shaohua Li
-- strict thread matches above, loose matches on Subject: below --
2017-07-26 23:57 [PATCH 0/9] Nowait feature " Goldwyn Rodrigues
2017-07-26 23:57 ` [PATCH 2/9] md: Add nowait support to md Goldwyn Rodrigues
2017-08-08 20:34 ` Shaohua Li
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=20171004135511.26110-3-rgoldwyn@suse.de \
--to=rgoldwyn@suse.de \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=rgoldwyn@suse.com \
--cc=shli@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox