diff options
author | Tom Caputi <[email protected]> | 2019-03-27 14:30:48 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-03-27 11:30:48 -0700 |
commit | 5dbf8b4edd5a60b0d043b09aa168e8be1fb30647 (patch) | |
tree | c669936d8489f78461b70ff64492bba9dcec4224 /module/zfs/dmu_recv.c | |
parent | 85a150ce1e6d609cec814f9af28ce4f2aef312ab (diff) |
Fix issues with truncated files in raw sends
This patch fixes a few issues with raw receives involving
truncated files:
* dnode_reallocate() now calls dnode_set_blksz() instead of
dnode_setdblksz(). This ensures that any remaining dbufs with
blkid 0 are resized along with their containing dnode upon
reallocation.
* One of the calls to dmu_free_long_range() in receive_object()
needs to check that the object it is about to free some contents
or hasn't been completely removed already by a previous call to
dmu_free_long_object() in the same function.
* The same call to dmu_free_long_range() in the previous point
needs to ensure it uses the object's current block size and
not the new block size. This ensures the blocks of the object
that are supposed to be freed are completely removed and not
simply partially zeroed out.
This patch also adds handling for DRR_OBJECT_RANGE records to
dprintf_drr() for debugging purposes.
Reviewed-by: Matt Ahrens <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tom Caputi <[email protected]>
Closes #7378
Closes #8528
Diffstat (limited to 'module/zfs/dmu_recv.c')
-rw-r--r-- | module/zfs/dmu_recv.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/module/zfs/dmu_recv.c b/module/zfs/dmu_recv.c index e49a0f4aa..e534540cb 100644 --- a/module/zfs/dmu_recv.c +++ b/module/zfs/dmu_recv.c @@ -1235,11 +1235,13 @@ receive_object(struct receive_writer_arg *rwa, struct drr_object *drro, * processed. However, for raw receives we manually set the * maxblkid from the drr_maxblkid and so we must first free * everything above that blkid to ensure the DMU is always - * consistent with itself. + * consistent with itself. We will never free the first block + * of the object here because a maxblkid of 0 could indicate + * an object with a single block or one with no blocks. */ - if (rwa->raw) { + if (rwa->raw && object != DMU_NEW_OBJECT) { err = dmu_free_long_range(rwa->os, drro->drr_object, - (drro->drr_maxblkid + 1) * drro->drr_blksz, + (drro->drr_maxblkid + 1) * doi.doi_data_block_size, DMU_OBJECT_END); if (err != 0) return (SET_ERROR(EINVAL)); @@ -1375,11 +1377,8 @@ receive_object(struct receive_writer_arg *rwa, struct drr_object *drro, drro->drr_nlevels, tx)); /* - * Set the maxblkid. We will never free the first block of - * an object here because a maxblkid of 0 could indicate - * an object with a single block or one with no blocks. - * This will always succeed because we freed all blocks - * beyond the new maxblkid above. + * Set the maxblkid. This will always succeed because + * we freed all blocks beyond the new maxblkid above. */ VERIFY0(dmu_object_set_maxblkid(rwa->os, drro->drr_object, drro->drr_maxblkid, tx)); @@ -2185,7 +2184,7 @@ dprintf_drr(struct receive_record_arg *rrd, int err) { struct drr_write *drrw = &rrd->header.drr_u.drr_write; dprintf("drr_type = WRITE obj = %llu type = %u offset = %llu " - "lsize = %llu cksumtype = %u cksumflags = %u " + "lsize = %llu cksumtype = %u flags = %u " "compress = %u psize = %llu err = %d\n", drrw->drr_object, drrw->drr_type, drrw->drr_offset, drrw->drr_logical_size, drrw->drr_checksumtype, @@ -2200,7 +2199,7 @@ dprintf_drr(struct receive_record_arg *rrd, int err) dprintf("drr_type = WRITE_BYREF obj = %llu offset = %llu " "length = %llu toguid = %llx refguid = %llx " "refobject = %llu refoffset = %llu cksumtype = %u " - "cksumflags = %u err = %d\n", + "flags = %u err = %d\n", drrwbr->drr_object, drrwbr->drr_offset, drrwbr->drr_length, drrwbr->drr_toguid, drrwbr->drr_refguid, drrwbr->drr_refobject, @@ -2236,6 +2235,16 @@ dprintf_drr(struct receive_record_arg *rrd, int err) "err = %d\n", drrs->drr_object, drrs->drr_length, err); break; } + case DRR_OBJECT_RANGE: + { + struct drr_object_range *drror = + &rrd->header.drr_u.drr_object_range; + dprintf("drr_type = OBJECT_RANGE firstobj = %llu " + "numslots = %llu flags = %u err = %d\n", + drror->drr_firstobj, drror->drr_numslots, + drror->drr_flags, err); + break; + } default: return; } @@ -2319,10 +2328,11 @@ receive_process_record(struct receive_writer_arg *rwa, { struct drr_object_range *drror = &rrd->header.drr_u.drr_object_range; - return (receive_object_range(rwa, drror)); + err = receive_object_range(rwa, drror); + break; } default: - return (SET_ERROR(EINVAL)); + err = (SET_ERROR(EINVAL)); } if (err != 0) |