Implement bookmark copying
authorChristian Schwarz <me@cschwarz.com>
Mon, 11 Nov 2019 07:24:14 +0000 (23:24 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 11 Feb 2020 21:19:12 +0000 (13:19 -0800)
commita73f361fdb2c0a7778e70b482e316054fc2d8630
tree094642f07952d4149c2dab358a35910961d0c42e
parent7b49bbc8164a8a5cd31cf1ba7a6cd88269fec8d0
Implement bookmark copying

This feature allows copying existing bookmarks using

    zfs bookmark fs#target fs#newbookmark

There are some niche use cases for such functionality,
e.g. when using bookmarks as markers for replication progress.

Copying redaction bookmarks produces a normal bookmark that
cannot be used for redacted send (we are not duplicating
the redaction object).

ZCP support for bookmarking (both creation and copying) will be
implemented in a separate patch based on this work.

Overview:

- Terminology:
    - source = existing snapshot or bookmark
    - new/bmark = new bookmark
- Implement bookmark copying in `dsl_bookmark.c`
  - create new bookmark node
  - copy source's `zbn_phys` to new's `zbn_phys`
  - zero-out redaction object id in copy
- Extend existing bookmark ioctl nvlist schema to accept
  bookmarks as sources
  - => `dsl_bookmark_create_nvl_validate` is authoritative
- use `dsl_dataset_is_before` check for both snapshot
  and bookmark sources
- Adjust CLI
  - refactor shortname expansion logic in `zfs_do_bookmark`
- Update man pages
  - warn about redaction bookmark handling
- Add test cases
  - CLI
  - pyyzfs libzfs_core bindings

Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Christian Schwarz <me@cschwarz.com>
Closes #9571
19 files changed:
cmd/zfs/zfs_main.c
contrib/pyzfs/libzfs_core/_constants.py
contrib/pyzfs/libzfs_core/_error_translation.py
contrib/pyzfs/libzfs_core/_libzfs_core.py
contrib/pyzfs/libzfs_core/exceptions.py
contrib/pyzfs/libzfs_core/test/test_libzfs_core.py
include/sys/dsl_bookmark.h
include/sys/fs/zfs.h
include/zfs_namecheck.h
lib/libzfs_core/libzfs_core.c
man/man8/zfs-bookmark.8
man/man8/zfs.8
module/zcommon/zfs_namecheck.c
module/zfs/dsl_bookmark.c
module/zfs/zfs_ioctl.c
tests/runfiles/common.run
tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/cleanup.ksh
tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/setup.ksh
tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh