Print this page
Optimize creation and removal of temporary "user holds" placed on
snapshots by a zfs send, by ensuring all the required holds and
releases are done in a single dsl_sync_task.
Creation now collates the required holds during a dry run and
then uses a single lzc_hold call via zfs_hold_apply instead of
processing each snapshot in turn.
Defered (on exit) cleanup by the kernel is also now done in
dsl_sync_task by reusing dsl_dataset_user_release.
On a test with 11 volumes in a tree each with 8 snapshots on a
single HDD zpool this reduces the time required to perform a full
send from 20 seconds to under 0.8 seconds.
For reference eliminating the hold entirely reduces this 0.15
seconds.
While I'm here:-
* Remove some unused structures
* Fix nvlist_t leak in zfs_release_one


 578         boolean_t props;
 579 
 580         /* do not send (no-op, ie. -n) */
 581         boolean_t dryrun;
 582 
 583         /* parsable verbose output (ie. -P) */
 584         boolean_t parsable;
 585 
 586         /* show progress (ie. -v) */
 587         boolean_t progress;
 588 } sendflags_t;
 589 
 590 typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, void *);
 591 
 592 extern int zfs_send(zfs_handle_t *, const char *, const char *,
 593     sendflags_t *, int, snapfilter_cb_t, void *, nvlist_t **);
 594 
 595 extern int zfs_promote(zfs_handle_t *);
 596 extern int zfs_hold(zfs_handle_t *, const char *, const char *,
 597     boolean_t, boolean_t, int);



 598 extern int zfs_release(zfs_handle_t *, const char *, const char *, boolean_t);
 599 extern int zfs_get_holds(zfs_handle_t *, nvlist_t **);
 600 extern uint64_t zvol_volsize_to_reservation(uint64_t, nvlist_t *);
 601 
 602 typedef int (*zfs_userspace_cb_t)(void *arg, const char *domain,
 603     uid_t rid, uint64_t space);
 604 
 605 extern int zfs_userspace(zfs_handle_t *, zfs_userquota_prop_t,
 606     zfs_userspace_cb_t, void *);
 607 
 608 extern int zfs_get_fsacl(zfs_handle_t *, nvlist_t **);
 609 extern int zfs_set_fsacl(zfs_handle_t *, boolean_t, nvlist_t *);
 610 
 611 typedef struct recvflags {
 612         /* print informational messages (ie, -v was specified) */
 613         boolean_t verbose;
 614 
 615         /* the destination is a prefix, not the exact fs (ie, -d) */
 616         boolean_t isprefix;
 617 




 578         boolean_t props;
 579 
 580         /* do not send (no-op, ie. -n) */
 581         boolean_t dryrun;
 582 
 583         /* parsable verbose output (ie. -P) */
 584         boolean_t parsable;
 585 
 586         /* show progress (ie. -v) */
 587         boolean_t progress;
 588 } sendflags_t;
 589 
 590 typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, void *);
 591 
 592 extern int zfs_send(zfs_handle_t *, const char *, const char *,
 593     sendflags_t *, int, snapfilter_cb_t, void *, nvlist_t **);
 594 
 595 extern int zfs_promote(zfs_handle_t *);
 596 extern int zfs_hold(zfs_handle_t *, const char *, const char *,
 597     boolean_t, boolean_t, int);
 598 extern int zfs_hold_add(zfs_handle_t *, const char *, const char *,
 599     boolean_t, nvlist_t *);
 600 extern int zfs_hold_apply(zfs_handle_t *, boolean_t, int, nvlist_t *);
 601 extern int zfs_release(zfs_handle_t *, const char *, const char *, boolean_t);
 602 extern int zfs_get_holds(zfs_handle_t *, nvlist_t **);
 603 extern uint64_t zvol_volsize_to_reservation(uint64_t, nvlist_t *);
 604 
 605 typedef int (*zfs_userspace_cb_t)(void *arg, const char *domain,
 606     uid_t rid, uint64_t space);
 607 
 608 extern int zfs_userspace(zfs_handle_t *, zfs_userquota_prop_t,
 609     zfs_userspace_cb_t, void *);
 610 
 611 extern int zfs_get_fsacl(zfs_handle_t *, nvlist_t **);
 612 extern int zfs_set_fsacl(zfs_handle_t *, boolean_t, nvlist_t *);
 613 
 614 typedef struct recvflags {
 615         /* print informational messages (ie, -v was specified) */
 616         boolean_t verbose;
 617 
 618         /* the destination is a prefix, not the exact fs (ie, -d) */
 619         boolean_t isprefix;
 620