From patchwork Thu Nov 9 18:49:57 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: 10051673 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 BD95960631 for ; Thu, 9 Nov 2017 18:50:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B150429AAF for ; Thu, 9 Nov 2017 18:50:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A60C42B069; Thu, 9 Nov 2017 18:50:13 +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=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 3D9C92B06A for ; Thu, 9 Nov 2017 18:50:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753962AbdKISuM (ORCPT ); Thu, 9 Nov 2017 13:50:12 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:38599 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753777AbdKISuF (ORCPT ); Thu, 9 Nov 2017 13:50:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1510253406; x=1541789406; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=dLWgRuWMNOOwn2d/sl+pZBaJ2GrcxQ9ALjSfGBb3XHo=; b=PXH3s+cuuUSzgz9TNPEtWfgoU/1o1VXE0DIlnkNECZT/ichErkY5ICHg ItMANlawV80ircvMFFSh0kM25X6vzpapGQh6XpFC/AOwKpQNvAh3+rVmc pHeC49h+gkCkWT1OA6kFQq3GFEbqJrvNJZbrA6e1Lp3KtSNXcDU1iOh8i SL2JD2ZZhCDwyEg6GkuQTqDDhf8hqzZByIG2N/csfCEjbSGqbpoufEc/v V9B3RKEYXaC61biQ9qy3PQs2MEZ9iwPP0EumvfZgt0fQXgwzrJBIvHmAz N+IRoLZsrr7Fx0eoefOBVsMw9rD//JhoupE2asB8SGPhDYcXx/DUm9iPP w==; X-IronPort-AV: E=Sophos;i="5.44,370,1505750400"; d="scan'208";a="61801484" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 10 Nov 2017 02:50:04 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 09 Nov 2017 10:47:26 -0800 Received: from unknown (HELO MILHUBIP03.sdcorp.global.sandisk.com) ([10.177.9.96]) by uls-op-cesaip02.wdc.com with ESMTP; 09 Nov 2017 10:50:03 -0800 Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Thu, 9 Nov 2017 10:50:02 -0800 X-AuditID: 0ab10959-41c5898000002c97-f5-5a04a359d359 Received: from thinkpad-bart.int.fusionio.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 84.AE.11415.953A40A5; Thu, 9 Nov 2017 10:50:01 -0800 (PST) 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 v12 5/7] block: Add the QUEUE_FLAG_PREEMPT_ONLY request queue flag Date: Thu, 9 Nov 2017 10:49:57 -0800 Message-ID: <20171109184959.4617-6-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171109184959.4617-1-bart.vanassche@wdc.com> References: <20171109184959.4617-1-bart.vanassche@wdc.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDJMWRmVeSWpSXmKPExsXCtZGTTTdyMUuUwcx1+har7/azWVz684XR YuXqo0wWj7tmsFrsvaVt0X19B5vF8uP/mCyWzGpmsjg0GUgsfLGJ2YHL4/LZUo+J6/k8dt9s YPN4eYnD4+PTWywe7/ddZfPYfLra4/MmOY/2A91MAZxRXDYpqTmZZalF+nYJXBl/j85nLJgi XfGg/yZbA+MfsS5GTg4JAROJIz+uM4LYQgIrGSVaToaC2GwCehKn5u1jArFFBBQken6vZAOx mQXeMEk8/CYJYgsLBEm0Pj/ICmKzCKhKLFi+nBnE5hWwkli49B8LxHx5ibVv74HN5xSwlvi7 Zy7QHA6gXVYSu+/zTGDkXsDIsIpRLDczpzg3PbPA0FCvODEvJbM4Wy85P3cTIyS8IncwPp1o foiRiYNTqoHxym7WIwuPWEpvV3vxcnnFsuP2kyfWuUStjNn20evFteiC7S/8HiTGi/5Yq6zx 6nQBZ6Hr05TwpZwHLvbbv09xTik+HTevLMIl/G/ewvWfVTlMXYMYV/LI+PTOWrMr8+7m2+GX FBg8p57Y5Gu+rerKrNQPnzi4X2zeM7XimYhJp2tf+ztzvtCNSizFGYmGWsxFxYkADttUzd8B AAA= 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 Tested-by: Oleksandr Natalenko 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 17eed16a6e04..edc276899116 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -348,6 +348,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 7e3ae8105d5f..b56a4f35720d 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 1af5ddd0f631..2147e2381a22 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -632,6 +632,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) | \ @@ -732,6 +733,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) {