From patchwork Fri Sep 8 23:52:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9945149 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 A3E1A602D7 for ; Fri, 8 Sep 2017 23:54:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 973CE2898E for ; Fri, 8 Sep 2017 23:54:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C219289C6; Fri, 8 Sep 2017 23:54:16 +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 E2C222898E for ; Fri, 8 Sep 2017 23:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757258AbdIHXyP (ORCPT ); Fri, 8 Sep 2017 19:54:15 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:20261 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757279AbdIHXyO (ORCPT ); Fri, 8 Sep 2017 19:54:14 -0400 X-IronPort-AV: E=Sophos;i="5.42,363,1500912000"; d="scan'208";a="145723571" Received: from sjappemgw11.hgst.com (HELO sjappemgw12.hgst.com) ([199.255.44.62]) by ob1.hgst.iphmx.com with ESMTP; 09 Sep 2017 08:12:40 +0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.172.152]) by sjappemgw12.hgst.com with ESMTP; 08 Sep 2017 16:52:28 -0700 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Hannes Reinecke , Johannes Thumshirn , "Rafael J . Wysocki" , Ming Lei Subject: [PATCH 3/5] block: Introduce REQ_PM and remove RQF_PM Date: Fri, 8 Sep 2017 16:52:24 -0700 Message-Id: <20170908235226.26622-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170908235226.26622-1-bart.vanassche@wdc.com> References: <20170908235226.26622-1-bart.vanassche@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Tell the block layer at request allocation time whether or not a request will be used to change the power management state of a block device. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Rafael J. Wysocki Cc: Ming Lei --- block/blk-core.c | 11 +++++++++-- block/blk-mq-debugfs.c | 2 +- block/elevator.c | 4 ++-- drivers/scsi/scsi_lib.c | 9 +++++---- include/linux/blk_types.h | 2 ++ include/linux/blkdev.h | 2 -- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index d709c0e3a2ac..bb53c6b58e8c 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1412,6 +1412,13 @@ static struct request *blk_old_get_request(struct request_queue *q, return rq; } +/** + * blk_get_request() - allocate a request + * @q: request queue. + * @op: bitwise or of operation (REQ_OP_*; see also enum req_opf) and flags + * (REQ_*; see also enum req_flag_bits). + * @gfp_mask: request memory allocation flags. + */ struct request *blk_get_request(struct request_queue *q, unsigned int op, gfp_t gfp_mask) { @@ -1529,7 +1536,7 @@ EXPORT_SYMBOL_GPL(part_round_stats); #ifdef CONFIG_PM static void blk_pm_put_request(struct request *rq) { - if (rq->q->dev && !(rq->rq_flags & RQF_PM) && !--rq->q->nr_pending) + if (rq->q->dev && !(rq->cmd_flags & REQ_PM) && !--rq->q->nr_pending) pm_runtime_mark_last_busy(rq->q->dev); } #else @@ -2460,7 +2467,7 @@ static struct request *blk_pm_peek_request(struct request_queue *q, struct request *rq) { if (q->dev && (q->rpm_status == RPM_SUSPENDED || - (q->rpm_status != RPM_ACTIVE && !(rq->rq_flags & RQF_PM)))) + (q->rpm_status != RPM_ACTIVE && !(rq->cmd_flags & REQ_PM)))) return NULL; else return rq; diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 980e73095643..ea21124b190b 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -266,6 +266,7 @@ static const char *const cmd_flag_name[] = { CMD_FLAG_NAME(BACKGROUND), CMD_FLAG_NAME(NOUNMAP), CMD_FLAG_NAME(NOWAIT), + CMD_FLAG_NAME(PM), }; #undef CMD_FLAG_NAME @@ -286,7 +287,6 @@ static const char *const rqf_name[] = { RQF_NAME(ELVPRIV), RQF_NAME(IO_STAT), RQF_NAME(ALLOCED), - RQF_NAME(PM), RQF_NAME(HASHED), RQF_NAME(STATS), RQF_NAME(SPECIAL_PAYLOAD), diff --git a/block/elevator.c b/block/elevator.c index 153926a90901..7898960bed2a 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -574,13 +574,13 @@ void elv_bio_merged(struct request_queue *q, struct request *rq, #ifdef CONFIG_PM static void blk_pm_requeue_request(struct request *rq) { - if (rq->q->dev && !(rq->rq_flags & RQF_PM)) + if (rq->q->dev && !(rq->cmd_flags & REQ_PM)) rq->q->nr_pending--; } static void blk_pm_add_request(struct request_queue *q, struct request *rq) { - if (q->dev && !(rq->rq_flags & RQF_PM) && q->nr_pending++ == 0 && + if (q->dev && !(rq->cmd_flags & REQ_PM) && q->nr_pending++ == 0 && (q->rpm_status == RPM_SUSPENDED || q->rpm_status == RPM_SUSPENDING)) pm_request_resume(q->dev); } diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 5be515c8c6bd..64ad70e8447c 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -242,11 +242,12 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, { struct request *req; struct scsi_request *rq; + unsigned int op_and_flags; int ret = DRIVER_ERROR << 24; - req = blk_get_request(sdev->request_queue, - data_direction == DMA_TO_DEVICE ? - REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, __GFP_RECLAIM); + op_and_flags = (data_direction == DMA_TO_DEVICE ? REQ_OP_SCSI_OUT : + REQ_OP_SCSI_IN) | (is_pm_req ? REQ_PM : 0); + req = blk_get_request(sdev->request_queue, op_and_flags, __GFP_RECLAIM); if (IS_ERR(req)) return ret; rq = scsi_req(req); @@ -260,7 +261,7 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, rq->retries = retries; req->timeout = timeout; req->cmd_flags |= flags; - req->rq_flags |= (is_pm_req ? RQF_PM : 0) | RQF_QUIET | RQF_PREEMPT; + req->rq_flags |= RQF_QUIET | RQF_PREEMPT; /* * head injection *required* here otherwise quiesce won't work diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index a2d2aa709cef..fdf4685a5856 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -229,6 +229,7 @@ enum req_flag_bits { __REQ_NOUNMAP, /* do not free blocks when zeroing */ __REQ_NOWAIT, /* Don't wait if request will block */ + __REQ_PM, /* Power management request */ __REQ_NR_BITS, /* stops here */ }; @@ -248,6 +249,7 @@ enum req_flag_bits { #define REQ_NOUNMAP (1ULL << __REQ_NOUNMAP) #define REQ_NOWAIT (1ULL << __REQ_NOWAIT) +#define REQ_PM (1ULL << __REQ_PM) #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 460294bb0fa5..7f9a0743fc09 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -111,8 +111,6 @@ typedef __u32 __bitwise req_flags_t; #define RQF_IO_STAT ((__force req_flags_t)(1 << 13)) /* request came from our alloc pool */ #define RQF_ALLOCED ((__force req_flags_t)(1 << 14)) -/* runtime pm request */ -#define RQF_PM ((__force req_flags_t)(1 << 15)) /* on IO scheduler merge hash */ #define RQF_HASHED ((__force req_flags_t)(1 << 16)) /* IO stats tracking on */