From patchwork Fri Jan 13 15:51:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9515925 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 E76B0601DA for ; Fri, 13 Jan 2017 15:51:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBA6328710 for ; Fri, 13 Jan 2017 15:51:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D034428723; Fri, 13 Jan 2017 15:51:48 +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 313E128710 for ; Fri, 13 Jan 2017 15:51:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752100AbdAMPvq (ORCPT ); Fri, 13 Jan 2017 10:51:46 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:40923 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751771AbdAMPvm (ORCPT ); Fri, 13 Jan 2017 10:51:42 -0500 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id v0DFpVFd007540 for ; Fri, 13 Jan 2017 07:51:31 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : mime-version : content-type; s=facebook; bh=Sl4/DmxnF22p3VvfEqhx2cPqOsOz75QDCOGJY/sbDjI=; b=aBFoYuu6FEr6z0wxwyn2sZchxw+ucuF4ePGaSyC4/BOXJAavi8TT+eu5jg8iiRDtVmzV xJNN/AHcPlW9H5cGOCPMArjgEGaNM8jSOlSlm+vbPKMzyfGPCWrMfWwZn5OgwMJLR7W0 0uZc+LNbCk+fKdcRJXIfZlatXw3j/ivRTl8= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 27xxg6ge5j-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 13 Jan 2017 07:51:31 -0800 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.22) with Microsoft SMTP Server (TLS) id 14.3.294.0; Fri, 13 Jan 2017 07:51:29 -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=GlDW5nlf8V1CDM7gSulb2hhKtq9aAfAx7BpuHi9W/0I=; b=HbG/Q4nqhVqp/qJrD/0c2j8fo4CDVDHadFRpo+Fz8xktrj0xo308+QkAPW8ocJ+k/Y9p3ZP1c2fCPGOkH8V7OzCTOVjHf/8F8wPklut3RqujNq7w/+A7w53ESx15Al2URDmFMrEncaaT8Pij6cgHqx7z7sPehZXcm/Dn/Lsv2qo= Received: from localhost (2606:a000:4381:1201:6e88:14ff:fe1b:6164) by DM5PR15MB1321.namprd15.prod.outlook.com (10.173.210.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.771.8; Fri, 13 Jan 2017 15:51:16 +0000 From: Josef Bacik To: Subject: [PATCH] nbd: create a recv workqueue per nbd device Date: Fri, 13 Jan 2017 10:51:13 -0500 Message-ID: <1484322673-10606-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.5.5 MIME-Version: 1.0 X-Originating-IP: [2606:a000:4381:1201:6e88:14ff:fe1b:6164] X-ClientProxiedBy: BN6PR10CA0022.namprd10.prod.outlook.com (10.172.16.160) To DM5PR15MB1321.namprd15.prod.outlook.com (10.173.210.11) X-MS-Office365-Filtering-Correlation-Id: e5512173-1cbd-4c4b-d95b-08d43bcc02a0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DM5PR15MB1321; X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1321; 3:xn4PuMRn6w4979rSdQZHEV9msTRUpZdcQGgKK58SWLNogua6amXtkwmPc/Sk5wWEN7kq8k9HNh+gXa5ZOXuz4hjOw5JmUe4UWnJmrcCEjfB0U5u0oUiqG3fszehQWaxeXU9BFPljH43kIIWBNl0/r1OdHOgctmb2e3ptjzghNTvCJEkLqz72fiQKnb2H0FVhcO2qKlECvK5WFt/RJd9cK7Q6jy9u4Reeci55tHfmE5KI/njqp5+53pqwa0fcbalG9ga621WgW3DB+qtQO7t/jA== X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1321; 25:jvhy4U83TwZPR/LTZo3J+gzKVwMczOKbia4bHTVDvAyXVBhJtTfTED5P7oYZCkR381FgtfSBzmVo4zHTsJC2Ovl+oGyl6JKgUL97cf63cSeqbIgpwT3HyoUBPXbV2cwyXOCaLWy+1+DxTr3tO2HTa5d9nB/nZfMxYypYxr16FqnCXDN172lAqGTTblIOsME2jaYJP+WvTg9rQWpf+EkacFaRyRO5DnwcPyQK34c+0vfaX70EpqzoRzUlc8erKab/4sbSQXyePjLaUZYYIeSx3mTkX86JiSbymIAnBlqovJHhLplcIvj6EFNN2xM/agpx9wM4gFJ26I5VM+pAf9nXwBdiFaTTqM8aZP1eOUY+lk0Xe5yOcsxKRvF1upD29yz+nYCMwqqA1rCPj+PSsCPhnmA/lwuDK0zsLuTfTL4rla8qnXkUZ7FdE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JtjpheOg3zy16fWFth+XW6k8jTJOWjL3aBmUT36/3DXiLoUbw8hgwP3aBuUlhlmKaVkhbM4rEK1mhR01lOVotKlajDTfXE4aEt11+Dk1WwOYnPXCuolNpSNzNQ+b/hYwot 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)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(6072148); SRVR:DM5PR15MB1321; BCL:0; PCL:0; RULEID:; SRVR:DM5PR15MB1321; X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1321; 4:No9oGAz4xxnSd3RIV1Zl52eE1XXf7YX0Z1RT4sWuWsYCrJ9hlx8AlcHhODOnwgL/gdZZCUP7l66Ft1XE5hINUidPdBkN5lBmGjdIYspK6zep0UP71gqZsznGGcUsOd05afQQqWQ5I4cPzA0P1DZEVB9YSoqS1WC+ch2ZrWWGG+uwpFtZfBMQeqhUYa//ZQaRloX2Y9MoCnXzHJTVhQFuRwavPJ7hJ06NasEcQI5NIYAIUx2/3pn6IisXmIH0GkeDAyumUGA2Oz+W1U/O6sF7crLxb7qXymlfD4OsnZPb+7dogAUO2BHxqDBKR01QYpJ+DrMghuovpnNPK772iHJrIPBYDmCd9b4ssO0fb8Q14HNBhqEV/WnGMCM0Jyq9i7QOmHQrEiotTSpnsrlR3WPMHpnrH9sRBnnSSPCkyVVJudofFG4tvYsPjSai+n9SxjJVi+NxkARmilkX8tZBFG5uuQYgtFnrpgEiVJpKVR2TtajkVNGmg78nJu8lwblsS569RGdHp3f9xK2wpJPaHc9xjUs6s/NSiprdTLlzH19Nvd71y+lAsCJxKMtXIQY2N38i8stMRYgMuxMJEOgUUeC1DEK6tIZqBBxaAHFa1HOPj6H70POylgbJEEt9PeroSBe+ X-Forefront-PRVS: 018632C080 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(39450400003)(39410400002)(39830400002)(189002)(199003)(575784001)(8676002)(48376002)(6666003)(2906002)(81166006)(38730400001)(97736004)(42186005)(68736007)(2351001)(7736002)(6916009)(105586002)(5660300001)(81156014)(86362001)(189998001)(5003940100001)(36756003)(6496003)(106356001)(6486002)(101416001)(25786008)(76506005)(50226002)(6116002)(305945005)(33646002)(110136003)(47776003)(50986999)(450100001)(92566002)(107886002)(50466002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR15MB1321; 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; DM5PR15MB1321; 23:PKM6UNPBpVgUTJLVrKuX07M3DAZzuMOlqqCo+xiQN?= =?us-ascii?Q?c2NTC0CTzcWmzkaoZTmkqNmapWOHAnJqIbIZEP9TcDBHxIIafl1GlSjWRkC9?= =?us-ascii?Q?FoFnAYwucUZffYvJ1D002m8JEGXCaa6+7UZnJ5L6dqyQGIYCyaMjV6+w2yEM?= =?us-ascii?Q?r07h7H3Vnilf/LMV36h6Q0Rn1nS5rR6NFOxlRIBAofrxQzIUP6e7Fn9BjO3D?= =?us-ascii?Q?GdA4+g75dRfwqhkGVQiA1GROCr6Pck5TsM/d7fiz7Vj53bntYKzy72N3w+by?= =?us-ascii?Q?tghKUsrQjdXhGF5xHqQZgQuAS/3dc8nyGu5FtZeRoBYoLgNHSo1OcywI92Pp?= =?us-ascii?Q?uLmcG4+udsxW7OPL3Gl7E5gMqQurk/UEKS/Y8nGeB1oa61r4WWqd90MfG8fV?= =?us-ascii?Q?oHkbKUUgP8dyyIeB9Rx6xyZ5KebK1jpUlIsiM1VyAqTw1l31ZhgTmJUa58Xk?= =?us-ascii?Q?2o2p5Z4eo3P1RiBX2Zo/CLFcCClc4RyXuyfYhzK52qRsjoKb/z1P6VmEgjbX?= =?us-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yn15v8fytfsdlb/W2C9bzqHiKfXzWYmBZMMNEe16UqJzCuQJRQ5+jz2lMzR+nQrbeiCSeuvKr7+RvH0hniOVVtF5PGc2eE= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2017 15:51:16.7834 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR15MB1321 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-13_09:, , 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 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 99c8446..e0a8d51 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -70,6 +70,7 @@ struct nbd_device { struct task_struct *task_recv; struct task_struct *task_setup; + struct workqueue_struct *recv_workqueue; #if IS_ENABLED(CONFIG_DEBUG_FS) struct dentry *dbg_dir; #endif @@ -787,7 +788,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(nbd->recv_workqueue, &args[i].work); } wait_event_interruptible(nbd->recv_wq, atomic_read(&nbd->recv_threads) == 0); @@ -1074,6 +1075,16 @@ static int __init nbd_init(void) goto out; } + nbd_dev[i].recv_workqueue = + alloc_workqueue("knbd-recv", + WQ_MEM_RECLAIM | WQ_HIGHPRI, 0); + if (!nbd_dev[i].recv_workqueue) { + blk_mq_free_tag_set(&nbd_dev[i].tag_set); + blk_cleanup_queue(disk->queue); + put_disk(disk); + goto out; + } + /* * Tell the block layer that we are not a rotational device */ @@ -1115,6 +1126,7 @@ static int __init nbd_init(void) blk_mq_free_tag_set(&nbd_dev[i].tag_set); blk_cleanup_queue(nbd_dev[i].disk->queue); put_disk(nbd_dev[i].disk); + destroy_workqueue(nbd_dev[i].recv_workqueue); } kfree(nbd_dev); return err; @@ -1134,6 +1146,7 @@ static void __exit nbd_cleanup(void) blk_cleanup_queue(disk->queue); blk_mq_free_tag_set(&nbd_dev[i].tag_set); put_disk(disk); + destroy_workqueue(nbd_dev[i].recv_workqueue); } } unregister_blkdev(NBD_MAJOR, "nbd");