* A write to a cache device has completed. Update all headers to allow * reads from these buffers to begin. */
| 8189 | * reads from these buffers to begin. |
| 8190 | */ |
| 8191 | static void |
| 8192 | l2arc_write_done(zio_t *zio) |
| 8193 | { |
| 8194 | l2arc_write_callback_t *cb; |
| 8195 | l2arc_lb_abd_buf_t *abd_buf; |
| 8196 | l2arc_lb_ptr_buf_t *lb_ptr_buf; |
| 8197 | l2arc_dev_t *dev; |
| 8198 | l2arc_dev_hdr_phys_t *l2dhdr; |
| 8199 | list_t *buflist; |
| 8200 | arc_buf_hdr_t *head, *hdr, *hdr_prev; |
| 8201 | kmutex_t *hash_lock; |
| 8202 | int64_t bytes_dropped = 0; |
| 8203 | |
| 8204 | cb = zio->io_private; |
| 8205 | ASSERT3P(cb, !=, NULL); |
| 8206 | dev = cb->l2wcb_dev; |
| 8207 | l2dhdr = dev->l2ad_dev_hdr; |
| 8208 | ASSERT3P(dev, !=, NULL); |
| 8209 | head = cb->l2wcb_head; |
| 8210 | ASSERT3P(head, !=, NULL); |
| 8211 | buflist = &dev->l2ad_buflist; |
| 8212 | ASSERT3P(buflist, !=, NULL); |
| 8213 | DTRACE_PROBE2(l2arc__iodone, zio_t *, zio, |
| 8214 | l2arc_write_callback_t *, cb); |
| 8215 | |
| 8216 | /* |
| 8217 | * All writes completed, or an error was hit. |
| 8218 | */ |
| 8219 | top: |
| 8220 | mutex_enter(&dev->l2ad_mtx); |
| 8221 | for (hdr = list_prev(buflist, head); hdr; hdr = hdr_prev) { |
| 8222 | hdr_prev = list_prev(buflist, hdr); |
| 8223 | |
| 8224 | hash_lock = HDR_LOCK(hdr); |
| 8225 | |
| 8226 | /* |
| 8227 | * We cannot use mutex_enter or else we can deadlock |
| 8228 | * with l2arc_write_buffers (due to swapping the order |
| 8229 | * the hash lock and l2ad_mtx are taken). |
| 8230 | */ |
| 8231 | if (!mutex_tryenter(hash_lock)) { |
| 8232 | /* |
| 8233 | * Missed the hash lock. We must retry so we |
| 8234 | * don't leave the ARC_FLAG_L2_WRITING bit set. |
| 8235 | */ |
| 8236 | ARCSTAT_BUMP(arcstat_l2_writes_lock_retry); |
| 8237 | |
| 8238 | /* |
| 8239 | * We don't want to rescan the headers we've |
| 8240 | * already marked as having been written out, so |
| 8241 | * we reinsert the head node so we can pick up |
| 8242 | * where we left off. |
| 8243 | */ |
| 8244 | list_remove(buflist, head); |
| 8245 | list_insert_after(buflist, hdr, head); |
| 8246 | |
| 8247 | mutex_exit(&dev->l2ad_mtx); |
| 8248 |
nothing calls this directly
no test coverage detected