Skip to content

Commit

Permalink
zfs: default device name to vblk0.1 if vdev_path different than /dev/…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
wkozaczuk authored and nyh committed Dec 23, 2019
1 parent 474c538 commit c9640a3
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down

0 comments on commit c9640a3

Please sign in to comment.