Add support for ZFS spare, log & dedup vdevs

This commit is contained in:
Michon van Dooren committed 2024-11-17 15:52:28 +01:00
1 parent cb64993826
commit 9b56c1afdb
3 files changed
+110 -14

No files matched your search

+67 -6
View File
@@ -43,9 +43,57 @@
};
};
};
z = {
spare = {
type = "disk";
device = "/dev/sdz";
device = "/dev/vdc";
content = {
type = "gpt";
partitions = {
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
log = {
type = "disk";
device = "/dev/vdd";
content = {
type = "gpt";
partitions = {
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
dedup = {
type = "disk";
device = "/dev/vde";
content = {
type = "gpt";
partitions = {
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
special = {
type = "disk";
device = "/dev/vdf";
content = {
type = "gpt";
partitions = {
@@ -61,7 +109,7 @@
};
cache = {
type = "disk";
device = "/dev/vdc";
device = "/dev/vdg";
content = {
type = "gpt";
partitions = {
@@ -91,9 +139,22 @@
];
}
];
special = {
members = [ "z" ];
};
spare = [ "spare" ];
log = [
{
members = [ "log" ];
}
];
dedup = [
{
members = [ "dedup" ];
}
];
special = [
{
members = [ "special" ];
}
];
cache = [ "cache" ];
};
};
+1 -1
View File
@@ -38,7 +38,7 @@ let
};
# list of devices generated inside qemu
devices = [ "/dev/vda" "/dev/vdb" "/dev/vdc" "/dev/vdd" "/dev/vde" "/dev/vdf" ];
devices = [ "/dev/vda" "/dev/vdb" "/dev/vdc" "/dev/vdd" "/dev/vde" "/dev/vdf" "/dev/vdg" "/dev/vdh" ];
# This is the test generator for a disko test
makeDiskoTest =
+42 -7
View File
@@ -68,11 +68,38 @@ in
members = [ "x" "y" "/dev/sda1" ];
}];
};
special = lib.mkOption {
type = lib.types.nullOr vdev;
default = null;
spare = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = ''
A vdev definition for a special device. See
A list of devices to use as hot spares. See
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#Hot_Spares
for details.
'';
};
log = lib.mkOption {
type = lib.types.listOf vdev;
default = [ ];
description = ''
A list of vdevs used for the zfs intent log (ZIL). See
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#Intent_Log
for details.
'';
};
dedup = lib.mkOption {
type = lib.types.listOf vdev;
default = [ ];
description = ''
A list of vdevs used for the deduplication table. See
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#dedup
for details.
'';
};
special = lib.mkOption {
type = lib.types.either (lib.types.listOf vdev) (lib.types.nullOr vdev);
default = [ ];
description = ''
A list of vdevs used as special devices. See
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#special
for details.
'';
@@ -86,7 +113,6 @@ in
for details.
'';
};
# TODO: Consider supporting log, spare, and dedup options.
};
});
};
@@ -182,8 +208,17 @@ in
entries=()
${lib.optionalString (hasTopology && topology.vdev != null)
(lib.concatMapStrings formatVdev topology.vdev)}
${lib.optionalString (hasTopology && topology.special != null)
(formatOutput "special ${topology.special.mode}" topology.special.members)}
${lib.optionalString (hasTopology && topology.spare != [])
(formatOutput "spare" topology.spare)}
${lib.optionalString (hasTopology && topology.log != [])
(lib.concatMapStrings (vdev: formatOutput "log ${vdev.mode}" vdev.members) topology.log)}
${lib.optionalString (hasTopology && topology.dedup != [])
(lib.concatMapStrings (vdev: formatOutput "dedup ${vdev.mode}" vdev.members) topology.dedup)}
${lib.optionalString (hasTopology && topology.special != null && topology.special != [])
(lib.concatMapStrings
(vdev: formatOutput "special ${vdev.mode}" vdev.members)
(lib.lists.toList topology.special)
)}
${lib.optionalString (hasTopology && topology.cache != [])
(formatOutput "cache" topology.cache)}
all_devices=()