Skip to content

Commit

Permalink
Do not crash zfs.dataset.unlocked_zvols_fast when volmode=full is…
Browse files Browse the repository at this point in the history
… set (#13742)
  • Loading branch information
themylogin authored May 16, 2024
1 parent 8826a3a commit e717ef7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/middlewared/middlewared/plugins/zfs_/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import enum
import logging
import os
import re

from middlewared.service_exception import MatchNotFound
from middlewared.utils.filesystem.constants import ZFSCTL
Expand All @@ -12,6 +13,7 @@

LEGACY_USERPROP_PREFIX = 'org.freenas'
USERPROP_PREFIX = 'org.truenas'
ZD_PARTITION = re.compile(r'zd[0-9]+p[0-9]+$')


class TNUserProp(enum.Enum):
Expand Down Expand Up @@ -128,6 +130,9 @@ def get_zvols(info_level, data):
# skip this file
continue

if ZD_PARTITION.match(dev_name):
continue

out.update({
zvol_name: {
'path': path,
Expand Down
12 changes: 12 additions & 0 deletions tests/api2/test_zfs_dataset_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from middlewared.test.integration.assets.pool import dataset
from middlewared.test.integration.utils import call, ssh


def test__unlocked_zvols_fast__volmode():
with dataset("container") as container:
ssh(f"zfs set volmode=full {container}")

with dataset("container/zvol", {"type": "VOLUME", "volsize": 100 * 1024 * 1024}) as zvol:
ssh(f"sgdisk -n 1:1MiB:2MiB /dev/zvol/{zvol}")

call("zfs.dataset.unlocked_zvols_fast", [["name", "=", zvol]], {}, ["SIZE", "RO", "DEVID", "ATTACHMENT"])

0 comments on commit e717ef7

Please sign in to comment.