Deleted Added
full compact
dmu_zfetch.c (219089) dmu_zfetch.c (251629)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 52 unchanged lines hidden (view full) ---

61SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, block_cap, CTLFLAG_RDTUN,
62 &zfetch_block_cap, 0, "Max number of blocks to fetch at a time");
63TUNABLE_QUAD("vfs.zfs.zfetch.array_rd_sz", &zfetch_array_rd_sz);
64SYSCTL_UQUAD(_vfs_zfs_zfetch, OID_AUTO, array_rd_sz, CTLFLAG_RDTUN,
65 &zfetch_array_rd_sz, 0,
66 "Number of bytes in a array_read at which we stop prefetching");
67
68/* forward decls for static routines */
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 52 unchanged lines hidden (view full) ---

61SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, block_cap, CTLFLAG_RDTUN,
62 &zfetch_block_cap, 0, "Max number of blocks to fetch at a time");
63TUNABLE_QUAD("vfs.zfs.zfetch.array_rd_sz", &zfetch_array_rd_sz);
64SYSCTL_UQUAD(_vfs_zfs_zfetch, OID_AUTO, array_rd_sz, CTLFLAG_RDTUN,
65 &zfetch_array_rd_sz, 0,
66 "Number of bytes in a array_read at which we stop prefetching");
67
68/* forward decls for static routines */
69static int dmu_zfetch_colinear(zfetch_t *, zstream_t *);
69static boolean_t dmu_zfetch_colinear(zfetch_t *, zstream_t *);
70static void dmu_zfetch_dofetch(zfetch_t *, zstream_t *);
71static uint64_t dmu_zfetch_fetch(dnode_t *, uint64_t, uint64_t);
72static uint64_t dmu_zfetch_fetchsz(dnode_t *, uint64_t, uint64_t);
70static void dmu_zfetch_dofetch(zfetch_t *, zstream_t *);
71static uint64_t dmu_zfetch_fetch(dnode_t *, uint64_t, uint64_t);
72static uint64_t dmu_zfetch_fetchsz(dnode_t *, uint64_t, uint64_t);
73static int dmu_zfetch_find(zfetch_t *, zstream_t *, int);
73static boolean_t dmu_zfetch_find(zfetch_t *, zstream_t *, int);
74static int dmu_zfetch_stream_insert(zfetch_t *, zstream_t *);
75static zstream_t *dmu_zfetch_stream_reclaim(zfetch_t *);
76static void dmu_zfetch_stream_remove(zfetch_t *, zstream_t *);
77static int dmu_zfetch_streams_equal(zstream_t *, zstream_t *);
78
79typedef struct zfetch_stats {
80 kstat_named_t zfetchstat_hits;
81 kstat_named_t zfetchstat_misses;

--- 35 unchanged lines hidden (view full) ---

117 * streams. If a set is found, coalesce the streams, removing one, and
118 * configure the prefetch so it looks for a strided access pattern.
119 *
120 * In other words: if we find two sequential access streams that are
121 * the same length and distance N appart, and this read is N from the
122 * last stream, then we are probably in a strided access pattern. So
123 * combine the two sequential streams into a single strided stream.
124 *
74static int dmu_zfetch_stream_insert(zfetch_t *, zstream_t *);
75static zstream_t *dmu_zfetch_stream_reclaim(zfetch_t *);
76static void dmu_zfetch_stream_remove(zfetch_t *, zstream_t *);
77static int dmu_zfetch_streams_equal(zstream_t *, zstream_t *);
78
79typedef struct zfetch_stats {
80 kstat_named_t zfetchstat_hits;
81 kstat_named_t zfetchstat_misses;

--- 35 unchanged lines hidden (view full) ---

117 * streams. If a set is found, coalesce the streams, removing one, and
118 * configure the prefetch so it looks for a strided access pattern.
119 *
120 * In other words: if we find two sequential access streams that are
121 * the same length and distance N appart, and this read is N from the
122 * last stream, then we are probably in a strided access pattern. So
123 * combine the two sequential streams into a single strided stream.
124 *
125 * If no co-linear streams are found, return NULL.
125 * Returns whether co-linear streams were found.
126 */
126 */
127static int
127static boolean_t
128dmu_zfetch_colinear(zfetch_t *zf, zstream_t *zh)
129{
130 zstream_t *z_walk;
131 zstream_t *z_comp;
132
133 if (! rw_tryenter(&zf->zf_rwlock, RW_WRITER))
134 return (0);
135

--- 203 unchanged lines hidden (view full) ---

339 return (fetchsz);
340}
341
342/*
343 * given a zfetch and a zstream structure, see if there is an associated zstream
344 * for this block read. If so, it starts a prefetch for the stream it
345 * located and returns true, otherwise it returns false
346 */
128dmu_zfetch_colinear(zfetch_t *zf, zstream_t *zh)
129{
130 zstream_t *z_walk;
131 zstream_t *z_comp;
132
133 if (! rw_tryenter(&zf->zf_rwlock, RW_WRITER))
134 return (0);
135

--- 203 unchanged lines hidden (view full) ---

339 return (fetchsz);
340}
341
342/*
343 * given a zfetch and a zstream structure, see if there is an associated zstream
344 * for this block read. If so, it starts a prefetch for the stream it
345 * located and returns true, otherwise it returns false
346 */
347static int
347static boolean_t
348dmu_zfetch_find(zfetch_t *zf, zstream_t *zh, int prefetched)
349{
350 zstream_t *zs;
351 int64_t diff;
352 int reset = !prefetched;
353 int rc = 0;
354
355 if (zh == NULL)

--- 308 unchanged lines hidden (view full) ---

664 * This is the prefetch entry point. It calls all of the other dmu_zfetch
665 * routines to create, delete, find, or operate upon prefetch streams.
666 */
667void
668dmu_zfetch(zfetch_t *zf, uint64_t offset, uint64_t size, int prefetched)
669{
670 zstream_t zst;
671 zstream_t *newstream;
348dmu_zfetch_find(zfetch_t *zf, zstream_t *zh, int prefetched)
349{
350 zstream_t *zs;
351 int64_t diff;
352 int reset = !prefetched;
353 int rc = 0;
354
355 if (zh == NULL)

--- 308 unchanged lines hidden (view full) ---

664 * This is the prefetch entry point. It calls all of the other dmu_zfetch
665 * routines to create, delete, find, or operate upon prefetch streams.
666 */
667void
668dmu_zfetch(zfetch_t *zf, uint64_t offset, uint64_t size, int prefetched)
669{
670 zstream_t zst;
671 zstream_t *newstream;
672 int fetched;
672 boolean_t fetched;
673 int inserted;
674 unsigned int blkshft;
675 uint64_t blksz;
676
677 if (zfs_prefetch_disable)
678 return;
679
680 /* files that aren't ln2 blocksz are only one block -- nothing to do */

--- 9 unchanged lines hidden (view full) ---

690 zst.zst_len = (P2ROUNDUP(offset + size, blksz) -
691 P2ALIGN(offset, blksz)) >> blkshft;
692
693 fetched = dmu_zfetch_find(zf, &zst, prefetched);
694 if (fetched) {
695 ZFETCHSTAT_BUMP(zfetchstat_hits);
696 } else {
697 ZFETCHSTAT_BUMP(zfetchstat_misses);
673 int inserted;
674 unsigned int blkshft;
675 uint64_t blksz;
676
677 if (zfs_prefetch_disable)
678 return;
679
680 /* files that aren't ln2 blocksz are only one block -- nothing to do */

--- 9 unchanged lines hidden (view full) ---

690 zst.zst_len = (P2ROUNDUP(offset + size, blksz) -
691 P2ALIGN(offset, blksz)) >> blkshft;
692
693 fetched = dmu_zfetch_find(zf, &zst, prefetched);
694 if (fetched) {
695 ZFETCHSTAT_BUMP(zfetchstat_hits);
696 } else {
697 ZFETCHSTAT_BUMP(zfetchstat_misses);
698 if (fetched = dmu_zfetch_colinear(zf, &zst)) {
698 fetched = dmu_zfetch_colinear(zf, &zst);
699 if (fetched) {
699 ZFETCHSTAT_BUMP(zfetchstat_colinear_hits);
700 } else {
701 ZFETCHSTAT_BUMP(zfetchstat_colinear_misses);
702 }
703 }
704
705 if (!fetched) {
706 newstream = dmu_zfetch_stream_reclaim(zf);

--- 48 unchanged lines hidden ---
700 ZFETCHSTAT_BUMP(zfetchstat_colinear_hits);
701 } else {
702 ZFETCHSTAT_BUMP(zfetchstat_colinear_misses);
703 }
704 }
705
706 if (!fetched) {
707 newstream = dmu_zfetch_stream_reclaim(zf);

--- 48 unchanged lines hidden ---