all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com
Subject: [pve-devel] [RFC zfsonlinux 1/1] Add systemd-unit for importing specific pools
Date: Wed, 16 Sep 2020 14:14:17 +0200	[thread overview]
Message-ID: <20200916121419.3997-2-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20200916121419.3997-1-s.ivanov@proxmox.com>

This patch addresses the problems some users experience when some zpools are
created/imported with cachefile (which then causes other pools not to get
imported during boot) - when our tooling creates a pool we explictly
instantiate the service with the pool's name, ensuring that it will get
imported by scanning.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 ...md-unit-for-importing-specific-pools.patch | 75 +++++++++++++++++++
 debian/patches/series                         |  1 +
 debian/zfsutils-linux.install                 |  1 +
 3 files changed, 77 insertions(+)
 create mode 100644 debian/patches/0008-Add-systemd-unit-for-importing-specific-pools.patch

diff --git a/debian/patches/0008-Add-systemd-unit-for-importing-specific-pools.patch b/debian/patches/0008-Add-systemd-unit-for-importing-specific-pools.patch
new file mode 100644
index 00000000..61c4e94a
--- /dev/null
+++ b/debian/patches/0008-Add-systemd-unit-for-importing-specific-pools.patch
@@ -0,0 +1,75 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Stoiko Ivanov <s.ivanov@proxmox.com>
+Date: Tue, 15 Sep 2020 19:07:24 +0200
+Subject: [PATCH] Add systemd-unit for importing specific pools
+
+The unit can be instantiated with a specific poolname, which will get imported
+by scanning /dev/disk/by-id, irrespective of the existence and content of
+/etc/zfs/zpool.cache.
+
+the instance name is used unescaped (see systemd.unit(5)), since zpool names
+can contain characters which will be escaped by systemd.
+
+Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
+---
+ etc/systemd/system/50-zfs.preset.in       |  1 +
+ etc/systemd/system/Makefile.am            |  2 ++
+ etc/systemd/system/zfs-import@.service.in | 17 +++++++++++++++++
+ 3 files changed, 20 insertions(+)
+ create mode 100644 etc/systemd/system/zfs-import@.service.in
+
+diff --git a/etc/systemd/system/50-zfs.preset.in b/etc/systemd/system/50-zfs.preset.in
+index e4056a92c..030611419 100644
+--- a/etc/systemd/system/50-zfs.preset.in
++++ b/etc/systemd/system/50-zfs.preset.in
+@@ -1,6 +1,7 @@
+ # ZFS is enabled by default
+ enable zfs-import-cache.service
+ disable zfs-import-scan.service
++enable zfs-import@.service
+ enable zfs-import.target
+ enable zfs-mount.service
+ enable zfs-share.service
+diff --git a/etc/systemd/system/Makefile.am b/etc/systemd/system/Makefile.am
+index 4e14467a0..ae72102af 100644
+--- a/etc/systemd/system/Makefile.am
++++ b/etc/systemd/system/Makefile.am
+@@ -5,6 +5,7 @@ systemdunit_DATA = \
+ 	zfs-zed.service \
+ 	zfs-import-cache.service \
+ 	zfs-import-scan.service \
++	zfs-import@.service \
+ 	zfs-mount.service \
+ 	zfs-share.service \
+ 	zfs-volume-wait.service \
+@@ -16,6 +17,7 @@ EXTRA_DIST = \
+ 	$(top_srcdir)/etc/systemd/system/zfs-zed.service.in \
+ 	$(top_srcdir)/etc/systemd/system/zfs-import-cache.service.in \
+ 	$(top_srcdir)/etc/systemd/system/zfs-import-scan.service.in \
++	$(top_srcdir)/etc/systemd/system/zfs-import@.service.in \
+ 	$(top_srcdir)/etc/systemd/system/zfs-mount.service.in \
+ 	$(top_srcdir)/etc/systemd/system/zfs-share.service.in \
+ 	$(top_srcdir)/etc/systemd/system/zfs-import.target.in \
+diff --git a/etc/systemd/system/zfs-import@.service.in b/etc/systemd/system/zfs-import@.service.in
+new file mode 100644
+index 000000000..2db9fdaab
+--- /dev/null
++++ b/etc/systemd/system/zfs-import@.service.in
+@@ -0,0 +1,17 @@
++[Unit]
++Description=Import ZFS pool %i
++Documentation=man:zpool(8)
++DefaultDependencies=no
++Requires=systemd-udev-settle.service
++After=systemd-udev-settle.service
++After=cryptsetup.target
++After=multipathd.target
++Before=zfs-import.target
++
++[Service]
++Type=oneshot
++RemainAfterExit=yes
++ExecStart=@sbindir@/zpool import -N -d /dev/disk/by-id -o cachefile=none %I
++
++[Install]
++WantedBy=zfs-import.target
diff --git a/debian/patches/series b/debian/patches/series
index 33a76ef1..e1d7c485 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -5,3 +5,4 @@
 0005-Enable-zed-emails.patch
 0006-dont-symlink-zed-scripts.patch
 0007-Use-installed-python3.patch
