diff options
author | Tom Caputi <[email protected]> | 2018-06-06 13:17:50 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-06-06 10:17:50 -0700 |
commit | b405837a6cf74165316bf996b4b79d171b19c211 (patch) | |
tree | ca31ac1409287cef394fbf50ce27b16eec370ed7 | |
parent | e7504d7a188b666a61a8c2d8c1ffaa9713f6cdfa (diff) |
Update the correct abd in l2arc_read_done()
This patch fixes an issue where l2arc_read_done() would always
write data to b_pabd, even if raw encrypted data was requested.
This only occured in cases where the L2ARC device had a different
ashift than the main pool.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Signed-off-by: Tom Caputi <[email protected]>
Closes #7586
Closes #7593
-rw-r--r-- | module/zfs/arc.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 8f90afaa1..bf514f00f 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -8248,17 +8248,18 @@ static void l2arc_read_done(zio_t *zio) { int tfm_error = 0; - l2arc_read_callback_t *cb; + l2arc_read_callback_t *cb = zio->io_private; arc_buf_hdr_t *hdr; kmutex_t *hash_lock; - boolean_t valid_cksum, using_rdata; + boolean_t valid_cksum; + boolean_t using_rdata = (BP_IS_ENCRYPTED(&cb->l2rcb_bp) && + (cb->l2rcb_flags & ZIO_FLAG_RAW_ENCRYPT)); ASSERT3P(zio->io_vd, !=, NULL); ASSERT(zio->io_flags & ZIO_FLAG_DONT_PROPAGATE); spa_config_exit(zio->io_spa, SCL_L2ARC, zio->io_vd); - cb = zio->io_private; ASSERT3P(cb, !=, NULL); hdr = cb->l2rcb_hdr; ASSERT3P(hdr, !=, NULL); @@ -8274,8 +8275,13 @@ l2arc_read_done(zio_t *zio) if (cb->l2rcb_abd != NULL) { ASSERT3U(arc_hdr_size(hdr), <, zio->io_size); if (zio->io_error == 0) { - abd_copy(hdr->b_l1hdr.b_pabd, cb->l2rcb_abd, - arc_hdr_size(hdr)); + if (using_rdata) { + abd_copy(hdr->b_crypt_hdr.b_rabd, + cb->l2rcb_abd, arc_hdr_size(hdr)); + } else { + abd_copy(hdr->b_l1hdr.b_pabd, + cb->l2rcb_abd, arc_hdr_size(hdr)); + } } /* @@ -8292,8 +8298,7 @@ l2arc_read_done(zio_t *zio) abd_free(cb->l2rcb_abd); zio->io_size = zio->io_orig_size = arc_hdr_size(hdr); - if (BP_IS_ENCRYPTED(&cb->l2rcb_bp) && - (cb->l2rcb_flags & ZIO_FLAG_RAW_ENCRYPT)) { + if (using_rdata) { ASSERT(HDR_HAS_RABD(hdr)); zio->io_abd = zio->io_orig_abd = hdr->b_crypt_hdr.b_rabd; @@ -8314,8 +8319,6 @@ l2arc_read_done(zio_t *zio) zio->io_bp = &zio->io_bp_copy; /* XXX fix in L2ARC 2.0 */ valid_cksum = arc_cksum_is_equal(hdr, zio); - using_rdata = (HDR_HAS_RABD(hdr) && - zio->io_abd == hdr->b_crypt_hdr.b_rabd); /* * b_rabd will always match the data as it exists on disk if it is |