2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* CDDL HEADER START
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the terms of the
|
|
|
|
* Common Development and Distribution License (the "License").
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
*
|
|
|
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
|
|
* or http://www.opensolaris.org/os/licensing.
|
|
|
|
* See the License for the specific language governing permissions
|
|
|
|
* and limitations under the License.
|
|
|
|
*
|
|
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
|
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
|
|
* If applicable, add the following below this CDDL HEADER, with the
|
|
|
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
|
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
|
|
*
|
|
|
|
* CDDL HEADER END
|
|
|
|
*/
|
|
|
|
/*
|
2010-05-28 20:45:14 +00:00
|
|
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
2014-06-25 18:37:59 +00:00
|
|
|
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
|
2013-08-01 20:02:10 +00:00
|
|
|
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
|
2008-11-20 20:01:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SYS_ARC_H
|
|
|
|
#define _SYS_ARC_H
|
|
|
|
|
|
|
|
#include <sys/zfs_context.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/zio.h>
|
|
|
|
#include <sys/dmu.h>
|
|
|
|
#include <sys/spa.h>
|
2011-12-22 20:20:43 +00:00
|
|
|
#include <sys/refcount.h>
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
typedef struct arc_buf_hdr arc_buf_hdr_t;
|
|
|
|
typedef struct arc_buf arc_buf_t;
|
2011-12-22 20:20:43 +00:00
|
|
|
typedef struct arc_prune arc_prune_t;
|
2008-11-20 20:01:55 +00:00
|
|
|
typedef void arc_done_func_t(zio_t *zio, arc_buf_t *buf, void *private);
|
2011-12-22 20:20:43 +00:00
|
|
|
typedef void arc_prune_func_t(int64_t bytes, void *private);
|
2008-11-20 20:01:55 +00:00
|
|
|
typedef int arc_evict_func_t(void *private);
|
|
|
|
|
|
|
|
/* generic arc_done_func_t's which you can use */
|
|
|
|
arc_done_func_t arc_bcopy_func;
|
|
|
|
arc_done_func_t arc_getbuf_func;
|
|
|
|
|
2011-12-22 20:20:43 +00:00
|
|
|
/* generic arc_prune_func_t wrapper for callbacks */
|
|
|
|
struct arc_prune {
|
|
|
|
arc_prune_func_t *p_pfunc;
|
|
|
|
void *p_private;
|
|
|
|
list_node_t p_node;
|
|
|
|
refcount_t p_refcnt;
|
|
|
|
};
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
struct arc_buf {
|
|
|
|
arc_buf_hdr_t *b_hdr;
|
|
|
|
arc_buf_t *b_next;
|
2010-05-28 20:45:14 +00:00
|
|
|
kmutex_t b_evict_lock;
|
2008-11-20 20:01:55 +00:00
|
|
|
void *b_data;
|
|
|
|
arc_evict_func_t *b_efunc;
|
|
|
|
void *b_private;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum arc_buf_contents {
|
|
|
|
ARC_BUFC_DATA, /* buffer contains data */
|
|
|
|
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 */
|
2008-12-03 20:09:06 +00:00
|
|
|
#define ARC_L2CACHE (1 << 5) /* cache in L2ARC */
|
2013-08-01 20:02:10 +00:00
|
|
|
#define ARC_L2COMPRESS (1 << 6) /* compress in L2ARC */
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2009-02-18 20:51:31 +00:00
|
|
|
/*
|
|
|
|
* The following breakdows of arc_size exist for kstat only.
|
|
|
|
*/
|
|
|
|
typedef enum arc_space_type {
|
|
|
|
ARC_SPACE_DATA,
|
2014-02-03 20:41:47 +00:00
|
|
|
ARC_SPACE_META,
|
2009-02-18 20:51:31 +00:00
|
|
|
ARC_SPACE_HDRS,
|
|
|
|
ARC_SPACE_L2HDRS,
|
|
|
|
ARC_SPACE_OTHER,
|
|
|
|
ARC_SPACE_NUMTYPES
|
|
|
|
} arc_space_type_t;
|
|
|
|
|
2013-10-03 00:11:19 +00:00
|
|
|
typedef enum arc_state_type {
|
|
|
|
ARC_STATE_ANON,
|
|
|
|
ARC_STATE_MRU,
|
|
|
|
ARC_STATE_MRU_GHOST,
|
|
|
|
ARC_STATE_MFU,
|
|
|
|
ARC_STATE_MFU_GHOST,
|
|
|
|
ARC_STATE_L2C_ONLY,
|
|
|
|
ARC_STATE_NUMTYPES
|
|
|
|
} arc_state_type_t;
|
|
|
|
|
|
|
|
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;
|
|
|
|
uint64_t abi_spa;
|
|
|
|
uint64_t abi_access;
|
|
|
|
uint32_t abi_mru_hits;
|
|
|
|
uint32_t abi_mru_ghost_hits;
|
|
|
|
uint32_t abi_mfu_hits;
|
|
|
|
uint32_t abi_mfu_ghost_hits;
|
|
|
|
uint32_t abi_l2arc_hits;
|
|
|
|
uint32_t abi_holds;
|
|
|
|
uint64_t abi_l2arc_dattr;
|
|
|
|
uint64_t abi_l2arc_asize;
|
|
|
|
enum zio_compress abi_l2arc_compress;
|
|
|
|
} arc_buf_info_t;
|
|
|
|
|
2009-02-18 20:51:31 +00:00
|
|
|
void arc_space_consume(uint64_t space, arc_space_type_t type);
|
|
|
|
void arc_space_return(uint64_t space, arc_space_type_t type);
|
2014-09-10 18:59:03 +00:00
|
|
|
arc_buf_t *arc_buf_alloc(spa_t *spa, uint64_t size, void *tag,
|
2008-11-20 20:01:55 +00:00
|
|
|
arc_buf_contents_t type);
|
2014-09-10 18:59:03 +00:00
|
|
|
arc_buf_t *arc_loan_buf(spa_t *spa, uint64_t size);
|
2009-07-02 22:44:48 +00:00
|
|
|
void arc_return_buf(arc_buf_t *buf, void *tag);
|
2010-05-28 20:45:14 +00:00
|
|
|
void arc_loan_inuse_buf(arc_buf_t *buf, void *tag);
|
2008-11-20 20:01:55 +00:00
|
|
|
void arc_buf_add_ref(arc_buf_t *buf, void *tag);
|
2013-09-04 12:00:57 +00:00
|
|
|
boolean_t arc_buf_remove_ref(arc_buf_t *buf, void *tag);
|
2013-10-03 00:11:19 +00:00
|
|
|
void arc_buf_info(arc_buf_t *buf, arc_buf_info_t *abi, int state_index);
|
2014-09-10 18:59:03 +00:00
|
|
|
uint64_t arc_buf_size(arc_buf_t *buf);
|
2008-11-20 20:01:55 +00:00
|
|
|
void arc_release(arc_buf_t *buf, void *tag);
|
|
|
|
int arc_released(arc_buf_t *buf);
|
2013-05-16 21:18:06 +00:00
|
|
|
void arc_buf_sigsegv(int sig, siginfo_t *si, void *unused);
|
2008-11-20 20:01:55 +00:00
|
|
|
void arc_buf_freeze(arc_buf_t *buf);
|
|
|
|
void arc_buf_thaw(arc_buf_t *buf);
|
2012-12-21 22:57:09 +00:00
|
|
|
boolean_t arc_buf_eviction_needed(arc_buf_t *buf);
|
2008-11-20 20:01:55 +00:00
|
|
|
#ifdef ZFS_DEBUG
|
|
|
|
int arc_referenced(arc_buf_t *buf);
|
|
|
|
#endif
|
|
|
|
|
2013-07-02 20:26:24 +00:00
|
|
|
int arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
arc_done_func_t *done, void *private, zio_priority_t priority, int flags,
|
2014-06-25 18:37:59 +00:00
|
|
|
uint32_t *arc_flags, const zbookmark_phys_t *zb);
|
2010-05-28 20:45:14 +00:00
|
|
|
zio_t *arc_write(zio_t *pio, spa_t *spa, uint64_t txg,
|
2013-08-01 20:02:10 +00:00
|
|
|
blkptr_t *bp, arc_buf_t *buf, boolean_t l2arc, boolean_t l2arc_compress,
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
const zio_prop_t *zp, arc_done_func_t *ready, arc_done_func_t *physdone,
|
|
|
|
arc_done_func_t *done, void *private, zio_priority_t priority,
|
2014-06-25 18:37:59 +00:00
|
|
|
int zio_flags, const zbookmark_phys_t *zb);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2011-12-22 20:20:43 +00:00
|
|
|
arc_prune_t *arc_add_prune_callback(arc_prune_func_t *func, void *private);
|
|
|
|
void arc_remove_prune_callback(arc_prune_t *p);
|
Illumos #3805 arc shouldn't cache freed blocks
3805 arc shouldn't cache freed blocks
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Richard Elling <richard.elling@dey-sys.com>
Reviewed by: Will Andrews <will@firepipe.net>
Approved by: Dan McDonald <danmcd@nexenta.com>
References:
illumos/illumos-gate@6e6d5868f52089b9026785bd90257a3d3f6e5ee2
https://www.illumos.org/issues/3805
ZFS should proactively evict freed blocks from the cache.
On dcenter, we saw that we were caching ~256GB of metadata, while the
pool only had <4GB of metadata on disk. We were wasting about half the
system's RAM (252GB) on blocks that have been freed.
Even though these freed blocks will never be used again, and thus will
eventually be evicted, this causes us to use memory inefficiently for 2
reasons:
1. A block that is freed has no chance of being accessed again, but will
be kept in memory preferentially to a block that was accessed before it
(and is thus older) but has not been freed and thus has at least some
chance of being accessed again.
2. We partition the ARC into several buckets:
user data that has been accessed only once (MRU)
metadata that has been accessed only once (MRU)
user data that has been accessed more than once (MFU)
metadata that has been accessed more than once (MFU)
The user data vs metadata split is somewhat arbitrary, and the primary
control on how much memory is used to cache data vs metadata is to
simply try to keep the proportion the same as it has been in the past
(each bucket "evicts against" itself). The secondary control is to
evict data before evicting metadata.
Because of this bucketing, we may end up with one bucket mostly
containing freed blocks that are very old, while another bucket has more
recently accessed, still-allocated blocks. Data in the useful bucket
(with still-allocated blocks) may be evicted in preference to data in
the useless bucket (with old, freed blocks).
On dcenter, we saw that the MFU metadata bucket was 230MB, while the MFU
data bucket was 27GB and the MRU metadata bucket was 256GB. However,
the vast majority of data in the MRU metadata bucket (256GB) was freed
blocks, and thus useless. Meanwhile, the MFU metadata bucket (230MB)
was constantly evicting useful blocks that will be soon needed.
The problem of cache segmentation is a larger problem that needs more
investigation. However, if we stop caching freed blocks, it should
reduce the impact of this more fundamental issue.
Ported-by: Richard Yao <ryao@cs.stonybrook.edu>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1503
2013-06-06 22:46:55 +00:00
|
|
|
void arc_freed(spa_t *spa, const blkptr_t *bp);
|
2011-12-22 20:20:43 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
void arc_set_callback(arc_buf_t *buf, arc_evict_func_t *func, void *private);
|
2014-07-15 07:43:18 +00:00
|
|
|
boolean_t arc_clear_callback(arc_buf_t *buf);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
void arc_flush(spa_t *spa);
|
|
|
|
void arc_tempreserve_clear(uint64_t reserve);
|
|
|
|
int arc_tempreserve_space(uint64_t reserve, uint64_t txg);
|
|
|
|
|
|
|
|
void arc_init(void);
|
|
|
|
void arc_fini(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Level 2 ARC
|
|
|
|
*/
|
|
|
|
|
2009-07-02 22:44:48 +00:00
|
|
|
void l2arc_add_vdev(spa_t *spa, vdev_t *vd);
|
2008-11-20 20:01:55 +00:00
|
|
|
void l2arc_remove_vdev(vdev_t *vd);
|
2008-12-03 20:09:06 +00:00
|
|
|
boolean_t l2arc_vdev_present(vdev_t *vd);
|
2008-11-20 20:01:55 +00:00
|
|
|
void l2arc_init(void);
|
|
|
|
void l2arc_fini(void);
|
2008-12-03 20:09:06 +00:00
|
|
|
void l2arc_start(void);
|
|
|
|
void l2arc_stop(void);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2013-05-16 21:18:06 +00:00
|
|
|
#ifndef _KERNEL
|
|
|
|
extern boolean_t arc_watch;
|
|
|
|
#endif
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _SYS_ARC_H */
|