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

Relax (ref)reservation constraints on ZVOLs #6610

Merged
merged 1 commit into from
Sep 12, 2017

Conversation

loli10K
Copy link
Contributor

@loli10K loli10K commented Sep 6, 2017

Description

This change allow refreservation to be set larger than the current ZVOL size: this should be safe as we normally set refreservation > volsize at ZVOL creation time when we account for metadata.

Motivation and Context

Fix #2468

How Has This Been Tested?

root@linux:/usr/src/zfs# # setup
root@linux:/usr/src/zfs# POOLNAME='testpool'
root@linux:/usr/src/zfs# if is_linux; then
>    TMPDIR='/dev/shm'
>    mountpoint -q $TMPDIR || mount -t tmpfs tmpfs $TMPDIR
>    zpool destroy $POOLNAME
>    fallocate -l 128m $TMPDIR/zpool.dat
>    zpool create $POOLNAME $TMPDIR/zpool.dat
> else
>    TMPDIR='/tmp'
>    zpool destroy $POOLNAME
>    mkfile 128m $TMPDIR/zpool.dat
>    zpool create $POOLNAME $TMPDIR/zpool.dat
> fi
cannot open 'testpool': no such pool
root@linux:/usr/src/zfs# #
root@linux:/usr/src/zfs# zfs create $POOLNAME/fs
root@linux:/usr/src/zfs# zfs create -V 10M $POOLNAME/zvol
root@linux:/usr/src/zfs# value=`zfs get -p -o value -H refreservation $POOLNAME/zvol`
root@linux:/usr/src/zfs# zfs set refreservation=none $POOLNAME/zvol
root@linux:/usr/src/zfs# zfs set refreservation=$value $POOLNAME/zvol

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:

  • My code follows the ZFS on Linux code style requirements.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commit messages are properly formatted and contain Signed-off-by.
  • Change has been approved by a ZFS on Linux member.

Copy link
Contributor

@richardelling richardelling left a comment

Choose a reason for hiding this comment

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

KISS

@@ -1459,7 +1459,6 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,

switch (prop) {
case ZFS_PROP_RESERVATION:
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole case should go, reservations make even less sense than refreservations here.

@@ -151,7 +151,8 @@ tests = ['zfs_rename_001_pos', 'zfs_rename_002_pos', 'zfs_rename_003_pos',
'zfs_rename_to_encrypted']

[tests/functional/cli_root/zfs_reservation]
tests = ['zfs_reservation_001_pos', 'zfs_reservation_002_pos']
tests = ['zfs_reservation_001_pos', 'zfs_reservation_002_pos',
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to add a new test file.
In refreserv_005_pos.ksh remove the tests for "# Verify it is affected by volsize" and if you want to add a bigger than test, do it there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is refreserv_005_pos.ksh even working properly? I don't understand why it tries to zfs set refreservation=- testpool/testfs/vol, does "-" have a different meaning on Illumos? On ZoL it will always fail with the following error: cannot set property for 'testpool/testfs/vol': bad numeric value '-'

source:

log_must zfs create -V 10M $vol

# Verify the parent filesystem does not affect volume
log_must zfs set quota=25M $fs
log_must zfs set refreservation=10M $vol
avail=$(get_prop mountpoint $vol)
log_mustnot zfs set refreservation=$avail $vol

log:

ASSERTION: Volume (ref)reservation is not limited by volsize
SUCCESS: zfs create -V 10M testpool/testfs/vol
SUCCESS: zfs set quota=25M testpool/testfs
SUCCESS: zfs set refreservation=10M testpool/testfs/vol
SUCCESS: zfs set refreservation=- testpool/testfs/vol exited 1

Copy link
Contributor

Choose a reason for hiding this comment

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

great question! '-' is the response for "not set" and mountpoint is not appropriate for size or volumes. Methinks this should be more like:

avail=$(get_prop available $vol)

thus avail is the total space available in the pool, which we'll presume is always > the quota on the file system. In reality we just need to test if the refreservation is > the quota, which we set previously. A lazy way would be:

log_must zfs set quota=25M $fs
log_must zfs set refreservation=26M $vol

but this test is kinda silly, too and knowing the code, this test should only fail if we don't have the available space (which quota doesn't need to know)

methinks a simple test to set refreservation less than and greater than the initial estimate thusly:

initial=$(zfs get -p -H -o value refreservation $vol)
log_must zfs set refreservation=$((initial + 1)) $vol
log_must zfs set refreservation=$((initial - 1)) $vol

NB, get_prop returns the pretty value, not easy to do math against

@loli10K loli10K added the Status: Work in Progress Not yet ready for general review label Sep 8, 2017
@loli10K loli10K force-pushed the issue-2468 branch 2 times, most recently from 8ff5933 to 502fed8 Compare September 10, 2017 14:18
@loli10K loli10K removed the Status: Work in Progress Not yet ready for general review label Sep 10, 2017
@loli10K loli10K changed the title Relax refreservation constraints on ZVOLs Relax (ref)reservation constraints on ZVOLs Sep 10, 2017
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.

Looks good. I was going to suggest updating the zfs.8 man page, but after reading the relevant sections I see that they make no mention of this specific case. Which is fine.

@richardelling could you please review and updated patch again and go ahead approve it if you're happy with it.

@@ -44,7 +44,7 @@ verify_runnable "both"

function cleanup
{
log_must zpool export $TESTPOOL
log_must_busy zpool export $TESTPOOL
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to include this in the PR? It looks like a fix for the occasional zfs_mount_remount failures we see under Fedora 26 (which I'm all for fixing).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes: i've seen it failing quite a lot on f26 and that seems to fix it. I tried to sneak it in even if it has nothing to do with the main issue.

Since now we have other recent issues reported on the ZTS (#6627) i'm ok with dropping this here and push it in a "ZTS-only fixes" PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. Yeah, let's drop it from this PR and make the fix in the context of #6627.

@behlendorf behlendorf requested a review from ahrens September 11, 2017 19:28
This change allow (ref)reservation to be set larger than the current
ZVOL size: this is safe as we normally set refreservation > volsize
at ZVOL creation time when we account for metadata.

Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
@richardelling
Copy link
Contributor

Looks good, thanks!

@behlendorf behlendorf merged commit ded8f06 into openzfs:master Sep 12, 2017
@loli10K loli10K deleted the issue-2468 branch September 17, 2017 10:37
@loli10K loli10K restored the issue-2468 branch November 1, 2018 15:40
FransUrbo pushed a commit to FransUrbo/zfs that referenced this pull request Apr 28, 2019
This change allow (ref)reservation to be set larger than the current
ZVOL size: this is safe as we normally set refreservation > volsize
at ZVOL creation time when we account for metadata.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes openzfs#2468 
Closes openzfs#6610
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

It's not possible to set refreservation larger than volsize for zvol.
5 participants