Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -u option to 'zfs create' #11254

Merged
merged 1 commit into from
Dec 4, 2020
Merged

Conversation

ghost
Copy link

@ghost ghost commented Nov 30, 2020

Motivation and Context

This was reported as a feature lost in FreeBSD with the switch to OpenZFS.

Description

Add -u option to 'zfs create' that prevents file system from being
automatically mounted. This is similar to the 'zfs receive -u'.

How Has This Been Tested?

This has been in FreeBSD since 2012. ZTS results pending.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist:

Copy link
Contributor

@allanjude allanjude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed By: Allan Jude [email protected]

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Nov 30, 2020
Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include a simple cli_root/zfs_create/ test for this.

@@ -1105,6 +1111,11 @@ zfs_do_create(int argc, char **argv)
"used when creating a volume\n"));
goto badusage;
}
if (nomount && type != ZFS_TYPE_FILESYSTEM) {
(void) fprintf(stderr, gettext("'-u' can only be "
"used when creating a file system\n"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It looks like all but a few of the error message use "filesystem" instead of "file system".

@@ -1265,7 +1276,8 @@ zfs_do_create(int argc, char **argv)
log_history = B_FALSE;
}

ret = zfs_mount_and_share(g_zfs, argv[0], ZFS_TYPE_DATASET);
if (!nomount)
ret = zfs_mount_and_share(g_zfs, argv[0], ZFS_TYPE_DATASET);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipping the zfs_mount_and_share here looks like it will incorrectly leave the return value ret as 1.

@ghost ghost force-pushed the create-o branch 2 times, most recently from df56ff5 to ea92198 Compare December 1, 2020 16:23
@ghost
Copy link
Author

ghost commented Dec 1, 2020

  • s/file system/filesystem/ in error message
  • Set ret=0 if nomount
  • Add a test

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) Status: Work in Progress Not yet ready for general review and removed Status: Code Review Needed Ready for review and testing Status: Accepted Ready to integrate (reviewed, tested) labels Dec 1, 2020
@behlendorf
Copy link
Contributor

It seems there's some trouble with the new test:

Test: /usr/share/zfs/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_nomount (run as root) [00:00] [FAIL]
17:25:22.45 ASSERTION: zfs create -u leaves the new file system unmounted
17:25:22.47 SUCCESS: zfs create -u testpool/testfs1
17:25:22.47 SUCCESS: create_dataset testpool/testfs1 -u
17:25:22.48 SUCCESS: ismounted testpool/testfs1 exited 1
17:25:22.49 ERROR: zfs create -V 150m -u testpool/testvol1 exited 2

Add -u option to 'zfs create' that prevents file system from being
automatically mounted. This is similar to the 'zfs receive -u'.

Authored by: pjd <[email protected]>
FreeBSD-commit: freebsd/freebsd-src@35c5823
Ported-by: Ryan Moeller <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
@ghost ghost force-pushed the create-o branch from ea92198 to 90e8d4f Compare December 2, 2020 17:37
@ghost ghost added Status: Code Review Needed Ready for review and testing and removed Status: Work in Progress Not yet ready for general review labels Dec 3, 2020
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Dec 3, 2020
@behlendorf behlendorf merged commit 4b6e2a5 into openzfs:master Dec 4, 2020
@ghost ghost deleted the create-o branch December 4, 2020 22:10
ghost pushed a commit to zfsonfreebsd/ZoF that referenced this pull request Dec 23, 2020
Add -u option to 'zfs create' that prevents file system from being
automatically mounted. This is similar to the 'zfs receive -u'.

Authored by: pjd <[email protected]>
FreeBSD-commit: freebsd/freebsd-src@35c5823

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Allan Jude <[email protected]>
Ported-by: Ryan Moeller <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#11254
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
Add -u option to 'zfs create' that prevents file system from being
automatically mounted. This is similar to the 'zfs receive -u'.

Authored by: pjd <[email protected]>
FreeBSD-commit: freebsd/freebsd-src@35c5823

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Allan Jude <[email protected]>
Ported-by: Ryan Moeller <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#11254
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
Add -u option to 'zfs create' that prevents file system from being
automatically mounted. This is similar to the 'zfs receive -u'.

Authored by: pjd <[email protected]>
FreeBSD-commit: freebsd/freebsd-src@35c5823

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Allan Jude <[email protected]>
Ported-by: Ryan Moeller <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#11254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants