Skip to content

Allow lockless zpool status #17305

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tonyhutter
Copy link
Contributor

Motivation and Context

Allow zpool status to work even when the pool is locked up. This is a reworked version of #17193 that uses an environment variable instead of command line flags.

Description

Add a new ZPOOL_LOCK_BEHAVIOR envvar to control zpool status lock behavior. ZPOOL_LOCK_BEHAVIOR can have one of these values:

lockless: Try for a short amount of time to get the spa_namespace lock. If that doesn't work, then do the zpool status locklessly. This is dangerous and can crash your system if the pools configs are being modified while zpool status is running. This setting requires zpool status to be run as root.

trylock: Try for a short amount of time to get the spa_namespace lock. If that doesn't work then simply abort zpool status.

wait: Wait forever for the lock. This is the default.

These options allow users to view the zpool status when the pool gets stuck while holding the spa_namespace lock.

How Has This Been Tested?

Added test case

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:

@tonyhutter tonyhutter changed the title Disable locks4 Allow lockless zpool status May 6, 2025
Add a new `ZPOOL_LOCK_BEHAVIOR` envvar to control `zpool status` lock
behavior.  `ZPOOL_LOCK_BEHAVIOR` can have one of these values:

"lockless": Try for a short amount of time to get the spa_namespace
lock.  If that doesn't work, then do the zpool status locklessly.  This
is dangerous and can crash your system if the pools configs are being
modified while zpool status is running. This setting requires `zpool
status` to be run as root.

"trylock": Try for a short amount of time to get the spa_namespace
lock.  If that doesn't work then simply abort 'zpool status'.

"wait": Wait forever for the lock.  This is the default.

These options allow users to view the zpool status when the pool
gets stuck while holding the spa_namespace lock.

Signed-off-by: Tony Hutter <[email protected]>
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