zpool iostat: refresh pool list every interval #17786
Open
+588
−70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[Sponsors: Klara, Inc., Wasabi Technology, Inc.]
Description
When running
zpool iostat
in interval mode, it would not notice any new pools created or imported, and would forget any destroyed or exported, so would not notice if they came back. This leads to outputting "no pools available" every interval until killed.It looks like this was at least intended to work; the comment above
zpool_do_iostat()
indicates that it is expected to "deal with pool creation/destruction" and thatpool_list_update()
would detect new pools. That call however was removed in 3e43edd, though its unclear if that broke this behaviour and it wasn't noticed, or if it never worked, or if something later broke it. That said, the lack ofpool_list_update()
is only part of the reason it doesn't work properly.The fundamental problem is that the various things involved in refreshing or updating the list of pools would aggressively ignore, remove, skip or fail on pools that stop existing, or that already exist. Mostly this meant that once a pool is removed from the list, it will never be seen again. Restoring
pool_list_update()
to thezpool_do_iostat()
loop only partially fixes this - it would find "new" pools again, but only in the "all pools" (no args) mode, and because its iterator callbackadd_pool()
would abort the iterator if it already has a pool listed, it would only add pools if there weren't any already.So, this commit reworks the structure somewhat.
pool_list_update()
becomespool_list_refresh()
, and will ensure the state of all pools in the list are updated. In the "all pools" mode, it will also add new pools and remove pools that disappear, but when a fixed list of pools is used, the list doesn't change, only the state of the pools within it.The rest of the commit is adjusting things for this much simpler structure. Regardless of the mode in use, pool_list_refresh() will always do the right thing, so the driver code can just get on with the display.
Now that pools can appear and disappear, I've made it so the header (if enabled) is re-printed when the list changes, so that its easier to see what's happening if the column widths change.
How Has This Been Tested?
New tests included to confirm the behaviour of both the "all pools" and "list of pools" modes.
Types of changes
Checklist:
Signed-off-by
.