* [pbs-devel] [PATCH backup] zfs: check if given pool name is reserved
@ 2021-11-23 12:21 Oguz Bektas
2021-11-23 12:52 ` Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Oguz Bektas @ 2021-11-23 12:21 UTC (permalink / raw)
To: pbs-devel
man zpool-create:
The pool names mirror, raidz, draid, spare and log are reserved, as
are names _beginning_ with mirror, raidz, draid, and spare. The vdev
specification is described in the Virtual Devices section of
zpoolconcepts(7).
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
---
src/api2/node/disks/zfs.rs | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs
index c9a6ac72..58e5a83e 100644
--- a/src/api2/node/disks/zfs.rs
+++ b/src/api2/node/disks/zfs.rs
@@ -201,6 +201,15 @@ pub fn create_zpool(
};
// Sanity checks
+
+ lazy_static::lazy_static! {
+ // pool names starting with these are reserved
+ static ref RESERVED_POOL_NAMES: regex::Regex = regex::Regex::new(r"^(mirror|raidz|draid|spare).*$").unwrap();
+ }
+ if RESERVED_POOL_NAMES.is_match(&name) || &name == "log" {
+ bail!("Pool name {:?} is reserved.", &name);
+ }
+
if raidlevel == ZfsRaidLevel::Raid10 && devices.len() % 2 != 0 {
bail!("Raid10 needs an even number of disks.");
}
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [pbs-devel] [PATCH backup] zfs: check if given pool name is reserved
2021-11-23 12:21 [pbs-devel] [PATCH backup] zfs: check if given pool name is reserved Oguz Bektas
@ 2021-11-23 12:52 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-11-23 12:52 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Oguz Bektas
On 23.11.21 13:21, Oguz Bektas wrote:
> man zpool-create:
> The pool names mirror, raidz, draid, spare and log are reserved, as
> are names _beginning_ with mirror, raidz, draid, and spare. The vdev
> specification is described in the Virtual Devices section of
> zpoolconcepts(7).
>
> Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
> ---
> src/api2/node/disks/zfs.rs | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs
> index c9a6ac72..58e5a83e 100644
> --- a/src/api2/node/disks/zfs.rs
> +++ b/src/api2/node/disks/zfs.rs
> @@ -201,6 +201,15 @@ pub fn create_zpool(
> };
>
> // Sanity checks
> +
> + lazy_static::lazy_static! {
> + // pool names starting with these are reserved
> + static ref RESERVED_POOL_NAMES: regex::Regex = regex::Regex::new(r"^(mirror|raidz|draid|spare).*$").unwrap();
> + }
> + if RESERVED_POOL_NAMES.is_match(&name) || &name == "log" {
> + bail!("Pool name {:?} is reserved.", &name);
> + }
> +
> if raidlevel == ZfsRaidLevel::Raid10 && devices.len() % 2 != 0 {
> bail!("Raid10 needs an even number of disks.");
> }
>
zpool already gets us the error, lets rather forward that as I do not want to
maintain such things here if somehow possible.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-23 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 12:21 [pbs-devel] [PATCH backup] zfs: check if given pool name is reserved Oguz Bektas
2021-11-23 12:52 ` Thomas Lamprecht
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