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 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #include <sys/zfs_context.h>
35 extern unsigned long zfetch_array_rd_sz
;
37 struct dnode
; /* so we can reference dnode */
39 typedef enum zfetch_dirn
{
40 ZFETCH_FORWARD
= 1, /* prefetch increasing block numbers */
41 ZFETCH_BACKWARD
= -1 /* prefetch decreasing block numbers */
44 typedef struct zstream
{
45 uint64_t zst_offset
; /* offset of starting block in range */
46 uint64_t zst_len
; /* length of range, in blocks */
47 zfetch_dirn_t zst_direction
; /* direction of prefetch */
48 uint64_t zst_stride
; /* length of stride, in blocks */
49 uint64_t zst_ph_offset
; /* prefetch offset, in blocks */
50 uint64_t zst_cap
; /* prefetch limit (cap), in blocks */
51 kmutex_t zst_lock
; /* protects stream */
52 clock_t zst_last
; /* lbolt of last prefetch */
53 list_node_t zst_node
; /* next zstream here */
56 typedef struct zfetch
{
57 krwlock_t zf_rwlock
; /* protects zfetch structure */
58 list_t zf_stream
; /* AVL tree of zstream_t's */
59 struct dnode
*zf_dnode
; /* dnode that owns this zfetch */
60 uint32_t zf_stream_cnt
; /* # of active streams */
61 uint64_t zf_alloc_fail
; /* # of failed attempts to alloc strm */
64 void zfetch_init(void);
65 void zfetch_fini(void);
67 void dmu_zfetch_init(zfetch_t
*, struct dnode
*);
68 void dmu_zfetch_rele(zfetch_t
*);
69 void dmu_zfetch(zfetch_t
*, uint64_t, uint64_t, int);
76 #endif /* _DFETCH_H */