public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
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 1/9] QUEUE_FLAG_NOWAIT to indicate device supports nowait
Date: Wed,  4 Oct 2017 08:55:03 -0500	[thread overview]
Message-ID: <20171004135511.26110-2-rgoldwyn@suse.de> (raw)
In-Reply-To: <20171004135511.26110-1-rgoldwyn@suse.de>

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Nowait is a feature of direct AIO, where users can request
to return immediately if the I/O is going to block. This translates
to REQ_NOWAIT in bio.bi_opf flags. While request based devices
don't wait, stacked devices such as md/dm will.

In order to explicitly mark stacked devices as supported, we
set the QUEUE_FLAG_NOWAIT in the queue_flags and return -EAGAIN
whenever the device would block.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 block/blk-core.c       | 4 ++--
 include/linux/blkdev.h | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 048be4aa6024..8de633f8c633 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2044,10 +2044,10 @@ generic_make_request_checks(struct bio *bio)
 
 	/*
 	 * For a REQ_NOWAIT based request, return -EOPNOTSUPP
-	 * if queue is not a request based queue.
+	 * if queue cannot handle nowait bio's
 	 */
 
-	if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_rq_based(q))
+	if ((bio->bi_opf & REQ_NOWAIT) && !blk_queue_supports_nowait(q))
 		goto not_supported;
 
 	if (should_fail_request(&bio->bi_disk->part0, bio->bi_iter.bi_size))
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 02fa42d24b52..1d0da2a9cf46 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -631,6 +631,7 @@ struct request_queue {
 #define QUEUE_FLAG_REGISTERED  26	/* queue has been registered to a disk */
 #define QUEUE_FLAG_SCSI_PASSTHROUGH 27	/* queue supports SCSI commands */
 #define QUEUE_FLAG_QUIESCED    28	/* queue has been quiesced */
+#define QUEUE_FLAG_NOWAIT      29	/* stack device driver supports REQ_NOWAIT */
 
 #define QUEUE_FLAG_DEFAULT	((1 << QUEUE_FLAG_IO_STAT) |		\
 				 (1 << QUEUE_FLAG_STACKABLE)	|	\
@@ -759,6 +760,11 @@ static inline bool queue_is_rq_based(struct request_queue *q)
 	return q->request_fn || q->mq_ops;
 }
 
+static inline bool blk_queue_supports_nowait(struct request_queue *q)
+{
+	return queue_is_rq_based(q) || test_bit(QUEUE_FLAG_NOWAIT, &q->queue_flags);
+}
+
 static inline unsigned int blk_queue_cluster(struct request_queue *q)
 {
 	return q->limits.cluster;
-- 
2.14.2

  reply	other threads:[~2017-10-04 13:55 UTC|newest]

Thread overview: 35+ 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 ` Goldwyn Rodrigues [this message]
2017-10-04 13:55 ` [PATCH 2/9] md: Add nowait support to md Goldwyn Rodrigues
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 1/9] QUEUE_FLAG_NOWAIT to indicate device supports nowait Goldwyn Rodrigues
2017-08-08 20:32   ` Shaohua Li
2017-08-08 20:36     ` Jens Axboe
2017-08-10  2:18       ` Jens Axboe
2017-08-10 11:38         ` Goldwyn Rodrigues
2017-08-10 14:14           ` Jens Axboe
2017-08-10 17:15             ` Goldwyn Rodrigues
2017-08-10 17:17               ` Jens Axboe
2017-08-09 11:44     ` Goldwyn Rodrigues
2017-08-09 15:02       ` Shaohua Li
2017-08-09 15:35         ` Goldwyn Rodrigues
2017-08-09 20:21           ` Shaohua Li
2017-08-09 22:16             ` Goldwyn Rodrigues
2017-08-10  1:17               ` Shaohua Li
2017-08-10  2:07                 ` Goldwyn Rodrigues
2017-08-10  2:17                   ` Jens Axboe
2017-08-10 11:49                     ` Goldwyn Rodrigues
2017-08-10 14:23                       ` Jens Axboe
2017-08-10 14:25                       ` Jan Kara
2017-08-10 14:28                         ` Jens Axboe
2017-08-10 17:15                           ` Goldwyn Rodrigues
2017-08-10 17:20                             ` Jens Axboe

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-2-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