Skip to content

Commit

Permalink
Avoid panic in case of pool errors and missing L2ARC
Browse files Browse the repository at this point in the history
In case an ARC buffer is allocated only on L2ARC, and there are
underlying errors in a pool with the cache device in faulty state, a
panic can occur in arc_read_done()->arc_hdr_destroy()->
arc_hdr_l2arc_destroy()->arc_hdr_clear_flags() when trying to free
the ARC buffer.

Fix this by checking in arc_read_done() if the ARC buffer to be freed
is stored on L2ARC and not empty, and acquiring its hash_lock in this
case.

Signed-off-by: George Amanakis <gamanakis@gmail.com>
  • Loading branch information
gamanakis committed Jul 19, 2021
1 parent ca14e08 commit aac389f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5867,8 +5867,15 @@ arc_read_done(zio_t *zio)
kmem_free(acb, sizeof (arc_callback_t));
}

if (freeable)
if (freeable) {
if (HDR_HAS_L2HDR(hdr) && !HDR_EMPTY(hdr))
mutex_enter(hash_lock);

arc_hdr_destroy(hdr);

if (MUTEX_HELD(hash_lock))
mutex_exit(hash_lock);
}
}

/*
Expand Down

0 comments on commit aac389f

Please sign in to comment.