summaryrefslogtreecommitdiffstats
path: root/drivers/block/nbd.c
diff options
context:
space:
mode:
authorJosef Bacik2017-08-14 20:25:33 +0200
committerJens Axboe2017-08-17 19:02:57 +0200
commite6a76272d0fb50cb3cc773f4fc6f67c14fb4b157 (patch)
tree998d7a6b571ef5f6090a742ee478bcde8c7ca313 /drivers/block/nbd.c
parentloop: fix to a race condition due to the early registration of device (diff)
downloadkernel-qcow2-linux-e6a76272d0fb50cb3cc773f4fc6f67c14fb4b157.tar.gz
kernel-qcow2-linux-e6a76272d0fb50cb3cc773f4fc6f67c14fb4b157.tar.xz
kernel-qcow2-linux-e6a76272d0fb50cb3cc773f4fc6f67c14fb4b157.zip
nbd: allow device creation at a specific index
If users really want to use a particular index for their nbd device and it doesn't already exist there's no reason we can't just create it for them. Do this instead of erroring out. Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r--drivers/block/nbd.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 5bdf923294a5..d816ae7db205 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1584,6 +1584,15 @@ again:
}
} else {
nbd = idr_find(&nbd_index_idr, index);
+ if (!nbd) {
+ ret = nbd_dev_add(index);
+ if (ret < 0) {
+ mutex_unlock(&nbd_index_mutex);
+ printk(KERN_ERR "nbd: failed to add new device\n");
+ return ret;
+ }
+ nbd = idr_find(&nbd_index_idr, index);
+ }
}
if (!nbd) {
printk(KERN_ERR "nbd: couldn't find device at index %d\n",