diff options
author | Ryan Moeller <[email protected]> | 2021-08-18 18:01:04 +0000 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-02-01 17:03:30 -0800 |
commit | 1910a3084872857ee997f09097a5240adbdf6530 (patch) | |
tree | 7739d38753bbf8258fc34b821f0729ae111b1dd0 /lib/libzfs | |
parent | 1ae783517727184442b713731c40788c740e6edd (diff) |
libzfs_sendrecv: Style pass on dump_filesystem
* Add high level comments.
* Eliminate unnecessarily void arg.
* Avoid unnecessary line wrapping.
* Initialize sdd fields with the correct types.
* Remove extra whitespace.
* Refactor replication checks for clarity.
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 | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 7d4cd1475..751e34a92 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -1149,15 +1149,20 @@ dump_snapshot(zfs_handle_t *zhp, void *arg) return (err); } +/* + * Send all snapshots for a filesystem, updating the send dump data. + */ static int -dump_filesystem(zfs_handle_t *zhp, void *arg) +dump_filesystem(zfs_handle_t *zhp, send_dump_data_t *sdd) { int rv = 0; - send_dump_data_t *sdd = arg; boolean_t missingfrom = B_FALSE; zfs_cmd_t zc = {"\0"}; uint64_t min_txg = 0, max_txg = 0; + /* + * Make sure the tosnap exists. + */ (void) snprintf(zc.zc_name, sizeof (zc.zc_name), "%s@%s", zhp->zfs_name, sdd->tosnap); if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_OBJSET_STATS, &zc) != 0) { @@ -1168,47 +1173,52 @@ dump_filesystem(zfs_handle_t *zhp, void *arg) return (0); } + /* + * If this fs does not have fromsnap, and we're doing + * recursive, we need to send a full stream from the + * beginning (or an incremental from the origin if this + * is a clone). If we're doing non-recursive, then let + * them get the error. + */ if (sdd->replicate && sdd->fromsnap) { /* - * If this fs does not have fromsnap, and we're doing - * recursive, we need to send a full stream from the - * beginning (or an incremental from the origin if this - * is a clone). If we're doing non-recursive, then let - * them get the error. + * Make sure the fromsnap exists. */ (void) snprintf(zc.zc_name, sizeof (zc.zc_name), "%s@%s", zhp->zfs_name, sdd->fromsnap); - if (zfs_ioctl(zhp->zfs_hdl, - ZFS_IOC_OBJSET_STATS, &zc) != 0) { + if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_OBJSET_STATS, &zc) != 0) missingfrom = B_TRUE; - } } - sdd->seenfrom = sdd->seento = sdd->prevsnap[0] = 0; + sdd->seenfrom = sdd->seento = B_FALSE; + sdd->prevsnap[0] = '\0'; sdd->prevsnap_obj = 0; if (sdd->fromsnap == NULL || missingfrom) sdd->seenfrom = B_TRUE; - - /* * Iterate through all snapshots and process the ones we will be * sending. If we only have a "from" and "to" snapshot to deal * with, we can avoid iterating through all the other snapshots. */ if (sdd->doall || sdd->replicate || sdd->tosnap == NULL) { - if (!sdd->replicate && sdd->fromsnap != NULL) - min_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name, - sdd->fromsnap); - if (!sdd->replicate && sdd->tosnap != NULL) - max_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name, - sdd->tosnap); - rv = zfs_iter_snapshots_sorted(zhp, dump_snapshot, arg, + if (!sdd->replicate) { + if (sdd->fromsnap != NULL) { + min_txg = get_snap_txg(zhp->zfs_hdl, + zhp->zfs_name, sdd->fromsnap); + } + if (sdd->tosnap != NULL) { + max_txg = get_snap_txg(zhp->zfs_hdl, + zhp->zfs_name, sdd->tosnap); + } + } + rv = zfs_iter_snapshots_sorted(zhp, dump_snapshot, sdd, min_txg, max_txg); } else { char snapname[MAXPATHLEN] = { 0 }; zfs_handle_t *snap; + /* Dump fromsnap. */ if (!sdd->seenfrom) { (void) snprintf(snapname, sizeof (snapname), "%s@%s", zhp->zfs_name, sdd->fromsnap); @@ -1220,6 +1230,7 @@ dump_filesystem(zfs_handle_t *zhp, void *arg) rv = -1; } + /* Dump tosnap. */ if (rv == 0) { (void) snprintf(snapname, sizeof (snapname), "%s@%s", zhp->zfs_name, sdd->tosnap); |