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

Expose zpool guids through procfs #68

Merged
merged 1 commit into from
May 18, 2022

Conversation

anodos325
Copy link

There are various places in middleware where we
look up zpool status and guid. Since the guid
is readily available through spa_guid() providing
via procfs is a significant enhancement because
it will reduce allow us to eliminate some frequent
libzfs / py-libzfs calls in favor of just reading
via procfs.

Signed-off-by: Andrew Walker awalker@ixsystems.com

Motivation and Context

Description

How Has This Been Tested?

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)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@anodos325 anodos325 requested a review from a user May 9, 2022 17:10
@anodos325 anodos325 force-pushed the add-guid-to-available-pool-info branch from c95de65 to aa77c28 Compare May 9, 2022 17:33
@anodos325
Copy link
Author

Need to add dealloc. Also appears that pool state not visible on FreeBSD side (possible bug).

@anodos325 anodos325 force-pushed the add-guid-to-available-pool-info branch 2 times, most recently from da5b394 to 657d6e0 Compare May 10, 2022 20:38
@ghost
Copy link

ghost commented May 13, 2022

There is a build error in the CI:

 /tmp/zfs-build-runner-Wj2VMpjj/BUILD/zfs-kmod-2.1.4/_kmod_build_5.13.0-1022-azure/../zfs-2.1.4/module/zfs/spa_stats.c: In function 'spa_guid_data':
/tmp/zfs-build-runner-Wj2VMpjj/BUILD/zfs-kmod-2.1.4/_kmod_build_5.13.0-1022-azure/../zfs-2.1.4/module/zfs/spa_stats.c:826:32: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]
  826 |  (void) snprintf(buf, size, "%lu\n", spa_guid(spa));
      |                              ~~^     ~~~~~~~~~~~~~
      |                                |     |
      |                                |     uint64_t {aka long long unsigned int}
      |                                long unsigned int
      |                              %llu
cc1: all warnings being treated as errors

Linux is a bit weird about this so in ZFS we use %llu and also cast the value to u_longlong_t when printing 64-bit uints.

@ghost
Copy link

ghost commented May 13, 2022

Please sign-off the commit when you update so we can see checkstyle pass, too.

@anodos325 anodos325 force-pushed the add-guid-to-available-pool-info branch from 657d6e0 to 439ee9c Compare May 16, 2022 14:18
There are times when end-users may wish to have
a fast and convenient method to get zpool guid
without having to use libzfs. This commit
exposes the zpool guid via kstats in similar
manner to the zpool state.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Andrew Walker <awalker@ixsystems.com>
Closes openzfs#13466
@anodos325 anodos325 force-pushed the add-guid-to-available-pool-info branch from 439ee9c to cf4deb4 Compare May 18, 2022 17:57
@anodos325 anodos325 merged commit 8e27c97 into truenas/zfs-2.1-release May 18, 2022
@anodos325 anodos325 deleted the add-guid-to-available-pool-info branch May 18, 2022 18:53
anodos325 added a commit that referenced this pull request May 18, 2022
There are times when end-users may wish to have
a fast and convenient method to get zpool guid
without having to use libzfs. This commit
exposes the zpool guid via kstats in similar
manner to the zpool state.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Andrew Walker <awalker@ixsystems.com>
Closes openzfs#13466
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.

1 participant