diff options
author | Alexander Motin <[email protected]> | 2023-05-05 12:17:55 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2023-05-05 09:17:55 -0700 |
commit | 190290a9ac3f2f0dd0021646f2fd787ea51b08bd (patch) | |
tree | e5230c7b51a35a3cad8d78002e2e12bc0cc2d14d /module/zfs | |
parent | 6fa6bb051c2b83f90dc12a64e63d1cb2b0d12c96 (diff) |
Fix two abd_gang_add_gang() issues.
- There is no reason to assert that added gang is not empty. It
may be weird to add an empty gang, but it is legal.
- When moving chain list from the added gang clear its size, or it
will trigger assertion in abd_verify() when that gang is freed.
Reviewed-by: Brian Atkinson <[email protected]>
Signed-off-by: Alexander Motin <[email protected]>
Sponsored by: iXsystems, Inc.
Closes #14816
Diffstat (limited to 'module/zfs')
-rw-r--r-- | module/zfs/abd.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/module/zfs/abd.c b/module/zfs/abd.c index 26222d2ef..745ee8f02 100644 --- a/module/zfs/abd.c +++ b/module/zfs/abd.c @@ -370,7 +370,20 @@ abd_gang_add_gang(abd_t *pabd, abd_t *cabd, boolean_t free_on_free) * will retain all the free_on_free settings after being * added to the parents list. */ +#ifdef ZFS_DEBUG + /* + * If cabd had abd_parent, we have to drop it here. We can't + * transfer it to pabd, nor we can clear abd_size leaving it. + */ + if (cabd->abd_parent != NULL) { + (void) zfs_refcount_remove_many( + &cabd->abd_parent->abd_children, + cabd->abd_size, cabd); + cabd->abd_parent = NULL; + } +#endif pabd->abd_size += cabd->abd_size; + cabd->abd_size = 0; list_move_tail(&ABD_GANG(pabd).abd_gang_chain, &ABD_GANG(cabd).abd_gang_chain); ASSERT(list_is_empty(&ABD_GANG(cabd).abd_gang_chain)); @@ -408,7 +421,6 @@ abd_gang_add(abd_t *pabd, abd_t *cabd, boolean_t free_on_free) */ if (abd_is_gang(cabd)) { ASSERT(!list_link_active(&cabd->abd_gang_link)); - ASSERT(!list_is_empty(&ABD_GANG(cabd).abd_gang_chain)); return (abd_gang_add_gang(pabd, cabd, free_on_free)); } ASSERT(!abd_is_gang(cabd)); |