summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/fs/zfs/vdev.c
diff options
context:
space:
mode:
authorGeorge Amanakis <gamanakis@gmail.com>2020-07-30 18:40:44 -0500
committerJason King <jason.king@joyent.com>2020-10-16 11:10:02 -0500
commitf0a052391861a2b96cf28973c3b7f2854591aa79 (patch)
tree653d2330669b465bac1ab1c55b7e24c018cddc8a /usr/src/uts/common/fs/zfs/vdev.c
parent6218f28969018904255fddf306e6489c7ae28bba (diff)
downloadillumos-joyent-f0a052391861a2b96cf28973c3b7f2854591aa79.tar.gz
3525 Persistent L2ARC
Portions contributed by: Saso Kiselkov <skiselkov@gmail.com> Portions contributed by: Jorgen Lundman <lundman@lundman.net> Portions contributed by: Brian Behlendorf <behlendorf1@llnl.gov> Portions contributed by: Alexander Motin <mav@FreeBSD.org> Portions contributed by: Jason King <jason.king@joyent.com> Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/uts/common/fs/zfs/vdev.c')
-rw-r--r--usr/src/uts/common/fs/zfs/vdev.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/usr/src/uts/common/fs/zfs/vdev.c b/usr/src/uts/common/fs/zfs/vdev.c
index 254af68099..cd05edcffa 100644
--- a/usr/src/uts/common/fs/zfs/vdev.c
+++ b/usr/src/uts/common/fs/zfs/vdev.c
@@ -2179,9 +2179,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);
}