From patchwork Thu Aug 9 19:41:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14B4013B4 for ; Thu, 9 Aug 2018 19:42:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 049E62B97D for ; Thu, 9 Aug 2018 19:42:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC76C2B97F; Thu, 9 Aug 2018 19:42:15 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 1D2B62B979 for ; Thu, 9 Aug 2018 19:42:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbeHIWIc (ORCPT ); Thu, 9 Aug 2018 18:08:32 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:1352 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHIWIc (ORCPT ); Thu, 9 Aug 2018 18:08:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843733; x=1565379733; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=bxvMCPZ6GBwylZMkltVuldxTL61qyD5LYS9MuJ6aSfM=; b=YS9mO1vA+w97Nxb9wKtFywgOiBjTiWWe3Zz0Btvkud3H2IHFJ/DNYiK4 OiNX4t9GSnVuQDx5zeb9Z/aIyOmbWytKZUkLgM4kZ0cz9YVboACcQavc0 eQLJu+7pKBTNruaLFr/elHB1Dz0VLQvSli3MFaN+byn4iTl0/GatkWPyM 4NFXuMNP5LNm/jhfXoJwxKGKM63QIxYwP1f4D4IokVNiyT/bq3/UI1Yw6 VjdC7p3EbpkkzBuSR4w7qRJSU4Rzs7IoM+QXFIHBZXXoN4mOUa3pBEjfP N1bAZLPWUU8w0udPIUs+dff8JD6CO3w985jtnCJGTdopkeCDXvCeqh252 g==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="191119598" Received: from mail-sn1nam01lp0115.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.115]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:12 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h4UzdQ0z5lL0tkKZN0l3IWXM8h3gGc/ZcQVDlLees2g=; b=LbGJToPS7jsSsdnfcS+FtPGcouImnr5krOPW8ukFHfEU3IzXKkk3cbT2aJgdGUIXxrKN8qLPAuyZoftJGDf4SIVnvyfUoIfe9cYIlML1T1A7uv0lhYfU1q9TCAZIPfpRm8ZpqGKxlTmKcy7kGdMTOwR68zq+i+VxL17Jyfq+puU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:07 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 05/12] block, scsi: Rename QUEUE_FLAG_PREEMPT_ONLY into DV_ONLY and introduce PM_ONLY Date: Thu, 9 Aug 2018 12:41:42 -0700 Message-Id: <20180809194149.15285-6-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 492e4db4-f53c-4265-3156-08d5fe303142 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:9DDM0PLEirBdDyVOBYKdVUZ0LEwohjb4F1m1l9ruC2xCa+UTr7pNv68N17MjWlD4hXdlOBsrazVpju4tB+pG1leZzmIWbNzL9iBaBN4s+ezZh8VHu0IX9b2DbRNa3JgKRuD4AUUg2LBHqj39keL8Rq5A4PDrzqsVc88AJuHzULC5pcDm1GY9PeFOtGTitfdmnjuPukn5mA3w4uAGhrurnnaikF0+8+VyfUD2s8rIcDBozXNoImBze68U2mgNwEDo;25:NYXqdzOP84SMk4YxzSt1DK5ohwoYXsEbSLyR5z7M8UwiTy9nECMZc3P2xrSeEjTZLI/ft/97LAULAHfo/lK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wEusCpKcplTP/IzHwq9Tp3d+5AvwSK1r;4:DBF2XPIhgs1GRCiaeN9e9ETnx4yoofM4rn70s2I7OE8lGuUW2cSi8wiULbZ4RLOB3harSJu+hbDnvRC553Nwvj841AWSKdjjme5O6ofZHU1xCDIQ0Op+/Zxs3IPZEAm0rZ58cz5apAovf05QOmMyX2Bkef0wbNsVx7dVqwgGO48EVmcnjJB1nR6rjmFp96ngLaNHV4JleUlqxVOa87N4Dt/bAGcCg9es68jVUHyuiVs2z1nnKKEHD4YfmmAq8k5kWiGA7UTHBqhZx6f7o6Ihev/MwKo78TE6yFHWNXzXYkdEM9i7crp92YLHm9k5o4W65bOlmSDJbJGzuyhoQj9o7sXz/ikfrCh9K4fiH946zTc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(966005)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6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GMv7joPOhjrLO5kJs/cYEK4do8K5AK6369/GyYj0oF+AwWoB2pm+KelnC3RnGKFZoVU2Slqgc+JQwP1pDhsWw8W3fmSzbfo2QGKeVrOcvAaZJQwbq1f9po54vZMV6saUvP3PAKGSsdxfHn1+10rwLDfOAS5arjV4VuUxZkJ3NA==;5:RxQGF7hYxwbR93tVJtpfvtiw2q0Yb3ZI6mbFeTiKbhI4ZNuAWru9rGtH4cC17QNr1b3PeK94EiZfnBkKDXZbizlYrg/XhaQrvtIcJ7N3sNxu2x27K/o6AM9LxIa3csd7n36G/2XL9+rIcxEn787XYEa9R/dXqgsL87JzBpVHyQs=;7:47Onc8CKKx35YycPdWPspTFNrH+ZzeHUeyLLOv9yTfpmZPArZHLa+u63eTgv6d7KBUlUwxYjyxcdhiB08zCwCE0pTurli6H8c6Ga7Hv9pOZm8TbWV6GX36pAslX6dShvfZYxfd5s+mtt0KsrARkvo/xHioNGLC8YaC/SrFBpuJLrt8EaD7R9D7MZHUHwEyJ/qHBjCekgPpqpxQwOO1+gqCNkUZyqZb3RnQ1Fjp70mGkkovJTvkYivnAk5yIba7Sa SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:4myuhesQ++AHkkjTQOzgjlcFNiHceWCfyUGyyiTAJv7Yd3fNfGu/pUnlqCuYM9EuM0lSIYnYmMgnFtimjuLaZswZdRKV1tVkC99knSIXqG2tHU0oDbUpkywx7BMxphaTJ4W0HCroHTQ8Lnzbak1CPwHqC/Yj/q/SEaheM/ush4Y= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:07.7076 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 492e4db4-f53c-4265-3156-08d5fe303142 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Instead of having one queue state (PREEMPT_ONLY) in which both power management and SCSI domain validation requests are processed, rename the PREEMPT_ONLY state into DV_ONLY and introduce a new queue flag QUEUE_FLAG_PM_ONLY. Provide the new functions blk_set_pm_only() and blk_clear_pm_only() for power management and blk_set_dv_only() and blk_clear_dv_only() functions for SCSI domain validation purposes. Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- block/blk-core.c | 65 ++++++++++++++++++++++++++++++----------- block/blk-mq-debugfs.c | 3 +- drivers/scsi/scsi_lib.c | 16 +++++----- include/linux/blkdev.h | 13 +++++---- 4 files changed, 66 insertions(+), 31 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index c4ff58491758..401f4927a8db 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -421,24 +421,44 @@ void blk_sync_queue(struct request_queue *q) EXPORT_SYMBOL(blk_sync_queue); /** - * blk_set_preempt_only - set QUEUE_FLAG_PREEMPT_ONLY + * blk_set_dv_only - set QUEUE_FLAG_DV_ONLY * @q: request queue pointer * - * Returns the previous value of the PREEMPT_ONLY flag - 0 if the flag was not + * Returns the previous value of the DV_ONLY flag - 0 if the flag was not * set and 1 if the flag was already set. */ -int blk_set_preempt_only(struct request_queue *q) +int blk_set_dv_only(struct request_queue *q) { - return blk_queue_flag_test_and_set(QUEUE_FLAG_PREEMPT_ONLY, q); + return blk_queue_flag_test_and_set(QUEUE_FLAG_DV_ONLY, q); } -EXPORT_SYMBOL_GPL(blk_set_preempt_only); +EXPORT_SYMBOL_GPL(blk_set_dv_only); -void blk_clear_preempt_only(struct request_queue *q) +void blk_clear_dv_only(struct request_queue *q) { - blk_queue_flag_clear(QUEUE_FLAG_PREEMPT_ONLY, q); + blk_queue_flag_clear(QUEUE_FLAG_DV_ONLY, q); wake_up_all(&q->mq_freeze_wq); } -EXPORT_SYMBOL_GPL(blk_clear_preempt_only); +EXPORT_SYMBOL_GPL(blk_clear_dv_only); + +/** + * blk_set_pm_only - set QUEUE_FLAG_PM_ONLY + * @q: request queue pointer + * + * Returns the previous value of the PM_ONLY flag - 0 if the flag was not + * set and 1 if the flag was already set. + */ +int blk_set_pm_only(struct request_queue *q) +{ + return blk_queue_flag_test_and_set(QUEUE_FLAG_PM_ONLY, q); +} +EXPORT_SYMBOL_GPL(blk_set_pm_only); + +void blk_clear_pm_only(struct request_queue *q) +{ + blk_queue_flag_clear(QUEUE_FLAG_PM_ONLY, q); + wake_up_all(&q->mq_freeze_wq); +} +EXPORT_SYMBOL_GPL(blk_clear_pm_only); /** * __blk_run_queue_uncond - run a queue whether or not it has been stopped @@ -910,6 +930,20 @@ struct request_queue *blk_alloc_queue(gfp_t gfp_mask) } EXPORT_SYMBOL(blk_alloc_queue); +/* + * Whether or not blk_queue_enter() should proceed. RQF_PM requests are always + * allowed. RQF_DV requests are allowed if the PM_ONLY queue flag has not been + * set. Other requests are only allowed if neither PM_ONLY nor DV_ONLY has been + * set. + */ +static inline bool blk_enter_allowed(struct request_queue *q, + blk_mq_req_flags_t flags) +{ + return flags & BLK_MQ_REQ_PM || + (!blk_queue_pm_only(q) && + (flags & BLK_MQ_REQ_DV || !blk_queue_dv_only(q))); +} + /** * blk_queue_enter() - try to increase q->q_usage_counter * @q: request queue pointer @@ -917,23 +951,20 @@ EXPORT_SYMBOL(blk_alloc_queue); */ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) { - const bool preempt = flags & (BLK_MQ_REQ_PM | BLK_MQ_REQ_DV); - while (true) { bool success = false; rcu_read_lock(); if (percpu_ref_tryget_live(&q->q_usage_counter)) { /* - * The code that sets the PREEMPT_ONLY flag is - * responsible for ensuring that that flag is globally - * visible before the queue is unfrozen. + * The code that sets the PM_ONLY or DV_ONLY queue + * flags is responsible for ensuring that that flag is + * globally visible before the queue is unfrozen. */ - if (preempt || !blk_queue_preempt_only(q)) { + if (blk_enter_allowed(q, flags)) success = true; - } else { + else percpu_ref_put(&q->q_usage_counter); - } } rcu_read_unlock(); @@ -954,7 +985,7 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) wait_event(q->mq_freeze_wq, (atomic_read(&q->mq_freeze_depth) == 0 && - (preempt || !blk_queue_preempt_only(q))) || + blk_enter_allowed(q, flags)) || blk_queue_dying(q)); if (blk_queue_dying(q)) return -ENODEV; diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index b4e722311ae1..2ac9949bf68e 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -132,7 +132,8 @@ static const char *const blk_queue_flag_name[] = { QUEUE_FLAG_NAME(REGISTERED), QUEUE_FLAG_NAME(SCSI_PASSTHROUGH), QUEUE_FLAG_NAME(QUIESCED), - QUEUE_FLAG_NAME(PREEMPT_ONLY), + QUEUE_FLAG_NAME(PM_ONLY), + QUEUE_FLAG_NAME(DV_ONLY), }; #undef QUEUE_FLAG_NAME diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index eb914d8e17fd..d466f846043f 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2997,11 +2997,11 @@ scsi_device_suspend(struct scsi_device *sdev) if (sdev->sdev_state == SDEV_SUSPENDED) return 0; - blk_set_preempt_only(q); + blk_set_pm_only(q); blk_mq_freeze_queue(q); /* - * Ensure that the effect of blk_set_preempt_only() will be visible + * Ensure that the effect of blk_set_pm_only() will be visible * for percpu_ref_tryget() callers that occur after the queue * unfreeze even if the queue was already frozen before this function * was called. See also https://lwn.net/Articles/573497/. @@ -3012,7 +3012,7 @@ scsi_device_suspend(struct scsi_device *sdev) mutex_lock(&sdev->state_mutex); err = scsi_device_set_state(sdev, SDEV_SUSPENDED); if (err) - blk_clear_preempt_only(q); + blk_clear_pm_only(q); mutex_unlock(&sdev->state_mutex); return err; @@ -3030,7 +3030,7 @@ EXPORT_SYMBOL(scsi_device_suspend); void scsi_device_unsuspend(struct scsi_device *sdev) { mutex_lock(&sdev->state_mutex); - blk_clear_preempt_only(sdev->request_queue); + blk_clear_pm_only(sdev->request_queue); if (sdev->sdev_state == SDEV_SUSPENDED) scsi_device_set_state(sdev, SDEV_RUNNING); mutex_unlock(&sdev->state_mutex); @@ -3088,11 +3088,11 @@ scsi_device_quiesce(struct scsi_device *sdev) */ WARN_ON_ONCE(sdev->quiesced_by && sdev->quiesced_by != current); - blk_set_preempt_only(q); + blk_set_dv_only(q); blk_mq_freeze_queue(q); /* - * Ensure that the effect of blk_set_preempt_only() will be visible + * Ensure that the effect of blk_set_dv_only() will be visible * for percpu_ref_tryget() callers that occur after the queue * unfreeze even if the queue was already frozen before this function * was called. See also https://lwn.net/Articles/573497/. @@ -3105,7 +3105,7 @@ scsi_device_quiesce(struct scsi_device *sdev) if (err == 0) sdev->quiesced_by = current; else - blk_clear_preempt_only(q); + blk_clear_dv_only(q); mutex_unlock(&sdev->state_mutex); return err; @@ -3125,7 +3125,7 @@ void scsi_device_unquiesce(struct scsi_device *sdev) mutex_lock(&sdev->state_mutex); WARN_ON_ONCE(!sdev->quiesced_by); sdev->quiesced_by = NULL; - blk_clear_preempt_only(sdev->request_queue); + blk_clear_dv_only(sdev->request_queue); if (sdev->sdev_state == SDEV_QUIESCE) scsi_device_set_state(sdev, SDEV_RUNNING); mutex_unlock(&sdev->state_mutex); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 938725ef492b..7717b71c6da3 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -699,7 +699,8 @@ 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_PREEMPT_ONLY 29 /* only process REQ_PREEMPT requests */ +#define QUEUE_FLAG_PM_ONLY 29 /* only process RQF_PM requests */ +#define QUEUE_FLAG_DV_ONLY 30 /* only process RQF_DV requests */ #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_SAME_COMP) | \ @@ -737,12 +738,14 @@ bool blk_queue_flag_test_and_clear(unsigned int flag, struct request_queue *q); ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ REQ_FAILFAST_DRIVER)) #define blk_queue_quiesced(q) test_bit(QUEUE_FLAG_QUIESCED, &(q)->queue_flags) -#define blk_queue_preempt_only(q) \ - test_bit(QUEUE_FLAG_PREEMPT_ONLY, &(q)->queue_flags) +#define blk_queue_pm_only(q) test_bit(QUEUE_FLAG_PM_ONLY, &(q)->queue_flags) +#define blk_queue_dv_only(q) test_bit(QUEUE_FLAG_DV_ONLY, &(q)->queue_flags) #define blk_queue_fua(q) test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags) -extern int blk_set_preempt_only(struct request_queue *q); -extern void blk_clear_preempt_only(struct request_queue *q); +extern int blk_set_pm_only(struct request_queue *q); +extern void blk_clear_pm_only(struct request_queue *q); +extern int blk_set_dv_only(struct request_queue *q); +extern void blk_clear_dv_only(struct request_queue *q); static inline int queue_in_flight(struct request_queue *q) {