public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Joaquin Varela <joaquinvarela@neatech.ar>
To: pve-devel@lists.proxmox.com
Cc: Joaquin Varela <joaquinvarela@neatech.ar>
Subject: [PATCH storage v2 1/7] zfs: make LUN provider dispatch overridable
Date: Sun,  2 Aug 2026 00:31:35 -0300	[thread overview]
Message-ID: <be52600bb8e231d43cb5f1f4f29f05d63ef2805f.1785636979.git.joaquinvarela@neatech.ar> (raw)
In-Reply-To: <cover.1785636979.git.joaquinvarela@neatech.ar>

ZFSPlugin hard-codes the LUN command provider in several
lifecycle paths. Move that selection behind zfs_lun_provider()
so subclasses can reuse the mature ZFS lifecycle with another
transport instead of copying it.

The default remains PVE::Storage::LunCmd::LIO. Existing ZFS
over iSCSI configurations keep their current behavior.

Signed-off-by: Joaquin Varela <joaquinvarela@neatech.ar>
---
 src/PVE/Storage/ZFSPlugin.pm | 45 ++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/src/PVE/Storage/ZFSPlugin.pm b/src/PVE/Storage/ZFSPlugin.pm
index 74e0a08..c633e4d 100644
--- a/src/PVE/Storage/ZFSPlugin.pm
+++ b/src/PVE/Storage/ZFSPlugin.pm
@@ -35,21 +35,30 @@ my $zfs_unknown_scsi_provider = sub {
     die "$provider: unknown iscsi provider. Available [comstar, istgt, iet, LIO]";
 };
 
-my $zfs_get_base = sub {
-    my ($scfg) = @_;
+sub zfs_lun_provider {
+    my ($class, $scfg) = @_;
 
     if ($scfg->{iscsiprovider} eq 'comstar') {
-        return PVE::Storage::LunCmd::Comstar::get_base($scfg);
+        return 'PVE::Storage::LunCmd::Comstar';
     } elsif ($scfg->{iscsiprovider} eq 'istgt') {
-        return PVE::Storage::LunCmd::Istgt::get_base($scfg);
+        return 'PVE::Storage::LunCmd::Istgt';
     } elsif ($scfg->{iscsiprovider} eq 'iet') {
-        return PVE::Storage::LunCmd::Iet::get_base($scfg);
+        return 'PVE::Storage::LunCmd::Iet';
     } elsif ($scfg->{iscsiprovider} eq 'LIO') {
-        return PVE::Storage::LunCmd::LIO::get_base($scfg);
+        return 'PVE::Storage::LunCmd::LIO';
     } else {
         $zfs_unknown_scsi_provider->($scfg->{iscsiprovider});
     }
-};
+}
+
+sub zfs_get_base {
+    my ($class, $scfg) = @_;
+
+    my $provider = $class->zfs_lun_provider($scfg);
+    my $get_base = $provider->can('get_base')
+        or die "$provider does not implement get_base\n";
+    return $get_base->($scfg);
+}
 
 sub zfs_request {
     my ($class, $scfg, $timeout, $method, @params) = @_;
@@ -60,18 +69,10 @@ sub zfs_request {
     my $msg = '';
 
     if ($lun_cmds->{$method}) {
-        if ($scfg->{iscsiprovider} eq 'comstar') {
-            $msg =
-                PVE::Storage::LunCmd::Comstar::run_lun_command($scfg, $timeout, $method, @params);
-        } elsif ($scfg->{iscsiprovider} eq 'istgt') {
-            $msg = PVE::Storage::LunCmd::Istgt::run_lun_command($scfg, $timeout, $method, @params);
-        } elsif ($scfg->{iscsiprovider} eq 'iet') {
-            $msg = PVE::Storage::LunCmd::Iet::run_lun_command($scfg, $timeout, $method, @params);
-        } elsif ($scfg->{iscsiprovider} eq 'LIO') {
-            $msg = PVE::Storage::LunCmd::LIO::run_lun_command($scfg, $timeout, $method, @params);
-        } else {
-            $zfs_unknown_scsi_provider->($scfg->{iscsiprovider});
-        }
+        my $provider = $class->zfs_lun_provider($scfg);
+        my $run_lun_command = $provider->can('run_lun_command')
+            or die "$provider does not implement run_lun_command\n";
+        $msg = $run_lun_command->($scfg, $timeout, $method, @params);
     } else {
 
         my $target = 'root@' . $scfg->{portal};
@@ -100,7 +101,7 @@ sub zfs_request {
 sub zfs_get_lu_name {
     my ($class, $scfg, $zvol) = @_;
 
-    my $base = $zfs_get_base->($scfg);
+    my $base = $class->zfs_get_base($scfg);
 
     $zvol = ($class->parse_volname($zvol))[1];
 
@@ -134,7 +135,7 @@ sub zfs_delete_lu {
 sub zfs_create_lu {
     my ($class, $scfg, $zvol) = @_;
 
-    my $base = $zfs_get_base->($scfg);
+    my $base = $class->zfs_get_base($scfg);
     my $guid = $class->zfs_request($scfg, undef, 'create_lu', "$base/$scfg->{pool}/$zvol");
 
     return $guid;
@@ -143,7 +144,7 @@ sub zfs_create_lu {
 sub zfs_import_lu {
     my ($class, $scfg, $zvol) = @_;
 
-    my $base = $zfs_get_base->($scfg);
+    my $base = $class->zfs_get_base($scfg);
     $class->zfs_request($scfg, undef, 'import_lu', "$base/$scfg->{pool}/$zvol");
 }
 
-- 
2.54.0.windows.1




  reply	other threads:[~2026-08-02  3:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-02  3:31 [PATCH storage v2 0/7] add native ZFS over NVMe/TCP backend Joaquin Varela
2026-08-02  3:31 ` Joaquin Varela [this message]
2026-08-02  3:31 ` [PATCH storage v2 2/7] zfs: add native NVMe/TCP storage backend Joaquin Varela
2026-08-02  3:31 ` [PATCH storage v2 3/7] zfsnvme: harden node preflight and storage teardown Joaquin Varela
2026-08-02  3:31 ` [PATCH storage v2 4/7] zfsnvme: make all-path loss policy explicit Joaquin Varela
2026-08-02  3:31 ` [PATCH storage v2 5/7] zfsnvme: accept activation hints from storage API Joaquin Varela
2026-08-02  3:31 ` [PATCH storage v2 6/7] zfsnvme: accept short volume activation calls Joaquin Varela
2026-08-02  3:31 ` [PATCH storage v2 7/7] zfsnvme: restore ACLs before publishing target Joaquin Varela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=be52600bb8e231d43cb5f1f4f29f05d63ef2805f.1785636979.git.joaquinvarela@neatech.ar \
    --to=joaquinvarela@neatech.ar \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal