Project

General

Profile

Feature #11355

zfs create needs dry-run

Added by Mike Gerdts 3 months ago. Updated 2 months ago.

Status:
New
Priority:
Normal
Assignee:
Category:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:

Description

There are times when we need to know the amount of space that a volume with refreservation=auto will reserve ahead of the volume creation. Forcing the callers to reimplement zvol_volsize_to_reservation() is not reasonable.

Rather than just having a one-off command that calculates this, we could extend zfs create so that it has dry-run, verbose, and parseable options. For example, the first form is intended to be readable by humans and the second form is tab separated parseable output.

# zfs create -b 16k -nvV 1t zones/bigvol
would create zones/bigvol
        volblocksize=16384
        volsize=1099511627776
        refreservation=1116710371328
# zfs create -b 16k -nPV 1t zones/bigvol
create  zones/bigvol
property        volblocksize    16384
property        volsize 1099511627776
property        refreservation  1116710371328

There is an open PR in zfsonlinux where the interface details should be hashed out.

https://github.com/zfsonlinux/zfs/pull/8974

Because of a somewhat urgent need, the functionality requested in this change is already in SmartOS. SmartOS does not advertise the change via the man page or usage messages.

https://github.com/joyent/illumos-joyent/commit/b322ba367cdb75882f1cede5a8b22c7fd17ced94

History

#1

Updated by Mike Gerdts 2 months ago

The illumos fix is an upstream of two fixes in SmartOS:

OS-7867 zfs create needs dry-run
OS-7895 make zfs create dryrun options from OS-7867 public

Those changes missed the new zfs_create_verbose that was added to zfsonlinux. This fix adds that file.

Testing:

- I viewed the zfs man page and confirmed the relevant changes are present.
- The `zfs create` usage statement looks correct
- The dry-run options seem to work
- I ran the zfs_create tests

$ cp /opt/zfs-tests/runfiles/omnios.run .
$ vi omnios.run (remove all tests but those in cli_root/zfs_create)
$ export KEEP=rpool
$ export DISKS="$(iostat -En | grep c0t6 | head -20 | nawk '{printf("%s ", $1)}')" 
$ /opt/zfs-tests/bin/zfstest -c omnios.run
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/setup (run as root) [00:00] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_001_pos (run as root) [00:01] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos (run as root) [00:03] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_003_pos (run as root) [00:01] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_004_pos (run as root) [00:06] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_005_pos (run as root) [00:01] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_006_pos (run as root) [00:02] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_007_pos (run as root) [00:00] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_008_neg (run as root) [00:01] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg (run as root) [00:00] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg (run as root) [00:01] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_011_pos (run as root) [00:01] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos (run as root) [00:01] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_013_pos (run as root) [00:03] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_encrypted (run as root) [00:10] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_crypt_combos (run as root) [00:17] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun (run as root) [00:00] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose (run as root) [00:02] [PASS]
Test: /opt/zfs-tests/tests/functional/cli_root/zfs_create/cleanup (run as root) [00:00] [PASS]

Results Summary
PASS      19

Running Time:    00:00:59
Percent passed:    100.0%
Log directory:    /var/tmp/test_results/20190802T035155

Also available in: Atom PDF