+0008-Add-systemd-unit-for-importing-specific-pools.patch
diff --git a/debian/zfsutils-linux.install b/debian/zfsutils-linux.install
index aa62d505..229ff2ea 100644
--- a/debian/zfsutils-linux.install
+++ b/debian/zfsutils-linux.install
@@ -5,6 +5,7 @@ etc/zfs/zpool.d/
 lib/systemd/system-preset/
 lib/systemd/system/zfs-import-cache.service
 lib/systemd/system/zfs-import-scan.service
+lib/systemd/system/zfs-import@.service
 lib/systemd/system/zfs-import.target
 lib/systemd/system/zfs-import.service
 lib/systemd/system/zfs-mount.service
-- 
2.20.1





WARNING: multiple messages have this Message-ID
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [RFC zfsonlinux 1/1] Add systemd-unit for importing specific pools
Date: Wed, 16 Sep 2020 14:14:17 +0200	[thread overview]
Message-ID: <20200916121419.3997-2-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20200916121419.3997-1-s.ivanov@proxmox.com>

This patch addresses the problems some users experience when some zpools are
created/imported with cachefile (which then causes other pools not to get
imported during boot) - when our tooling creates a pool we explictly
instantiate the service with the pool's name, ensuring that it will get
imported by scanning.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 ...md-unit-for-importing-specific-pools.patch | 75 +++++++++++++++++++
 debian/patches/series                         |  1 +
 debian/zfsutils-linux.install                 |  1 +
 3 files changed, 77 insertions(+)
 create mode 100644 debian/patches/0008-Add-systemd-unit-for-importing-specific-pools.patch

diff --git a/debian/patches/0008-Add-systemd-unit-for-importing-specific-pools.patch b/debian/patches/0008-Add-systemd-unit-for-importing-specific-pools.patch
new file mode 100644
index 00000000..61c4e94a
--- /dev/null
+++ b/debian/patches/0008-Add-systemd-unit-for-importing-specific-pools.patch
@@ -0,0 +1,75 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Stoiko Ivanov <s.ivanov@proxmox.com>
+Date: Tue, 15 Sep 2020 19:07:24 +0200
+Subject: [PATCH] Add systemd-unit for importing specific pools
+
+The unit can be instantiated with a specific poolname, which will get imported
+by scanning /dev/disk/by-id, irrespective of the existence and content of
+/etc/zfs/zpool.cache.
+
+the instance name is used unescaped (see systemd.unit(5)), since zpool names
+can contain characters which will be escaped by systemd.
+
+Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
+---
+ etc/systemd/system/50-zfs.preset.in       |  1 +
+ etc/systemd/system/Makefile.am            |  2 ++
+ etc/systemd/system/zfs-import@.service.in | 17 +++++++++++++++++
+ 3 files changed, 20 insertions(+)
+ create mode 100644 etc/systemd/system/zfs-import@.service.in
+
+diff --git a/etc/systemd/system/50-zfs.preset.in b/etc/systemd/system/50-zfs.preset.in
+index e4056a92c..030611419 100644
+--- a/etc/systemd/system/50-zfs.preset.in
++++ b/etc/systemd/system/50-zfs.preset.in
+@@ -1,6 +1,7 @@
+ # ZFS is enabled by default
+ enable zfs-import-cache.service
+ disable zfs-import-scan.service
++enable zfs-import@.service
+ enable zfs-import.target
+ enable zfs-mount.service
+ enable zfs-share.service
+diff --git a/etc/systemd/system/Makefile.am b/etc/systemd/system/Makefile.am
+index 4e14467a0..ae72102af 100644
+--- a/etc/systemd/system/Makefile.am
++++ b/etc/systemd/system/Makefile.am
+@@ -5,6 +5,7 @@ systemdunit_DATA = \
+ 	zfs-zed.service \
+ 	zfs-import-cache.service \
+ 	zfs-import-scan.service \
++	zfs-import@.service \
+ 	zfs-mount.service \
+ 	zfs-share.service \
+ 	zfs-volume-wait.service \
+@@ -16,6 +17,7 @@ EXTRA_DIST = \
+ 	$(top_srcdir)/etc/systemd/system/zfs-zed.service.in \
+ 	$(top_srcdir)/etc/systemd/system/zfs-import-cache.service.in \
+ 	$(top_srcdir)/etc/systemd/system/zfs-import-scan.service.in \
++	$(top_srcdir)/etc/systemd/system/zfs-import@.service.in \
+ 	$(top_srcdir)/etc/systemd/system/zfs-mount.service.in \
+ 	$(top_srcdir)/etc/systemd/system/zfs-share.service.in \
+ 	$(top_srcdir)/etc/systemd/system/zfs-import.target.in \
+diff --git a/etc/systemd/system/zfs-import@.service.in b/etc/systemd/system/zfs-import@.service.in
+new file mode 100644
+index 000000000..2db9fdaab
+--- /dev/null
++++ b/etc/systemd/system/zfs-import@.service.in
+@@ -0,0 +1,17 @@
++[Unit]
++Description=Import ZFS pool %i
++Documentation=man:zpool(8)
++DefaultDependencies=no
++Requires=systemd-udev-settle.service
++After=systemd-udev-settle.service
++After=cryptsetup.target
++After=multipathd.target
++Before=zfs-import.target
++
++[Service]
++Type=oneshot
++RemainAfterExit=yes
++ExecStart=@sbindir@/zpool import -N -d /dev/disk/by-id -o cachefile=none %I
++
++[Install]
++WantedBy=zfs-import.target
diff --git a/debian/patches/series b/debian/patches/series
index 33a76ef1..e1d7c485 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -5,3 +5,4 @@
 0005-Enable-zed-emails.patch
 0006-dont-symlink-zed-scripts.patch
 0007-Use-installed-python3.patch
