From 171b1d54e85474623aa863f1045d52eee3a07b90 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 22 Nov 2021 03:43:47 +0000 Subject: [PATCH] scst_vdisk: Restore support for adding a block device with non-existent filename This patch is a fix for commit df4c250b8db5 ("scst_vdisk: Port to Linux kernel v5.11"). git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9595 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index b2137e67a..ef0bec8ea 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1347,6 +1347,12 @@ static int vdisk_open_fd(struct scst_vdisk_dev *virt_dev, bool read_only) virt_dev->bdev = blkdev_get_by_path(virt_dev->filename, virt_dev->bdev_mode, (void *)__func__); res = IS_ERR(virt_dev->bdev) ? PTR_ERR(virt_dev->bdev) : 0; + if ((!virt_dev->dev_active) && (res == -ENOENT)) + { + TRACE_MGMT_DBG("Skip opening for not active dev %s", + virt_dev->dev->virt_name); + res = -EMEDIUMTYPE; + } } else { virt_dev->fd = vdev_open_fd(virt_dev, virt_dev->filename, read_only);