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.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/zfs_context.h>
37 extern uint64_t zfetch_array_rd_sz;
39 struct dnode; /* so we can reference dnode */
41 typedef enum zfetch_dirn {
42 ZFETCH_FORWARD = 1, /* prefetch increasing block numbers */
43 ZFETCH_BACKWARD = -1 /* prefetch decreasing block numbers */
46 typedef struct zstream {
47 uint64_t zst_offset; /* offset of starting block in range */
48 uint64_t zst_len; /* length of range, in blocks */
49 zfetch_dirn_t zst_direction; /* direction of prefetch */
50 uint64_t zst_stride; /* length of stride, in blocks */
51 uint64_t zst_ph_offset; /* prefetch offset, in blocks */
52 uint64_t zst_cap; /* prefetch limit (cap), in blocks */
53 kmutex_t zst_lock; /* protects stream */
54 clock_t zst_last; /* lbolt of last prefetch */
55 avl_node_t zst_node; /* embed avl node here */
58 typedef struct zfetch {
59 krwlock_t zf_rwlock; /* protects zfetch structure */
60 list_t zf_stream; /* AVL tree of zstream_t's */
61 struct dnode *zf_dnode; /* dnode that owns this zfetch */
62 uint32_t zf_stream_cnt; /* # of active streams */
63 uint64_t zf_alloc_fail; /* # of failed attempts to alloc strm */
66 void dmu_zfetch_init(zfetch_t *, struct dnode *);
67 void dmu_zfetch_rele(zfetch_t *);
68 void dmu_zfetch(zfetch_t *, uint64_t, uint64_t, int);
75 #endif /* _DFETCH_H */