Skip to content

Commit f28cd34

Browse files
gamanakisbehlendorf
authored andcommitted
Store the L2ARC device ashift in the vdev label
If this is not done, and the pool has an ashift other than the default (at the moment 9) then the following happens: 1) vdev_alloc() assigns the ashift of the pool to L2ARC device, but upon export it is not stored anywhere 2) at the first import, vdev_open() sees an vdev_ashift() of 0 and assigns the logical_ashift, which is 9 3) reading the contents of L2ARC, including the header fails 4) L2ARC buffers are not restored in ARC. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: George Amanakis <[email protected]> Closes #14313 Closes #14963
1 parent c12b582 commit f28cd34

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

module/zfs/vdev_label.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,9 @@ vdev_config_generate(spa_t *spa, vdev_t *vd, boolean_t getstats,
468468
if (vd->vdev_isspare)
469469
fnvlist_add_uint64(nv, ZPOOL_CONFIG_IS_SPARE, 1);
470470

471+
if (flags & VDEV_CONFIG_L2CACHE)
472+
fnvlist_add_uint64(nv, ZPOOL_CONFIG_ASHIFT, vd->vdev_ashift);
473+
471474
if (!(flags & (VDEV_CONFIG_SPARE | VDEV_CONFIG_L2CACHE)) &&
472475
vd == vd->vdev_top) {
473476
fnvlist_add_uint64(nv, ZPOOL_CONFIG_METASLAB_ARRAY,

tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@
2727
#
2828
# STRATEGY:
2929
# 1. Create pool with a cache device.
30-
# 2. Export and re-import pool without writing any data.
31-
# 3. Create a random file in that pool and random read for 10 sec.
32-
# 4. Export pool.
33-
# 5. Read the amount of log blocks written from the header of the
30+
# 2. Create a random file in that pool and random read for 10 sec.
31+
# 3. Export pool.
32+
# 4. Read the amount of log blocks written from the header of the
3433
# L2ARC device.
35-
# 6. Import pool.
36-
# 7. Read the amount of log blocks rebuilt in arcstats and compare to
34+
# 5. Import pool.
35+
# 6. Read the amount of log blocks rebuilt in arcstats and compare to
3736
# (5).
38-
# 8. Check if the labels of the L2ARC device are intact.
37+
# 7. Check if the labels of the L2ARC device are intact.
3938
#
4039
# * We can predict the minimum bytes of L2ARC restored if we subtract
4140
# from the effective size of the cache device the bytes l2arc_evict()
@@ -75,10 +74,8 @@ export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M
7574

7675
log_must truncate -s ${cache_sz}M $VDEV_CACHE
7776

78-
log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE
79-
80-
log_must zpool export $TESTPOOL
81-
log_must zpool import -d $VDIR $TESTPOOL
77+
log_must zpool create -f -o ashift=12 $TESTPOOL $VDEV
78+
log_must zpool add $TESTPOOL cache $VDEV_CACHE
8279

8380
log_must fio $FIO_SCRIPTS/mkfiles.fio
8481
log_must fio $FIO_SCRIPTS/random_reads.fio

0 commit comments

Comments
 (0)