Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Feb 2018 00:26:34 +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-11@freebsd.org
Subject:   svn commit: r329494 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201802180026.w1I0QY8M061700@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sun Feb 18 00:26:34 2018
New Revision: 329494
URL: https://svnweb.freebsd.org/changeset/base/329494

Log:
  MFC r328254:
  MFV r328253: 8835 Speculative prefetch in ZFS not working for misaligned reads
  
  illumos/illumos-gate@5cb8d943bc8513c6230589aad5a409d58b0297cb
  
  https://www.illumos.org/issues/8835:
  Sequential reads not aligned to block size are not detected by ZFS
  prefetcher as sequential, killing prefetch and severely hurting
  performance.  It is caused by dmu_zfetch() in case of misaligned
  sequential accesses being called with overlap of one block.
  
  Reviewed by: Matthew Ahrens <mahrens@delphix.com>
  Reviewed by: Allan Jude <allanjude@freebsd.org>
  Approved by: Gordon Ross <gwr@nexenta.com>
  Author: Alexander Motin <mav@FreeBSD.org>

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

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c
==============================================================================
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c	Sun Feb 18 00:26:00 2018	(r329493)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c	Sun Feb 18 00:26:34 2018	(r329494)
@@ -240,19 +240,33 @@ dmu_zfetch(zfetch_t *zf, uint64_t blkid, uint64_t nblk
 
 	rw_enter(&zf->zf_rwlock, RW_READER);
 
+	/*
+	 * Find matching prefetch stream.  Depending on whether the accesses
+	 * are block-aligned, first block of the new access may either follow
+	 * the last block of the previous access, or be equal to it.
+	 */
 	for (zs = list_head(&zf->zf_stream); zs != NULL;
 	    zs = list_next(&zf->zf_stream, zs)) {
-		if (blkid == zs->zs_blkid) {
+		if (blkid == zs->zs_blkid || blkid + 1 == zs->zs_blkid) {
 			mutex_enter(&zs->zs_lock);
 			/*
 			 * zs_blkid could have changed before we
 			 * acquired zs_lock; re-check them here.
 			 */
-			if (blkid != zs->zs_blkid) {
-				mutex_exit(&zs->zs_lock);
-				continue;
+			if (blkid == zs->zs_blkid) {
+				break;
+			} else if (blkid + 1 == zs->zs_blkid) {
+				blkid++;
+				nblks--;
+				if (nblks == 0) {
+					/* Already prefetched this before. */
+					mutex_exit(&zs->zs_lock);
+					rw_exit(&zf->zf_rwlock);
+					return;
+				}
+				break;
 			}
-			break;
+			mutex_exit(&zs->zs_lock);
 		}
 	}
 



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