Commit e6a76272 authored by Josef Bacik's avatar Josef Bacik Committed by Jens Axboe
Browse files

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: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent a8c1d064
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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",