Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Nov 2015 09:52:36 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r290766 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201511130952.tAD9qaMa019812@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Nov 13 09:52:36 2015
New Revision: 290766
URL: https://svnweb.freebsd.org/changeset/base/290766

Log:
  MFC r290191 (by avg):
  l2arc: do not call trim_map_free() for blocks with zero b_asize
  
  b_asize can be zero if the block is compressed into an empty block
  (ZIO_COMPRESS_EMPTY) and the trim code asserts that meaningless
  zero-sized trimming is not attempted.
  The logic for calling trim_map_free() is extracted into a new function
  l2arc_trim() to minimize code duplication.
  
  PR:             203473
  Reported by:    Willem Jan Withagen <wjw@digiware.nl>
  Tested by:      Willem Jan Withagen <wjw@digiware.nl>

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Fri Nov 13 09:50:08 2015	(r290765)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Fri Nov 13 09:52:36 2015	(r290766)
@@ -1134,6 +1134,24 @@ static boolean_t l2arc_compress_buf(arc_
 static void l2arc_decompress_zio(zio_t *, arc_buf_hdr_t *, enum zio_compress);
 static void l2arc_release_cdata_buf(arc_buf_hdr_t *);
 
+static void
+l2arc_trim(const arc_buf_hdr_t *hdr)
+{
+	l2arc_dev_t *dev = hdr->b_l2hdr.b_dev;
+
+	ASSERT(HDR_HAS_L2HDR(hdr));
+	ASSERT(MUTEX_HELD(&dev->l2ad_mtx));
+
+	if (hdr->b_l2hdr.b_daddr == L2ARC_ADDR_UNSET)
+		return;
+	if (hdr->b_l2hdr.b_asize != 0) {
+		trim_map_free(dev->l2ad_vdev, hdr->b_l2hdr.b_daddr,
+		    hdr->b_l2hdr.b_asize, 0);
+	} else {
+		ASSERT3U(hdr->b_l2hdr.b_compress, ==, ZIO_COMPRESS_EMPTY);
+	}
+}
+
 static uint64_t
 buf_hash(uint64_t spa, const dva_t *dva, uint64_t birth)
 {
@@ -2406,10 +2424,7 @@ arc_hdr_destroy(arc_buf_hdr_t *hdr)
 		 * want to re-destroy the header's L2 portion.
 		 */
 		if (HDR_HAS_L2HDR(hdr)) {
-			if (hdr->b_l2hdr.b_daddr != L2ARC_ADDR_UNSET)
-				trim_map_free(dev->l2ad_vdev,
-				    hdr->b_l2hdr.b_daddr,
-				    hdr->b_l2hdr.b_asize, 0);
+			l2arc_trim(hdr);
 			arc_hdr_l2hdr_destroy(hdr);
 		}
 
@@ -4779,10 +4794,7 @@ arc_release(arc_buf_t *buf, void *tag)
 		 * to acquire the l2ad_mtx.
 		 */
 		if (HDR_HAS_L2HDR(hdr)) {
-			if (hdr->b_l2hdr.b_daddr != L2ARC_ADDR_UNSET)
-				trim_map_free(hdr->b_l2hdr.b_dev->l2ad_vdev,
-				    hdr->b_l2hdr.b_daddr,
-				    hdr->b_l2hdr.b_asize, 0);
+			l2arc_trim(hdr);
 			arc_hdr_l2hdr_destroy(hdr);
 		}
 
@@ -5969,8 +5981,7 @@ top:
 			 * Error - drop L2ARC entry.
 			 */
 			list_remove(buflist, hdr);
-			trim_map_free(hdr->b_l2hdr.b_dev->l2ad_vdev,
-			    hdr->b_l2hdr.b_daddr, hdr->b_l2hdr.b_asize, 0);
+			l2arc_trim(hdr);
 			hdr->b_flags &= ~ARC_FLAG_HAS_L2HDR;
 
 			ARCSTAT_INCR(arcstat_l2_asize, -hdr->b_l2hdr.b_asize);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511130952.tAD9qaMa019812>