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

Function arc_read

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

* "Read" the block at the specified DVA (in bp) via the * cache. If the block is found in the cache, invoke the provided * callback immediately and return. Note that the `zio' parameter * in the callback will be NULL in this case, since no IO was * required. If the block is not in the cache pass the read request * on to the spa with a substitute callback function, so that the * requested

Source from the content-addressed store, hash-verified

5904 * for readers of this block.
5905 */
5906int
5907arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
5908 arc_read_done_func_t *done, void *private, zio_priority_t priority,
5909 int zio_flags, arc_flags_t *arc_flags, const zbookmark_phys_t *zb)
5910{
5911 arc_buf_hdr_t *hdr = NULL;
5912 kmutex_t *hash_lock = NULL;
5913 zio_t *rzio;
5914 uint64_t guid = spa_load_guid(spa);
5915 boolean_t compressed_read = (zio_flags & ZIO_FLAG_RAW_COMPRESS) != 0;
5916 boolean_t encrypted_read = BP_IS_ENCRYPTED(bp) &&
5917 (zio_flags & ZIO_FLAG_RAW_ENCRYPT) != 0;
5918 boolean_t noauth_read = BP_IS_AUTHENTICATED(bp) &&
5919 (zio_flags & ZIO_FLAG_RAW_ENCRYPT) != 0;
5920 boolean_t embedded_bp = !!BP_IS_EMBEDDED(bp);
5921 boolean_t no_buf = *arc_flags & ARC_FLAG_NO_BUF;
5922 int rc = 0;
5923
5924 ASSERT(!embedded_bp ||
5925 BPE_GET_ETYPE(bp) == BP_EMBEDDED_TYPE_DATA);
5926 ASSERT(!BP_IS_HOLE(bp));
5927 ASSERT(!BP_IS_REDACTED(bp));
5928
5929 /*
5930 * Normally SPL_FSTRANS will already be set since kernel threads which
5931 * expect to call the DMU interfaces will set it when created. System
5932 * calls are similarly handled by setting/cleaning the bit in the
5933 * registered callback (module/os/.../zfs/zpl_*).
5934 *
5935 * External consumers such as Lustre which call the exported DMU
5936 * interfaces may not have set SPL_FSTRANS. To avoid a deadlock
5937 * on the hash_lock always set and clear the bit.
5938 */
5939 fstrans_cookie_t cookie = spl_fstrans_mark();
5940top:
5941 if (!embedded_bp) {
5942 /*
5943 * Embedded BP's have no DVA and require no I/O to "read".
5944 * Create an anonymous arc buf to back it.
5945 */
5946 hdr = buf_hash_find(guid, bp, &hash_lock);
5947 }
5948
5949 /*
5950 * Determine if we have an L1 cache hit or a cache miss. For simplicity
5951 * we maintain encrypted data separately from compressed / uncompressed
5952 * data. If the user is requesting raw encrypted data and we don't have
5953 * that in the header we will read from disk to guarantee that we can
5954 * get it even if the encryption keys aren't loaded.
5955 */
5956 if (hdr != NULL && HDR_HAS_L1HDR(hdr) && (HDR_HAS_RABD(hdr) ||
5957 (hdr->b_l1hdr.b_pabd != NULL && !encrypted_read))) {
5958 arc_buf_t *buf = NULL;
5959 *arc_flags |= ARC_FLAG_CACHED;
5960
5961 if (HDR_IO_IN_PROGRESS(hdr)) {
5962 zio_t *head_zio = hdr->b_l1hdr.b_acb->acb_zio_head;
5963

Callers 15

diff_cbFunction · 0.85
dbuf_read_implFunction · 0.85
dbuf_prefetch_implFunction · 0.85
do_dumpFunction · 0.85
issue_data_readFunction · 0.85
dmu_objset_open_implFunction · 0.85
traverse_visitbpFunction · 0.85
traverse_prefetcherFunction · 0.85
traverse_implFunction · 0.85

Calls 15

spa_load_guidFunction · 0.85
buf_hash_findFunction · 0.85
mutex_exitFunction · 0.85
zio_change_priorityFunction · 0.85
arc_hdr_clear_flagsFunction · 0.85
cv_waitFunction · 0.85
zio_nullFunction · 0.85
arc_buf_alloc_implFunction · 0.85
spa_log_errorFunction · 0.85
zfs_ereport_postFunction · 0.85
remove_referenceFunction · 0.85
arc_buf_destroy_implFunction · 0.85

Tested by

no test coverage detected