From patchwork Fri Jan 27 06:40:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9540629 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 B464E60415 for ; Fri, 27 Jan 2017 06:40:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AB7227F9F for ; Fri, 27 Jan 2017 06:40:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AF06280B0; Fri, 27 Jan 2017 06:40:29 +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 6036D27F9F for ; Fri, 27 Jan 2017 06:40:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753965AbdA0Gk1 (ORCPT ); Fri, 27 Jan 2017 01:40:27 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:39738 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753841AbdA0GkZ (ORCPT ); Fri, 27 Jan 2017 01:40:25 -0500 Received: from pps.filterd (m0044008.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v0R6YHMH015257; Thu, 26 Jan 2017 22:40:16 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=subject : to : references : cc : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=facebook; bh=gjVZWnkDJRmJ9K83XowIfVmIB5Y33teWLYJSi/vuOMA=; b=J1E3kq7b87FiurMI8nBXuGNj25BKvrTK1pHEWEbXWSwFX1X7RtRTbGCP/OfdASQnMDpD kdBRDlMQFLubuUrVW2SOFmhtJcctHeOJnGY6r4yOb5mSottW58VTDq/CdGczYvy4bY4a QDPdqQQ3zH1AVGXIGPEBuU5gCEVWVOMcre0= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 287w98rj0n-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 26 Jan 2017 22:40:16 -0800 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.23) with Microsoft SMTP Server (TLS) id 14.3.294.0; Thu, 26 Jan 2017 22:40:15 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=gjVZWnkDJRmJ9K83XowIfVmIB5Y33teWLYJSi/vuOMA=; b=B6bBbACmtSTaU17oavH8U18yJxtHj5yyT3CI2HyRt2hyJTZCfqE7Oy/uscmSuMuXJJnLhunSQk9bOUebjPY8UFnmLNUi/lmLRCB8nevpw39fLQ+ZoHTMsuKHRSXmqVeeamO8dlF07NoXl6MTSB/fh3s+6SiY/u8Cczkm4SWOMik= Received: from [192.168.1.176] (66.29.164.166) by CY4PR15MB1192.namprd15.prod.outlook.com (10.172.177.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Fri, 27 Jan 2017 06:40:10 +0000 Subject: Re: [dm-devel] split scsi passthrough fields out of struct request V2 To: Bart Van Assche , "hch@lst.de" References: <1485365126-23210-1-git-send-email-hch@lst.de> <1485455329.2540.7.camel@sandisk.com> <1485456745.2540.9.camel@sandisk.com> <20170126185924.GA25289@lst.de> <71e22257-0592-fdd3-25e5-a78ceced2ab9@sandisk.com> <4054e944-b28d-1cd6-574f-6cd90e28c301@fb.com> <1485464486.2540.12.camel@sandisk.com> <6995c991-65a4-8dca-c36e-fb2eff277ca9@fb.com> <1485467235.2540.14.camel@sandisk.com> <1485472465.2540.19.camel@sandisk.com> <1485474426.2540.25.camel@sandisk.com> <1485477510.2540.27.camel@sandisk.com> <2d971693-b79d-c1b9-fb2a-f5dd04128c68@fb.com> <1485479738.2540.30.camel@sandisk.com> CC: "linux-scsi@vger.kernel.org" , "linux-raid@vger.kernel.org" , "dm-devel@redhat.com" , "linux-block@vger.kernel.org" , "snitzer@redhat.com" , "j-nomura@ce.jp.nec.com" From: Jens Axboe Message-ID: <37ab009a-bc2d-d2ae-a875-269ab563a430@fb.com> Date: Thu, 26 Jan 2017 23:40:06 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [66.29.164.166] X-ClientProxiedBy: BN6PR03CA0014.namprd03.prod.outlook.com (10.168.230.152) To CY4PR15MB1192.namprd15.prod.outlook.com (10.172.177.14) X-MS-Office365-Filtering-Correlation-Id: 41b77b82-ab8e-478f-ea18-08d4467f58a5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY4PR15MB1192; X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1192; 3:jcwS09oMVF9VFsEJjSjKcrODE0yQQ+0BovxJG4oEHP4wykX7WmXSf2Isn6MeZATjRfJMP6dNnmvSYmZxxWXE6xfE5fsPpDlN+b+aSGWJSEZAubCFbJixAZ0Ap2JW9FsHKv2Vh4i+r6zVSbcR9BxnxjJf/WQ+R0Mw0RiXkhAab8CtQRhFgf18pGwyiifwSykJoqGscfMNFG3bKGqP970QoQEvTO3xQN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WDYz0xwWTJy0a0pBUukHhmhly7VHOlNtPTdMjaSEdCowekavsA7ewlyotF1dpUx9nixWnIOIGXSPubGu8bBnWwcpNsU3jpmUj7x5b8+D1YeLyYez+b5CVJgHDO6s6RfOLhHJ8oRarAaAE64TVCO+o8S4yL8hVba+uMsYGQRzGZ0++8PVFq/COgrTvakPpPY2XskugGVjwIC4HQCiPRIcTajufRUC07YJvLAucxcKezDCLyxfWv02Lu27FNzp5vazL2iJM6SDzd7VyGPfwKFEgU X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123564025)(20161123562025)(20161123560025)(20161123555025)(6072148); SRVR:CY4PR15MB1192; BCL:0; PCL:0; RULEID:; SRVR:CY4PR15MB1192; X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1192; 4:Qoi5YOaABBZJ9gj2m1dKD+kTX+nm+S568mLJueL1ZSWSKn42uLKg648i88vS9q78/q3hOj1/1UfECLSJf1F2vIZuXlczoGFTuAeQmHPB9BOeS8+DHgSftxKRk9ss7GJDjhMc+0z5QJN8luZ99vY/+TUfM1bRAHuyfA+oGGCpcHmsFfwKvoG2SmyZew9JBC7wXPAp5m62kf5PyATrD6KioMYw+RVnt4I+0bTn4me1jrr4IM5GGAoLerr5zjKzrmkGUmECDTdTCnbtlrNWkYuDAHRQ0PucP6TJnj6+y/2wQxbCfqcW2ofANbcCfFAqW4YspXb4w4fP6u9pHaPaPTQqCYdrHWxLT/pRxVYp9X148r1HFCKDgm3xa3o+zd69j4Zv2ArvVg9Mrbz30oPOe8+HMXrGBDdEJHZ/Jwnq4EjEZK30ejWAKlwaSvL+bqcJAvTztCm4mJLC87ojbrIoViAtjHbe2sTE2Rmowm0b10OaEAGst9iFrv6Ys4ci3Yhd7XIRFUPXbsHoKIydhY9fMjCddmUjj4tBHodW4UUpuDREX7FUu4PvBfmlT6tARUampvwlh8ZX/CSm1YIOtHQI0faiHHWJcS7VS1892AMAfvYgRcGjkcfn3aYIUA2hdrDv35ZQ X-Forefront-PRVS: 0200DDA8BE X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6049001)(7916002)(39450400003)(51234002)(377424004)(377454003)(199003)(24454002)(189002)(25786008)(4001350100001)(106356001)(5001770100001)(2501003)(5660300001)(97736004)(6486002)(77096006)(83506001)(53936002)(90366009)(1691005)(36756003)(68736007)(50466002)(54906002)(575784001)(65826007)(86362001)(8656002)(64126003)(31696002)(92566002)(305945005)(229853002)(31686004)(47776003)(38730400001)(101416001)(230700001)(2906002)(4326007)(42186005)(93886004)(23746002)(117156001)(54356999)(189998001)(33646002)(65806001)(105586002)(65956001)(66066001)(7736002)(50986999)(8676002)(6116002)(81156014)(81166006)(3846002)(76176999)(6666003)(2950100002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR15MB1192; H:[192.168.1.176]; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; CY4PR15MB1192; 23:Bt9+pWCsX4yZMrFVZUUtV+RDjM/9T2ijxMFLb?= =?Windows-1252?Q?EJegf9pWCU1cy9USAPr+jbBOSypOXZhR1+AmEnpccDAo3Veqdg6IM0eC?= =?Windows-1252?Q?okp9skWaGfvHfok6NDth+ajL7NYIAvdB42+NA5j0S27sTk3Bgf3Y2v4L?= =?Windows-1252?Q?T2Y/NXqduBIcQgi5Clxv+5akljyJQuIVMEBx/QnLj4vSO58TvsjXgTi/?= =?Windows-1252?Q?do0I1A94/gGZZr4l0qIQX+k8a9mr3s1HuaNFxz/4KDw9sCIF4UyniH6C?= =?Windows-1252?Q?V3/A/ox/D2qB5tpa9w5knIF9t5GmyoHPWFSjG0Qbx45GG5n+siSVCJIn?= =?Windows-1252?Q?ouERFPQWqNZNH74MeMM8H8NjtONDE2eW7OWsdqpKD8u3RMTxxnkb1VLu?= =?Windows-1252?Q?4JB2OvkgJY+hSmEs3OWiOYMthW8HbeNLrEBSt06LJLnC71e4pM2RYpUB?= =?Windows-1252?Q?KD7zf3MoX4+0TS+Vr95ABv+5WSd8tgjG/284/R+iSOSmtpn2MHN5SLFJ?= =?Windows-1252?Q?aN3bPJoKS3hBMkxr8iQmforH1JL0naP5JtPTAXpaiGQQeVvyByqebCzl?= =?Windows-1252?Q?0Oup95apsu+t7uQaNPFi2of7x9m1ObePbzzDKaCzctqtnc2kSE8T8VzS?= =?Windows-1252?Q?QLXL7nwyfZBvj4gojf15NFRwi3rR3/0y2RajU/X/u+kt5rLDEl1yGdW8?= =?Windows-1252?Q?BP9sQetI6Xs2toOcS8c6M8h69kMdMGmXwbaqHS/8MZEb001+SRihBkbu?= =?Windows-1252?Q?eEaSk1zv4lfPxqvOInu7U0HWaaTCbY33dA5X0v2YaaOAWpnjQ0UdtTrq?= =?Windows-1252?Q?w3UpxOVX7WqRiJIOvNoUdRIjHeSk3f99mEEHcFcZm6c4G2XFUIUw8Vd3?= =?Windows-1252?Q?kBDMdLGBi234YjTJ/1WFptan+2Vu/5pfSLdRC4Xpk+yXSY/Jcd6doOox?= =?Windows-1252?Q?S5q7KjfIkWv2WS/CPKHxnLIKjk2am74wN8QnHOv/vTFiX6XUphWE5aQ/?= =?Windows-1252?Q?FI1EbQfswSCxDCAl6XmiHnCwZVjNFn/7hPksFIYQ6P1t0bUUa0MrM0m+?= =?Windows-1252?Q?cSHrl+Ojqod5jcvT5iYSybyMk63xe8IyvLpDfBd2GK96pKBoOunuMIUR?= =?Windows-1252?Q?7ftCRp3CK/U2doj7wD1vm+/AmwQK1JW9h+/KTe9po0UxbZUWvsNX3PX5?= =?Windows-1252?Q?cjvDO5hPU7uPbEiK6WssgzJPD3XEbsFf8viko9bH9UKnTqaWaQOFr1Vb?= =?Windows-1252?Q?nBM0f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eI480euWQps5x5BVWswtDA/cAT2pCs0JdjqcqN3GB+RA9QpmCTjE0cimecM2ThbgoDUOBA==; 24:JD0iKjkfYtmJtUrr/Mm8QKpY754Wnq82aei3jwyEnvhEOl7g/uZzbopnUYJMnapWGL+saIbPtT853TZcgDg87F1DtydpPWvmPnRcAEIUZ3c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1192; 7:MXaUZ5LDTfLszCGhiL+LUY/UMrPf4pOPwYOEK41Af/QfC9orDFX1QOkLC4mOHLDeRPZDBoKo65fhD0cf0SkFijQblWI7uzOnuPEYciBcFIGldCYoLJJmnre8PtbaScf1P2UUFjNzRA7LxZqqN/hIX5NGHK7/eWSzf4bsmTCDNuGtYncqt4ZtUREITT9pJOeL+9IW1ktYj25VoVKamaF+eGKmTSRIUgKtPvnYbytbd2ryIRNygSuopWPadKj6lvun89YW2G7MlpCXyr0VVtIyweof3gv0ZQaeBBJBFEpxyhGW3g8/PqRrGh3S74kB9RnQ7OESbeUrHFV7jx+31k7Nj/TKl9E05q7Uxc6dTA431ByNCaZ9Ua/XTFJVDqLrttE1cVgn+O0Cd4QFcXhjWo0Sh+xLs/lreI4Ck7eTSASlfM2ftqTThVy+lKC9eDtNKUG02tPm2j1f3wAAPuntnRJ4ww==; 20:nmPEEB9GLUpNBNCI/029Uy55y/cqUEwnb1g+r0KStp+vAv4/5ZhnuhBCHNRNyQ0qY7eARzCyn0VObDUHcusym74Dwlkf1Lf/MnTye6dtUZUH5YSjwTdWQazWPwiRAjRe/mNbqmB8xrXI7BM5Zspb5GldAsXCxXCixuF72r/HCJQ= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2017 06:40:10.7187 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1192 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-01-27_02:, , signatures=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 On 01/26/2017 06:22 PM, Jens Axboe wrote: > On 01/26/2017 06:15 PM, Bart Van Assche wrote: >> On Thu, 2017-01-26 at 17:41 -0700, Jens Axboe wrote: >>> On 01/26/2017 05:38 PM, Bart Van Assche wrote: >>>> I see similar behavior with the blk-mq-sched branch of >>>> git://git.kernel.dk/linux-block.git (git commit ID 0efe27068ecf): >>>> booting happens much slower than usual and I/O hangs if I run the >>>> srp-test software. >>> >>> Please don't run that, run for-4.11/block and merge it to master. >>> Same behavior? >> >> I have not yet had the chance to run the srp-test software against that >> kernel. But I already see that booting takes more than ten times longer >> than usual. Note: as far as I know the dm-mpath driver is not involved >> in the boot process of my test system. > > What's your boot device? I've been booting this on a variety of setups, > no problems observed. It's booting my laptop, and on SCSI and SATA as > well. What is your root drive? What is the queue depth of it? > Controller? Are you using dm for your root device? I think I see what is going on. The scheduler framework put the insertion of flushes on the side, whereas it's integrated "nicely" on the legacy side. Can you try with this applied? This is on top of the previous two that we already went through. Or, you can just pull: git://git.kernel.dk/linux-block for-4.11/next which is for-4.11/block with the next set of fixes on top that I haven't pulled in yet. commit 995447bfd14dd871e0c8771261ed7d1f2b5b4c86 Author: Jens Axboe Date: Thu Jan 26 23:34:56 2017 -0700 blk-mq-sched: integrate flush insertion into blk_mq_sched_get_request() Instead of letting the caller check this and handle the details of inserting a flush request, put the logic in the scheduler insertion function. Outside of cleaning up the code, this handles the case where outside callers insert a flush, like through blk_insert_cloned_request(). Signed-off-by: Jens Axboe diff --git a/block/blk-core.c b/block/blk-core.c index a61f1407f4f6..78daf5b6d7cb 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2129,7 +2129,7 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq) if (q->mq_ops) { if (blk_queue_io_stat(q)) blk_account_io_start(rq, true); - blk_mq_sched_insert_request(rq, false, true, false); + blk_mq_sched_insert_request(rq, false, true, false, false); return 0; } diff --git a/block/blk-exec.c b/block/blk-exec.c index 86656fdfa637..ed1f10165268 100644 --- a/block/blk-exec.c +++ b/block/blk-exec.c @@ -66,7 +66,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk, * be reused after dying flag is set */ if (q->mq_ops) { - blk_mq_sched_insert_request(rq, at_head, true, false); + blk_mq_sched_insert_request(rq, at_head, true, false, false); return; } diff --git a/block/blk-flush.c b/block/blk-flush.c index d7de34ee39c2..4427896641ac 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -456,7 +456,7 @@ void blk_insert_flush(struct request *rq) if ((policy & REQ_FSEQ_DATA) && !(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH))) { if (q->mq_ops) - blk_mq_sched_insert_request(rq, false, true, false); + blk_mq_sched_insert_request(rq, false, true, false, false); else list_add_tail(&rq->queuelist, &q->queue_head); return; diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index c27613de80c5..fa2ff0f458fa 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -336,6 +336,64 @@ void blk_mq_sched_restart_queues(struct blk_mq_hw_ctx *hctx) } } +/* + * Add flush/fua to the queue. If we fail getting a driver tag, then + * punt to the requeue list. Requeue will re-invoke us from a context + * that's safe to block from. + */ +static void blk_mq_sched_insert_flush(struct blk_mq_hw_ctx *hctx, + struct request *rq, bool can_block) +{ + if (blk_mq_get_driver_tag(rq, &hctx, can_block)) { + blk_insert_flush(rq); + blk_mq_run_hw_queue(hctx, !can_block); + } else + blk_mq_add_to_requeue_list(rq, true, true); +} + +void blk_mq_sched_insert_request(struct request *rq, bool at_head, + bool run_queue, bool async, bool can_block) +{ + struct request_queue *q = rq->q; + struct elevator_queue *e = q->elevator; + struct blk_mq_ctx *ctx = rq->mq_ctx; + struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu); + + if (rq->tag == -1 && (rq->cmd_flags & (REQ_PREFLUSH | REQ_FUA))) { + blk_mq_sched_insert_flush(hctx, rq, can_block); + return; + } + + if (e && e->type->ops.mq.insert_requests) { + LIST_HEAD(list); + + list_add(&rq->queuelist, &list); + e->type->ops.mq.insert_requests(hctx, &list, at_head); + } else { + spin_lock(&ctx->lock); + __blk_mq_insert_request(hctx, rq, at_head); + spin_unlock(&ctx->lock); + } + + if (run_queue) + blk_mq_run_hw_queue(hctx, async); +} + +void blk_mq_sched_insert_requests(struct request_queue *q, + struct blk_mq_ctx *ctx, + struct list_head *list, bool run_queue_async) +{ + struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu); + struct elevator_queue *e = hctx->queue->elevator; + + if (e && e->type->ops.mq.insert_requests) + e->type->ops.mq.insert_requests(hctx, list, false); + else + blk_mq_insert_requests(hctx, ctx, list); + + blk_mq_run_hw_queue(hctx, run_queue_async); +} + static void blk_mq_sched_free_tags(struct blk_mq_tag_set *set, struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx) diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h index becbc7840364..9478aaeb48c5 100644 --- a/block/blk-mq-sched.h +++ b/block/blk-mq-sched.h @@ -21,6 +21,12 @@ bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio); bool blk_mq_sched_try_insert_merge(struct request_queue *q, struct request *rq); void blk_mq_sched_restart_queues(struct blk_mq_hw_ctx *hctx); +void blk_mq_sched_insert_request(struct request *rq, bool at_head, + bool run_queue, bool async, bool can_block); +void blk_mq_sched_insert_requests(struct request_queue *q, + struct blk_mq_ctx *ctx, + struct list_head *list, bool run_queue_async); + void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx); void blk_mq_sched_move_to_dispatch(struct blk_mq_hw_ctx *hctx, struct list_head *rq_list, @@ -62,45 +68,6 @@ static inline void blk_mq_sched_put_rq_priv(struct request_queue *q, e->type->ops.mq.put_rq_priv(q, rq); } -static inline void -blk_mq_sched_insert_request(struct request *rq, bool at_head, bool run_queue, - bool async) -{ - struct request_queue *q = rq->q; - struct elevator_queue *e = q->elevator; - struct blk_mq_ctx *ctx = rq->mq_ctx; - struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu); - - if (e && e->type->ops.mq.insert_requests) { - LIST_HEAD(list); - - list_add(&rq->queuelist, &list); - e->type->ops.mq.insert_requests(hctx, &list, at_head); - } else { - spin_lock(&ctx->lock); - __blk_mq_insert_request(hctx, rq, at_head); - spin_unlock(&ctx->lock); - } - - if (run_queue) - blk_mq_run_hw_queue(hctx, async); -} - -static inline void -blk_mq_sched_insert_requests(struct request_queue *q, struct blk_mq_ctx *ctx, - struct list_head *list, bool run_queue_async) -{ - struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu); - struct elevator_queue *e = hctx->queue->elevator; - - if (e && e->type->ops.mq.insert_requests) - e->type->ops.mq.insert_requests(hctx, list, false); - else - blk_mq_insert_requests(hctx, ctx, list); - - blk_mq_run_hw_queue(hctx, run_queue_async); -} - static inline bool blk_mq_sched_allow_merge(struct request_queue *q, struct request *rq, struct bio *bio) diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 1b156ca79af6..78bbacd129c9 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -106,6 +106,7 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) struct sbq_wait_state *ws; DEFINE_WAIT(wait); unsigned int tag_offset; + bool drop_ctx; int tag; if (data->flags & BLK_MQ_REQ_RESERVED) { @@ -128,6 +129,7 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) return BLK_MQ_TAG_FAIL; ws = bt_wait_ptr(bt, data->hctx); + drop_ctx = data->ctx == NULL; do { prepare_to_wait(&ws->wait, &wait, TASK_UNINTERRUPTIBLE); @@ -150,7 +152,8 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) if (tag != -1) break; - blk_mq_put_ctx(data->ctx); + if (data->ctx) + blk_mq_put_ctx(data->ctx); io_schedule(); @@ -166,6 +169,9 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) ws = bt_wait_ptr(bt, data->hctx); } while (1); + if (drop_ctx && data->ctx) + blk_mq_put_ctx(data->ctx); + finish_wait(&ws->wait, &wait); found_tag: diff --git a/block/blk-mq.c b/block/blk-mq.c index 4df397910251..9046f7802de3 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -568,13 +568,13 @@ static void blk_mq_requeue_work(struct work_struct *work) rq->rq_flags &= ~RQF_SOFTBARRIER; list_del_init(&rq->queuelist); - blk_mq_sched_insert_request(rq, true, false, false); + blk_mq_sched_insert_request(rq, true, false, false, true); } while (!list_empty(&rq_list)) { rq = list_entry(rq_list.next, struct request, queuelist); list_del_init(&rq->queuelist); - blk_mq_sched_insert_request(rq, false, false, false); + blk_mq_sched_insert_request(rq, false, false, false, true); } blk_mq_run_hw_queues(q, false); @@ -847,12 +847,11 @@ static inline unsigned int queued_to_index(unsigned int queued) return min(BLK_MQ_MAX_DISPATCH_ORDER - 1, ilog2(queued) + 1); } -static bool blk_mq_get_driver_tag(struct request *rq, - struct blk_mq_hw_ctx **hctx, bool wait) +bool blk_mq_get_driver_tag(struct request *rq, struct blk_mq_hw_ctx **hctx, + bool wait) { struct blk_mq_alloc_data data = { .q = rq->q, - .ctx = rq->mq_ctx, .hctx = blk_mq_map_queue(rq->q, rq->mq_ctx->cpu), .flags = wait ? 0 : BLK_MQ_REQ_NOWAIT, }; @@ -1395,7 +1394,7 @@ static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie) } insert: - blk_mq_sched_insert_request(rq, false, true, true); + blk_mq_sched_insert_request(rq, false, true, true, false); } /* @@ -1445,12 +1444,8 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) cookie = request_to_qc_t(data.hctx, rq); - if (unlikely(is_flush_fua)) { - blk_mq_bio_to_request(rq, bio); - blk_mq_get_driver_tag(rq, NULL, true); - blk_insert_flush(rq); - goto run_queue; - } + if (unlikely(is_flush_fua)) + goto insert; plug = current->plug; /* @@ -1499,10 +1494,11 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) } if (q->elevator) { +insert: blk_mq_put_ctx(data.ctx); blk_mq_bio_to_request(rq, bio); blk_mq_sched_insert_request(rq, false, true, - !is_sync || is_flush_fua); + !is_sync || is_flush_fua, true); goto done; } if (!blk_mq_merge_queue_io(data.hctx, data.ctx, rq, bio)) { @@ -1512,7 +1508,6 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) * latter allows for merging opportunities and more efficient * dispatching. */ -run_queue: blk_mq_run_hw_queue(data.hctx, !is_sync || is_flush_fua); } blk_mq_put_ctx(data.ctx); @@ -1567,12 +1562,8 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio) cookie = request_to_qc_t(data.hctx, rq); - if (unlikely(is_flush_fua)) { - blk_mq_bio_to_request(rq, bio); - blk_mq_get_driver_tag(rq, NULL, true); - blk_insert_flush(rq); - goto run_queue; - } + if (unlikely(is_flush_fua)) + goto insert; /* * A task plug currently exists. Since this is completely lockless, @@ -1609,10 +1600,11 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio) } if (q->elevator) { +insert: blk_mq_put_ctx(data.ctx); blk_mq_bio_to_request(rq, bio); blk_mq_sched_insert_request(rq, false, true, - !is_sync || is_flush_fua); + !is_sync || is_flush_fua, true); goto done; } if (!blk_mq_merge_queue_io(data.hctx, data.ctx, rq, bio)) { @@ -1622,7 +1614,6 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio) * latter allows for merging opportunities and more efficient * dispatching. */ -run_queue: blk_mq_run_hw_queue(data.hctx, !is_sync || is_flush_fua); } diff --git a/block/blk-mq.h b/block/blk-mq.h index d19b0e75a129..d34929968071 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -34,6 +34,8 @@ void blk_mq_wake_waiters(struct request_queue *q); bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *, struct list_head *); void blk_mq_flush_busy_ctxs(struct blk_mq_hw_ctx *hctx, struct list_head *list); bool blk_mq_hctx_has_pending(struct blk_mq_hw_ctx *hctx); +bool blk_mq_get_driver_tag(struct request *rq, struct blk_mq_hw_ctx **hctx, + bool wait); /* * Internal helpers for allocating/freeing the request map