aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorXin Li <[email protected]>2011-10-21 16:39:53 -0700
committerBrian Behlendorf <[email protected]>2011-10-24 09:57:52 -0700
commitc47516762758c989a443c0a6a9e38ae8fb46e6f1 (patch)
tree322102432cc80e701000ed47668d3857e5250b00 /module
parent3cee2262a6efd06031a2ff511f66e6a51f743e6a (diff)
Illumos #1661: Fix flaw in sa_find_sizes() calculation
When calculating space needed for SA_BONUS buffers, hdrsize is always rounded up to next 8-aligned boundary. However, in two places the round up was done against sum of 'total' plus hdrsize. On the other hand, hdrsize increments by 4 each time, which means in certain conditions, we would end up returning with will_spill == 0 and (total + hdrsize) larger than full_space, leading to a failed assertion because it's invalid for dmu_set_bonus. Reviewed by: Matthew Ahrens <[email protected]> Reviewed by: Dan McDonald <[email protected]> Approved by: Gordon Ross <[email protected]> References to Illumos issue: https://www.illumos.org/issues/1661 Signed-off-by: Brian Behlendorf <[email protected]> Closes #426
Diffstat (limited to 'module')
-rw-r--r--module/zfs/sa.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/module/zfs/sa.c b/module/zfs/sa.c
index 8acbb0cbb..4278ed7e4 100644
--- a/module/zfs/sa.c
+++ b/module/zfs/sa.c
@@ -607,14 +607,14 @@ sa_find_sizes(sa_os_t *sa, sa_bulk_attr_t *attr_desc, int attr_count,
* and spill buffer.
*/
if (buftype == SA_BONUS && *index == -1 &&
- P2ROUNDUP(*total + hdrsize, 8) >
+ (*total + P2ROUNDUP(hdrsize, 8)) >
(full_space - sizeof (blkptr_t))) {
*index = i;
done = B_TRUE;
}
next:
- if (P2ROUNDUP(*total + hdrsize, 8) > full_space &&
+ if ((*total + P2ROUNDUP(hdrsize, 8)) > full_space &&
buftype == SA_BONUS)
*will_spill = B_TRUE;
}