Skip to content

volblocksize in datasetProperties gets overridden — can datasetProperties take precedence per StorageClass? #519

@isac322

Description

@isac322

Summary
I’m running a homelab Kubernetes cluster with multiple nodes. One node hosts a ZFS pool. I’m provisioning volumes over iSCSI via this Helm chart. I want different block sizes per StorageClass: PostgreSQL at 8K (to match its page size) and everything else (backup-like data) at the default 16K.
However, PVCs created from both StorageClasses end up with volblocksize=16K.

What I expected

  • StorageClass A (postgres): volblocksize=8K
  • StorageClass B (default/backup): volblocksize=16K

What actually happened

  • Both volumes are created with volblocksize=16K.

Repro (abridged)

Abridged values.yaml:

csiDriver:
  name: "org.democratic-csi.iscsi"

storageClasses:
  - name: ssd-iscsi
    defaultClass: false
    reclaimPolicy: Delete
    volumeBindingMode: Immediate
    allowVolumeExpansion: true
    parameters:
      fsType: xfs
      volblocksize: 16K
  - name: ssd-iscsi-2
    defaultClass: false
    reclaimPolicy: Delete
    volumeBindingMode: Immediate
    allowVolumeExpansion: true
    parameters:
      fsType: xfs
      volblocksize: 8K

driver:
  config:
    driver: zfs-generic-iscsi
    sshConnection:
      host: n2p1
      username: democratic-csi
      privateKey: |
        -----BEGIN OPENSSH PRIVATE KEY-----
        ...
        -----END OPENSSH PRIVATE KEY-----

    zfs:
      cli:
        sudoEnabled: true

      datasetProperties:
        "volblocksize": "{{ parameters.volblocksize }}"

      datasetParentName: nas/k8s
      detachedSnapshotsDatasetParentName: tanks/k8s/test-snapshots

      zvolEnableReservation: false
# sudo zfs get volblocksize nas/k8s/pvc-c44942d4-0142-498c-aa93-051ac59afb34 nas/k8s/pvc-f000b4ba-2414-4cfe-8c43-fb2b6be8ad43
NAME                                              PROPERTY      VALUE     SOURCE
nas/k8s/pvc-c44942d4-0142-498c-aa93-051ac59afb34  volblocksize  16K       default
nas/k8s/pvc-f000b4ba-2414-4cfe-8c43-fb2b6be8ad43  volblocksize  16K       default

What I found in the code
While tracing the provisioning path, I noticed that the value from datasetProperties.volblocksize is being overwritten later in the flow (

// force blocksize on newly created zvols
if (driverZfsResourceType == "volume") {
volumeProperties.volblocksize = zvolBlocksize;
}
). This appears to force volblocksize to a fixed value regardless of what’s provided via datasetProperties in the StorageClass/values.

Questions

  1. Is there a specific reason volblocksize from datasetProperties is always overwritten?
  2. If not, can we change the precedence so that datasetProperties (per StorageClass) has the highest priority?

Rationale

  • PostgreSQL benefits from 8K blocks to align with its page size and reduce write amplification.
  • Backup/archival data can stay on 16K to optimize throughput/fragmentation differently.
  • Being able to tune this per StorageClass is a common operational need.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions