Repository navigation
Initialize vr_last_txg for rebuild - #18482
Merged
Merged
Conversation
Only call txg_wait_synced() when rebuild IOs were issued for this metaslab. This is a small optimization since in practice the first metaslab is very likely to have allocations and cause vr_last_txg to be initialized. After this point when processing empty metaslabs txg_wait_synced() is called but with an already committed txg so it will not wait. Still it's better not to call txg_wait_synced() at all when it's not needed. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
amotin
approved these changes
May 1, 2026
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR aims to avoid unnecessary txg_wait_synced() calls during vdev rebuild by only waiting when rebuild I/Os have actually set vr_last_txg.
Changes:
- Initialize
vr_last_txgto0when starting the rebuild thread. - Guard
txg_wait_synced()so it’s only called whenvr_last_txghas been set.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4 of 14 tasks
andriytk
approved these changes
May 1, 2026
tonyhutter
pushed a commit
to tonyhutter/zfs
that referenced
this pull request
May 4, 2026
Only call txg_wait_synced() when rebuild IOs were issued for this metaslab. This is a small optimization since in practice the first metaslab is very likely to have allocations and cause vr_last_txg to be initialized. After this point when processing empty metaslabs txg_wait_synced() is called but with an already committed txg so it will not wait. Still it's better not to call txg_wait_synced() at all when it's not needed. Reviewed-by: Andriy Tkachuk <atkachuk@wasabi.com> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#18482
tonyhutter
pushed a commit
to tonyhutter/zfs
that referenced
this pull request
May 4, 2026
Only call txg_wait_synced() when rebuild IOs were issued for this metaslab. This is a small optimization since in practice the first metaslab is very likely to have allocations and cause vr_last_txg to be initialized. After this point when processing empty metaslabs txg_wait_synced() is called but with an already committed txg so it will not wait. Still it's better not to call txg_wait_synced() at all when it's not needed. Reviewed-by: Andriy Tkachuk <atkachuk@wasabi.com> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#18482
tonyhutter
pushed a commit
to tonyhutter/zfs
that referenced
this pull request
May 6, 2026
Only call txg_wait_synced() when rebuild IOs were issued for this metaslab. This is a small optimization since in practice the first metaslab is very likely to have allocations and cause vr_last_txg to be initialized. After this point when processing empty metaslabs txg_wait_synced() is called but with an already committed txg so it will not wait. Still it's better not to call txg_wait_synced() at all when it's not needed. Reviewed-by: Andriy Tkachuk <atkachuk@wasabi.com> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#18482
kithrup
pushed a commit
to KlaraSystems/zfs
that referenced
this pull request
May 7, 2026
Only call txg_wait_synced() when rebuild IOs were issued for this metaslab. This is a small optimization since in practice the first metaslab is very likely to have allocations and cause vr_last_txg to be initialized. After this point when processing empty metaslabs txg_wait_synced() is called but with an already committed txg so it will not wait. Still it's better not to call txg_wait_synced() at all when it's not needed. Reviewed-by: Andriy Tkachuk <atkachuk@wasabi.com> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#18482
Gality369
pushed a commit
to Gality369/zfs
that referenced
this pull request
May 12, 2026
Only call txg_wait_synced() when rebuild IOs were issued for this metaslab. This is a small optimization since in practice the first metaslab is very likely to have allocations and cause vr_last_txg to be initialized. After this point when processing empty metaslabs txg_wait_synced() is called but with an already committed txg so it will not wait. Still it's better not to call txg_wait_synced() at all when it's not needed. Reviewed-by: Andriy Tkachuk <atkachuk@wasabi.com> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#18482
lundman
pushed a commit
to openzfsonosx/openzfs-fork
that referenced
this pull request
Jul 30, 2026
Only call txg_wait_synced() when rebuild IOs were issued for this metaslab. This is a small optimization since in practice the first metaslab is very likely to have allocations and cause vr_last_txg to be initialized. After this point when processing empty metaslabs txg_wait_synced() is called but with an already committed txg so it will not wait. Still it's better not to call txg_wait_synced() at all when it's not needed. Reviewed-by: Andriy Tkachuk <atkachuk@wasabi.com> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#18482
pull Bot
pushed a commit
to A-Archives-and-Forks/openzfs
that referenced
this pull request
Sep 26, 2026
Only call txg_wait_synced() when rebuild IOs were issued for this metaslab. This is a small optimization since in practice the first metaslab is very likely to have allocations and cause vr_last_txg to be initialized. After this point when processing empty metaslabs txg_wait_synced() is called but with an already committed txg so it will not wait. Still it's better not to call txg_wait_synced() at all when it's not needed. Reviewed-by: Andriy Tkachuk <atkachuk@wasabi.com> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#18482
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation and Context
Minor optimization as a followup to #18473.
Description
Only call txg_wait_synced() when rebuild IOs were issued for this metaslab. This is a small optimization since in practice the first metaslab is very likely to have allocations and cause vr_last_txg to be initialized. After this point when processing empty metaslabs txg_wait_synced() is called but with an already committed txg so it will not wait. Still it's better not to call txg_wait_synced() at all when it's not needed.
How Has This Been Tested?
Compiled, will be tested by the CI along with additional local testing.
Types of changes