]> git.proxmox.com Git - mirror_zfs-debian.git/blobdiff - include/sys/arc.h
Imported Upstream version 0.6.5.3
[mirror_zfs-debian.git] / include / sys / arc.h
index 215c75b6dfa31519066802eae796ea75d0517784..db7a64aa2e22e43d7adccd3900e7e53abe51a6a3 100644 (file)
@@ -38,6 +38,12 @@ extern "C" {
 #include <sys/spa.h>
 #include <sys/refcount.h>
 
+/*
+ * Used by arc_flush() to inform arc_evict_state() that it should evict
+ * all available buffers from the arc state being passed in.
+ */
+#define        ARC_EVICT_ALL   -1ULL
+
 typedef struct arc_buf_hdr arc_buf_hdr_t;
 typedef struct arc_buf arc_buf_t;
 typedef struct arc_prune arc_prune_t;
@@ -45,6 +51,9 @@ typedef void arc_done_func_t(zio_t *zio, arc_buf_t *buf, void *private);
 typedef void arc_prune_func_t(int64_t bytes, void *private);
 typedef int arc_evict_func_t(void *private);
 
+/* Shared module parameters */
+extern int zfs_arc_average_blocksize;
+
 /* generic arc_done_func_t's which you can use */
 arc_done_func_t arc_bcopy_func;
 arc_done_func_t arc_getbuf_func;
@@ -53,10 +62,51 @@ arc_done_func_t arc_getbuf_func;
 struct arc_prune {
        arc_prune_func_t        *p_pfunc;
        void                    *p_private;
+       uint64_t                p_adjust;
        list_node_t             p_node;
        refcount_t              p_refcnt;
 };
 
+typedef enum arc_strategy {
+       ARC_STRATEGY_META_ONLY          = 0, /* Evict only meta data buffers */
+       ARC_STRATEGY_META_BALANCED      = 1, /* Evict data buffers if needed */
+} arc_strategy_t;
+
+typedef enum arc_flags
+{
+       /*
+        * Public flags that can be passed into the ARC by external consumers.
+        */
+       ARC_FLAG_NONE                   = 1 << 0,       /* No flags set */
+       ARC_FLAG_WAIT                   = 1 << 1,       /* perform sync I/O */
+       ARC_FLAG_NOWAIT                 = 1 << 2,       /* perform async I/O */
+       ARC_FLAG_PREFETCH               = 1 << 3,       /* I/O is a prefetch */
+       ARC_FLAG_CACHED                 = 1 << 4,       /* I/O was in cache */
+       ARC_FLAG_L2CACHE                = 1 << 5,       /* cache in L2ARC */
+       ARC_FLAG_L2COMPRESS             = 1 << 6,       /* compress in L2ARC */
+
+       /*
+        * Private ARC flags.  These flags are private ARC only flags that
+        * will show up in b_flags in the arc_hdr_buf_t. These flags should
+        * only be set by ARC code.
+        */
+       ARC_FLAG_IN_HASH_TABLE          = 1 << 7,       /* buffer is hashed */
+       ARC_FLAG_IO_IN_PROGRESS         = 1 << 8,       /* I/O in progress */
+       ARC_FLAG_IO_ERROR               = 1 << 9,       /* I/O failed for buf */
+       ARC_FLAG_FREED_IN_READ          = 1 << 10,      /* freed during read */
+       ARC_FLAG_BUF_AVAILABLE          = 1 << 11,      /* block not in use */
+       ARC_FLAG_INDIRECT               = 1 << 12,      /* indirect block */
+       ARC_FLAG_L2_WRITING             = 1 << 13,      /* write in progress */
+       ARC_FLAG_L2_EVICTED             = 1 << 14,      /* evicted during I/O */
+       ARC_FLAG_L2_WRITE_HEAD          = 1 << 15,      /* head of write list */
+       /* indicates that the buffer contains metadata (otherwise, data) */
+       ARC_FLAG_BUFC_METADATA          = 1 << 16,
+
+       /* Flags specifying whether optional hdr struct fields are defined */
+       ARC_FLAG_HAS_L1HDR              = 1 << 17,
+       ARC_FLAG_HAS_L2HDR              = 1 << 18,
+} arc_flags_t;
+
 struct arc_buf {
        arc_buf_hdr_t           *b_hdr;
        arc_buf_t               *b_next;
@@ -71,15 +121,6 @@ typedef enum arc_buf_contents {
        ARC_BUFC_METADATA,                      /* buffer contains metadata */
        ARC_BUFC_NUMTYPES
 } arc_buf_contents_t;
-/*
- * These are the flags we pass into calls to the arc
- */
-#define        ARC_WAIT        (1 << 1)        /* perform I/O synchronously */
-#define        ARC_NOWAIT      (1 << 2)        /* perform I/O asynchronously */
-#define        ARC_PREFETCH    (1 << 3)        /* I/O is a prefetch */
-#define        ARC_CACHED      (1 << 4)        /* I/O was already in cache */
-#define        ARC_L2CACHE     (1 << 5)        /* cache in L2ARC */
-#define        ARC_L2COMPRESS  (1 << 6)        /* compress in L2ARC */
 
 /*
  * The following breakdows of arc_size exist for kstat only.
@@ -106,7 +147,6 @@ typedef enum arc_state_type {
 typedef struct arc_buf_info {
        arc_state_type_t        abi_state_type;
        arc_buf_contents_t      abi_state_contents;
-       uint64_t                abi_state_index;
        uint32_t                abi_flags;
        uint32_t                abi_datacnt;
        uint64_t                abi_size;
@@ -146,7 +186,7 @@ int arc_referenced(arc_buf_t *buf);
 
 int arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
     arc_done_func_t *done, void *private, zio_priority_t priority, int flags,
-    uint32_t *arc_flags, const zbookmark_phys_t *zb);
+    arc_flags_t *arc_flags, const zbookmark_phys_t *zb);
 zio_t *arc_write(zio_t *pio, spa_t *spa, uint64_t txg,
     blkptr_t *bp, arc_buf_t *buf, boolean_t l2arc, boolean_t l2arc_compress,
     const zio_prop_t *zp, arc_done_func_t *ready, arc_done_func_t *physdone,
@@ -160,7 +200,7 @@ void arc_freed(spa_t *spa, const blkptr_t *bp);
 void arc_set_callback(arc_buf_t *buf, arc_evict_func_t *func, void *private);
 boolean_t arc_clear_callback(arc_buf_t *buf);
 
-void arc_flush(spa_t *spa);
+void arc_flush(spa_t *spa, boolean_t retry);
 void arc_tempreserve_clear(uint64_t reserve);
 int arc_tempreserve_space(uint64_t reserve, uint64_t txg);