All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fb.com>
To: <arnd@arndb.de>, <gregkh@linuxfoundation.org>, <axboe@fb.com>,
	<nbd-general@lists.sourceforge.net>,
	<linux-block@vger.kernel.org>, <kernel-team@fb.com>
Subject: [PATCH 1/4] nbd: use our own workqueue for recv threads
Date: Fri, 20 Jan 2017 16:56:49 -0500	[thread overview]
Message-ID: <1484949412-6903-1-git-send-email-jbacik@fb.com> (raw)

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 <jbacik@fb.com>
---
 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);
-- 
2.7.4


             reply	other threads:[~2017-01-20 21:57 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 21:56 Josef Bacik [this message]
2017-01-20 21:56 ` [PATCH 2/4] miscdevice: add a minor number for nbd-control Josef Bacik
2017-01-21  9:03   ` Greg KH
2017-01-21 13:25     ` Josef Bacik
2017-01-22 11:09       ` Greg KH
2017-01-20 21:56 ` [PATCH 3/4] nbd: use an idr to keep track of nbd devices Josef Bacik
2017-01-20 21:56 ` [PATCH 4/4] nbd: add a nbd-control interface Josef Bacik
2017-01-21  9:05   ` Greg KH
2017-01-23 14:42     ` Josef Bacik
2017-01-23 14:52       ` Greg KH
2017-01-23 14:57         ` Josef Bacik
2017-01-23 15:03           ` Greg KH
2017-01-23 15:52             ` Josef Bacik
2017-01-24  7:11               ` Greg KH
2017-01-25  8:55                 ` [Nbd] " Wouter Verhelst
2017-01-25 13:47                 ` Josef Bacik
2017-01-25 14:23                   ` Arnd Bergmann
2017-01-25 16:48                     ` Alex Gartrell
2017-01-25 18:21                       ` [Nbd] " Wouter Verhelst
2017-01-25 18:25                       ` Alex Bligh
2017-01-25 21:30                         ` Greg KH
2017-01-25 21:36                           ` Eric Blake
2017-01-26  8:40                             ` Christoph Hellwig
2017-01-26  9:17                               ` Greg KH
2017-01-26 13:17                                 ` Christoph Hellwig
2017-01-25 18:24                     ` Paul Clements
2017-01-21 12:11   ` Wouter Verhelst
2017-01-21 13:44     ` Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1484949412-6903-1-git-send-email-jbacik@fb.com \
    --to=jbacik@fb.com \
    --cc=arnd@arndb.de \
    --cc=axboe@fb.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-team@fb.com \
    --cc=linux-block@vger.kernel.org \
    --cc=nbd-general@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.