Project

General

Profile

Actions

Bug #8731

closed

ASSERT3U(nui64s, <=, UINT16_MAX) fails for large blocks

Added by Andriy Gapon over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
zfs - Zettabyte File System
Start date:
2017-10-26
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

annotate_ecksum() asserts that nui64s, calculated as nui64s = size / sizeof (uint64_t), is not greater than UINT16_MAX.
This restriction is needed because histograms of incorrectly set and cleared bits have 16 bit counters and if the buffer consists of too many 64-bit words, then a counter can potentially overflow producing an incorrect result.
When the largest buffer size was 128KB the greatest value of nui64s was 16K, well within the limit.
But now we have support for large buffers and for buffer sizes of 512KB and above the restriction is violated.

Per discussion with Matt Ahrens there are two ways to fix this problem.

One is to clip the histogram counters at UINT16_MAX to avoid the wrap-around.
So, even if the values are clipped they still give an idea about the scale of the problem and the pattern of the corruption.

The other is to extend the counter type to 32 bits.
This should cover all supported buffer sizes.
But there is a concern about consumers of the histograms.

Actions

Also available in: Atom PDF