mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 19:28:53 +03:00
Allow and prefer special vdevs as ZIL
Before this change ZIL blocks were allocated only from normal or SLOG vdevs. In typical situation when special vdevs are SSDs and normal are HDDs it could cause weird inversions when data blocks are written to SSDs, but ZIL referencing them to HDDs. This change assumes that special vdevs typically have much better (or at least not worse) latency than normal, and so in absence of SLOGs should store ZIL blocks. It means similar to normal vdevs introduction of special embedded log allocation class and updating the allocation fallback order to: SLOG -> special embedded log -> special -> normal embedded log -> normal. The code tries to guess whether data block is going to be written to normal or special vdev (it can not be done precisely before compression) and prefer indirect writes for blocks written to a special vdev to avoid double-write. For blocks that are going to be written to normal vdev, special vdev by default plays as SLOG, reducing write latency by the cost of higher special vdev wear, but it is tunable via module parameter. This should allow HDD pools with decent SSD as special vdev to work under synchronous workloads without requiring additional SLOG SSD, impractical in many scenarios. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Rob Norris <rob.norris@klarasystems.com> Reviewed-by: Paul Dagnelie <paul.dagnelie@klarasystems.com> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored by: iXsystems, Inc. Closes #17505
This commit is contained in:
+15
-6
@@ -282,12 +282,15 @@ vdev_getops(const char *type)
|
||||
* Given a vdev and a metaslab class, find which metaslab group we're
|
||||
* interested in. All vdevs may belong to two different metaslab classes.
|
||||
* Dedicated slog devices use only the primary metaslab group, rather than a
|
||||
* separate log group. For embedded slogs, the vdev_log_mg will be non-NULL.
|
||||
* separate log group. For embedded slogs, vdev_log_mg will be non-NULL and
|
||||
* will point to a metaslab group of either embedded_log_class (for normal
|
||||
* vdevs) or special_embedded_log_class (for special vdevs).
|
||||
*/
|
||||
metaslab_group_t *
|
||||
vdev_get_mg(vdev_t *vd, metaslab_class_t *mc)
|
||||
{
|
||||
if (mc == spa_embedded_log_class(vd->vdev_spa) &&
|
||||
if ((mc == spa_embedded_log_class(vd->vdev_spa) ||
|
||||
mc == spa_special_embedded_log_class(vd->vdev_spa)) &&
|
||||
vd->vdev_log_mg != NULL)
|
||||
return (vd->vdev_log_mg);
|
||||
else
|
||||
@@ -1508,8 +1511,13 @@ vdev_metaslab_group_create(vdev_t *vd)
|
||||
vd->vdev_mg = metaslab_group_create(mc, vd);
|
||||
|
||||
if (!vd->vdev_islog) {
|
||||
vd->vdev_log_mg = metaslab_group_create(
|
||||
spa_embedded_log_class(spa), vd);
|
||||
if (mc == spa_special_class(spa)) {
|
||||
vd->vdev_log_mg = metaslab_group_create(
|
||||
spa_special_embedded_log_class(spa), vd);
|
||||
} else {
|
||||
vd->vdev_log_mg = metaslab_group_create(
|
||||
spa_embedded_log_class(spa), vd);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1624,9 +1632,10 @@ vdev_metaslab_init(vdev_t *vd, uint64_t txg)
|
||||
/*
|
||||
* Find the emptiest metaslab on the vdev and mark it for use for
|
||||
* embedded slog by moving it from the regular to the log metaslab
|
||||
* group.
|
||||
* group. This works for normal and special vdevs.
|
||||
*/
|
||||
if (vd->vdev_mg->mg_class == spa_normal_class(spa) &&
|
||||
if ((vd->vdev_mg->mg_class == spa_normal_class(spa) ||
|
||||
vd->vdev_mg->mg_class == spa_special_class(spa)) &&
|
||||
vd->vdev_ms_count > zfs_embedded_slog_min_ms &&
|
||||
avl_is_empty(&vd->vdev_log_mg->mg_metaslab_tree)) {
|
||||
uint64_t slog_msid = 0;
|
||||
|
||||
Reference in New Issue
Block a user