From patchwork Mon Feb 22 17:07:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 8380481 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7F498C0553 for ; Mon, 22 Feb 2016 17:08:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0AF8204EB for ; Mon, 22 Feb 2016 17:08:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C276D20504 for ; Mon, 22 Feb 2016 17:08:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752681AbcBVRIH (ORCPT ); Mon, 22 Feb 2016 12:08:07 -0500 Received: from casper.infradead.org ([85.118.1.10]:56322 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751049AbcBVRIF (ORCPT ); Mon, 22 Feb 2016 12:08:05 -0500 Received: from [83.175.99.196] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.85 #2 (Red Hat Linux)) id 1aXtxs-0004sm-81; Mon, 22 Feb 2016 17:08:04 +0000 From: Christoph Hellwig To: viro@zeniv.linux.org.uk, axboe@fb.com Cc: milosz@adfin.com, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-api@vger.kernel.org Subject: [PATCH 7/7] block, directio: set a REQ_POLL flag when submitting polled bios Date: Mon, 22 Feb 2016 18:07:56 +0100 Message-Id: <1456160876-14560-8-git-send-email-hch@lst.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456160876-14560-1-git-send-email-hch@lst.de> References: <1456160876-14560-1-git-send-email-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Christoph Hellwig --- block/blk-core.c | 9 +++++++-- fs/direct-io.c | 4 ++++ include/linux/blk_types.h | 2 ++ include/linux/blkdev.h | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index b83d297..81b4b8b 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -3335,13 +3335,18 @@ void blk_finish_plug(struct blk_plug *plug) } EXPORT_SYMBOL(blk_finish_plug); +inline bool blk_queue_can_poll(struct request_queue *q) +{ + return q->mq_ops && q->mq_ops->poll && + test_bit(QUEUE_FLAG_POLL, &q->queue_flags); +} + bool blk_poll(struct request_queue *q, blk_qc_t cookie) { struct blk_plug *plug; long state; - if (!q->mq_ops || !q->mq_ops->poll || !blk_qc_t_valid(cookie) || - !test_bit(QUEUE_FLAG_POLL, &q->queue_flags)) + if (!blk_queue_can_poll(q) || !blk_qc_t_valid(cookie)) return false; plug = current->plug; diff --git a/fs/direct-io.c b/fs/direct-io.c index 0a8d937..ba5ba7e 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -1197,6 +1197,10 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode, dio->inode = inode; dio->rw = iov_iter_rw(iter) == WRITE ? WRITE_ODIRECT : READ; + if ((iocb->ki_flags & IOCB_HIPRI) && + blk_queue_can_poll(bdev_get_queue(bdev))) + dio->rw |= REQ_POLL; + /* * For AIO O_(D)SYNC writes we need to defer completions to a workqueue * so that we can call ->fsync. diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 86a38ea..d667bb4 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -161,6 +161,7 @@ enum rq_flag_bits { __REQ_INTEGRITY, /* I/O includes block integrity payload */ __REQ_FUA, /* forced unit access */ __REQ_FLUSH, /* request for cache flush */ + __REQ_POLL, /* request polling for completion */ /* bio only flags */ __REQ_RAHEAD, /* read ahead, can fail anytime */ @@ -202,6 +203,7 @@ enum rq_flag_bits { #define REQ_WRITE_SAME (1ULL << __REQ_WRITE_SAME) #define REQ_NOIDLE (1ULL << __REQ_NOIDLE) #define REQ_INTEGRITY (1ULL << __REQ_INTEGRITY) +#define REQ_POLL (1ULL << __REQ_POLL) #define REQ_FAILFAST_MASK \ (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 458f6ef..d79353f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -824,6 +824,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_queue_can_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)