From patchwork Fri Jan 20 21:56:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9529565 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 19DA66020B for ; Fri, 20 Jan 2017 21:57:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A0EF286D6 for ; Fri, 20 Jan 2017 21:57:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F148286DD; Fri, 20 Jan 2017 21:57:49 +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 8F8C2286D6 for ; Fri, 20 Jan 2017 21:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752234AbdATV5q (ORCPT ); Fri, 20 Jan 2017 16:57:46 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:50941 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752229AbdATV5M (ORCPT ); Fri, 20 Jan 2017 16:57:12 -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 v0KLrtnB027501; Fri, 20 Jan 2017 13:57:01 -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=MzKRJVU8K/H4GWFawXClKwtz6ckFsfz+LHWLppN3iBtiV8gRQC1Rnxd0Xj27txsWKD4Z Acsn/6/JCQFX1KMdgcXj3jCxrLDeVkNocdtq+P0CIYOJIRGqtunbGmVR2hO+bKUD7ta9 UF0Rfn23kT/ExQgGiYMMhC/nGQlVLf1xCJE= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 283p3r8w8y-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 20 Jan 2017 13:57:01 -0800 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.27) with Microsoft SMTP Server (TLS) id 14.3.294.0; Fri, 20 Jan 2017 16:56:59 -0500 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=VQd2jRUtzgG0AU2M5xH+I1z4aoZULDH396MEDcbV36TxXTpboUccYxoiKUPjkSCn7WwNNbMQRXMqjFyemHQqQ9EEseUogNjyubv3OUrmB0AdeXVobo0SXshNCz0rLCDrqSCFHMXyMGN0777a89aRAqHLCj7HQ5qUgKxwSqvOUUo= Received: from localhost (2606:a000:4381:1201:225:22ff:feb3:e51a) by MWHPR15MB1327.namprd15.prod.outlook.com (10.175.3.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Fri, 20 Jan 2017 21:56:57 +0000 From: Josef Bacik To: , , , , , Subject: [PATCH 1/4] nbd: use our own workqueue for recv threads Date: Fri, 20 Jan 2017 16:56:49 -0500 Message-ID: <1484949412-6903-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: DM5PR18CA0015.namprd18.prod.outlook.com (10.175.218.153) To MWHPR15MB1327.namprd15.prod.outlook.com (10.175.3.141) X-MS-Office365-Filtering-Correlation-Id: fc17d5d4-5d2a-44c0-2728-08d4417f418b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:MWHPR15MB1327; X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1327; 3:rUvUCGBwd+GLwjSDESpqh2BGHfgQxRn9PS2f2QjVn8AZ2Gg6kD8qbLEUmjBLblrnxATwAwTKgWs/rU+6LyfpIZ0hNwiwAKaaCICREC+KZkFWd6z4QIY+un4fR9nD+2kbyDXY78lXWMLNuT0uDDXJyEofurVM/0u+SrIyo4KuBxIN10hH8w79AIhXbodMDVumi1AeLp+EXsvnp/aZTJwXFBNkleEvUCLlcV563jarsAFnLp9zlNJgeI0HO81Z310m0yRg2qs4QLWscMR3t/+NzA==; 25:n/MqWpSnCRIExcX4Xmh91wb1UtsK02VVvfjsqgkYfNxw+MA7NpJ5Fj8W2nfkstL0/AZVwsjsEcaffmHqzdkYhenw6STgaFuwre+v9R64FXloyXz72BzCGUn09DHrh0Gd5kBlJsmRGebVHKi1oFdiizlofPGvb6revFul1FPiwYx+/8WwIHP7V0YC0RYcHblSoLYgTthtG+rs0wEKtjAuWdF7zwau23/fCqeNwPhPG7mfQMdlTE7NHothv2ONFxATKE6ikQoCxoiN9MoBgzoaukN9tlZEeLXRLulIxJcFfzyILpGNM8Q9M4+k7BMCw0EV0AaG7u2N+Z9kVSZALUdvo0pTl87ZPvnIbtVwb2c0hjd+8joh4DC6NeI0KmpckjFPef48PDR9tUkOEbmWkfOT0AGW3IlB5qdPcpHcyVc5jBIKamOQsXjGGcEw1M8vVqvBziXPIOjroAL6ZyYfievrIw== X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1327; 31:FY/+YzbblSXPGY00O4nBwBF6g4IRAzwfxWSeGMwDzWkMcOyOeGBxlR7Panejt8rgmukazYMVh0wPSJE0l59tRz9w+1/zjoF2hw4nOdRftRRaMbicQ/ZCgW5hNqpNcRrzFqAPfYt+Asoeg8uQ9vWedIZmgHLjeRS4kWdYYuKIGUo+EavOHwVfm46dqPULob+wkfb0lKet9wP7LGYEa6RHJzrqH/+ehNLgj+iEjBv8ANifsihvpNSlAHuu3pWt7bjT; 20:Jzx8lBIJFFyab660UlB5O+lEoBUBAdDCpUwjkmxe1dDW8hbSvtn5wXcMAHWP2v0prWqY1MAGavpQ1yJ6w9gt3zP+OH28popicFRNks1dFe/VuhLwnUIcRevaUZEH/8WfXrb4AHzahEIHjI9ZLZZV6pJx9kN17T3gPfuq9QS+zwovYgOyK8+GnabJ9H2o53CbljNTHhgw5gUPZ2yBuuGILgcwiL/ddPH/iOL8CRKudFcW7CH+Yaf1SKvdqXg1gSAEiKtuYsqjWPhd2gfP5ro2hn8xdZAYLZEVl2+2CS00Sm0k+DQuXWWRhUGflB6qHFaD2qMn+hmzq+4z8L9M3Pc6wMCVr+wIiHUVj0xToFfDoXnrcN6nu497YaydNsMzG4Zx3JBh6OwkCBuFMj7SxNI7cJ3nnqmfDbfLaE/A0d1HNQRbTa3qNkIsHHXOXYClPct2Ad8rHTem74METEo5SmFUaPXONAQdHAFF4LwkeXh5w1yOMBI8F4kY/1snI2G6D0Kw 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)(20161123560025)(20161123564025)(20161123555025)(20161123558021)(20161123562025)(6072148); SRVR:MWHPR15MB1327; BCL:0; PCL:0; RULEID:; SRVR:MWHPR15MB1327; X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1327; 4:pJU2npdRU4dBly2+DUqV47x+rWdm99a/f/c4Xou2wj2oMAq3yCTu2R8/elLaTP8iu61xLkIGbdyhAkXB1cHM0D6iu/Gkuqt/SdO1X+u6SRJvV8AQpYNf/NtoxnbCZ0j0tWO51L5PSPWjMgG0TqER4e9c2tKGreeWeGA2dJ8TvKtAPkvZmx/ufk4PJVPeOLd16eRmJ0Z5ullFDmnHl5MmK1G/bNPfGXUh4fC03gb2ZpUePDnnnAWu9DZWJGU7xsfYq+H8iL/dWzz85qRXlvFMAAmADdq26RTtAOreCyZ7KK04JKSyEFYLjYPIR3md0XciDHuyZypVFOM5k80uLGI+SQH89Uv0QPVGC/Nebih6u6Tk0JDCNKfttrqG1TELjzvne41j4LBJSyi+b0wg5seBm2l0svwO3lGQNPfcLlyEP4VTgUdbgs4/2SqWMvc6QHl/w4gSXl06/oXkKL80VNBEzeeswg/agnCo3Xnxs+1Cak2jHDp27mnCm1OuJqJcVr1pAFJ/7AhPTX3F6VuC7PK40FSdnOY3cy1JDXIb+Vu35gJOaSPJpUsM3kPWJMIdICEi0QRpQwFPN/86xBquv3FEYWwJ5vjMaXcHj1yllqR37bYRK9sC9tGQiOCoLWYUv3aBzzr8rYmKFncv6e/T95YUrQ== X-Forefront-PRVS: 01930B2BA8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(39450400003)(39410400002)(39830400002)(199003)(189002)(6116002)(106356001)(25786008)(97736004)(53936002)(5001770100001)(107886002)(6666003)(50226002)(68736007)(8676002)(92566002)(81166006)(305945005)(81156014)(189998001)(36756003)(5003940100001)(6486002)(6496003)(2201001)(50986999)(76506005)(42186005)(101416001)(7736002)(33646002)(2906002)(105586002)(6636002)(38730400001)(48376002)(50466002)(86362001)(5660300001)(47776003); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR15MB1327; H:localhost; 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: =?us-ascii?Q?1; MWHPR15MB1327; 23:RcV4EA105wpRdHjtpjRWY/91+k5t5SPz+3Yam2NkD?= =?us-ascii?Q?kj3r54V0t2CgpdUuw+drxbvRqE0zRfsmAxHOIdjKMUM4FNORCXyX9IlNwDeI?= =?us-ascii?Q?UJESs3Dwfyoiby3nAic6f/gctku8zf/5bOwBpowVyBQr2HO6wscXomsEIKUT?= =?us-ascii?Q?RcYIMYgHrdf9Fe8vYSWWIS0ZutxaYmwphmIlDiVCnFKwKOdOJR9TRbxyywHz?= =?us-ascii?Q?ygwj8JYimlgS2jXUcBlYOB7rs4o+jWvyE8k6onZcScqDdKNS0eZ2QhKSTeCG?= =?us-ascii?Q?F7D9hAS7CH7BmDo7Vbv3s7cWgL4JvXMUgcrfMcOLGrpVYUTeWECcf/cLsMzW?= =?us-ascii?Q?XAUK6FBTyW3GUzkzJ00/eo6o+bdpebWbTpL8gBitEYsm5MedlctlnOOgUyLW?= =?us-ascii?Q?UKo/F2ePz+66q98frAhdS6r1rDZg8mxKPPzD+mWrsiCCMG2nnC1p6oqy/5sH?= =?us-ascii?Q?Bgz/jTGd6ZEOAtQFNLX/+Q2bwdUwjDZNvQjwONHCyBZYwf8Cmrcb0ray3x9L?= =?us-ascii?Q?+RR4Hm/+7Qfef822k+h4XfPld4PJHBgUAiP0g9n4NM3cnhuegYDVc2zZZ09z?= =?us-ascii?Q?juiMxODVBUHzNxqRhW1mgzncVhpWNTprB5LCneGWEirtZRTu/puz66n5Ncaz?= =?us-ascii?Q?OqizO5uAaGfnnz2KIxtHFidphuoSUTE6OMGQenNRP2QZtTc0VfxPMry717nT?= =?us-ascii?Q?wpkm+5GdIo90Zw1urKdjjeS6OXsuEJ9Inqdwow8n3MXBHgqott0cYvnQBniI?= =?us-ascii?Q?SbuPNOfmw13pYeadhsFNvTHUjte9ZGL2IgcE9P8fJvct+ykBguy3a5gNW3az?= =?us-ascii?Q?unXVi8606W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qooymHqU9762F21Gi+hUF4TjIOOESves= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1327; 7:QIn+tNloMSspz2VptQDhKJiTPdSggO18s2ED7CaiPifwo9hbOQLXnW1gsWnyhQtmu1ZDc9tBQH7/S4hMhoUG5WTW3U9if+k3FF9k9N8WT8RBkcjRBsF8QW5Fx0L15Z5Wy22ewtO6F6iE1TZ+lsdLXVZkyJJmC47DFlsRu4trYGzozYwNpUvkoxfCEScRzoz8r7vNIJ0lttRAdvV7vEJJ8Mz+2Tf1N+iHtYa3qwvllpAoibKxnbn2U5MaozltBgjz+y5N6F4RxZZiKM05ilEtTlgWwblaHuL1v6MNlCKPw366h2Eca79DGb8Ooh5DCbo1XkSNJ+tkWZ8Fy38Qtiq25rLZmON6X+pypQINK4zl6xU8lDYjc0hNu5o/IiEGP1NWBWxqjE48EDSZkD94pbnXulv1iBhEtGUQuTKc0LGUddKlPUzZvKpJKfmgsPU2P8S25LyWjhh7ux7DsKBcSe4plA==; 20:CH4SIuA7PH25EMzn5EZFvq34PYMbkTE1Cra0XB2K/m9CbizqXAzXI9EiTCqlVxuH823J5hsvGeyVcsm7MvWZh+UiJItFTgyz+Tipd96bU3T7/kB5uuYFiHlR5g55WYgYQBtGXqbxFZV8iEN5RiJhzOXrtlOnk1J911GUSBGLSps= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2017 21:56:57.9901 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1327 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-20_14:, , 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);