From patchwork Wed Sep 27 05:48:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9973071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6118760375 for ; Wed, 27 Sep 2017 05:51:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 523682906F for ; Wed, 27 Sep 2017 05:51:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46FB02909D; Wed, 27 Sep 2017 05:51:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7D352906F for ; Wed, 27 Sep 2017 05:51:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752178AbdI0Fvi (ORCPT ); Wed, 27 Sep 2017 01:51:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51002 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751396AbdI0Fvd (ORCPT ); Wed, 27 Sep 2017 01:51:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B97C7C047B8A; Wed, 27 Sep 2017 05:51:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B97C7C047B8A Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ming.lei@redhat.com Received: from localhost (ovpn-12-112.pek2.redhat.com [10.72.12.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BEC57B9D8; Wed, 27 Sep 2017 05:51:23 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , linux-scsi@vger.kernel.org, "Martin K . Petersen" , "James E . J . Bottomley" Cc: Bart Van Assche , Oleksandr Natalenko , Johannes Thumshirn , Cathy Avery , Martin Steigerwald , Ming Lei Subject: [PATCH V6 3/6] block: pass flags to blk_queue_enter() Date: Wed, 27 Sep 2017 13:48:50 +0800 Message-Id: <20170927054853.6647-4-ming.lei@redhat.com> In-Reply-To: <20170927054853.6647-1-ming.lei@redhat.com> References: <20170927054853.6647-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 27 Sep 2017 05:51:32 +0000 (UTC) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to pass PREEMPT flags to blk_queue_enter() for allocating request with RQF_PREEMPT in the following patch. Signed-off-by: Ming Lei --- block/blk-core.c | 10 ++++++---- block/blk-mq.c | 5 +++-- block/blk-timeout.c | 2 +- fs/block_dev.c | 4 ++-- include/linux/blkdev.h | 7 ++++++- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index abfba798ee03..be17b5bcf6e7 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -766,7 +766,7 @@ struct request_queue *blk_alloc_queue(gfp_t gfp_mask) } EXPORT_SYMBOL(blk_alloc_queue); -int blk_queue_enter(struct request_queue *q, bool nowait) +int blk_queue_enter(struct request_queue *q, unsigned flags) { while (true) { int ret; @@ -774,7 +774,7 @@ int blk_queue_enter(struct request_queue *q, bool nowait) if (percpu_ref_tryget_live(&q->q_usage_counter)) return 0; - if (nowait) + if (flags & BLK_REQ_NOWAIT) return -EBUSY; /* @@ -1405,7 +1405,8 @@ static struct request *blk_old_get_request(struct request_queue *q, /* create ioc upfront */ create_io_context(gfp_mask, q->node); - ret = blk_queue_enter(q, !(gfp_mask & __GFP_DIRECT_RECLAIM)); + ret = blk_queue_enter(q, !(gfp_mask & __GFP_DIRECT_RECLAIM) ? + BLK_REQ_NOWAIT : 0); if (ret) return ERR_PTR(ret); spin_lock_irq(q->queue_lock); @@ -2212,7 +2213,8 @@ blk_qc_t generic_make_request(struct bio *bio) do { struct request_queue *q = bio->bi_disk->queue; - if (likely(blk_queue_enter(q, bio->bi_opf & REQ_NOWAIT) == 0)) { + if (likely(blk_queue_enter(q, (bio->bi_opf & REQ_NOWAIT) ? + BLK_REQ_NOWAIT : 0) == 0)) { struct bio_list lower, same; /* Create a fresh bio_list for all subordinate requests */ diff --git a/block/blk-mq.c b/block/blk-mq.c index 10c1f49f663d..45bff90e08f7 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -384,7 +384,8 @@ struct request *blk_mq_alloc_request(struct request_queue *q, unsigned int op, struct request *rq; int ret; - ret = blk_queue_enter(q, flags & BLK_MQ_REQ_NOWAIT); + ret = blk_queue_enter(q, (flags & BLK_MQ_REQ_NOWAIT) ? + BLK_REQ_NOWAIT : 0); if (ret) return ERR_PTR(ret); @@ -423,7 +424,7 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q, if (hctx_idx >= q->nr_hw_queues) return ERR_PTR(-EIO); - ret = blk_queue_enter(q, true); + ret = blk_queue_enter(q, BLK_REQ_NOWAIT); if (ret) return ERR_PTR(ret); diff --git a/block/blk-timeout.c b/block/blk-timeout.c index 17ec83bb0900..e803106a5e5b 100644 --- a/block/blk-timeout.c +++ b/block/blk-timeout.c @@ -134,7 +134,7 @@ void blk_timeout_work(struct work_struct *work) struct request *rq, *tmp; int next_set = 0; - if (blk_queue_enter(q, true)) + if (blk_queue_enter(q, BLK_REQ_NOWAIT)) return; spin_lock_irqsave(q->queue_lock, flags); diff --git a/fs/block_dev.c b/fs/block_dev.c index 93d088ffc05c..98cf2d7ee9d3 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -674,7 +674,7 @@ int bdev_read_page(struct block_device *bdev, sector_t sector, if (!ops->rw_page || bdev_get_integrity(bdev)) return result; - result = blk_queue_enter(bdev->bd_queue, false); + result = blk_queue_enter(bdev->bd_queue, 0); if (result) return result; result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, false); @@ -710,7 +710,7 @@ int bdev_write_page(struct block_device *bdev, sector_t sector, if (!ops->rw_page || bdev_get_integrity(bdev)) return -EOPNOTSUPP; - result = blk_queue_enter(bdev->bd_queue, false); + result = blk_queue_enter(bdev->bd_queue, 0); if (result) return result; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 460294bb0fa5..107e2fd48486 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -857,6 +857,11 @@ enum { BLKPREP_INVALID, /* invalid command, kill, return -EREMOTEIO */ }; +/* passed to blk_queue_enter */ +enum { + BLK_REQ_NOWAIT = (1 << 0), +}; + extern unsigned long blk_max_low_pfn, blk_max_pfn; /* @@ -962,7 +967,7 @@ extern int scsi_cmd_ioctl(struct request_queue *, struct gendisk *, fmode_t, extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t, struct scsi_ioctl_command __user *); -extern int blk_queue_enter(struct request_queue *q, bool nowait); +extern int blk_queue_enter(struct request_queue *q, unsigned flags); extern void blk_queue_exit(struct request_queue *q); extern void blk_start_queue(struct request_queue *q); extern void blk_start_queue_async(struct request_queue *q);