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

Function l2arc_write_buffers

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

* Find and write ARC buffers to the L2ARC device. * * An ARC_FLAG_L2_WRITING flag is set so that the L2ARC buffers are not valid * for reading until they have completed writing. * The headroom_boost is an in-out parameter used to maintain headroom boost * state between calls to this function. * * Returns the number of bytes actually written (which may be smaller than * the delta by which t

Source from the content-addressed store, hash-verified

9056 * writing of log blocks).
9057 */
9058static uint64_t
9059l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz)
9060{
9061 arc_buf_hdr_t *hdr, *hdr_prev, *head;
9062 uint64_t write_asize, write_psize, write_lsize, headroom;
9063 boolean_t full;
9064 l2arc_write_callback_t *cb = NULL;
9065 zio_t *pio, *wzio;
9066 uint64_t guid = spa_load_guid(spa);
9067 l2arc_dev_hdr_phys_t *l2dhdr = dev->l2ad_dev_hdr;
9068
9069 ASSERT3P(dev->l2ad_vdev, !=, NULL);
9070
9071 pio = NULL;
9072 write_lsize = write_asize = write_psize = 0;
9073 full = B_FALSE;
9074 head = kmem_cache_alloc(hdr_l2only_cache, KM_PUSHPAGE);
9075 arc_hdr_set_flags(head, ARC_FLAG_L2_WRITE_HEAD | ARC_FLAG_HAS_L2HDR);
9076
9077 /*
9078 * Copy buffers for L2ARC writing.
9079 */
9080 for (int try = 0; try < L2ARC_FEED_TYPES; try++) {
9081 /*
9082 * If try == 1 or 3, we cache MRU metadata and data
9083 * respectively.
9084 */
9085 if (l2arc_mfuonly) {
9086 if (try == 1 || try == 3)
9087 continue;
9088 }
9089
9090 multilist_sublist_t *mls = l2arc_sublist_lock(try);
9091 uint64_t passed_sz = 0;
9092
9093 VERIFY3P(mls, !=, NULL);
9094
9095 /*
9096 * L2ARC fast warmup.
9097 *
9098 * Until the ARC is warm and starts to evict, read from the
9099 * head of the ARC lists rather than the tail.
9100 */
9101 if (arc_warm == B_FALSE)
9102 hdr = multilist_sublist_head(mls);
9103 else
9104 hdr = multilist_sublist_tail(mls);
9105
9106 headroom = target_sz * l2arc_headroom;
9107 if (zfs_compressed_arc_enabled)
9108 headroom = (headroom * l2arc_headroom_boost) / 100;
9109
9110 for (; hdr; hdr = hdr_prev) {
9111 kmutex_t *hash_lock;
9112 abd_t *to_write = NULL;
9113
9114 if (arc_warm == B_FALSE)
9115 hdr_prev = multilist_sublist_next(mls, hdr);

Callers 1

l2arc_feed_threadFunction · 0.85

Calls 15

spa_load_guidFunction · 0.85
kmem_cache_allocFunction · 0.85
arc_hdr_set_flagsFunction · 0.85
l2arc_sublist_lockFunction · 0.85
multilist_sublist_headFunction · 0.85
multilist_sublist_tailFunction · 0.85
multilist_sublist_nextFunction · 0.85
multilist_sublist_prevFunction · 0.85
mutex_tryenterFunction · 0.85
mutex_exitFunction · 0.85
l2arc_write_eligibleFunction · 0.85
arc_hdr_sizeFunction · 0.85

Tested by

no test coverage detected