diff mbox series

btrfs: do not require EXTENT_NOWAIT for btrfs_redirty_list_add()

Message ID bd9358f329b4574724250f1c0ba1ef2939f1feaa.1693293259.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: do not require EXTENT_NOWAIT for btrfs_redirty_list_add() | expand

Commit Message

Qu Wenruo Aug. 29, 2023, 7:14 a.m. UTC
The flag EXTENT_NOWAIT is a special flag to notify extent-io-tree code
that this operation should not sleep for the extent state preallocation.

However for btrfs_redirty_list_add(), all callers are able to sleep:

- clean_log_buffer()
  Just 2 lines before, we call btrfs_pin_reserved_extent(), which calls
  pin_down_extent(), and that function does not require EXTENT_NOWAIT.
  Thus we're safe to call it without EXTENT_NOWAIT.

- btrfs_free_tree_block()
  This function have several call sites which trigger tree read, e.g.
  walk_up_proc(), thus we're safe to call it without EXTENT_NOWAIT.

Thus there is no need to require EXTENT_NOWAIT flag.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/zoned.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba Sept. 5, 2023, 1:29 p.m. UTC | #1
On Tue, Aug 29, 2023 at 03:14:25PM +0800, Qu Wenruo wrote:
> The flag EXTENT_NOWAIT is a special flag to notify extent-io-tree code
> that this operation should not sleep for the extent state preallocation.
> 
> However for btrfs_redirty_list_add(), all callers are able to sleep:
> 
> - clean_log_buffer()
>   Just 2 lines before, we call btrfs_pin_reserved_extent(), which calls
>   pin_down_extent(), and that function does not require EXTENT_NOWAIT.
>   Thus we're safe to call it without EXTENT_NOWAIT.
> 
> - btrfs_free_tree_block()
>   This function have several call sites which trigger tree read, e.g.
>   walk_up_proc(), thus we're safe to call it without EXTENT_NOWAIT.
> 
> Thus there is no need to require EXTENT_NOWAIT flag.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Added to misc-next, thanks. I did some research if we need the
EXTENT_NOWAIT at all, it's obscured by a lot of code refactoring but
it's still needed due to

add_extent_mapping
  extent_map_device_set_bits

done under extent_map_tree::lock (rwlock_t), added in 1c11b63eff2a
("btrfs: replace pending/pinned chunks lists with io tree").
diff mbox series

Patch

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 21aad9704026..d42a672539a5 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1609,7 +1609,7 @@  void btrfs_redirty_list_add(struct btrfs_transaction *trans,
 	set_bit(EXTENT_BUFFER_NO_CHECK, &eb->bflags);
 	set_extent_buffer_dirty(eb);
 	set_extent_bit(&trans->dirty_pages, eb->start, eb->start + eb->len - 1,
-			EXTENT_DIRTY | EXTENT_NOWAIT, NULL);
+			EXTENT_DIRTY, NULL);
 }
 
 bool btrfs_use_zone_append(struct btrfs_bio *bbio)