Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register correct handlers in nvlist_alloc()
Browse files Browse the repository at this point in the history
The non-blocking allocation handlers in nvlist_alloc() would be
mistakenly assigned if any flags other than KM_SLEEP were passed.
This meant that nvlists allocated with KM_PUSHPUSH or other KM_*
debug flags were effectively always using atomic allocations.

While these failures were unlikely it could lead to assertions
because KM_PUSHPAGE allocation in particular are guaranteed to
succeed or block.  They must never fail.

Since this code is already wrapped in a _KERNEL define the
cleanest fix is to check the __GFP_HIGH bit.  When set the
caller is signaling it is safe for the allocation to block,
when it's clear atomic allocations must be used.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs/spl#249
behlendorf committed Jun 18, 2013
1 parent 0377189 commit e06f121
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion module/nvpair/nvpair.c
Original file line number Diff line number Diff line change
@@ -271,7 +271,7 @@ nvlist_alloc(nvlist_t **nvlp, uint_t nvflag, int kmflag)
{
#if defined(_KERNEL) && !defined(_BOOT)
return (nvlist_xalloc(nvlp, nvflag,
(kmflag == KM_SLEEP ? nv_alloc_sleep : nv_alloc_nosleep)));
(kmflag & __GFP_WAIT ? nv_alloc_sleep : nv_alloc_nosleep)));
#else
return (nvlist_xalloc(nvlp, nvflag, nv_alloc_nosleep));
#endif

0 comments on commit e06f121

Please sign in to comment.