Skip to content

Commit 87d9373

Browse files
gamanakistonyhutter
authored andcommitted
Avoid deadlock when removing L2ARC devices under I/O
In case we have I/O and try to remove an L2ARC device a deadlock might occur. arc_read()->zio_read()->zfs_blkptr_verify() waits for SCL_VDEV to be dropped while holding the hash_lock. However, spa_l2cache_load() holds SCL_ALL and waits for the hash_lock in l2arc_evict(). Fix this by moving zfs_blkptr_verify() to the top top arc_read() before the hash_lock is taken. Verify the block pointer and return a checksum error if damaged rather than halting the system, by using BLK_VERIFY_LOG instead of BLK_VERIFY_HALT. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Mark Maybee <[email protected]> Signed-off-by: George Amanakis <[email protected]> Closes #12054
1 parent bd19737 commit 87d9373

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

module/zfs/arc.c

+6-11
Original file line numberDiff line numberDiff line change
@@ -5835,6 +5835,12 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
58355835
* Embedded BP's have no DVA and require no I/O to "read".
58365836
* Create an anonymous arc buf to back it.
58375837
*/
5838+
if (!zfs_blkptr_verify(spa, bp, zio_flags &
5839+
ZIO_FLAG_CONFIG_WRITER, BLK_VERIFY_LOG)) {
5840+
rc = SET_ERROR(ECKSUM);
5841+
goto out;
5842+
}
5843+
58385844
hdr = buf_hash_find(guid, bp, &hash_lock);
58395845
}
58405846

@@ -6003,17 +6009,6 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
60036009
goto out;
60046010
}
60056011

6006-
/*
6007-
* Gracefully handle a damaged logical block size as a
6008-
* checksum error.
6009-
*/
6010-
if (lsize > spa_maxblocksize(spa)) {
6011-
rc = SET_ERROR(ECKSUM);
6012-
if (hash_lock != NULL)
6013-
mutex_exit(hash_lock);
6014-
goto out;
6015-
}
6016-
60176012
if (hdr == NULL) {
60186013
/*
60196014
* This block is not in the cache or it has

module/zfs/zio.c

-3
Original file line numberDiff line numberDiff line change
@@ -1106,9 +1106,6 @@ zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
11061106
{
11071107
zio_t *zio;
11081108

1109-
(void) zfs_blkptr_verify(spa, bp, flags & ZIO_FLAG_CONFIG_WRITER,
1110-
BLK_VERIFY_HALT);
1111-
11121109
zio = zio_create(pio, spa, BP_PHYSICAL_BIRTH(bp), bp,
11131110
data, size, size, done, private,
11141111
ZIO_TYPE_READ, priority, flags, NULL, 0, zb,

0 commit comments

Comments
 (0)