diff options
author | Ryan Moeller <[email protected]> | 2021-08-18 17:04:46 +0000 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-02-01 17:03:21 -0800 |
commit | 1ae783517727184442b713731c40788c740e6edd (patch) | |
tree | 702ab343e19473833be2616bd6411aa971339026 /lib/libzfs | |
parent | 447e90e360a1737eb5e5b4d0374a0adfc6dcfbbd (diff) |
libzfs_sendrecv: Style pass on dump_snapshot
* Add a high level comment.
* Avoid unnecessary line wrapping.
* Simplify size accounting logic.
* Eliminate unnecessary buffer on the stack.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #12967
Diffstat (limited to 'lib/libzfs')
-rw-r--r-- | lib/libzfs/libzfs_sendrecv.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index d3b2b56ad..7d4cd1475 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -995,6 +995,10 @@ send_print_verbose(FILE *fout, const char *tosnap, const char *fromsnap, (void) fprintf(fout, "\n"); } +/* + * Send a single filesystem snapshot, updating the send dump data. + * This interface is intended for use as a zfs_iter_snapshots_sorted visitor. + */ static int dump_snapshot(zfs_handle_t *zhp, void *arg) { @@ -1016,8 +1020,7 @@ dump_snapshot(zfs_handle_t *zhp, void *arg) if (!sdd->seenfrom && isfromsnap) { gather_holds(zhp, sdd); sdd->seenfrom = B_TRUE; - (void) strlcpy(sdd->prevsnap, thissnap, - sizeof (sdd->prevsnap)); + (void) strlcpy(sdd->prevsnap, thissnap, sizeof (sdd->prevsnap)); sdd->prevsnap_obj = zfs_prop_get_int(zhp, ZFS_PROP_OBJSETID); zfs_close(zhp); return (0); @@ -1097,14 +1100,12 @@ dump_snapshot(zfs_handle_t *zhp, void *arg) (void) strlcat(fromds, sdd->prevsnap, sizeof (fromds)); } if (zfs_send_space(zhp, zhp->zfs_name, - sdd->prevsnap[0] ? fromds : NULL, flags, &size) != 0) { - size = 0; /* cannot estimate send space */ - } else { + sdd->prevsnap[0] ? fromds : NULL, flags, &size) == 0) { send_print_verbose(fout, zhp->zfs_name, sdd->prevsnap[0] ? sdd->prevsnap : NULL, size, sdd->parsable); + sdd->size += size; } - sdd->size += size; } if (!sdd->dryrun) { @@ -1135,12 +1136,9 @@ dump_snapshot(zfs_handle_t *zhp, void *arg) (void) pthread_join(tid, &status); int error = (int)(uintptr_t)status; if (error != 0 && status != PTHREAD_CANCELED) { - char errbuf[1024]; - (void) snprintf(errbuf, sizeof (errbuf), - dgettext(TEXT_DOMAIN, - "progress thread exited nonzero")); return (zfs_standard_error(zhp->zfs_hdl, error, - errbuf)); + dgettext(TEXT_DOMAIN, + "progress thread exited nonzero"))); } } } |