summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2017-02-02 00:11:11 +0300
committerJens Axboe <axboe@fb.com>2017-02-02 02:28:06 +0300
commit124d6db07c3bd0bdb57ba0e22ff4e5b87e7cb32e (patch)
tree2b9ea08621a7199aa331cf71e9a44e18dafdf0f7
parent72f2f8f6929cf680d42ca44f87b7d370aff94d85 (diff)
downloadlinux-124d6db07c3bd0bdb57ba0e22ff4e5b87e7cb32e.tar.xz
nbd: use our own workqueue for recv threads
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> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--drivers/block/nbd.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 58296e4427b0..94e76579622d 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)
{
@@ -781,7 +782,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);
@@ -1030,10 +1031,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;
@@ -1113,6 +1120,7 @@ out:
put_disk(nbd_dev[i].disk);
}
kfree(nbd_dev);
+ destroy_workqueue(recv_workqueue);
return err;
}
@@ -1132,6 +1140,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);