diff options
author | Brian Behlendorf <[email protected]> | 2013-07-25 10:28:45 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-08-09 10:06:08 -0700 |
commit | 68121a03daf58a7d5b9351f110196b8ce806e1fa (patch) | |
tree | c8c6a3e402c2e2f76881df9a004f8297815bb418 /module/zfs | |
parent | 4e59f475118b7081a3f950ebf7c70b5bfc7c9778 (diff) |
Allow arc_evict_ghost() to only evict meta data
The default behavior of arc_evict_ghost() is to start by evicting
data buffers. Then only if the requested number of bytes to evict
cannot be satisfied by data buffers move on to meta data buffers.
This is ideal for honoring arc_c since it's preferable to keep the
meta data cached. However, if we're trying to free memory from the
arc to honor the meta limit it's a problem because we will need to
discard all the data to get to the meta data.
To avoid this issue the arc_evict_ghost() is now passed a fourth
argumented describing which buffer type to start with. The
arc_evict() function already behaves exactly like this for a
same reason so this is consistent with the existing code.
All existing callers have been updated to pass ARC_BUFC_DATA so
this patch introduces no functional change. New callers may
pass ARC_BUFC_METADATA to skip immediately to evicting meta
data leaving the normal data untouched.
Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'module/zfs')
-rw-r--r-- | module/zfs/arc.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/module/zfs/arc.c b/module/zfs/arc.c index e6e31eccb..ce4a0239c 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -550,7 +550,8 @@ static arc_buf_hdr_t arc_eviction_hdr; static void arc_get_data_buf(arc_buf_t *buf); static void arc_access(arc_buf_hdr_t *buf, kmutex_t *hash_lock); static int arc_evict_needed(arc_buf_contents_t type); -static void arc_evict_ghost(arc_state_t *state, uint64_t spa, int64_t bytes); +static void arc_evict_ghost(arc_state_t *state, uint64_t spa, int64_t bytes, + arc_buf_contents_t type); static boolean_t l2arc_write_eligible(uint64_t spa_guid, arc_buf_hdr_t *ab); @@ -1864,12 +1865,14 @@ arc_evict(arc_state_t *state, uint64_t spa, int64_t bytes, boolean_t recycle, if (mru_over > 0 && arc_mru_ghost->arcs_lsize[type] > 0) { int64_t todelete = MIN(arc_mru_ghost->arcs_lsize[type], mru_over); - arc_evict_ghost(arc_mru_ghost, 0, todelete); + arc_evict_ghost(arc_mru_ghost, 0, todelete, + ARC_BUFC_DATA); } else if (arc_mfu_ghost->arcs_lsize[type] > 0) { int64_t todelete = MIN(arc_mfu_ghost->arcs_lsize[type], arc_mru_ghost->arcs_size + arc_mfu_ghost->arcs_size - arc_c); - arc_evict_ghost(arc_mfu_ghost, 0, todelete); + arc_evict_ghost(arc_mfu_ghost, 0, todelete, + ARC_BUFC_DATA); } } @@ -1881,11 +1884,12 @@ arc_evict(arc_state_t *state, uint64_t spa, int64_t bytes, boolean_t recycle, * bytes. Destroy the buffers that are removed. */ static void -arc_evict_ghost(arc_state_t *state, uint64_t spa, int64_t bytes) +arc_evict_ghost(arc_state_t *state, uint64_t spa, int64_t bytes, + arc_buf_contents_t type) { arc_buf_hdr_t *ab, *ab_prev; arc_buf_hdr_t marker; - list_t *list = &state->arcs_list[ARC_BUFC_DATA]; + list_t *list = &state->arcs_list[type]; kmutex_t *hash_lock; uint64_t bytes_deleted = 0; uint64_t bufs_skipped = 0; @@ -2015,7 +2019,7 @@ arc_adjust(void) if (adjustment > 0 && arc_mru_ghost->arcs_size > 0) { delta = MIN(arc_mru_ghost->arcs_size, adjustment); - arc_evict_ghost(arc_mru_ghost, 0, delta); + arc_evict_ghost(arc_mru_ghost, 0, delta, ARC_BUFC_DATA); } adjustment = @@ -2023,7 +2027,7 @@ arc_adjust(void) if (adjustment > 0 && arc_mfu_ghost->arcs_size > 0) { delta = MIN(arc_mfu_ghost->arcs_size, adjustment); - arc_evict_ghost(arc_mfu_ghost, 0, delta); + arc_evict_ghost(arc_mfu_ghost, 0, delta, ARC_BUFC_DATA); } } @@ -2151,8 +2155,8 @@ arc_flush(spa_t *spa) break; } - arc_evict_ghost(arc_mru_ghost, guid, -1); - arc_evict_ghost(arc_mfu_ghost, guid, -1); + arc_evict_ghost(arc_mru_ghost, guid, -1, ARC_BUFC_DATA); + arc_evict_ghost(arc_mfu_ghost, guid, -1, ARC_BUFC_DATA); mutex_enter(&arc_reclaim_thr_lock); arc_do_user_evicts(); |