ZFS send/recv with ashift 9->12 leads to data corruption
Improve the ability of zfs send to determine if a block is compressed or not by using information contained in the blkptr. Reviewed-by: Rich Ercolani <rincebrain@gmail.com> Reviewed-by: Matthew Ahrens <matthew.ahrens@delphix.com> Signed-off-by: Paul Dagnelie <pcd@delphix.com> Closes #12770
This commit is contained in:
parent
b6fc42b5e1
commit
376027331d
|
@ -2070,7 +2070,6 @@ arc_buf_fill(arc_buf_t *buf, spa_t *spa, const zbookmark_phys_t *zb,
|
||||||
} else {
|
} else {
|
||||||
ASSERT(hdr_compressed);
|
ASSERT(hdr_compressed);
|
||||||
ASSERT(!compressed);
|
ASSERT(!compressed);
|
||||||
ASSERT3U(HDR_GET_LSIZE(hdr), !=, HDR_GET_PSIZE(hdr));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the buf is sharing its data with the hdr, unlink it and
|
* If the buf is sharing its data with the hdr, unlink it and
|
||||||
|
|
|
@ -165,6 +165,7 @@ struct send_range {
|
||||||
kmutex_t lock;
|
kmutex_t lock;
|
||||||
kcondvar_t cv;
|
kcondvar_t cv;
|
||||||
boolean_t io_outstanding;
|
boolean_t io_outstanding;
|
||||||
|
boolean_t io_compressed;
|
||||||
int io_err;
|
int io_err;
|
||||||
} data;
|
} data;
|
||||||
struct srh {
|
struct srh {
|
||||||
|
@ -450,7 +451,8 @@ dump_redact(dmu_send_cookie_t *dscp, uint64_t object, uint64_t offset,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dmu_dump_write(dmu_send_cookie_t *dscp, dmu_object_type_t type, uint64_t object,
|
dmu_dump_write(dmu_send_cookie_t *dscp, dmu_object_type_t type, uint64_t object,
|
||||||
uint64_t offset, int lsize, int psize, const blkptr_t *bp, void *data)
|
uint64_t offset, int lsize, int psize, const blkptr_t *bp,
|
||||||
|
boolean_t io_compressed, void *data)
|
||||||
{
|
{
|
||||||
uint64_t payload_size;
|
uint64_t payload_size;
|
||||||
boolean_t raw = (dscp->dsc_featureflags & DMU_BACKUP_FEATURE_RAW);
|
boolean_t raw = (dscp->dsc_featureflags & DMU_BACKUP_FEATURE_RAW);
|
||||||
|
@ -487,7 +489,10 @@ dmu_dump_write(dmu_send_cookie_t *dscp, dmu_object_type_t type, uint64_t object,
|
||||||
drrw->drr_logical_size = lsize;
|
drrw->drr_logical_size = lsize;
|
||||||
|
|
||||||
/* only set the compression fields if the buf is compressed or raw */
|
/* only set the compression fields if the buf is compressed or raw */
|
||||||
if (raw || lsize != psize) {
|
boolean_t compressed =
|
||||||
|
(bp != NULL ? BP_GET_COMPRESS(bp) != ZIO_COMPRESS_OFF &&
|
||||||
|
io_compressed : lsize != psize);
|
||||||
|
if (raw || compressed) {
|
||||||
ASSERT(raw || dscp->dsc_featureflags &
|
ASSERT(raw || dscp->dsc_featureflags &
|
||||||
DMU_BACKUP_FEATURE_COMPRESSED);
|
DMU_BACKUP_FEATURE_COMPRESSED);
|
||||||
ASSERT(!BP_IS_EMBEDDED(bp));
|
ASSERT(!BP_IS_EMBEDDED(bp));
|
||||||
|
@ -1014,7 +1019,8 @@ do_dump(dmu_send_cookie_t *dscp, struct send_range *range)
|
||||||
int n = MIN(srdp->datablksz,
|
int n = MIN(srdp->datablksz,
|
||||||
SPA_OLD_MAXBLOCKSIZE);
|
SPA_OLD_MAXBLOCKSIZE);
|
||||||
err = dmu_dump_write(dscp, srdp->obj_type,
|
err = dmu_dump_write(dscp, srdp->obj_type,
|
||||||
range->object, offset, n, n, NULL, data);
|
range->object, offset, n, n, NULL, B_FALSE,
|
||||||
|
data);
|
||||||
offset += n;
|
offset += n;
|
||||||
/*
|
/*
|
||||||
* When doing dry run, data==NULL is used as a
|
* When doing dry run, data==NULL is used as a
|
||||||
|
@ -1028,7 +1034,8 @@ do_dump(dmu_send_cookie_t *dscp, struct send_range *range)
|
||||||
} else {
|
} else {
|
||||||
err = dmu_dump_write(dscp, srdp->obj_type,
|
err = dmu_dump_write(dscp, srdp->obj_type,
|
||||||
range->object, offset,
|
range->object, offset,
|
||||||
srdp->datablksz, srdp->datasz, bp, data);
|
srdp->datablksz, srdp->datasz, bp,
|
||||||
|
srdp->io_compressed, data);
|
||||||
}
|
}
|
||||||
return (err);
|
return (err);
|
||||||
}
|
}
|
||||||
|
@ -1081,6 +1088,7 @@ range_alloc(enum type type, uint64_t object, uint64_t start_blkid,
|
||||||
cv_init(&range->sru.data.cv, NULL, CV_DEFAULT, NULL);
|
cv_init(&range->sru.data.cv, NULL, CV_DEFAULT, NULL);
|
||||||
range->sru.data.io_outstanding = 0;
|
range->sru.data.io_outstanding = 0;
|
||||||
range->sru.data.io_err = 0;
|
range->sru.data.io_err = 0;
|
||||||
|
range->sru.data.io_compressed = B_FALSE;
|
||||||
}
|
}
|
||||||
return (range);
|
return (range);
|
||||||
}
|
}
|
||||||
|
@ -1646,10 +1654,13 @@ issue_data_read(struct send_reader_thread_arg *srta, struct send_range *range)
|
||||||
|
|
||||||
enum zio_flag zioflags = ZIO_FLAG_CANFAIL;
|
enum zio_flag zioflags = ZIO_FLAG_CANFAIL;
|
||||||
|
|
||||||
if (srta->featureflags & DMU_BACKUP_FEATURE_RAW)
|
if (srta->featureflags & DMU_BACKUP_FEATURE_RAW) {
|
||||||
zioflags |= ZIO_FLAG_RAW;
|
zioflags |= ZIO_FLAG_RAW;
|
||||||
else if (request_compressed)
|
srdp->io_compressed = B_TRUE;
|
||||||
|
} else if (request_compressed) {
|
||||||
zioflags |= ZIO_FLAG_RAW_COMPRESS;
|
zioflags |= ZIO_FLAG_RAW_COMPRESS;
|
||||||
|
srdp->io_compressed = B_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
srdp->datasz = (zioflags & ZIO_FLAG_RAW_COMPRESS) ?
|
srdp->datasz = (zioflags & ZIO_FLAG_RAW_COMPRESS) ?
|
||||||
BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp);
|
BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp);
|
||||||
|
|
Loading…
Reference in New Issue