Skip to content

Commit

Permalink
Avoid panic with recordsize > 128k, raw sending and no large_blocks
Browse files Browse the repository at this point in the history
The current codebase does not support raw sending buffers with block
size > 128kB when large_blocks is not active. Instead of panicking
due to a NULL pointer dereference in dmu_dump_write() print out an
error message. Also during scrub if there are blocks > 128kB check
if large_blocks is active, and if not activate it.

Signed-off-by: George Amanakis <gamanakis@gmail.com>
  • Loading branch information
gamanakis committed Jul 27, 2021
1 parent 9776838 commit 3764406
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/libzfs/libzfs_sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,11 @@ dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, uint64_t fromsnap_obj,
case EINVAL:
zfs_error_aux(hdl, "%s", strerror(errno));
return (zfs_error(hdl, EZFS_BADBACKUP, errbuf));
case ENOTSUP:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"large blocks detected but large_blocks feature "
"is inactive; raw send unsupported"));
return (zfs_error(hdl, EZFS_NOTSUP, errbuf));

default:
return (zfs_standard_error(hdl, errno, errbuf));
Expand Down Expand Up @@ -2567,6 +2572,11 @@ zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags,
case EROFS:
zfs_error_aux(hdl, "%s", strerror(errno));
return (zfs_error(hdl, EZFS_BADBACKUP, errbuf));
case ENOTSUP:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"large blocks detected but large_blocks feature "
"is inactive; raw send unsupported"));
return (zfs_error(hdl, EZFS_NOTSUP, errbuf));

default:
return (zfs_standard_error(hdl, errno, errbuf));
Expand Down
4 changes: 4 additions & 0 deletions module/zfs/dmu_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ dmu_dump_write(dmu_send_cookie_t *dscp, dmu_object_type_t type, uint64_t object,

/* only set the compression fields if the buf is compressed or raw */
if (raw || lsize != psize) {
ASSERT(bp != NULL);
ASSERT(raw || dscp->dsc_featureflags &
DMU_BACKUP_FEATURE_COMPRESSED);
ASSERT(!BP_IS_EMBEDDED(bp));
Expand Down Expand Up @@ -1010,6 +1011,9 @@ do_dump(dmu_send_cookie_t *dscp, struct send_range *range)
if (srdp->datablksz > SPA_OLD_MAXBLOCKSIZE &&
!(dscp->dsc_featureflags &
DMU_BACKUP_FEATURE_LARGE_BLOCKS)) {
if (dscp->dsc_featureflags & DMU_BACKUP_FEATURE_RAW)
return (SET_ERROR(ENOTSUP));

while (srdp->datablksz > 0 && err == 0) {
int n = MIN(srdp->datablksz,
SPA_OLD_MAXBLOCKSIZE);
Expand Down
14 changes: 14 additions & 0 deletions module/zfs/dsl_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,20 @@ dsl_scan_visitbp(blkptr_t *bp, const zbookmark_phys_t *zb,
return;
}

/*
* If there are blocks larger than 128kB check if large_blocks
* is active. If not, activate it.
*/
if (BP_GET_LSIZE(bp) > SPA_OLD_MAXBLOCKSIZE) {
spa_feature_t f = SPA_FEATURE_LARGE_BLOCKS;
if (!dsl_dataset_feature_is_active(ds, f)) {
ds->ds_feature_activation[f] = (void *)B_TRUE;
dsl_dataset_activate_feature(ds->ds_object, f,
ds->ds_feature_activation[f], tx);
ds->ds_feature[f] = ds->ds_feature_activation[f];
}
}

This comment has been minimized.

Copy link
@amotin

amotin Jul 27, 2021

Member

This looks like a workaround for something that has already happened, but should not have. The proper activation code I see in dsl_dataset_block_born(), but the question how could we get around it?


if (bp->blk_birth <= scn->scn_phys.scn_cur_min_txg) {
scn->scn_lt_min_this_txg++;
return;
Expand Down

0 comments on commit 3764406

Please sign in to comment.