Fix ZFS_DEBUG_MODIFY assert in arc_buf_try_copy_decompressed_data

The assert does not account for the case where there is a single
buffer in the chain that is decompressed and has a valid
checksum.

Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
This commit is contained in:
Matt Macy 2020-09-16 13:05:14 -07:00 committed by Ameer Hamza
parent 23f878a89d
commit ae78a23f75
1 changed files with 14 additions and 3 deletions

View File

@ -1701,6 +1701,7 @@ arc_buf_try_copy_decompressed_data(arc_buf_t *buf)
{
arc_buf_hdr_t *hdr = buf->b_hdr;
boolean_t copied = B_FALSE;
int nbufs = 0;
ASSERT(HDR_HAS_L1HDR(hdr));
ASSERT3P(buf->b_data, !=, NULL);
@ -1712,7 +1713,7 @@ arc_buf_try_copy_decompressed_data(arc_buf_t *buf)
if (from == buf) {
continue;
}
nbufs++;
if (!ARC_BUF_COMPRESSED(from)) {
memcpy(buf->b_data, from->b_data, arc_buf_size(buf));
copied = B_TRUE;
@ -1725,8 +1726,18 @@ arc_buf_try_copy_decompressed_data(arc_buf_t *buf)
* There were no decompressed bufs, so there should not be a
* checksum on the hdr either.
*/
if (zfs_flags & ZFS_DEBUG_MODIFY)
EQUIV(!copied, hdr->b_l1hdr.b_freeze_cksum == NULL);
if (zfs_flags & ZFS_DEBUG_MODIFY) {
if (nbufs)
EQUIV(!copied, hdr->b_l1hdr.b_freeze_cksum == NULL);
else if (!ARC_BUF_COMPRESSED(buf) &&
hdr->b_l1hdr.b_freeze_cksum != NULL) {
zio_cksum_t cksum;
fletcher_2_native(buf->b_data, arc_buf_size(buf), NULL,
&cksum);
ASSERT0(memcmp(&cksum, hdr->b_l1hdr.b_freeze_cksum,
sizeof (zio_cksum_t)));
}
}
#endif
return (copied);