@@ -6627,27 +6627,11 @@ arc_release(arc_buf_t *buf, const void *tag)
6627
6627
arc_state_t * state = hdr -> b_l1hdr .b_state ;
6628
6628
ASSERT3P (hash_lock , = = , HDR_LOCK (hdr ));
6629
6629
ASSERT3P (state , != , arc_anon );
6630
+ ASSERT3P (state , != , arc_l2c_only );
6630
6631
6631
6632
/* this buffer is not on any list */
6632
6633
ASSERT3S (zfs_refcount_count (& hdr -> b_l1hdr .b_refcnt ), > , 0 );
6633
6634
6634
- if (HDR_HAS_L2HDR (hdr )) {
6635
- mutex_enter (& hdr -> b_l2hdr .b_dev -> l2ad_mtx );
6636
-
6637
- /*
6638
- * We have to recheck this conditional again now that
6639
- * we're holding the l2ad_mtx to prevent a race with
6640
- * another thread which might be concurrently calling
6641
- * l2arc_evict(). In that case, l2arc_evict() might have
6642
- * destroyed the header's L2 portion as we were waiting
6643
- * to acquire the l2ad_mtx.
6644
- */
6645
- if (HDR_HAS_L2HDR (hdr ))
6646
- arc_hdr_l2hdr_destroy (hdr );
6647
-
6648
- mutex_exit (& hdr -> b_l2hdr .b_dev -> l2ad_mtx );
6649
- }
6650
-
6651
6635
/*
6652
6636
* Do we have more than one buf?
6653
6637
*/
@@ -6659,21 +6643,17 @@ arc_release(arc_buf_t *buf, const void *tag)
6659
6643
boolean_t protected = HDR_PROTECTED (hdr );
6660
6644
enum zio_compress compress = arc_hdr_get_compress (hdr );
6661
6645
arc_buf_contents_t type = arc_buf_type (hdr );
6662
- VERIFY3U (hdr -> b_type , = = , type );
6663
-
6664
- ASSERT (hdr -> b_l1hdr .b_buf != buf || buf -> b_next != NULL );
6665
- VERIFY3S (remove_reference (hdr , tag ), > , 0 );
6666
6646
6667
6647
if (ARC_BUF_SHARED (buf ) && !ARC_BUF_COMPRESSED (buf )) {
6668
6648
ASSERT3P (hdr -> b_l1hdr .b_buf , != , buf );
6669
6649
ASSERT (ARC_BUF_LAST (buf ));
6670
6650
}
6671
6651
6672
6652
/*
6673
- * Pull the data off of this hdr and attach it to
6674
- * a new anonymous hdr. Also find the last buffer
6653
+ * Pull the buffer off of this hdr and find the last buffer
6675
6654
* in the hdr's buffer list.
6676
6655
*/
6656
+ VERIFY3S (remove_reference (hdr , tag ), > , 0 );
6677
6657
arc_buf_t * lastbuf = arc_buf_remove (hdr , buf );
6678
6658
ASSERT3P (lastbuf , != , NULL );
6679
6659
@@ -6682,7 +6662,6 @@ arc_release(arc_buf_t *buf, const void *tag)
6682
6662
* buffer, then we must stop sharing that block.
6683
6663
*/
6684
6664
if (ARC_BUF_SHARED (buf )) {
6685
- ASSERT3P (hdr -> b_l1hdr .b_buf , != , buf );
6686
6665
ASSERT (!arc_buf_is_shared (lastbuf ));
6687
6666
6688
6667
/*
@@ -6704,7 +6683,6 @@ arc_release(arc_buf_t *buf, const void *tag)
6704
6683
abd_copy_from_buf (hdr -> b_l1hdr .b_pabd ,
6705
6684
buf -> b_data , psize );
6706
6685
}
6707
- VERIFY3P (lastbuf -> b_data , != , NULL );
6708
6686
} else if (HDR_SHARED_DATA (hdr )) {
6709
6687
/*
6710
6688
* Uncompressed shared buffers are always at the end
@@ -6720,18 +6698,10 @@ arc_release(arc_buf_t *buf, const void *tag)
6720
6698
}
6721
6699
6722
6700
ASSERT (hdr -> b_l1hdr .b_pabd != NULL || HDR_HAS_RABD (hdr ));
6723
- ASSERT3P (state , != , arc_l2c_only );
6724
6701
6725
6702
(void ) zfs_refcount_remove_many (& state -> arcs_size [type ],
6726
6703
arc_buf_size (buf ), buf );
6727
6704
6728
- if (zfs_refcount_is_zero (& hdr -> b_l1hdr .b_refcnt )) {
6729
- ASSERT3P (state , != , arc_l2c_only );
6730
- (void ) zfs_refcount_remove_many (
6731
- & state -> arcs_esize [type ],
6732
- arc_buf_size (buf ), buf );
6733
- }
6734
-
6735
6705
arc_cksum_verify (buf );
6736
6706
arc_buf_unwatch (buf );
6737
6707
@@ -6759,6 +6729,15 @@ arc_release(arc_buf_t *buf, const void *tag)
6759
6729
/* protected by hash lock, or hdr is on arc_anon */
6760
6730
ASSERT (!multilist_link_active (& hdr -> b_l1hdr .b_arc_node ));
6761
6731
ASSERT (!HDR_IO_IN_PROGRESS (hdr ));
6732
+
6733
+ if (HDR_HAS_L2HDR (hdr )) {
6734
+ mutex_enter (& hdr -> b_l2hdr .b_dev -> l2ad_mtx );
6735
+ /* Recheck to prevent race with l2arc_evict(). */
6736
+ if (HDR_HAS_L2HDR (hdr ))
6737
+ arc_hdr_l2hdr_destroy (hdr );
6738
+ mutex_exit (& hdr -> b_l2hdr .b_dev -> l2ad_mtx );
6739
+ }
6740
+
6762
6741
hdr -> b_l1hdr .b_mru_hits = 0 ;
6763
6742
hdr -> b_l1hdr .b_mru_ghost_hits = 0 ;
6764
6743
hdr -> b_l1hdr .b_mfu_hits = 0 ;
0 commit comments