Print this page
13389 After persistent L2ARC import, cache device has constant 8KB/sec load
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>


8330  * Find and write ARC buffers to the L2ARC device.
8331  *
8332  * An ARC_FLAG_L2_WRITING flag is set so that the L2ARC buffers are not valid
8333  * for reading until they have completed writing.
8334  * The headroom_boost is an in-out parameter used to maintain headroom boost
8335  * state between calls to this function.
8336  *
8337  * Returns the number of bytes actually written (which may be smaller than
8338  * the delta by which the device hand has changed due to alignment and the
8339  * writing of log blocks).
8340  */
8341 static uint64_t
8342 l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz)
8343 {
8344         arc_buf_hdr_t           *hdr, *hdr_prev, *head;
8345         uint64_t                write_asize, write_psize, write_lsize, headroom;
8346         boolean_t               full;
8347         l2arc_write_callback_t  *cb = NULL;
8348         zio_t                   *pio, *wzio;
8349         uint64_t                guid = spa_load_guid(spa);

8350 
8351         ASSERT3P(dev->l2ad_vdev, !=, NULL);
8352 
8353         pio = NULL;
8354         write_lsize = write_asize = write_psize = 0;
8355         full = B_FALSE;
8356         head = kmem_cache_alloc(hdr_l2only_cache, KM_PUSHPAGE);
8357         arc_hdr_set_flags(head, ARC_FLAG_L2_WRITE_HEAD | ARC_FLAG_HAS_L2HDR);
8358 
8359         /*
8360          * Copy buffers for L2ARC writing.
8361          */
8362         for (int try = 0; try <= 3; try++) {
8363                 multilist_sublist_t *mls = l2arc_sublist_lock(try);
8364                 uint64_t passed_sz = 0;
8365 
8366                 VERIFY3P(mls, !=, NULL);
8367 
8368                 /*
8369                  * L2ARC fast warmup.


8548 
8549                         (void) zio_nowait(wzio);
8550                 }
8551 
8552                 multilist_sublist_unlock(mls);
8553 
8554                 if (full == B_TRUE)
8555                         break;
8556         }
8557 
8558         /* No buffers selected for writing? */
8559         if (pio == NULL) {
8560                 ASSERT0(write_lsize);
8561                 ASSERT(!HDR_HAS_L1HDR(head));
8562                 kmem_cache_free(hdr_l2only_cache, head);
8563 
8564                 /*
8565                  * Although we did not write any buffers l2ad_evict may
8566                  * have advanced.
8567                  */

8568                 l2arc_dev_hdr_update(dev);
8569 
8570                 return (0);
8571         }
8572 
8573         if (!dev->l2ad_first)
8574                 ASSERT3U(dev->l2ad_hand, <=, dev->l2ad_evict);
8575 
8576         ASSERT3U(write_asize, <=, target_sz);
8577         ARCSTAT_BUMP(arcstat_l2_writes_sent);
8578         ARCSTAT_INCR(arcstat_l2_write_bytes, write_psize);
8579         ARCSTAT_INCR(arcstat_l2_lsize, write_lsize);
8580         ARCSTAT_INCR(arcstat_l2_psize, write_psize);
8581 
8582         dev->l2ad_writing = B_TRUE;
8583         (void) zio_wait(pio);
8584         dev->l2ad_writing = B_FALSE;
8585 
8586         /*
8587          * Update the device header after the zio completes as




8330  * Find and write ARC buffers to the L2ARC device.
8331  *
8332  * An ARC_FLAG_L2_WRITING flag is set so that the L2ARC buffers are not valid
8333  * for reading until they have completed writing.
8334  * The headroom_boost is an in-out parameter used to maintain headroom boost
8335  * state between calls to this function.
8336  *
8337  * Returns the number of bytes actually written (which may be smaller than
8338  * the delta by which the device hand has changed due to alignment and the
8339  * writing of log blocks).
8340  */
8341 static uint64_t
8342 l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz)
8343 {
8344         arc_buf_hdr_t           *hdr, *hdr_prev, *head;
8345         uint64_t                write_asize, write_psize, write_lsize, headroom;
8346         boolean_t               full;
8347         l2arc_write_callback_t  *cb = NULL;
8348         zio_t                   *pio, *wzio;
8349         uint64_t                guid = spa_load_guid(spa);
8350         l2arc_dev_hdr_phys_t    *l2dhdr = dev->l2ad_dev_hdr;
8351 
8352         ASSERT3P(dev->l2ad_vdev, !=, NULL);
8353 
8354         pio = NULL;
8355         write_lsize = write_asize = write_psize = 0;
8356         full = B_FALSE;
8357         head = kmem_cache_alloc(hdr_l2only_cache, KM_PUSHPAGE);
8358         arc_hdr_set_flags(head, ARC_FLAG_L2_WRITE_HEAD | ARC_FLAG_HAS_L2HDR);
8359 
8360         /*
8361          * Copy buffers for L2ARC writing.
8362          */
8363         for (int try = 0; try <= 3; try++) {
8364                 multilist_sublist_t *mls = l2arc_sublist_lock(try);
8365                 uint64_t passed_sz = 0;
8366 
8367                 VERIFY3P(mls, !=, NULL);
8368 
8369                 /*
8370                  * L2ARC fast warmup.


8549 
8550                         (void) zio_nowait(wzio);
8551                 }
8552 
8553                 multilist_sublist_unlock(mls);
8554 
8555                 if (full == B_TRUE)
8556                         break;
8557         }
8558 
8559         /* No buffers selected for writing? */
8560         if (pio == NULL) {
8561                 ASSERT0(write_lsize);
8562                 ASSERT(!HDR_HAS_L1HDR(head));
8563                 kmem_cache_free(hdr_l2only_cache, head);
8564 
8565                 /*
8566                  * Although we did not write any buffers l2ad_evict may
8567                  * have advanced.
8568                  */
8569                 if (dev->l2ad_evict != l2dhdr->dh_evict)
8570                         l2arc_dev_hdr_update(dev);
8571 
8572                 return (0);
8573         }
8574 
8575         if (!dev->l2ad_first)
8576                 ASSERT3U(dev->l2ad_hand, <=, dev->l2ad_evict);
8577 
8578         ASSERT3U(write_asize, <=, target_sz);
8579         ARCSTAT_BUMP(arcstat_l2_writes_sent);
8580         ARCSTAT_INCR(arcstat_l2_write_bytes, write_psize);
8581         ARCSTAT_INCR(arcstat_l2_lsize, write_lsize);
8582         ARCSTAT_INCR(arcstat_l2_psize, write_psize);
8583 
8584         dev->l2ad_writing = B_TRUE;
8585         (void) zio_wait(pio);
8586         dev->l2ad_writing = B_FALSE;
8587 
8588         /*
8589          * Update the device header after the zio completes as