MCPcopy Create free account
hub / github.com/F-Stack/f-stack / l2arc_untransform

Function l2arc_untransform

freebsd/contrib/openzfs/module/zfs/arc.c:8371–8460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8369}
8370
8371static int
8372l2arc_untransform(zio_t *zio, l2arc_read_callback_t *cb)
8373{
8374 int ret;
8375 spa_t *spa = zio->io_spa;
8376 arc_buf_hdr_t *hdr = cb->l2rcb_hdr;
8377 blkptr_t *bp = zio->io_bp;
8378 uint8_t salt[ZIO_DATA_SALT_LEN];
8379 uint8_t iv[ZIO_DATA_IV_LEN];
8380 uint8_t mac[ZIO_DATA_MAC_LEN];
8381 boolean_t no_crypt = B_FALSE;
8382
8383 /*
8384 * ZIL data is never be written to the L2ARC, so we don't need
8385 * special handling for its unique MAC storage.
8386 */
8387 ASSERT3U(BP_GET_TYPE(bp), !=, DMU_OT_INTENT_LOG);
8388 ASSERT(MUTEX_HELD(HDR_LOCK(hdr)));
8389 ASSERT3P(hdr->b_l1hdr.b_pabd, !=, NULL);
8390
8391 /*
8392 * If the data was encrypted, decrypt it now. Note that
8393 * we must check the bp here and not the hdr, since the
8394 * hdr does not have its encryption parameters updated
8395 * until arc_read_done().
8396 */
8397 if (BP_IS_ENCRYPTED(bp)) {
8398 abd_t *eabd = arc_get_data_abd(hdr, arc_hdr_size(hdr), hdr,
8399 B_TRUE);
8400
8401 zio_crypt_decode_params_bp(bp, salt, iv);
8402 zio_crypt_decode_mac_bp(bp, mac);
8403
8404 ret = spa_do_crypt_abd(B_FALSE, spa, &cb->l2rcb_zb,
8405 BP_GET_TYPE(bp), BP_GET_DEDUP(bp), BP_SHOULD_BYTESWAP(bp),
8406 salt, iv, mac, HDR_GET_PSIZE(hdr), eabd,
8407 hdr->b_l1hdr.b_pabd, &no_crypt);
8408 if (ret != 0) {
8409 arc_free_data_abd(hdr, eabd, arc_hdr_size(hdr), hdr);
8410 goto error;
8411 }
8412
8413 /*
8414 * If we actually performed decryption, replace b_pabd
8415 * with the decrypted data. Otherwise we can just throw
8416 * our decryption buffer away.
8417 */
8418 if (!no_crypt) {
8419 arc_free_data_abd(hdr, hdr->b_l1hdr.b_pabd,
8420 arc_hdr_size(hdr), hdr);
8421 hdr->b_l1hdr.b_pabd = eabd;
8422 zio->io_abd = eabd;
8423 } else {
8424 arc_free_data_abd(hdr, eabd, arc_hdr_size(hdr), hdr);
8425 }
8426 }
8427
8428 /*

Callers 1

l2arc_read_doneFunction · 0.85

Calls 9

arc_get_data_abdFunction · 0.85
arc_hdr_sizeFunction · 0.85
spa_do_crypt_abdFunction · 0.85
arc_free_data_abdFunction · 0.85
abd_borrow_bufFunction · 0.85
zio_decompress_dataFunction · 0.85
abd_return_buf_copyFunction · 0.85
zio_crypt_decode_mac_bpFunction · 0.50

Tested by

no test coverage detected