From a4069eef2e403a3b2a307b23b7500e2adc6ecae5 Mon Sep 17 00:00:00 2001 From: Prakash Surya Date: Fri, 27 Mar 2015 13:03:22 +1100 Subject: [PATCH] Illumos 5695 - dmu_sync'ed holes do not retain birth time 5695 dmu_sync'ed holes do not retain birth time Reviewed by: Matthew Ahrens Reviewed by: George Wilson Reviewed by: Christopher Siden Reviewed by: Bayard Bell Approved by: Dan McDonald References: https://www.illumos.org/issues/5695 https://github.com/illumos/illumos-gate/commit/70163ac Ported-by: Chris Dunlop Signed-off-by: Brian Behlendorf Closes #3229 --- cmd/zdb/zdb.c | 4 +++- include/sys/spa.h | 13 +++++++------ module/zfs/dmu.c | 14 +++++++++++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index b0d7170b92b2..1d76f2a7da3e 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -1115,7 +1115,9 @@ snprintf_blkptr_compact(char *blkbuf, size_t buflen, const blkptr_t *bp) if (BP_IS_HOLE(bp)) { (void) snprintf(blkbuf + strlen(blkbuf), - buflen - strlen(blkbuf), "B=%llu", + buflen - strlen(blkbuf), + "%llxL B=%llu", + (u_longlong_t)BP_GET_LSIZE(bp), (u_longlong_t)bp->blk_birth); } else { (void) snprintf(blkbuf + strlen(blkbuf), diff --git a/include/sys/spa.h b/include/sys/spa.h index 2f73793fedb2..83b6723a4f73 100644 --- a/include/sys/spa.h +++ b/include/sys/spa.h @@ -501,12 +501,13 @@ _NOTE(CONSTCOND) } while (0) if (bp == NULL) { \ len += func(buf + len, size - len, ""); \ } else if (BP_IS_HOLE(bp)) { \ - len += func(buf + len, size - len, ""); \ - if (bp->blk_birth > 0) { \ - len += func(buf + len, size - len, \ - " birth=%lluL", \ - (u_longlong_t)bp->blk_birth); \ - } \ + len += func(buf + len, size - len, \ + "HOLE [L%llu %s] " \ + "size=%llxL birth=%lluL", \ + (u_longlong_t)BP_GET_LEVEL(bp), \ + type, \ + (u_longlong_t)BP_GET_LSIZE(bp), \ + (u_longlong_t)bp->blk_birth); \ } else if (BP_IS_EMBEDDED(bp)) { \ len = func(buf + len, size - len, \ "EMBEDDED [L%llu %s] et=%u %s " \ diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 1501ae8046ad..3b7bbefc2f73 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -1472,7 +1472,19 @@ dmu_sync_done(zio_t *zio, arc_buf_t *buf, void *varg) dr->dt.dl.dr_overridden_by = *zio->io_bp; dr->dt.dl.dr_override_state = DR_OVERRIDDEN; dr->dt.dl.dr_copies = zio->io_prop.zp_copies; - if (BP_IS_HOLE(&dr->dt.dl.dr_overridden_by)) + + /* + * Old style holes are filled with all zeros, whereas + * new-style holes maintain their lsize, type, level, + * and birth time (see zio_write_compress). While we + * need to reset the BP_SET_LSIZE() call that happened + * in dmu_sync_ready for old style holes, we do *not* + * want to wipe out the information contained in new + * style holes. Thus, only zero out the block pointer if + * it's an old style hole. + */ + if (BP_IS_HOLE(&dr->dt.dl.dr_overridden_by) && + dr->dt.dl.dr_overridden_by.blk_birth == 0) BP_ZERO(&dr->dt.dl.dr_overridden_by); } else { dr->dt.dl.dr_override_state = DR_NOT_OVERRIDDEN;