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"; 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 = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
@@ -61,7 +109,7 @@
}; };
cache = { cache = {
type = "disk"; type = "disk";
device = "/dev/vdc"; device = "/dev/vdg";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
@@ -91,9 +139,22 @@
]; ];
} }
]; ];
special = { spare = [ "spare" ];
members = [ "z" ]; log = [
}; {
members = [ "log" ];
}
];
dedup = [
{
members = [ "dedup" ];
}
];
special = [
{
members = [ "special" ];
}
];
cache = [ "cache" ]; cache = [ "cache" ];
}; };
}; };
+1 -1
View File
@@ -38,7 +38,7 @@ let
}; };
# list of devices generated inside qemu # 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 # This is the test generator for a disko test
makeDiskoTest = makeDiskoTest =
+42 -7
View File
@@ -68,11 +68,38 @@ in
members = [ "x" "y" "/dev/sda1" ]; members = [ "x" "y" "/dev/sda1" ];
}]; }];
}; };
special = lib.mkOption { spare = lib.mkOption {
type = lib.types.nullOr vdev; type = lib.types.listOf lib.types.str;
default = null; default = [ ];
description = '' 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 https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#special
for details. for details.
''; '';
@@ -86,7 +113,6 @@ in
for details. for details.
''; '';
}; };
# TODO: Consider supporting log, spare, and dedup options.
}; };
}); });
}; };
@@ -182,8 +208,17 @@ in
entries=() entries=()
${lib.optionalString (hasTopology && topology.vdev != null) ${lib.optionalString (hasTopology && topology.vdev != null)
(lib.concatMapStrings formatVdev topology.vdev)} (lib.concatMapStrings formatVdev topology.vdev)}
${lib.optionalString (hasTopology && topology.special != null) ${lib.optionalString (hasTopology && topology.spare != [])
(formatOutput "special ${topology.special.mode}" topology.special.members)} (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 != []) ${lib.optionalString (hasTopology && topology.cache != [])
(formatOutput "cache" topology.cache)} (formatOutput "cache" topology.cache)}
all_devices=() all_devices=()