Commit ad252c6
btrfs: preallocate extent changeset before acquiring extent_io_tree lock
In btrfs_clear_extent_bit_changeset(), the extent changeset ulist may need
to allocate new nodes. Currently, this can happen while holding the
extent_io_tree->lock spinlock. Although ulist_prealloc() uses GFP_NOFS to
avoid deadlock with filesystem reclaim, it's better to preallocate before
acquiring the spinlock to:
1. Avoid potential allocation failures while holding the lock
2. Be consistent with set_extent_bit() which already preallocates both
extent state and changeset before the spinlock
3. Reduce lock contention by not doing allocations under the lock
Preallocate the changeset ulist node before acquiring the spinlock,
mirroring the pattern used for extent state preallocation.
Signed-off-by: Ting-Chang Hou <tchou@synology.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>1 parent 662114b commit ad252c6
1 file changed
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
663 | 663 | | |
664 | 664 | | |
665 | 665 | | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
666 | 669 | | |
667 | 670 | | |
668 | 671 | | |
| |||
0 commit comments