aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/vdev.c
diff options
context:
space:
mode:
authorGeorge Amanakis <[email protected]>2020-04-10 13:33:35 -0400
committerGitHub <[email protected]>2020-04-10 10:33:35 -0700
commit77f6826b83b7e27f0996f6d192202c36f65e41fd (patch)
treeb9946c99348bf6742cc41739aeff1a2b952d9d2f /module/zfs/vdev.c
parent36a6e2335c45212f2609269bcee3004908ac6bcb (diff)
Persistent L2ARC
This commit makes the L2ARC persistent across reboots. We implement a light-weight persistent L2ARC metadata structure that allows L2ARC contents to be recovered after a reboot. This significantly eases the impact a reboot has on read performance on systems with large caches. Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: George Wilson <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Co-authored-by: Saso Kiselkov <[email protected]> Co-authored-by: Jorgen Lundman <[email protected]> Co-authored-by: George Amanakis <[email protected]> Ported-by: Yuxuan Shui <[email protected]> Signed-off-by: George Amanakis <[email protected]> Closes #925 Closes #1823 Closes #2672 Closes #3744 Closes #9582
Diffstat (limited to 'module/zfs/vdev.c')
-rw-r--r--module/zfs/vdev.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c
index fb0d02eea..59147ce31 100644
--- a/module/zfs/vdev.c
+++ b/module/zfs/vdev.c
@@ -2279,9 +2279,22 @@ vdev_reopen(vdev_t *vd)
if (vd->vdev_aux) {
(void) vdev_validate_aux(vd);
if (vdev_readable(vd) && vdev_writeable(vd) &&
- vd->vdev_aux == &spa->spa_l2cache &&
- !l2arc_vdev_present(vd))
- l2arc_add_vdev(spa, vd);
+ vd->vdev_aux == &spa->spa_l2cache) {
+ /*
+ * When reopening we can assume the device label has
+ * already the attribute l2cache_persistent, since we've
+ * opened the device in the past and updated the label.
+ * In case the vdev is present we should evict all ARC
+ * buffers and pointers to log blocks and reclaim their
+ * space before restoring its contents to L2ARC.
+ */
+ if (l2arc_vdev_present(vd)) {
+ l2arc_rebuild_vdev(vd, B_TRUE);
+ } else {
+ l2arc_add_vdev(spa, vd);
+ }
+ spa_async_request(spa, SPA_ASYNC_L2CACHE_REBUILD);
+ }
} else {
(void) vdev_validate(vd);
}