From patchwork Mon Oct 30 22:42:03 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: 10033399 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 C1F0B6039A for ; Mon, 30 Oct 2017 22:42:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4B342898D for ; Mon, 30 Oct 2017 22:42:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A91F72898F; Mon, 30 Oct 2017 22:42:35 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 518CE2898D for ; Mon, 30 Oct 2017 22:42:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbdJ3Wme (ORCPT ); Mon, 30 Oct 2017 18:42:34 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:25300 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752485AbdJ3WmM (ORCPT ); Mon, 30 Oct 2017 18:42:12 -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=1509403333; x=1540939333; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=f4WC2hXaUBAsytc+W5dq/6LHYY0nUZNEp/jiaE1GLwU=; b=hRMq85KJNu+SUHOX3mf+MAxcsA8oAOPdrNVGkSoEc64XEcVXFFJCdB4/ HbzoXTI78/C2H3XSjNf9u+s0qPmihNNobakbm3qGa51mSfmCIo13YtnZP c300jdprfBNssEdCm+Cf4zug20Ul09Fty2/2FfxoorCGaEmBJ41h/jZF0 /HnEXBfiOiu84MWDMVR318muwTigzJaQb6nvLPH8U1VZI1yVdSPOvcl/U bWdYInyBF3yp9tlCCEtP+yj9Apt0BG9VdPCTgLYQ+mquZkePtnVBL78+L wINd2/iBRscaWkQ5EK4KdHWXLyImag6TLzQVdkDo0VGQKC8WhwlpmVWAT Q==; X-IronPort-AV: E=Sophos;i="5.44,321,1505750400"; d="scan'208";a="60181988" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 31 Oct 2017 06:42:10 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 30 Oct 2017 15:40:18 -0700 Received: from unknown (HELO MILHUBIP04.sdcorp.global.sandisk.com) ([10.177.9.97]) by uls-op-cesaip02.wdc.com with ESMTP; 30 Oct 2017 15:42:09 -0700 Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Mon, 30 Oct 2017 15:42:07 -0700 X-AuditID: 0ab10959-41c5898000002c97-95-59f7aabfc3fb Received: from thinkpad-bart.int.fusionio.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 92.BD.11415.FBAA7F95; Mon, 30 Oct 2017 15:42:07 -0700 (PDT) From: Bart Van Assche To: Jens Axboe CC: , , "Christoph Hellwig" , "Martin K . Petersen" , Oleksandr Natalenko , Ming Lei , Martin Steigerwald , "Bart Van Assche" , Johannes Thumshirn Subject: [PATCH v11 5/7] block: Add the QUEUE_FLAG_PREEMPT_ONLY request queue flag Date: Mon, 30 Oct 2017 15:42:03 -0700 Message-ID: <20171030224205.25212-6-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171030224205.25212-1-bart.vanassche@wdc.com> References: <20171030224205.25212-1-bart.vanassche@wdc.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLJMWRmVeSWpSXmKPExsXCtZEjRXf/qu+RBmc/a1usvtvPZnHpzxdG i5WrjzJZPO6awWqx95a2Rff1HWwWy4//Y7JYMquZyeLQZCCx8MUmZgcuj8tnSz0mrufz2H2z gc3j5SUOj49Pb7F4vN93lc1j8+lqj8+b5DzaD3QzBXBGcdmkpOZklqUW6dslcGW8XfyOpeCm VMWWw42sDYzHxLoYOTgkBEwkWo/adTFycQgJrGaUODz/OXMXIycHm4CexKl5+5hAbBEBBYme 3yvZQGxmgTdMEg+/SYLYwgJBErs3LwKLswioSnx72g1m8wpYS3y8f48FxJYQkJd4v+A+I4jN KWAjsWjTd3YQWwioZtfE6UwTGLkXMDKsYhTLzcwpzk3PLDA01CtOzEvJLM7WS87P3cQIDjDO yB2MTyeaH2Jk4uCUamBsa2/5Jvz0xf3sGxOVZ29/eUbWbvaCzSd6lJ+r66iIZW14X3dpinPV /PTE4rAve/Wbfi7Zc1BXg0/hL8uhdxIXb9rs+m7TdYDzwesFtzInHJp6rK/26g3Ta3wnM0Od 1kx7osz8Tjbx9znmgFmykVreKfc/dlt5cqnUVO3jdNxZJB/Otjt6r4mDEktxRqKhFnNRcSIA izra7uABAAA= MIME-Version: 1.0 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 This flag will be used in the next patch to let the block layer core know whether or not a SCSI request queue has been quiesced. A quiesced SCSI queue namely only processes RQF_PREEMPT requests. Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke Tested-by: Martin Steigerwald Cc: Ming Lei Cc: Christoph Hellwig Cc: Johannes Thumshirn --- block/blk-core.c | 30 ++++++++++++++++++++++++++++++ block/blk-mq-debugfs.c | 1 + include/linux/blkdev.h | 6 ++++++ 3 files changed, 37 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index 48f18f5e2e16..16ddd52e6408 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -347,6 +347,36 @@ void blk_sync_queue(struct request_queue *q) } EXPORT_SYMBOL(blk_sync_queue); +/** + * blk_set_preempt_only - set QUEUE_FLAG_PREEMPT_ONLY + * @q: request queue pointer + * + * Returns the previous value of the PREEMPT_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) +{ + unsigned long flags; + int res; + + spin_lock_irqsave(q->queue_lock, flags); + res = queue_flag_test_and_set(QUEUE_FLAG_PREEMPT_ONLY, q); + spin_unlock_irqrestore(q->queue_lock, flags); + + return res; +} +EXPORT_SYMBOL_GPL(blk_set_preempt_only); + +void blk_clear_preempt_only(struct request_queue *q) +{ + unsigned long flags; + + spin_lock_irqsave(q->queue_lock, flags); + queue_flag_clear(QUEUE_FLAG_PREEMPT_ONLY, q); + spin_unlock_irqrestore(q->queue_lock, flags); +} +EXPORT_SYMBOL_GPL(blk_clear_preempt_only); + /** * __blk_run_queue_uncond - run a queue whether or not it has been stopped * @q: The queue to run diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 7f4a1ba532af..75f31535f280 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -74,6 +74,7 @@ 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), }; #undef QUEUE_FLAG_NAME diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 05203175eb9c..864ad2e4a58c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -630,6 +630,7 @@ 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_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_SAME_COMP) | \ @@ -730,6 +731,11 @@ static inline void queue_flag_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) + +extern int blk_set_preempt_only(struct request_queue *q); +extern void blk_clear_preempt_only(struct request_queue *q); static inline bool blk_account_rq(struct request *rq) {