Skip to content
Permalink
Browse files

8835 Speculative prefetch in ZFS not working for misaligned reads

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Allan Jude <allanjude@freebsd.org>
Approved by: Gordon Ross <gwr@nexenta.com>
  • Loading branch information...
amotin authored and prakashsurya committed Nov 20, 2017
1 parent 4ae5f5f commit 5cb8d943bc8513c6230589aad5a409d58b0297cb
Showing with 19 additions and 5 deletions.
  1. +19 −5 usr/src/uts/common/fs/zfs/dmu_zfetch.c
@@ -235,19 +235,33 @@ dmu_zfetch(zfetch_t *zf, uint64_t blkid, uint64_t nblks, boolean_t fetch_data)

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);
}
}

0 comments on commit 5cb8d94

Please sign in to comment.
You can’t perform that action at this time.