From: jonathan.derrick@intel.com (Jon Derrick)
Subject: [PATCH 1/2] block: add queue flag to always poll
Date: Thu, 31 Mar 2016 14:19:13 -0600 [thread overview]
Message-ID: <1459455554-2794-2-git-send-email-jonathan.derrick@intel.com> (raw)
In-Reply-To: <1459455554-2794-1-git-send-email-jonathan.derrick@intel.com>
This patch adds poll-by-default functionality back for 4.6 by adding a
queue flag which specifies that it should always try polling, rather
than only if the io specifies it.
Signed-off-by: Jon Derrick <jonathan.derrick at intel.com>
---
block/blk-core.c | 8 ++++++++
fs/direct-io.c | 7 ++++++-
include/linux/blkdev.h | 2 ++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 827f8ba..d85f913 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -3335,6 +3335,14 @@ void blk_finish_plug(struct blk_plug *plug)
}
EXPORT_SYMBOL(blk_finish_plug);
+bool blk_force_poll(struct request_queue *q)
+{
+ if (!q->mq_ops || !q->mq_ops->poll ||
+ !test_bit(QUEUE_FLAG_POLL_FORCE, &q->queue_flags))
+ return false;
+ return true;
+}
+
bool blk_poll(struct request_queue *q, blk_qc_t cookie)
{
struct blk_plug *plug;
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 476f1ec..2775552 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -450,7 +450,12 @@ static struct bio *dio_await_one(struct dio *dio)
__set_current_state(TASK_UNINTERRUPTIBLE);
dio->waiter = current;
spin_unlock_irqrestore(&dio->bio_lock, flags);
- if (!(dio->iocb->ki_flags & IOCB_HIPRI) ||
+ /*
+ * Polling must be enabled explicitly on a per-IO basis,
+ * or through the queue's sysfs io_poll_force control
+ */
+ if (!((dio->iocb->ki_flags & IOCB_HIPRI) ||
+ (blk_force_poll(bdev_get_queue(dio->bio_bdev)))) ||
!blk_poll(bdev_get_queue(dio->bio_bdev), dio->bio_cookie))
io_schedule();
/* wake up sets us TASK_RUNNING */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 7e5d7e0..e87ef17 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -491,6 +491,7 @@ struct request_queue {
#define QUEUE_FLAG_INIT_DONE 20 /* queue is initialized */
#define QUEUE_FLAG_NO_SG_MERGE 21 /* don't attempt to merge SG segments*/
#define QUEUE_FLAG_POLL 22 /* IO polling enabled if set */
+#define QUEUE_FLAG_POLL_FORCE 23 /* IO polling forced if set */
#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
(1 << QUEUE_FLAG_STACKABLE) | \
@@ -824,6 +825,7 @@ extern int blk_execute_rq(struct request_queue *, struct gendisk *,
extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
struct request *, int, rq_end_io_fn *);
+bool blk_force_poll(struct request_queue *q);
bool blk_poll(struct request_queue *q, blk_qc_t cookie);
static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
--
2.5.0
next prev parent reply other threads:[~2016-03-31 20:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-31 20:19 [PATCH 0/2] Block: Give option to force io polling Jon Derrick
2016-03-31 20:19 ` Jon Derrick [this message]
2016-05-05 21:23 ` [PATCH 1/2] block: add queue flag to always poll Jeff Moyer
2016-05-05 21:34 ` Jon Derrick
2016-03-31 20:19 ` [PATCH 2/2] block: add forced polling sysfs controls Jon Derrick
2016-04-05 12:38 ` [PATCH 0/2] Block: Give option to force io polling Christoph Hellwig
2016-04-05 15:54 ` Keith Busch
2016-04-05 17:27 ` Christoph Hellwig
2016-04-05 18:07 ` Stephen Bates
2016-05-05 19:44 ` Stephen Bates
2016-05-08 9:02 ` hch
2016-05-09 14:53 ` Stephen Bates
2016-05-12 7:08 ` hch
2016-05-12 17:27 ` Stephen Bates
2016-05-12 17:34 ` Derrick, Jonathan
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=1459455554-2794-2-git-send-email-jonathan.derrick@intel.com \
--to=jonathan.derrick@intel.com \
/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