From c9640a385c44704626a9169c03cff0752bfe764d Mon Sep 17 00:00:00 2001 From: Waldemar Kozaczuk Date: Sun, 22 Dec 2019 10:05:26 -0500 Subject: [PATCH] zfs: default device name to vblk0.1 if vdev_path different than /dev/vblk* This patch allows mounting OSv zfs image on Linux host and/or modifying and using again to boot OSv. It also allows mounting ZFS disks created on Linux host. Typically when mounting OSv image on Linux, the zpool utility would change so called vdev_path from /dev/vblk0.1 to /dev/nbd0p2 and OSv would fail mounting it afterwards as it tries open device using the vdev_path stored on the disk. This patch effectively validates the vdev_path to make sure it starts with /dev/vblk. Fixes #918 Signed-off-by: Waldemar Kozaczuk Message-Id: <20191222150526.10964-1-jwkozaczuk@gmail.com> --- .../cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c index 15b05c0faf..3d0d6324f5 100644 --- a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c +++ b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c @@ -56,6 +56,7 @@ vdev_disk_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, { struct vdev_disk *dvd; int error; + char *device_name; /* * We must have a pathname, and it must be absolute. @@ -72,7 +73,11 @@ vdev_disk_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, if (vd->vdev_tsd == NULL) { dvd = vd->vdev_tsd = kmem_zalloc(sizeof(struct vdev_disk), KM_SLEEP); - error = device_open(vd->vdev_path + 5, DO_RDWR, &dvd->device); + device_name = vd->vdev_path + 5; + if (strncmp(device_name, "vblk", 4) != 0) { + device_name = "vblk0.1"; + } + error = device_open(device_name, DO_RDWR, &dvd->device); if (error) { vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED; return error;