Skip to content

Commit b43c67b

Browse files
0mpAlexander Stetsenko
authored andcommitted
arc: Fall back to the regular single evict if kmem_alloc for task queue entries fails
1 parent b6c7222 commit b43c67b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

module/zfs/arc.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4088,6 +4088,8 @@ arc_evict_state(arc_state_t *state, arc_buf_contents_t type, uint64_t spa,
40884088
multilist_t *ml = &state->arcs_list[type];
40894089
arc_buf_hdr_t **markers;
40904090
unsigned num_sublists = multilist_get_num_sublists(ml);
4091+
evict_arg_t *evarg;
4092+
boolean_t usetskq = zfs_arc_evict_threads_live > 1;
40914093

40924094
if (bytes == 0)
40934095
return (total_evicted);
@@ -4113,15 +4115,22 @@ arc_evict_state(arc_state_t *state, arc_buf_contents_t type, uint64_t spa,
41134115
multilist_sublist_unlock(mls);
41144116
}
41154117

4116-
evict_arg_t *evarg = kmem_alloc(sizeof (*evarg) * num_sublists,
4117-
KM_SLEEP);
4118+
if (usetskq) {
4119+
evarg = kmem_alloc(sizeof (*evarg) * num_sublists, KM_NOSLEEP);
4120+
/*
4121+
* Fall back to the regular single evict if it is not possible
4122+
* to allocate memory for the task queue entries.
4123+
*/
4124+
if (evarg == NULL)
4125+
usetskq = B_FALSE;
4126+
}
4127+
41184128
/*
41194129
* While we haven't hit our target number of bytes to evict, or
41204130
* we're evicting all available buffers.
41214131
*/
41224132
while (total_evicted < bytes) {
41234133
int sublist_idx = multilist_get_random_index(ml);
4124-
boolean_t usetskq = zfs_arc_evict_threads_live > 1;
41254134
uint64_t scan_evicted = 0;
41264135

41274136
uint64_t left = (bytes == ARC_EVICT_ALL ? bytes :
@@ -4254,7 +4263,8 @@ arc_evict_state(arc_state_t *state, arc_buf_contents_t type, uint64_t spa,
42544263
}
42554264
}
42564265

4257-
kmem_free(evarg, sizeof (*evarg) * num_sublists);
4266+
if (usetskq)
4267+
kmem_free(evarg, sizeof (*evarg) * num_sublists);
42584268

42594269
for (int i = 0; i < num_sublists; i++) {
42604270
multilist_sublist_t *mls = multilist_sublist_lock_idx(ml, i);

0 commit comments

Comments
 (0)