FreeBSD ZFS
The Zettabyte File System
|
00001 /* 00002 * CDDL HEADER START 00003 * 00004 * The contents of this file are subject to the terms of the 00005 * Common Development and Distribution License (the "License"). 00006 * You may not use this file except in compliance with the License. 00007 * 00008 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 00009 * or http://www.opensolaris.org/os/licensing. 00010 * See the License for the specific language governing permissions 00011 * and limitations under the License. 00012 * 00013 * When distributing Covered Code, include this CDDL HEADER in each 00014 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 00015 * If applicable, add the following below this CDDL HEADER, with the 00016 * fields enclosed by brackets "[]" replaced with your own identifying 00017 * information: Portions Copyright [yyyy] [name of copyright owner] 00018 * 00019 * CDDL HEADER END 00020 */ 00021 /* 00022 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 00023 * Copyright (c) 2012 by Delphix. All rights reserved. 00024 */ 00025 00026 #ifndef _SYS_ARC_H 00027 #define _SYS_ARC_H 00028 00029 #include <sys/zfs_context.h> 00030 00031 #ifdef __cplusplus 00032 extern "C" { 00033 #endif 00034 00035 #include <sys/zio.h> 00036 #include <sys/dmu.h> 00037 #include <sys/spa.h> 00038 00039 typedef struct arc_buf_hdr arc_buf_hdr_t; 00040 typedef struct arc_buf arc_buf_t; 00041 typedef void arc_done_func_t(zio_t *zio, arc_buf_t *buf, void *priv); 00042 typedef int arc_evict_func_t(void *priv); 00043 00044 /* generic arc_done_func_t's which you can use */ 00045 arc_done_func_t arc_bcopy_func; 00046 arc_done_func_t arc_getbuf_func; 00047 00048 struct arc_buf { 00049 arc_buf_hdr_t *b_hdr; 00050 arc_buf_t *b_next; 00051 kmutex_t b_evict_lock; 00052 krwlock_t b_data_lock; 00053 void *b_data; 00054 arc_evict_func_t *b_efunc; 00055 void *b_private; 00056 }; 00057 00058 typedef enum arc_buf_contents { 00059 ARC_BUFC_DATA, 00060 ARC_BUFC_METADATA, 00061 ARC_BUFC_NUMTYPES 00062 } arc_buf_contents_t; 00063 /* 00064 * These are the flags we pass into calls to the arc 00065 */ 00066 #define ARC_WAIT (1 << 1) 00067 #define ARC_NOWAIT (1 << 2) 00068 #define ARC_PREFETCH (1 << 3) 00069 #define ARC_CACHED (1 << 4) 00070 #define ARC_L2CACHE (1 << 5) 00075 typedef enum arc_space_type { 00076 ARC_SPACE_DATA, 00077 ARC_SPACE_HDRS, 00078 ARC_SPACE_L2HDRS, 00079 ARC_SPACE_OTHER, 00080 ARC_SPACE_NUMTYPES 00081 } arc_space_type_t; 00082 00083 void arc_space_consume(uint64_t space, arc_space_type_t type); 00084 void arc_space_return(uint64_t space, arc_space_type_t type); 00085 void *arc_data_buf_alloc(uint64_t space); 00086 void arc_data_buf_free(void *buf, uint64_t space); 00087 arc_buf_t *arc_buf_alloc(spa_t *spa, int size, void *tag, 00088 arc_buf_contents_t type); 00089 arc_buf_t *arc_loan_buf(spa_t *spa, int size); 00090 void arc_return_buf(arc_buf_t *buf, void *tag); 00091 void arc_loan_inuse_buf(arc_buf_t *buf, void *tag); 00092 void arc_buf_add_ref(arc_buf_t *buf, void *tag); 00093 int arc_buf_remove_ref(arc_buf_t *buf, void *tag); 00094 int arc_buf_size(arc_buf_t *buf); 00095 void arc_release(arc_buf_t *buf, void *tag); 00096 int arc_release_bp(arc_buf_t *buf, void *tag, blkptr_t *bp, spa_t *spa, 00097 zbookmark_t *zb); 00098 int arc_released(arc_buf_t *buf); 00099 int arc_has_callback(arc_buf_t *buf); 00100 void arc_buf_freeze(arc_buf_t *buf); 00101 void arc_buf_thaw(arc_buf_t *buf); 00102 boolean_t arc_buf_eviction_needed(arc_buf_t *buf); 00103 #ifdef ZFS_DEBUG 00104 int arc_referenced(arc_buf_t *buf); 00105 #endif 00106 00107 int arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, arc_buf_t *pbuf, 00108 arc_done_func_t *done, void *priv, int priority, int zio_flags, 00109 uint32_t *arc_flags, const zbookmark_t *zb); 00110 int arc_read_nolock(zio_t *pio, spa_t *spa, const blkptr_t *bp, 00111 arc_done_func_t *done, void *priv, int priority, int flags, 00112 uint32_t *arc_flags, const zbookmark_t *zb); 00113 zio_t *arc_write(zio_t *pio, spa_t *spa, uint64_t txg, 00114 blkptr_t *bp, arc_buf_t *buf, boolean_t l2arc, const zio_prop_t *zp, 00115 arc_done_func_t *ready, arc_done_func_t *done, void *priv, 00116 int priority, int zio_flags, const zbookmark_t *zb); 00117 00118 void arc_set_callback(arc_buf_t *buf, arc_evict_func_t *func, void *priv); 00119 int arc_buf_evict(arc_buf_t *buf); 00120 00121 void arc_flush(spa_t *spa); 00122 void arc_tempreserve_clear(uint64_t reserve); 00123 int arc_tempreserve_space(uint64_t reserve, uint64_t txg); 00124 00125 void arc_init(void); 00126 void arc_fini(void); 00127 00128 /* 00129 * Level 2 ARC 00130 */ 00131 00132 void l2arc_add_vdev(spa_t *spa, vdev_t *vd); 00133 void l2arc_remove_vdev(vdev_t *vd); 00134 boolean_t l2arc_vdev_present(vdev_t *vd); 00135 void l2arc_init(void); 00136 void l2arc_fini(void); 00137 void l2arc_start(void); 00138 void l2arc_stop(void); 00139 00140 #ifdef illumos 00141 #ifndef _KERNEL 00142 extern boolean_t arc_watch; 00143 extern int arc_procfd; 00144 #endif 00145 #endif /* illumos */ 00146 00147 #ifdef __cplusplus 00148 } 00149 #endif 00150 00151 #endif /* _SYS_ARC_H */