From owner-svn-src-all@freebsd.org Tue Sep 19 09:02:27 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3ED79E069BB; Tue, 19 Sep 2017 09:02:27 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 19DCF72A0E; Tue, 19 Sep 2017 09:02:27 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8J92Qej051723; Tue, 19 Sep 2017 09:02:26 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8J92Qpk051722; Tue, 19 Sep 2017 09:02:26 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201709190902.v8J92Qpk051722@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 19 Sep 2017 09:02:26 +0000 (UTC) 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 X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 323752 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Sep 2017 09:02:27 -0000 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 Reviewed by: Prakash Surya Approved by: Matthew Ahrens Author: Andriy Gapon 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); }