xref: /titanic_44/usr/src/uts/common/fs/zfs/sys/arc.h (revision 28167c24ba5be8b7c1d05e02d053f4a55cd21cc9)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_ARC_H
28 #define	_SYS_ARC_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/zfs_context.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #include <sys/zio.h>
39 
40 typedef struct arc_buf_hdr arc_buf_hdr_t;
41 typedef struct arc_buf arc_buf_t;
42 typedef void arc_done_func_t(zio_t *zio, arc_buf_t *buf, void *private);
43 typedef void arc_byteswap_func_t(void *buf, size_t size);
44 
45 /* generic arc_done_func_t's which you can use */
46 arc_done_func_t arc_bcopy_func;
47 arc_done_func_t arc_getbuf_func;
48 
49 struct arc_buf {
50 	arc_buf_hdr_t		*b_hdr;
51 	arc_buf_t		*b_next;
52 	void			*b_data;
53 };
54 
55 /*
56  * These are the flags we pass into calls to the arc
57  */
58 #define	ARC_WAIT	(1 << 1)	/* perform I/O synchronously */
59 #define	ARC_NOWAIT	(1 << 2)	/* perform I/O asynchronously */
60 #define	ARC_PREFETCH	(1 << 3)	/* I/O is a prefetch */
61 
62 arc_buf_t *arc_buf_alloc(spa_t *spa, int size, void *tag);
63 void arc_buf_free(arc_buf_t *buf, void *tag);
64 int arc_buf_size(arc_buf_t *buf);
65 void arc_release(arc_buf_t *buf, void *tag);
66 int arc_released(arc_buf_t *buf);
67 
68 int arc_read(zio_t *pio, spa_t *spa, blkptr_t *bp, arc_byteswap_func_t *swap,
69     arc_done_func_t *done, void *private, int priority, int flags,
70     uint32_t arc_flags);
71 int arc_write(zio_t *pio, spa_t *spa, int checksum, int compress,
72     uint64_t txg, blkptr_t *bp, arc_buf_t *buf,
73     arc_done_func_t *done, void *private, int priority, int flags,
74     uint32_t arc_flags);
75 int arc_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
76     zio_done_func_t *done, void *private, uint32_t arc_flags);
77 int arc_tryread(spa_t *spa, blkptr_t *bp, void *data);
78 
79 void arc_flush(void);
80 void arc_tempreserve_clear(uint64_t tempreserve);
81 int arc_tempreserve_space(uint64_t tempreserve);
82 
83 void arc_init(void);
84 void arc_fini(void);
85 
86 #ifdef	__cplusplus
87 }
88 #endif
89 
90 #endif /* _SYS_ARC_H */
91