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

Allow for '-o feature@<feature>=disable' on the command line. #3465

Closed
wants to merge 1 commit into from

Conversation

FransUrbo
Copy link
Contributor

Sometimes it is desired to specifically disable or enable a feature directly on the 'zpool create' command line.

If a disable have been specified, the default for all not mentioned features is 'enabled'.

If a enable have been specified, the default for all the not mentioned features is 'disabled'.

Signed-off-by: Turbo Fredriksson turbo@bayour.com
Closes #3460

@FransUrbo
Copy link
Contributor Author

Note that this still contains debugging output and fails the cstyle. But input on it should be possible.

@FransUrbo FransUrbo force-pushed the explicit_feature_disable branch 3 times, most recently from d4388b7 to a007aa3 Compare June 2, 2015 19:40
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.

This change needs to be rebased on master, have the man pages updated, and a test case added to ensure it's behaving as designed. That will make it much easier to review and get a feel for the proposed command line interface.

@FransUrbo
Copy link
Contributor Author

Apparently the test cases already exists:

tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_001_pos.ksh:

log_assert "'zpool create' creates pools with all features enabled"

log_must $ZPOOL create -f $TESTPOOL $DISKS
check_features
log_must $ZPOOL destroy -f $TESTPOOL

log_must $ZPOOL create -f -o feature@async_destroy=enabled $TESTPOOL $DISKS
check_features

log_pass "'zpool create' creates pools with all features enabled"

I'm going to setup a couple of test machines to try this, but do these tests run cleanly/successfully now?

@behlendorf
Copy link
Contributor

All 4 of the zpool_create_features test cases do regularly pass, here's a link to a recent PR rebased on master. It looks like you'd still want to add a zpool_create_features_005_pos which verifies the more flexible syntax works.

@FransUrbo
Copy link
Contributor Author

Ok, so if this works already, then maybe we don't need this PR?

@behlendorf
Copy link
Contributor

The test case zpool_create_features_004_neg.ksh explicitly verifies that the only syntax that works is feature@async_destroy=enabled. Both feature@async_destroy=disabled and feature@async_destroy=active are expected to fail. I'm OK with dropping this but I thought you wanted to support the feature@async_destroy=disabled syntax.

@FransUrbo
Copy link
Contributor Author

Ah, right. Is that something we want? I find it kind'a useful, but I create pools so seldom, I haven't used it (this functionality) in a long time..

@behlendorf
Copy link
Contributor

It could prove handy particularly as we accumulate more features but it's definitely not crucial.

Unless you're excited to dive in to implement this I suggest we close it for now. We can always revisit implementation this when it's really needed or someone wants to work on it.

@FransUrbo
Copy link
Contributor Author

No, that's ok. The code is there, I just need to create the test cases for it.

@FransUrbo
Copy link
Contributor Author

Is there a way to, programmatically, discover what features are available? So that I don't have to hard code them in the test script(s)..

I found a couple of ways to do it, but they all require an existing pool to query (zpool get all | grep 'feature@' | while read line; do set -- $(echo "${line}"); echo "${2}"; done | sort | uniq), but I don't think I can expect an existing pool - that's what I'm [about to] create!

@FransUrbo
Copy link
Contributor Author

FransUrbo commented Sep 21, 2016

I'm looking over the other script, and I think this will break zpool_create_features_001_pos.ksh. It assumes that when using -o feature@async_destroy=enabled, all features will still be in the enabled state (i.e., it's supposed to be a no-op). But with this PR, they will be disabled!

@behlendorf
Copy link
Contributor

Is there a way to, programmatically, discover what features are available?

Aside from the method you described there isn't an easy way to do this. Although in this case I don't think it's necessary, it would be OK to just use a couple existing features to validate it's behaving as desired. It would be ideal to verify them all but even verifying a handful provides decent test coverage.

-o feature@async_destroy=enabled, all features will still be in the enabled state (i.e., it's supposed to be a no-op). But with this PR, they will be disabled!

I think this can be done without breaking any of the existing test cases. And that's critical because we can't break existing scripts which depend on the current behavior. This PR just needs to extend that logic.

Speaking for myself I would expect this patch to simply allow disabled to be a valid option. Specifying a value of enabled or disabled would simply act as an override to the default behavior. Which is by default all features are enabled unless -d in specified in which case all features are disabled.

Here are a few concrete examples:

# ONLY large_block enabled (this works today)
$ zpool create -d -o feature@large_blocks=enabled mypool
# All features EXCEPT large_blocks are enabled (this doesn't work today)
$ zpool create -o feature@large_blocks=disabled mypool

@FransUrbo did you have something different in mind? @DeHackEd would this be inline with your expectations?

@DeHackEd
Copy link
Contributor

I tend to agree with @behlendorf, the best way to do this is to only disable all features if -d is specified. Maybe print a warning for using feature@something=enabled without using -d would be an idea to prevent people from making mistakes - in that situation it's a brand new pool and it can be quickly destroyed and recreated from your shell history.

@FransUrbo
Copy link
Contributor Author

On Sep 21, 2016, at 8:34 PM, Brian Behlendorf wrote:

# All features EXCEPT large_blocks are enabled (this doesn't work today)
$ zpool create -o feature@large_blocks=disabled mypool

@FransUrbo did you have something different in mind? @DeHackEd would this be inline with your expectations?

Initially I had, but this actually makes more sense. I'll rework the patch and finish the test script (which would be much simpler this way) as soon as I can.

@FransUrbo
Copy link
Contributor Author

I'm struggling with trying to test a specific feature as disabled and all others enabled.

How does this look:

function check_features
{
    feature="${1}"
    feature_set=false
    other_feature_set=false

    ${ZPOOL} get all ${TESTPOOL} | \
        grep feature@ | \
        while read line; do
            set -- $(echo "${line}")

            if [[ "${3}" == "enabled" || "${3}" == "active" ]]; then
                if [[ "feature@${feature}" == "${2}" ]]; then
                    feature_set=true
                else
                    other_feature_set=true
                fi
            fi
        done

    if [[ "${feature_set}" == "true" ]]; then
        # This is a success                                                                                                                                                          
        if [[ "${other_feature_set}" == "true" ]]; then
            # .. but if _any_ of the other features is enabled,                                                                                                                         
            # it's a failure!                                                                                                                                                        
            return 0
        else
            # All good - feature is enabled, all other disabled                                                                                                                      
            return 1
        fi
    else
        # Feature is not set - failure.                                                                                                                                              
        return 1
    fi
}

Then something like this to run the tests:

for feature in async_destroy bookmarks embedded_data empty_bpobj enabled_txg \
               extensible_dataset filesystem_limits hole_birth large_blocks  \
               lz4_compress spacemap_histogram
do
        log_assert "'zpool create' creates pools with ${feature} disabled"

        log_must $ZPOOL create -f -o "feature@${feature}=disabled" $TESTPOOL $DISKS
        check_features ${feature}
        log_must $ZPOOL destroy -f $TESTPOOL

        log_pass "'zpool create' creates pools with ${feature} disabled"
done

@FransUrbo
Copy link
Contributor Author

Updated the PR. Need to test these new changes.

@FransUrbo
Copy link
Contributor Author

Seems to be working just fine:

DebianZFS-Jessie64-Devel-Daily:/usr/src# zpool create -f -o feature@async_destroy=disabled test /dev/sd[bc]
DebianZFS-Jessie64-Devel-Daily:/usr/src# zpool get all test | grep @
test  feature@async_destroy       disabled                    local
test  feature@empty_bpobj         enabled                     local
test  feature@lz4_compress        active                      local
test  feature@spacemap_histogram  active                      local
test  feature@enabled_txg         active                      local
test  feature@hole_birth          active                      local
test  feature@extensible_dataset  enabled                     local
test  feature@embedded_data       active                      local
test  feature@bookmarks           enabled                     local
test  feature@filesystem_limits   enabled                     local
test  feature@large_blocks        enabled                     local
test  feature@large_dnode         enabled                     local
DebianZFS-Jessie64-Devel-Daily:/usr/src# zpool destroy test
DebianZFS-Jessie64-Devel-Daily:/usr/src# zpool create -f -o feature@spacemap_histogram=disabled test /dev/sd[bc]
DebianZFS-Jessie64-Devel-Daily:/usr/src# zpool get all test | grep @
test  feature@async_destroy       enabled                     local
test  feature@empty_bpobj         enabled                     local
test  feature@lz4_compress        active                      local
test  feature@spacemap_histogram  disabled                    local
test  feature@enabled_txg         active                      local
test  feature@hole_birth          active                      local
test  feature@extensible_dataset  enabled                     local
test  feature@embedded_data       active                      local
test  feature@bookmarks           enabled                     local
test  feature@filesystem_limits   enabled                     local
test  feature@large_blocks        enabled                     local
test  feature@large_dnode         enabled                     local
DebianZFS-Jessie64-Devel-Daily:/usr/src# zpool destroy test
DebianZFS-Jessie64-Devel-Daily:/usr/src# zpool create -f -o feature@large_blocks=disabled test /dev/sd[bc]
DebianZFS-Jessie64-Devel-Daily:/usr/src# zpool get all test | grep @
test  feature@async_destroy       enabled                     local
test  feature@empty_bpobj         enabled                     local
test  feature@lz4_compress        active                      local
test  feature@spacemap_histogram  active                      local
test  feature@enabled_txg         active                      local
test  feature@hole_birth          active                      local
test  feature@extensible_dataset  enabled                     local
test  feature@embedded_data       active                      local
test  feature@bookmarks           enabled                     local
test  feature@filesystem_limits   enabled                     local
test  feature@large_blocks        disabled                    local
test  feature@large_dnode         enabled                     local

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.

The existing test cases are failing because all the features are not enabled for the following command.

$ sudo ./cmd/zpool/zpool create -f -o feature@async_destroy=enabled tank vdb
$ sudo ./cmd/zpool/zpool get all tank | grep feature
tank  feature@async_destroy       disabled                    local
tank  feature@empty_bpobj         disabled                    local
tank  feature@lz4_compress        disabled                    local
tank  feature@spacemap_histogram  disabled                    local
tank  feature@enabled_txg         disabled                    local
tank  feature@hole_birth          disabled                    local
tank  feature@extensible_dataset  disabled                    local
tank  feature@embedded_data       disabled                    local
tank  feature@bookmarks           disabled                    local
tank  feature@filesystem_limits   disabled                    local
tank  feature@large_blocks        disabled                    local
tank  feature@large_dnode         disabled                    local

@@ -1,4 +1,4 @@
'\" te
n'\" te
Copy link
Contributor

Choose a reason for hiding this comment

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

Stray 'n' character.

{
feature="${1}"
feature_set=false
other_feature_set=false
Copy link
Contributor

Choose a reason for hiding this comment

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

The scripts use the same formatting as the C. Tabs for indents and continued lines indented by 4 spaces.

@behlendorf behlendorf added Type: Feature Feature request or new feature Status: Work in Progress Not yet ready for general review labels Oct 7, 2016
Sometimes it is desired to specifically disable a feature
directly on the 'zpool create' command line.

Signed-off-by: Turbo Fredriksson turbo@bayour.com
Closes openzfs#3460, openzfs#5142
@FransUrbo
Copy link
Contributor Author

I've been looking at the code for hours now, and I'm at a complete loss! I can't for the life of me remember what I was thinking/planning..

If someone have time/interest in taking a gander, I'd appreciate it.

@loli10K
Copy link
Contributor

loli10K commented Oct 22, 2016

If someone have time/interest in taking a gander, I'd appreciate it.

I may have cracked this, but can i even push my code in this PR or do i have to open a new one?

@rlaager
Copy link
Member

rlaager commented Oct 22, 2016

@loli10K Open a new one.

@behlendorf
Copy link
Contributor

Superseded by #5324.

@behlendorf behlendorf closed this Oct 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Work in Progress Not yet ready for general review Type: Feature Feature request or new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zpool create -o feature@[...]=disabled isn't accepted
5 participants