zfs icon indicating copy to clipboard operation
zfs copied to clipboard

Add support for zpool user properties

Open allanjude opened this issue 4 years ago • 4 comments

zpool set org.freebsd:comment="this is my pool" poolname

Signed-off-by: Allan Jude [email protected]

Motivation and Context

Allow users to create and set arbitrary pool properties, with the same syntax as dataset user properties (a user property is identified by the colon separator, and by convention is formatted org.name:propername)

Description

Allows to set and get user properties on the pool (district from dataset properties on the root dataset)

How Has This Been Tested?

Not very much

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] 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)
  • [ ] Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • [ ] Documentation (a change to man pages or other documentation)

Checklist:

  • [ ] My code follows the OpenZFS code style requirements.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the contributing document.
  • [ ] I have added tests to cover my changes.
  • [ ] I have run the ZFS Test Suite with this change applied.
  • [x] All commit messages are properly formatted and contain Signed-off-by.

allanjude avatar Mar 02 '21 22:03 allanjude

Error:

free(): invalid pointer Aborted

# zpool set org.linux:comment="test pool" test2

# zpool get all test2                          

--- skip

test2  compatibility                  off                            default
test2  org.linux:comment              test pool                      local
test2  feature@async_destroy          enabled                        local

--- skip

test2  feature@draid                  enabled                        local
test2  feature@compress_adaptive      enabled                        local
free(): invalid pointer
Aborted

AndyLavr avatar Mar 03 '21 14:03 AndyLavr

Error:

free(): invalid pointer Aborted

in zpool_expand_proplist() I had:

entry->pl_user_prop = propname;

But later in zprop_free_list() it would free pl_user_prop, which was the middle of the nvlist allocation. Solved by using zfs_strdup() to keep a separate copy of the property name.

allanjude avatar Mar 07 '21 04:03 allanjude

Fixed style

allanjude avatar Mar 07 '21 16:03 allanjude

Mateusz has written the first few tests for this, and cleaned things up.

allanjude avatar Mar 31 '23 16:03 allanjude

The new tests are working correctly now

allanjude avatar Apr 17 '23 20:04 allanjude

Hmm, I pushed the fixes to the https://github.com/allanjude/zfs/tree/zpool_user_props branch but GitHub does not seem to have propagated the changes to this PR... It should be pointing to https://github.com/allanjude/zfs/commit/cf2005833b3b377602dfbe91947cf257cd0627e7 now.

0mp avatar Apr 18 '23 09:04 0mp

@0mp we're resolved the FreeBSD build failure. Can you rebase on the latest commits to master so we can verify this builds cleanly on FreeBSD.

behlendorf avatar Apr 19 '23 18:04 behlendorf

@0mp we're resolved the FreeBSD build failure. Can you rebase on the latest commits to master so we can verify this builds cleanly on FreeBSD.

Rebased!

0mp avatar Apr 20 '23 13:04 0mp

Sorry, it looks like this has some minor conflicts with the recently merged 3e4ed4213d7b4e8892e9def8b06363391d8dbd60. One last rebase is needed, then I'll get it merged.

behlendorf avatar Apr 20 '23 17:04 behlendorf

Sorry, it looks like this has some minor conflicts with the recently merged 3e4ed42. One last rebase is needed, then I'll get it merged.

Hey Brian, I've resolved the conflict, rebased, and pushed the latest version. :)

0mp avatar Apr 21 '23 09:04 0mp