public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH storage] api: disks: zfs: enable monthly scrub when creating a pool
@ 2024-08-27 13:52 Maximiliano Sandoval
  0 siblings, 0 replies; only message in thread
From: Maximiliano Sandoval @ 2024-08-27 13:52 UTC (permalink / raw)
  To: pve-devel

And disable it when destroying the pool.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---

I think this should be safe to enable by default on a monthly basis. Please tell
me if this is something that should be enabled via a new API parameter.

 src/PVE/API2/Disks/ZFS.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/PVE/API2/Disks/ZFS.pm b/src/PVE/API2/Disks/ZFS.pm
index 6fb6bd6b..022710b4 100644
--- a/src/PVE/API2/Disks/ZFS.pm
+++ b/src/PVE/API2/Disks/ZFS.pm
@@ -490,6 +490,13 @@ __PACKAGE__->register_method ({
 		run_command($cmd);
 	    }
 
+	    if (-e '/lib/systemd/system/zfs-scrub-monthly@.timer') {
+		my $scrubtimer = 'zfs-scrub-monthly@'. PVE::Systemd::escape_unit($name, undef) . '.timer';
+		$cmd = ['systemctl', 'enable', $scrubtimer];
+		print "# ", join(' ', @$cmd), "\n";
+		run_command($cmd);
+	    }
+
 	    PVE::Diskmanage::udevadm_trigger($devs->@*);
 
 	    if ($param->{add_storage}) {
@@ -583,6 +590,11 @@ __PACKAGE__->register_method ({
 		    run_command(['systemctl', 'disable', $importunit]);
 		}
 
+		if (-e '/lib/systemd/system/zfs-scrub-monthly@.timer') {
+		    my $scrubtimer = 'zfs-scrub-monthly@' . PVE::Systemd::escape_unit($name) . '.timer';
+		    run_command(['systemctl', 'disable', $scrubtimer]);
+		}
+
 		run_command(['zpool', 'destroy', $name]);
 
 		my $config_err;
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-08-27 13:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-27 13:52 [pve-devel] [PATCH storage] api: disks: zfs: enable monthly scrub when creating a pool Maximiliano Sandoval

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