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

Function l2arc_read_done

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

* A read to a cache device completed. Validate buffer contents before * handing over to the regular ARC routines. */

Source from the content-addressed store, hash-verified

8465 * handing over to the regular ARC routines.
8466 */
8467static void
8468l2arc_read_done(zio_t *zio)
8469{
8470 int tfm_error = 0;
8471 l2arc_read_callback_t *cb = zio->io_private;
8472 arc_buf_hdr_t *hdr;
8473 kmutex_t *hash_lock;
8474 boolean_t valid_cksum;
8475 boolean_t using_rdata = (BP_IS_ENCRYPTED(&cb->l2rcb_bp) &&
8476 (cb->l2rcb_flags & ZIO_FLAG_RAW_ENCRYPT));
8477
8478 ASSERT3P(zio->io_vd, !=, NULL);
8479 ASSERT(zio->io_flags & ZIO_FLAG_DONT_PROPAGATE);
8480
8481 spa_config_exit(zio->io_spa, SCL_L2ARC, zio->io_vd);
8482
8483 ASSERT3P(cb, !=, NULL);
8484 hdr = cb->l2rcb_hdr;
8485 ASSERT3P(hdr, !=, NULL);
8486
8487 hash_lock = HDR_LOCK(hdr);
8488 mutex_enter(hash_lock);
8489 ASSERT3P(hash_lock, ==, HDR_LOCK(hdr));
8490
8491 /*
8492 * If the data was read into a temporary buffer,
8493 * move it and free the buffer.
8494 */
8495 if (cb->l2rcb_abd != NULL) {
8496 ASSERT3U(arc_hdr_size(hdr), <, zio->io_size);
8497 if (zio->io_error == 0) {
8498 if (using_rdata) {
8499 abd_copy(hdr->b_crypt_hdr.b_rabd,
8500 cb->l2rcb_abd, arc_hdr_size(hdr));
8501 } else {
8502 abd_copy(hdr->b_l1hdr.b_pabd,
8503 cb->l2rcb_abd, arc_hdr_size(hdr));
8504 }
8505 }
8506
8507 /*
8508 * The following must be done regardless of whether
8509 * there was an error:
8510 * - free the temporary buffer
8511 * - point zio to the real ARC buffer
8512 * - set zio size accordingly
8513 * These are required because zio is either re-used for
8514 * an I/O of the block in the case of the error
8515 * or the zio is passed to arc_read_done() and it
8516 * needs real data.
8517 */
8518 abd_free(cb->l2rcb_abd);
8519 zio->io_size = zio->io_orig_size = arc_hdr_size(hdr);
8520
8521 if (using_rdata) {
8522 ASSERT(HDR_HAS_RABD(hdr));
8523 zio->io_abd = zio->io_orig_abd =
8524 hdr->b_crypt_hdr.b_rabd;

Callers

nothing calls this directly

Calls 13

spa_config_exitFunction · 0.85
mutex_enterFunction · 0.85
arc_hdr_sizeFunction · 0.85
abd_copyFunction · 0.85
abd_freeFunction · 0.85
arc_cksum_is_equalFunction · 0.85
l2arc_untransformFunction · 0.85
mutex_exitFunction · 0.85
arc_read_doneFunction · 0.85
zio_unique_parentFunction · 0.85
zio_readFunction · 0.85
zio_nowaitFunction · 0.85

Tested by

no test coverage detected