+0008-Add-systemd-unit-for-importing-specific-pools.patch
diff --git a/debian/zfsutils-linux.install b/debian/zfsutils-linux.install
index aa62d505..229ff2ea 100644
--- a/debian/zfsutils-linux.install
+++ b/debian/zfsutils-linux.install
@@ -5,6 +5,7 @@ etc/zfs/zpool.d/
 lib/systemd/system-preset/
 lib/systemd/system/zfs-import-cache.service
 lib/systemd/system/zfs-import-scan.service
+lib/systemd/system/zfs-import@.service
 lib/systemd/system/zfs-import.target
 lib/systemd/system/zfs-import.service
 lib/systemd/system/zfs-mount.service
-- 
2.20.1





  reply	other threads:[~2020-09-16 12:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-16 12:14 [pve-devel] [RFC proxmox-backup/storage/zfsonlinux] improve zpool import for freshly created zpools Stoiko Ivanov
2020-09-16 12:14 ` [pbs-devel] " Stoiko Ivanov
2020-09-16 12:14 ` Stoiko Ivanov [this message]
2020-09-16 12:14   ` [pbs-devel] [RFC zfsonlinux 1/1] Add systemd-unit for importing specific pools Stoiko Ivanov
2020-09-29  3:54   ` [pve-devel] " Thomas Lamprecht
2020-09-29  3:54     ` [pbs-devel] " Thomas Lamprecht
2020-09-29 13:03   ` [pve-devel] applied: " Thomas Lamprecht
2020-09-29 13:03     ` [pbs-devel] applied: [pve-devel] " Thomas Lamprecht
2020-09-16 12:14 ` [pve-devel] [RFC proxmox-backup 1/1] api2/node/disks/zfs: instantiate import service Stoiko Ivanov
2020-09-16 12:14   ` [pbs-devel] " Stoiko Ivanov
2020-09-30  7:35   ` [pve-devel] applied: " Thomas Lamprecht
2020-09-30  7:35     ` [pbs-devel] applied: " Thomas Lamprecht
2020-09-16 12:14 ` [pve-devel] [RFC storage 1/1] Disks: instantiate import unit for created zpool Stoiko Ivanov
2020-09-16 12:14   ` [pbs-devel] " Stoiko Ivanov
2020-09-29 16:58   ` [pve-devel] applied: " Thomas Lamprecht
2020-09-29 16:58     ` [pbs-devel] applied: [pve-devel] " Thomas Lamprecht

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=20200916121419.3997-2-s.ivanov@proxmox.com \
    --to=s.ivanov@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal