blist_meta_alloc assumes that mask=scan->bm_bitmap is nonzero. But if the

cursor lies in the middle of the space that the meta node represents, then
blanking the low bits of mask may make it zero, and break later code that
expects a nonzero value.  Add a test that returns failure if the mask has
been cleared.

Submitted by:	Doug Moore <dougm@rice.edu>
Reported by:	pho
Tested by:	pho
X-MFC with:	r340402
Differential Revision:	https://reviews.freebsd.org/D18058
This commit is contained in:
Alan Cox 2018-11-24 21:52:10 +00:00
parent 80203ccefd
commit ee73fef96e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=340914

View File

@ -764,6 +764,8 @@ blst_meta_alloc(blmeta_t *scan, daddr_t cursor, daddr_t count, u_daddr_t radix)
/* Discard any candidates that appear before cursor. */
digit = (cursor / radix) & BLIST_META_MASK;
mask &= (u_daddr_t)-1 << digit;
if (mask == 0)
return (SWAPBLK_NONE);
/*
* If the first try is for a block that includes the cursor, pre-undo