mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-27 03:19:35 +03:00
Fix abd leak, kmem_free correct size of abd_t
Fix a leak of abd_t that manifested mostly when using raidzN with at least as many columns as N (e.g. a four-disk raidz2 but not a three-disk raidz2). Sufficiently heavy raidz use would eventually run a system out of memory. Additionally: * Switch abd_cache arena to FIRSTFIT, which empirically improves perofrmance. * Make abd_chunk_cache more performant and debuggable. * Allocate the abd_zero_buf from abd_chunk_cache rather than the heap. * Don't try to reap non-existent qcaches in abd_cache arena. * KM_PUSHPAGE->KM_SLEEP when allocating chunks from their own arena Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Jorgen Lundman <lundman@lundman.net> Co-authored-by: Sean Doran <smd@use.net> Closes #12295
This commit is contained in:
parent
eca174527e
commit
c6d1112bf4
@ -64,7 +64,7 @@ void abd_free_struct(abd_t *);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
abd_t *abd_alloc_struct_impl(size_t);
|
abd_t *abd_alloc_struct_impl(size_t);
|
||||||
abd_t *abd_get_offset_scatter(abd_t *, abd_t *, size_t);
|
abd_t *abd_get_offset_scatter(abd_t *, abd_t *, size_t, size_t);
|
||||||
void abd_free_struct_impl(abd_t *);
|
void abd_free_struct_impl(abd_t *);
|
||||||
void abd_alloc_chunks(abd_t *, size_t);
|
void abd_alloc_chunks(abd_t *, size_t);
|
||||||
void abd_free_chunks(abd_t *);
|
void abd_free_chunks(abd_t *);
|
||||||
|
@ -374,14 +374,17 @@ abd_alloc_for_io(size_t size, boolean_t is_metadata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
abd_t *
|
abd_t *
|
||||||
abd_get_offset_scatter(abd_t *abd, abd_t *sabd, size_t off)
|
abd_get_offset_scatter(abd_t *abd, abd_t *sabd, size_t off,
|
||||||
|
size_t size)
|
||||||
{
|
{
|
||||||
abd_verify(sabd);
|
abd_verify(sabd);
|
||||||
ASSERT3U(off, <=, sabd->abd_size);
|
ASSERT3U(off, <=, sabd->abd_size);
|
||||||
|
|
||||||
size_t new_offset = ABD_SCATTER(sabd).abd_offset + off;
|
size_t new_offset = ABD_SCATTER(sabd).abd_offset + off;
|
||||||
uint_t chunkcnt = abd_scatter_chunkcnt(sabd) -
|
size_t chunkcnt = abd_chunkcnt_for_bytes(
|
||||||
(new_offset / zfs_abd_chunk_size);
|
(new_offset % zfs_abd_chunk_size) + size);
|
||||||
|
|
||||||
|
ASSERT3U(chunkcnt, <=, abd_scatter_chunkcnt(sabd));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If an abd struct is provided, it is only the minimum size. If we
|
* If an abd struct is provided, it is only the minimum size. If we
|
||||||
|
@ -835,7 +835,8 @@ abd_alloc_for_io(size_t size, boolean_t is_metadata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
abd_t *
|
abd_t *
|
||||||
abd_get_offset_scatter(abd_t *abd, abd_t *sabd, size_t off)
|
abd_get_offset_scatter(abd_t *abd, abd_t *sabd, size_t off,
|
||||||
|
size_t size)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
struct scatterlist *sg = NULL;
|
struct scatterlist *sg = NULL;
|
||||||
|
@ -531,7 +531,7 @@ abd_get_offset_impl(abd_t *abd, abd_t *sabd, size_t off, size_t size)
|
|||||||
}
|
}
|
||||||
ASSERT3U(left, ==, 0);
|
ASSERT3U(left, ==, 0);
|
||||||
} else {
|
} else {
|
||||||
abd = abd_get_offset_scatter(abd, sabd, off);
|
abd = abd_get_offset_scatter(abd, sabd, off, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT3P(abd, !=, NULL);
|
ASSERT3P(abd, !=, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user