From: George Melikov <mail@gmelikov.ru>
Reproduce:
```bash
# Order is crucial here, if we create zvol with name which won't be last - we'll get size from different zvol
root@minime:~# virsh vol-list rpool
Name Path
----------------------------------------------------------------------------------------------------
da52bdd9-eb75-5746-a2ce-a511067914f5 /dev/zvol/rpool/disks/da52bdd9-eb75-5746-a2ce-a511067914f5
faafd0f9-33c8-5b23-990c-fa7b4bfe8dcf /dev/zvol/rpool/disks/faafd0f9-33c8-5b23-990c-fa7b4bfe8dcf
# Create zvol with name which will be before `faaf...`
root@minime:~# cat > /tmp/vol
<volume>
<name>eeee</name>
<capacity>4294967296</capacity>
<allocation>4294967296</allocation>
</volume>
root@minime:~# virsh vol-create rpool /tmp/vol
Vol eeee created from /tmp/vol
root@minime:~# virsh vol-list rpool
Name Path
----------------------------------------------------------------------------------------------------
da52bdd9-eb75-5746-a2ce-a511067914f5 /dev/zvol/rpool/disks/da52bdd9-eb75-5746-a2ce-a511067914f5
eeee /dev/zvol/rpool/disks/eeee
faafd0f9-33c8-5b23-990c-fa7b4bfe8dcf /dev/zvol/rpool/disks/faafd0f9-33c8-5b23-990c-fa7b4bfe8dcf
# Here we've got Capacity from last zvol (ordered by name)
root@minime:~# virsh vol-info --pool rpool eeee
Name: eeee
Type: block
Capacity: 10.00 GiB
Allocation: 0.00 B
# Full refresh fixes it
root@minime:~# virsh pool-refresh --pool rpool
Pool rpool refreshed
root@minime:~# virsh vol-info --pool rpool eeee
Name: eeee
Type: block
Capacity: 4.00 GiB
Allocation: 4.06 GiB
```
Fix is trivial: check zvol by name and return early if this is different
zvol.
Signed-off-by: George Melikov <mail@gmelikov.ru>
---
src/storage/storage_backend_zfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index 33434d0cac..2cb555a6e6 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -132,8 +132,10 @@ virStorageBackendZFSParseVol(virStoragePoolObj *pool,
if (vol == NULL)
volume = virStorageVolDefFindByName(pool, vol_name);
- else
+ else if (STREQ(vol_name, vol->name))
volume = vol;
+ else
+ return 0;
if (volume == NULL) {
volume = g_new0(virStorageVolDef, 1);
--
2.53.0
George Melikov wrote:
> From: George Melikov <mail@gmelikov.ru>
>
> Reproduce:
> ```bash
> # Order is crucial here, if we create zvol with name which won't be last - we'll get size from different zvol
> root@minime:~# virsh vol-list rpool
> Name Path
> ----------------------------------------------------------------------------------------------------
> da52bdd9-eb75-5746-a2ce-a511067914f5 /dev/zvol/rpool/disks/da52bdd9-eb75-5746-a2ce-a511067914f5
> faafd0f9-33c8-5b23-990c-fa7b4bfe8dcf /dev/zvol/rpool/disks/faafd0f9-33c8-5b23-990c-fa7b4bfe8dcf
>
> # Create zvol with name which will be before `faaf...`
> root@minime:~# cat > /tmp/vol
> <volume>
> <name>eeee</name>
> <capacity>4294967296</capacity>
> <allocation>4294967296</allocation>
> </volume>
>
> root@minime:~# virsh vol-create rpool /tmp/vol
> Vol eeee created from /tmp/vol
>
> root@minime:~# virsh vol-list rpool
> Name Path
> ----------------------------------------------------------------------------------------------------
> da52bdd9-eb75-5746-a2ce-a511067914f5 /dev/zvol/rpool/disks/da52bdd9-eb75-5746-a2ce-a511067914f5
> eeee /dev/zvol/rpool/disks/eeee
> faafd0f9-33c8-5b23-990c-fa7b4bfe8dcf /dev/zvol/rpool/disks/faafd0f9-33c8-5b23-990c-fa7b4bfe8dcf
>
> # Here we've got Capacity from last zvol (ordered by name)
> root@minime:~# virsh vol-info --pool rpool eeee
> Name: eeee
> Type: block
> Capacity: 10.00 GiB
> Allocation: 0.00 B
>
> # Full refresh fixes it
> root@minime:~# virsh pool-refresh --pool rpool
> Pool rpool refreshed
>
> root@minime:~# virsh vol-info --pool rpool eeee
> Name: eeee
> Type: block
> Capacity: 4.00 GiB
> Allocation: 4.06 GiB
> ```
>
> Fix is trivial: check zvol by name and return early if this is different
> zvol.
>
> Signed-off-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
and pushed.
> ---
> src/storage/storage_backend_zfs.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
> index 33434d0cac..2cb555a6e6 100644
> --- a/src/storage/storage_backend_zfs.c
> +++ b/src/storage/storage_backend_zfs.c
> @@ -132,8 +132,10 @@ virStorageBackendZFSParseVol(virStoragePoolObj *pool,
>
> if (vol == NULL)
> volume = virStorageVolDefFindByName(pool, vol_name);
> - else
> + else if (STREQ(vol_name, vol->name))
> volume = vol;
> + else
> + return 0;
>
> if (volume == NULL) {
> volume = g_new0(virStorageVolDef, 1);
> --
> 2.53.0
>
© 2016 - 2026 Red Hat, Inc.