Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Sep 2017 09:02:26 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r323752 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201709190902.v8J92Qpk051722@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Tue Sep 19 09:02:26 2017
New Revision: 323752
URL: https://svnweb.freebsd.org/changeset/base/323752

Log:
  MFC r322239: MFV r322238: 7915 checks in l2arc_evict could use some cleaning up
  
  illumos/illumos-gate@267ae6c3a88d2fc39276af66caafa978b0935b82
  https://github.com/illumos/illumos-gate/commit/267ae6c3a88d2fc39276af66caafa978b0935b82
  
  https://www.illumos.org/issues/7915
    l2arc_evict() is strictly serialized with respect to
    l2arc_write_buffers() and l2arc_write_done().  Normally, l2arc_evict()
    and l2arc_write_buffers() are called from the same thread, so they can
    not be concurrent.  Also, l2arc_write_buffers() uses zio_wait() on the
    parent zio of all cache zio-s.  That ensures that l2arc_write_done()
    is completed before l2arc_write_buffers() returns.  Finally, if a
    cache device is removed, then l2arc_evict() is called under SCL_ALL in
    the exclusive mode.  That ensures that it can not be concurrent with
    the normal L2ARC accesses to the device (including writing and
    evicting buffers).  Given the above, some checks and actions in
    l2arc_evict() do not make sense.  For instance, it must never
    encounter the write head header let alone remove it from the buffer
    list.
  
  Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
  Reviewed by: Prakash Surya <prakash.surya@delphix.com>
  Approved by: Matthew Ahrens <mahrens@delphix.com>
  Author: Andriy Gapon <avg@FreeBSD.org>

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

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==============================================================================
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Tue Sep 19 08:59:11 2017	(r323751)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Tue Sep 19 09:02:26 2017	(r323752)
@@ -7314,18 +7314,16 @@ top:
 			goto top;
 		}
 
-		if (HDR_L2_WRITE_HEAD(hdr)) {
-			/*
-			 * We hit a write head node.  Leave it for
-			 * l2arc_write_done().
-			 */
-			list_remove(buflist, hdr);
-			mutex_exit(hash_lock);
-			continue;
-		}
+		/*
+		 * A header can't be on this list if it doesn't have L2 header.
+		 */
+		ASSERT(HDR_HAS_L2HDR(hdr));
 
-		if (!all && HDR_HAS_L2HDR(hdr) &&
-		    (hdr->b_l2hdr.b_daddr >= taddr ||
+		/* Ensure this header has finished being written. */
+		ASSERT(!HDR_L2_WRITING(hdr));
+		ASSERT(!HDR_L2_WRITE_HEAD(hdr));
+
+		if (!all && (hdr->b_l2hdr.b_daddr >= taddr ||
 		    hdr->b_l2hdr.b_daddr < dev->l2ad_hand)) {
 			/*
 			 * We've evicted to the target address,
@@ -7335,7 +7333,6 @@ top:
 			break;
 		}
 
-		ASSERT(HDR_HAS_L2HDR(hdr));
 		if (!HDR_HAS_L1HDR(hdr)) {
 			ASSERT(!HDR_L2_READING(hdr));
 			/*
@@ -7357,9 +7354,6 @@ top:
 				ARCSTAT_BUMP(arcstat_l2_evict_reading);
 				arc_hdr_set_flags(hdr, ARC_FLAG_L2_EVICTED);
 			}
-
-			/* Ensure this header has finished being written */
-			ASSERT(!HDR_L2_WRITING(hdr));
 
 			arc_hdr_l2hdr_destroy(hdr);
 		}



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