From patchwork Wed Feb 1 21:11:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9550681 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 E586160236 for ; Wed, 1 Feb 2017 21:11:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEC252846F for ; Wed, 1 Feb 2017 21:11:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1C8F28497; Wed, 1 Feb 2017 21:11: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=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 0A9CE2846F for ; Wed, 1 Feb 2017 21:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751075AbdBAVLe (ORCPT ); Wed, 1 Feb 2017 16:11:34 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:49964 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750863AbdBAVLd (ORCPT ); Wed, 1 Feb 2017 16:11:33 -0500 Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v11L9Hwu002694; Wed, 1 Feb 2017 13:11:32 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : subject : date : message-id : mime-version : content-type; s=facebook; bh=e+uFkj55MzVzcSlK+zqGZ13rwt9R4hcnvFEg/8AcAXQ=; b=Uioi0/MAQ5hBIyhy37J8JdnM4K9yLrO78lD92tqiRmKOhp21zRODZmq/fzJsJrUXA+/V /I0xags7RQLUecGCX4hg32mT9xXQv5rKtmpO8HEB44YkxrJevX0ynLEBVaW999htOu8p Mw5v9geBUOGHfkMz3xlIWPkdpO3A0oyP7UM= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 28bp4m08ut-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 01 Feb 2017 13:11:32 -0800 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.13) with Microsoft SMTP Server (TLS) id 14.3.294.0; Wed, 1 Feb 2017 13:11:31 -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=e+uFkj55MzVzcSlK+zqGZ13rwt9R4hcnvFEg/8AcAXQ=; b=j6XuGnL4j7JWzA6H4u38AY10utySd+2NJEYHYn5Hb5tnDFxpgS4qTER3kftdAFee0lAq3sdo0eQ58gnFJ7wu/RynO2+GUmBaiJF7gyanhvKHIk4GngQAWVACUlGEcUXrGPRgnDHL9CpM3YLpXeyika7cTi2hYBN3EodgvtOZVwQ= Received: from localhost (2606:a000:4381:1201:225:22ff:feb3:e51a) by CY4PR15MB1320.namprd15.prod.outlook.com (10.172.182.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Wed, 1 Feb 2017 21:11:14 +0000 From: Josef Bacik To: , , Subject: [PATCH] nbd: use our own workqueue for recv threads Date: Wed, 1 Feb 2017 16:11:11 -0500 Message-ID: <1485983471-3717-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [2606:a000:4381:1201:225:22ff:feb3:e51a] X-ClientProxiedBy: BN6PR10CA0005.namprd10.prod.outlook.com (10.172.16.143) To CY4PR15MB1320.namprd15.prod.outlook.com (10.172.182.8) X-MS-Office365-Filtering-Correlation-Id: 4b15a9f2-4f12-424f-f016-08d44ae6db42 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY4PR15MB1320; X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1320; 3:fa3LwcYVAdnuGn7/8Ltdr5XgKu2YjlG3keOqFtLA4SlHnQ1wkD0Jeoya3BdObv5lNNU8FQz4zJm6adj3LHxykfCG6Y5/5qgDAZg6xGmpVO/0tzxNoMdoLFR85HCsDo3V03j4nlfOEwx6F3mMV+gSuemUY6dU3JvdRcNbqPJZ4ERDHTt46CSAVn5INRnD250loiEJNLT5h/ha66oATN1p7v2CA2V0H6TpB3u8lzcWIz87euLge/UbtNS6foF1BtiFruMr0+jIf/kt6+YLmlEcWg==; 25:pyEQ8liZ5xOyThNLA4kzHe1fm4Lufavxv3GaoRnaBjJ6d0dXB9S39OBLrbMwXczIqbjT8+MOAY2hXk5AzitBKeP64Wj1HXeOuJzYoyflg0WmXSJi38zgVK2joMV5CJNB5ilMstoXnVtU12wxUgdsaM0cG5bEwqfmHeJtqAT5S+M/eIX2xmZ7nJ5mU0fUuvCvBW8Llt8nhQqi1rF+NBzZTUu7uS3fBvuvVYUlXa/yzw598nvTyf75y5UIDfS3oaCBIbAEIa2rzqAFlwIpUWXTOvuqzTC2E5SUpvBQc0h2XRmjsD0gJIda94udg5V6MnBmxoA4HKp0dt+BevHujtfePPwbw5mXhRhbXALEgssh/hygX48JnFr76x+lfdNq+XjYTO6zC91xoaSsvslIUpEGdDfeT/As2YXXNUgdZTfSm2f9gRVmssvAt0euw+fLP3Hmdzr8KpVPngxH4FfN53N6BQ== X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1320; 31:sMepsaSH7KERS1/xI6mjLDE+XOwydqSlDpK2HgpA59h2dRCc3EvwRYDguDFDmwJ3hN/hSpSgM1A8TbZ7/P33ow+ZlbBb+zgQKVPL/pMS4GZDMke7H9dWHb1KM/VelcWq9qkUklfIqDSzUOdMqe0LfHmZgQqrQlH4lKdtWda9qsvRtzbzRc8YhIISj9qlBNsTps0W5GMqL2yPZH+2n8qQfThl1ObSQQb26AX6+kqGrwy5WvMPXKvM8HKYze/coNBoCMxlWsIHhdQ0CuqBTrsKOg==; 20:22CBvgZdIjEfOS7Z7nqqeLhxlq1jqI4EgApzwJ6IDBdYZK5M3RWqFK6pQxykgy3ySOptnElzYve8WAZcjHM1m6l+qzRQCEVy5tFQmwsQzcYJaqKcl7v3GM643xOTRQIAcGOTF/uvZuaWkmW6ldix0tkApQo7ipNWrxYZk50cEuDygtLiEI9vkkcBX2RxC35wPjXDwRNfLyeREvm48CQsEc15zlth6I9D1HtVSuKgCa2rpMUSdgYWuSAkpcgqbjoFYY3Fyq2C4s4+j5vE+w1gG75XGCUcAk+BbGPby2qo0bWGm1IsYy+VHwUjl5wApXfUGku63Doct2yvEpIo6cfxxRcb/bWoy6HFUcw8IUkMnbW88EUPYzwn9cP5DG+Sv+IcaaiIf2KwAc/WGloaSPhMiu4h4HNJ8uyXzi/UQ7t99cd+HBn/Pq5YZ/E608GHB7sPVNVlOl6KXkWHdmVu/FLJgYo7uoGry/o1WK5LxODC0NYqTbTesxv6FTlcugfocbad 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)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123560025)(20161123558025)(20161123555025)(6072148); SRVR:CY4PR15MB1320; BCL:0; PCL:0; RULEID:; SRVR:CY4PR15MB1320; X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1320; 4:na4xkurYkMdh+Y6D6cP1+7JFw2VajQQFB4fnVyA2DZuewiqAm8DsPS3XlNveZBldLdvWw6PhZML4lNOQT2afX/rUuMQeyOb6oAbz6qL+UKpDNL3pZd/3DjdGhF33YSK0V+9a950KlkwUpheWdaxn34SuJDi1gHfxTT0GpeqxRO8n6NWSyfJqpsYpiMbpv15jqGxaDWxihnbKSUOH7fFk+iVDuxsShSQdz1IBdkDfx+BEwmhOSNLueBqZCObZQDWy8vvQEG9wPKvQ6oKU7+ruds795SA/yebgb6hJORvqwcD9RmSpKcj3s36mckrnpU2TQJCVvTo6faWtHQc/UeAKf4MR9NEELbZ+LASdoeXfGkPrmW+uLU4TDC2gcb4z+ysAwLgLOUW2UqapAwk7X7RChNoJ1KU1+T7pB6xejxunF7Q6WthA79WGX/O0D/qBaAjqf5+qcpdO54H8hHJmFPDXtEu+WzsypToeGwgkWbWlg2btNAl2UCNxH89p7OhgPp5S6S1v8DDtCmM6wq2r3JpFUrQOpD2OuqZ96YThRJ8KeMAU3V29THjQzq+ZwLtO+lWys4B5cHoI76S+5/O/RfzXhGEWQigy1Z1q1aAe7Zlg2Et4Ba7w7AYoli7QktzfcfuGS6m+Mv+xrSl2AOAK53gEVQ== X-Forefront-PRVS: 0205EDCD76 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(7916002)(39410400002)(39830400002)(39450400003)(189002)(199003)(6496005)(36756003)(33646002)(97736004)(53936002)(305945005)(6116002)(189998001)(38730400001)(6486002)(2906002)(5003940100001)(107886002)(5001770100001)(7736002)(50986999)(6636002)(106356001)(105586002)(42186005)(50466002)(47776003)(68736007)(48376002)(76506005)(2201001)(92566002)(86362001)(81156014)(101416001)(81166006)(5660300001)(50226002)(25786008)(8676002)(6666003); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR15MB1320; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR15MB1320; 23:i4LMGHU7Nlb0+P256BYhcePADlW/wTw0Ici2lFd63?= =?us-ascii?Q?bTc5PTIdTpFyQ04okGeWEX/8oyCdcD6dEgW6Lf7gecLIFwtRXawZJV5cXoAM?= =?us-ascii?Q?UzaGVWYJJcqXr0knA96KarY44DW8MGBTO5ligu/EY12wdpmZxW3+M4fFSiHm?= =?us-ascii?Q?KCBPBxg8GCjLF0hZ64YCjAX86dg7Syz+JB2zLrUB4JPd2zihfVc/OzAtWTzv?= =?us-ascii?Q?lEKbRtfOFcXllvKnSZQ4d/fVYbxPJDVCK7aS4hvctxI4ZPfStCXl8v+1HMav?= =?us-ascii?Q?4QS+TzrgEkdMVoTsmcgStu+KRiG2HkvtMVzCVFxkyxj7wf5Ucx8V+GlEHce+?= =?us-ascii?Q?Jc1MewJdOXWLpditevdBIci4ZaiMaMK/bKGdVivkPCKLac+UHYg47O+uCX7T?= =?us-ascii?Q?DHNdKItbEpnUo0IXEQ4m/AnyC2TQ9ZqkJZcgc/QEMI/s0KKVdGHelL5/bRRK?= =?us-ascii?Q?3aZXMuMSdNpm2IHrAYZXYxTsgVnQHLWeOPQWK3z2S+CXqrQJzzUs/nt/miZg?= =?us-ascii?Q?L66PN5MymPyAMjcKL+v9BJ+zYOTDK7LystX5K3vvV2ClB5rsmrbYLqEPm5ch?= =?us-ascii?Q?5FsCCAxcZFA98ILlqasx6FJDsxQV3W8/5t62lfop+aCjMD8d/tK8f74gdTsr?= =?us-ascii?Q?maHNlrPQb+v5eBrbmPMhRSwQW36Dn71k1xSARQOpwY+SAKjBNfjO+vROVybv?= =?us-ascii?Q?TP+wyzgEjzuHeaIdeRR4wqSw0V5lrhtKC8uqsojlhiEFIxfogPJHgn6RJtAW?= =?us-ascii?Q?Zw7B06ANOHyKDqTUcstZOQOjRcjBk3J+/Xt/RlE1SgLmcgJoC9BdTBdW7Pmr?= =?us-ascii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88jNYFZFC0vc+V9pkpIkcq0jbEA4Koc9mLsxzgUpfKfllIe8A3ElpfxSX3c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1320; 7:VkLII3I6AqKX4eiOLI5YhVXF7Iixk0olu0tGRVw8iEaBmembBXlJorjJ3F6gbtfD0vyyke5iTZD/zN1M11sN94fOxaUMH9pPEe/JwDQNTfCxzM5mtDyvKoHoaHbckDy6H9C9yVDL4wRREG8avYkKCg1Psg8R5AUMj8D8rulCHEezrYKTt07vGrPfA52VJwdGE9AOP4uMti0zUZZTfkumJEuWrtyE08Q1Xe4yyS0sPyF17zwNUKmwRynFZ+ItmkEDK9WtP75RxfuZ1XeO51cPiuycu4fWGcLKFQVhlqF57GfF5kEjCgQ3hC/2IcNpUbUiRlzW5QHzPXlBfs1xSrKhUYuq/fRscYvSSNfO4vkcZrrDYH5q9zz2kIkBLGvaJyo+UFbiVWp1d4K6mM02jtGfBD3ZWDi7MCyNMsX/T5b0G8o22Gb6+maCpAykrdLfsPQVy9AMT883/SDPeoSe2sjpcWGHGbcj09hqyJbd9RsoiK4Ee4hM0d3HfWx7fLLDrvVekyc0Qc4tXhUvGhC2YLeBO+F97dlzqNgXyS7x5uckaLpCnGL0L3jht46UAnpGiF7j; 20:I5+DD3hWs+M6TbfEtvmB+wePZpRJVsQwfEL+CrkMi1NSkSl16SNFRP4NPiR0v/eSG6WMU9S4v2693MEu+MtzQsTqig+JIS/pmrW8cONSHXxoHwUth6ItvBp5ZQsjZJJPNwAoTWzBqH/mKpqAID+thZ1iL9WdwsrD/gZTNdsClps= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2017 21:11:14.5941 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1320 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-02-01_15:, , signatures=0 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 Since we are in the memory reclaim path we need our recv work to be on a workqueue that has WQ_MEM_RECLAIM set so we can avoid deadlocks. Also set WQ_HIGHPRI since we are in the completion path for IO. Signed-off-by: Josef Bacik --- drivers/block/nbd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 9fd06ee..9fe9763 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -91,6 +91,7 @@ static struct dentry *nbd_dbg_dir; static unsigned int nbds_max = 16; static struct nbd_device *nbd_dev; static int max_part; +static struct workqueue_struct *recv_workqueue; static inline struct device *nbd_to_dev(struct nbd_device *nbd) { @@ -785,7 +786,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, INIT_WORK(&args[i].work, recv_work); args[i].nbd = nbd; args[i].index = i; - queue_work(system_long_wq, &args[i].work); + queue_work(recv_workqueue, &args[i].work); } wait_event_interruptible(nbd->recv_wq, atomic_read(&nbd->recv_threads) == 0); @@ -1034,10 +1035,16 @@ static int __init nbd_init(void) if (nbds_max > 1UL << (MINORBITS - part_shift)) return -EINVAL; + recv_workqueue = alloc_workqueue("knbd-recv", + WQ_MEM_RECLAIM | WQ_HIGHPRI, 0); + if (!recv_workqueue) + return -ENOMEM; nbd_dev = kcalloc(nbds_max, sizeof(*nbd_dev), GFP_KERNEL); - if (!nbd_dev) + if (!nbd_dev) { + destroy_workqueue(recv_workqueue); return -ENOMEM; + } for (i = 0; i < nbds_max; i++) { struct request_queue *q; @@ -1117,6 +1124,7 @@ static int __init nbd_init(void) put_disk(nbd_dev[i].disk); } kfree(nbd_dev); + destroy_workqueue(recv_workqueue); return err; } @@ -1136,6 +1144,7 @@ static void __exit nbd_cleanup(void) put_disk(disk); } } + destroy_workqueue(recv_workqueue); unregister_blkdev(NBD_MAJOR, "nbd"); kfree(nbd_dev); printk(KERN_INFO "nbd: unregistered device at major %d\n", NBD_MAJOR);