public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/18] Random cleanups for 6.14
@ 2025-01-09 10:23 David Sterba
  2025-01-09 10:23 ` [PATCH 01/18] btrfs: drop unused parameter fs_info to btrfs_delete_delayed_insertion_item() David Sterba
                   ` (19 more replies)
  0 siblings, 20 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Unsorteed small cleanups and renames.

David Sterba (18):
  btrfs: drop unused parameter fs_info to btrfs_delete_delayed_insertion_item()
  btrfs: remove stray comment about SRCU
  btrfs: use SECTOR_SIZE defines in btrfs_issue_discard()
  btrfs: rename __unlock_for_delalloc() and drop underscores
  btrfs: open code set_page_extent_mapped()
  btrfs: rename __get_extent_map() and pass btrfs_inode
  btrfs: use btrfs_inode in extent_writepage()
  btrfs: make wait_on_extent_buffer_writeback() static inline
  btrfs: drop one time used local variable in end_bbio_meta_write()
  btrfs: open code __free_extent_buffer()
  btrfs: rename btrfs_release_extent_buffer_pages() to mention folios
  btrfs: switch grab_extent_buffer() to folios
  btrfs: change return type to bool type of check_eb_alignment()
  btrfs: unwrap folio locking helpers
  btrfs: remove unused define WAIT_PAGE_LOCK for extent io
  btrfs: split waiting from read_extent_buffer_pages(), drop parameter wait
  btrfs: remove redundant variables from __process_folios_contig() and lock_delalloc_folios()
  btrfs: async-thread: rename DFT_THRESHOLD to DEFAULT_THRESHOLD

 fs/btrfs/async-thread.c     |   6 +-
 fs/btrfs/delayed-inode.c    |   5 +-
 fs/btrfs/disk-io.c          |   2 +-
 fs/btrfs/disk-io.h          |   3 -
 fs/btrfs/extent-tree.c      |   4 +-
 fs/btrfs/extent_io.c        | 143 ++++++++++++++++--------------------
 fs/btrfs/extent_io.h        |  16 ++--
 fs/btrfs/free-space-cache.c |   2 +-
 fs/btrfs/relocation.c       |   2 +-
 9 files changed, 84 insertions(+), 99 deletions(-)

-- 
2.47.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 01/18] btrfs: drop unused parameter fs_info to btrfs_delete_delayed_insertion_item()
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
@ 2025-01-09 10:23 ` David Sterba
  2025-01-09 10:24 ` [PATCH 02/18] btrfs: remove stray comment about SRCU David Sterba
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/delayed-inode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index f9f1a972a6f7..0b4933c6a889 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1555,8 +1555,7 @@ int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans,
 	return ret;
 }
 
-static int btrfs_delete_delayed_insertion_item(struct btrfs_fs_info *fs_info,
-					       struct btrfs_delayed_node *node,
+static int btrfs_delete_delayed_insertion_item(struct btrfs_delayed_node *node,
 					       u64 index)
 {
 	struct btrfs_delayed_item *item;
@@ -1614,7 +1613,7 @@ int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,
 	if (IS_ERR(node))
 		return PTR_ERR(node);
 
-	ret = btrfs_delete_delayed_insertion_item(trans->fs_info, node, index);
+	ret = btrfs_delete_delayed_insertion_item(node, index);
 	if (!ret)
 		goto end;
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 02/18] btrfs: remove stray comment about SRCU
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
  2025-01-09 10:23 ` [PATCH 01/18] btrfs: drop unused parameter fs_info to btrfs_delete_delayed_insertion_item() David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 11:00   ` Daniel Vacek
  2025-01-09 10:24 ` [PATCH 03/18] btrfs: use SECTOR_SIZE defines in btrfs_issue_discard() David Sterba
                   ` (17 subsequent siblings)
  19 siblings, 1 reply; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The subvol_sruce was removed in c75e839414d361 ("btrfs: kill the
subvol_srcu") years ago.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/disk-io.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index a7051e2570c1..587842991b24 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -96,9 +96,6 @@ struct btrfs_root *btrfs_alloc_dummy_root(struct btrfs_fs_info *fs_info);
 /*
  * This function is used to grab the root, and avoid it is freed when we
  * access it. But it doesn't ensure that the tree is not dropped.
- *
- * If you want to ensure the whole tree is safe, you should use
- * 	fs_info->subvol_srcu
  */
 static inline struct btrfs_root *btrfs_grab_root(struct btrfs_root *root)
 {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 03/18] btrfs: use SECTOR_SIZE defines in btrfs_issue_discard()
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
  2025-01-09 10:23 ` [PATCH 01/18] btrfs: drop unused parameter fs_info to btrfs_delete_delayed_insertion_item() David Sterba
  2025-01-09 10:24 ` [PATCH 02/18] btrfs: remove stray comment about SRCU David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 04/18] btrfs: rename __unlock_for_delalloc() and drop underscores David Sterba
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Use the existing define for single sector size.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent-tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 1cb1bd45f7ec..3014a1a23efd 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1256,12 +1256,12 @@ static int btrfs_issue_discard(struct block_device *bdev, u64 start, u64 len,
 {
 	int j, ret = 0;
 	u64 bytes_left, end;
-	u64 aligned_start = ALIGN(start, 1 << SECTOR_SHIFT);
+	u64 aligned_start = ALIGN(start, SECTOR_SIZE);
 
 	/* Adjust the range to be aligned to 512B sectors if necessary. */
 	if (start != aligned_start) {
 		len -= aligned_start - start;
-		len = round_down(len, 1 << SECTOR_SHIFT);
+		len = round_down(len, SECTOR_SIZE);
 		start = aligned_start;
 	}
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 04/18] btrfs: rename __unlock_for_delalloc() and drop underscores
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (2 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 03/18] btrfs: use SECTOR_SIZE defines in btrfs_issue_discard() David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 12:07   ` Johannes Thumshirn
  2025-01-09 10:24 ` [PATCH 05/18] btrfs: open code set_page_extent_mapped() David Sterba
                   ` (15 subsequent siblings)
  19 siblings, 1 reply; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Drop the underscores as the naming scheme does not apply here and to
have the unlock for parity with lock_delalloc_folios().

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 9725ff7f274d..8c472560e43e 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -221,7 +221,7 @@ static void __process_folios_contig(struct address_space *mapping,
 	}
 }
 
-static noinline void __unlock_for_delalloc(const struct inode *inode,
+static noinline void unlock_delalloc_folio(const struct inode *inode,
 					   const struct folio *locked_folio,
 					   u64 start, u64 end)
 {
@@ -288,8 +288,7 @@ static noinline int lock_delalloc_folios(struct inode *inode,
 out:
 	folio_batch_release(&fbatch);
 	if (processed_end > start)
-		__unlock_for_delalloc(inode, locked_folio, start,
-				      processed_end);
+		unlock_delalloc_folio(inode, locked_folio, start, processed_end);
 	return -EAGAIN;
 }
 
@@ -390,7 +389,7 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode,
 
 	unlock_extent(tree, delalloc_start, delalloc_end, &cached_state);
 	if (!ret) {
-		__unlock_for_delalloc(inode, locked_folio, delalloc_start,
+		unlock_delalloc_folio(inode, locked_folio, delalloc_start,
 				      delalloc_end);
 		cond_resched();
 		goto again;
@@ -1247,7 +1246,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode,
 			 */
 			unlock_extent(&inode->io_tree, found_start,
 				      found_start + found_len - 1, NULL);
-			__unlock_for_delalloc(&inode->vfs_inode, folio,
+			unlock_delalloc_folio(&inode->vfs_inode, folio,
 					      found_start,
 					      found_start + found_len - 1);
 		}
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 05/18] btrfs: open code set_page_extent_mapped()
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (3 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 04/18] btrfs: rename __unlock_for_delalloc() and drop underscores David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 06/18] btrfs: rename __get_extent_map() and pass btrfs_inode David Sterba
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function set_page_extent_mapped() is now a simple wrapper so use the
folio helper.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c        | 5 -----
 fs/btrfs/extent_io.h        | 1 -
 fs/btrfs/free-space-cache.c | 2 +-
 fs/btrfs/relocation.c       | 2 +-
 4 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 8c472560e43e..39113772241b 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -861,11 +861,6 @@ static int attach_extent_buffer_folio(struct extent_buffer *eb,
 	return ret;
 }
 
-int set_page_extent_mapped(struct page *page)
-{
-	return set_folio_extent_mapped(page_folio(page));
-}
-
 int set_folio_extent_mapped(struct folio *folio)
 {
 	struct btrfs_fs_info *fs_info;
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 8a36117ed453..d14bda928e7b 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -248,7 +248,6 @@ int btree_write_cache_pages(struct address_space *mapping,
 			    struct writeback_control *wbc);
 void btrfs_readahead(struct readahead_control *rac);
 int set_folio_extent_mapped(struct folio *folio);
-int set_page_extent_mapped(struct page *page);
 void clear_folio_extent_mapped(struct folio *folio);
 
 struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 3048cb38dc80..d42b6f882f57 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -461,7 +461,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
 			return -ENOMEM;
 		}
 
-		ret = set_page_extent_mapped(page);
+		ret = set_folio_extent_mapped(page_folio(page));
 		if (ret < 0) {
 			unlock_page(page);
 			put_page(page);
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index d4100e58172f..af0969b70b53 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2870,7 +2870,7 @@ static int relocate_one_folio(struct reloc_control *rc,
 
 	/*
 	 * We could have lost folio private when we dropped the lock to read the
-	 * folio above, make sure we set_page_extent_mapped here so we have any
+	 * folio above, make sure we set_folio_extent_mapped() here so we have any
 	 * of the subpage blocksize stuff we need in place.
 	 */
 	ret = set_folio_extent_mapped(folio);
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 06/18] btrfs: rename __get_extent_map() and pass btrfs_inode
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (4 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 05/18] btrfs: open code set_page_extent_mapped() David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 07/18] btrfs: use btrfs_inode in extent_writepage() David Sterba
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The double underscore naming scheme does not apply here, there's only
only get_extent_map(). As the definition is changed also pass the struct
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 39113772241b..f503735c302c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -895,9 +895,9 @@ void clear_folio_extent_mapped(struct folio *folio)
 	folio_detach_private(folio);
 }
 
-static struct extent_map *__get_extent_map(struct inode *inode,
-					   struct folio *folio, u64 start,
-					   u64 len, struct extent_map **em_cached)
+static struct extent_map *get_extent_map(struct btrfs_inode *inode,
+					 struct folio *folio, u64 start,
+					 u64 len, struct extent_map **em_cached)
 {
 	struct extent_map *em;
 	struct extent_state *cached_state = NULL;
@@ -916,14 +916,14 @@ static struct extent_map *__get_extent_map(struct inode *inode,
 		*em_cached = NULL;
 	}
 
-	btrfs_lock_and_flush_ordered_range(BTRFS_I(inode), start, start + len - 1, &cached_state);
-	em = btrfs_get_extent(BTRFS_I(inode), folio, start, len);
+	btrfs_lock_and_flush_ordered_range(inode, start, start + len - 1, &cached_state);
+	em = btrfs_get_extent(inode, folio, start, len);
 	if (!IS_ERR(em)) {
 		BUG_ON(*em_cached);
 		refcount_inc(&em->refs);
 		*em_cached = em;
 	}
-	unlock_extent(&BTRFS_I(inode)->io_tree, start, start + len - 1, &cached_state);
+	unlock_extent(&inode->io_tree, start, start + len - 1, &cached_state);
 
 	return em;
 }
@@ -979,8 +979,7 @@ static int btrfs_do_readpage(struct folio *folio, struct extent_map **em_cached,
 			end_folio_read(folio, true, cur, iosize);
 			break;
 		}
-		em = __get_extent_map(inode, folio, cur, end - cur + 1,
-				      em_cached);
+		em = get_extent_map(BTRFS_I(inode), folio, cur, end - cur + 1, em_cached);
 		if (IS_ERR(em)) {
 			end_folio_read(folio, false, cur, end + 1 - cur);
 			return PTR_ERR(em);
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 07/18] btrfs: use btrfs_inode in extent_writepage()
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (5 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 06/18] btrfs: rename __get_extent_map() and pass btrfs_inode David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 08/18] btrfs: make wait_on_extent_buffer_writeback() static inline David Sterba
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

As extent_writepage() is internal helper we should use our inode type,
so change it from struct inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index f503735c302c..eca28c99bbc8 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1457,15 +1457,15 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
  */
 static int extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrl)
 {
-	struct inode *inode = folio->mapping->host;
-	struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
+	struct btrfs_inode *inode = BTRFS_I(folio->mapping->host);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	const u64 page_start = folio_pos(folio);
 	int ret;
 	size_t pg_offset;
-	loff_t i_size = i_size_read(inode);
+	loff_t i_size = i_size_read(&inode->vfs_inode);
 	unsigned long end_index = i_size >> PAGE_SHIFT;
 
-	trace_extent_writepage(folio, inode, bio_ctrl->wbc);
+	trace_extent_writepage(folio, &inode->vfs_inode, bio_ctrl->wbc);
 
 	WARN_ON(!folio_test_locked(folio));
 
@@ -1489,13 +1489,13 @@ static int extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrl
 	if (ret < 0)
 		goto done;
 
-	ret = writepage_delalloc(BTRFS_I(inode), folio, bio_ctrl);
+	ret = writepage_delalloc(inode, folio, bio_ctrl);
 	if (ret == 1)
 		return 0;
 	if (ret)
 		goto done;
 
-	ret = extent_writepage_io(BTRFS_I(inode), folio, folio_pos(folio),
+	ret = extent_writepage_io(inode, folio, folio_pos(folio),
 				  PAGE_SIZE, bio_ctrl, i_size);
 	if (ret == 1)
 		return 0;
@@ -1504,7 +1504,7 @@ static int extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrl
 
 done:
 	if (ret) {
-		btrfs_mark_ordered_io_finished(BTRFS_I(inode), folio,
+		btrfs_mark_ordered_io_finished(inode, folio,
 					       page_start, PAGE_SIZE, !ret);
 		mapping_set_error(folio->mapping, ret);
 	}
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 08/18] btrfs: make wait_on_extent_buffer_writeback() static inline
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (6 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 07/18] btrfs: use btrfs_inode in extent_writepage() David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 09/18] btrfs: drop one time used local variable in end_bbio_meta_write() David Sterba
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The simple helper can be inlined, no need for the separate function.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 6 ------
 fs/btrfs/extent_io.h | 7 ++++++-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index eca28c99bbc8..4f71877f9b76 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1518,12 +1518,6 @@ static int extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrl
 	return ret;
 }
 
-void wait_on_extent_buffer_writeback(struct extent_buffer *eb)
-{
-	wait_on_bit_io(&eb->bflags, EXTENT_BUFFER_WRITEBACK,
-		       TASK_UNINTERRUPTIBLE);
-}
-
 /*
  * Lock extent buffer status and pages for writeback.
  *
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index d14bda928e7b..986f15022fef 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -266,7 +266,12 @@ void free_extent_buffer_stale(struct extent_buffer *eb);
 #define WAIT_PAGE_LOCK	2
 int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
 			     const struct btrfs_tree_parent_check *parent_check);
-void wait_on_extent_buffer_writeback(struct extent_buffer *eb);
+static inline void wait_on_extent_buffer_writeback(struct extent_buffer *eb)
+{
+	wait_on_bit_io(&eb->bflags, EXTENT_BUFFER_WRITEBACK,
+		       TASK_UNINTERRUPTIBLE);
+}
+
 void btrfs_readahead_tree_block(struct btrfs_fs_info *fs_info,
 				u64 bytenr, u64 owner_root, u64 gen, int level);
 void btrfs_readahead_node_child(struct extent_buffer *node, int slot);
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 09/18] btrfs: drop one time used local variable in end_bbio_meta_write()
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (7 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 08/18] btrfs: make wait_on_extent_buffer_writeback() static inline David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 10/18] btrfs: open code __free_extent_buffer() David Sterba
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 4f71877f9b76..6466f74bd2bb 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1658,11 +1658,10 @@ static void end_bbio_meta_write(struct btrfs_bio *bbio)
 {
 	struct extent_buffer *eb = bbio->private;
 	struct btrfs_fs_info *fs_info = eb->fs_info;
-	bool uptodate = !bbio->bio.bi_status;
 	struct folio_iter fi;
 	u32 bio_offset = 0;
 
-	if (!uptodate)
+	if (bbio->bio.bi_status != BLK_STS_OK)
 		set_btree_ioerr(eb);
 
 	bio_for_each_folio_all(fi, &bbio->bio) {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 10/18] btrfs: open code __free_extent_buffer()
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (8 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 09/18] btrfs: drop one time used local variable in end_bbio_meta_write() David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 11/18] btrfs: rename btrfs_release_extent_buffer_pages() to mention folios David Sterba
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Using the kmem cache freeing directly is clear enough, we don't need to
wrap it.  All the users are in the same file.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 6466f74bd2bb..1a00a46a681b 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2481,11 +2481,6 @@ bool try_release_extent_mapping(struct folio *folio, gfp_t mask)
 	return try_release_extent_state(io_tree, folio);
 }
 
-static void __free_extent_buffer(struct extent_buffer *eb)
-{
-	kmem_cache_free(extent_buffer_cache, eb);
-}
-
 static int extent_buffer_under_io(const struct extent_buffer *eb)
 {
 	return (test_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags) ||
@@ -2591,7 +2586,7 @@ static inline void btrfs_release_extent_buffer(struct extent_buffer *eb)
 {
 	btrfs_release_extent_buffer_pages(eb);
 	btrfs_leak_debug_del_eb(eb);
-	__free_extent_buffer(eb);
+	kmem_cache_free(extent_buffer_cache, eb);
 }
 
 static struct extent_buffer *
@@ -2689,7 +2684,7 @@ struct extent_buffer *__alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
 			folio_put(eb->folios[i]);
 		}
 	}
-	__free_extent_buffer(eb);
+	kmem_cache_free(extent_buffer_cache, eb);
 	return NULL;
 }
 
@@ -3181,7 +3176,7 @@ static inline void btrfs_release_extent_buffer_rcu(struct rcu_head *head)
 	struct extent_buffer *eb =
 			container_of(head, struct extent_buffer, rcu_head);
 
-	__free_extent_buffer(eb);
+	kmem_cache_free(extent_buffer_cache, eb);
 }
 
 static int release_extent_buffer(struct extent_buffer *eb)
@@ -3209,7 +3204,7 @@ static int release_extent_buffer(struct extent_buffer *eb)
 		btrfs_release_extent_buffer_pages(eb);
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
 		if (unlikely(test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags))) {
-			__free_extent_buffer(eb);
+			kmem_cache_free(extent_buffer_cache, eb);
 			return 1;
 		}
 #endif
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 11/18] btrfs: rename btrfs_release_extent_buffer_pages() to mention folios
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (9 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 10/18] btrfs: open code __free_extent_buffer() David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 12/18] btrfs: switch grab_extent_buffer() to folios David Sterba
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Continue page to folio updates, sync what the function does with it's
name.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 1a00a46a681b..2815972f69ec 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2561,8 +2561,8 @@ static void detach_extent_buffer_folio(const struct extent_buffer *eb, struct fo
 	spin_unlock(&folio->mapping->i_private_lock);
 }
 
-/* Release all pages attached to the extent buffer */
-static void btrfs_release_extent_buffer_pages(const struct extent_buffer *eb)
+/* Release all folios attached to the extent buffer */
+static void btrfs_release_extent_buffer_folios(const struct extent_buffer *eb)
 {
 	ASSERT(!extent_buffer_under_io(eb));
 
@@ -2584,7 +2584,7 @@ static void btrfs_release_extent_buffer_pages(const struct extent_buffer *eb)
  */
 static inline void btrfs_release_extent_buffer(struct extent_buffer *eb)
 {
-	btrfs_release_extent_buffer_pages(eb);
+	btrfs_release_extent_buffer_folios(eb);
 	btrfs_leak_debug_del_eb(eb);
 	kmem_cache_free(extent_buffer_cache, eb);
 }
@@ -3200,8 +3200,8 @@ static int release_extent_buffer(struct extent_buffer *eb)
 		}
 
 		btrfs_leak_debug_del_eb(eb);
-		/* Should be safe to release our pages at this point */
-		btrfs_release_extent_buffer_pages(eb);
+		/* Should be safe to release folios at this point. */
+		btrfs_release_extent_buffer_folios(eb);
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
 		if (unlikely(test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags))) {
 			kmem_cache_free(extent_buffer_cache, eb);
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 12/18] btrfs: switch grab_extent_buffer() to folios
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (10 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 11/18] btrfs: rename btrfs_release_extent_buffer_pages() to mention folios David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 12:40   ` Johannes Thumshirn
  2025-01-09 10:24 ` [PATCH 13/18] btrfs: change return type to bool type of check_eb_alignment() David Sterba
                   ` (7 subsequent siblings)
  19 siblings, 1 reply; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Use the folio API, remove page_folio/folio_page conversions.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 2815972f69ec..ad1e54ab665e 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2811,13 +2811,11 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
 }
 #endif
 
-static struct extent_buffer *grab_extent_buffer(
-		struct btrfs_fs_info *fs_info, struct page *page)
+static struct extent_buffer *grab_extent_buffer(struct btrfs_fs_info *fs_info, struct folio *folio)
 {
-	struct folio *folio = page_folio(page);
 	struct extent_buffer *exists;
 
-	lockdep_assert_held(&page->mapping->i_private_lock);
+	lockdep_assert_held(&folio->mapping->i_private_lock);
 
 	/*
 	 * For subpage case, we completely rely on radix tree to ensure we
@@ -2832,7 +2830,7 @@ static struct extent_buffer *grab_extent_buffer(
 		return NULL;
 
 	/*
-	 * We could have already allocated an eb for this page and attached one
+	 * We could have already allocated an eb for this folio and attached one
 	 * so lets see if we can get a ref on the existing eb, and if we can we
 	 * know it's good and we can just return that one, else we know we can
 	 * just overwrite folio private.
@@ -2841,7 +2839,7 @@ static struct extent_buffer *grab_extent_buffer(
 	if (atomic_inc_not_zero(&exists->refs))
 		return exists;
 
-	WARN_ON(PageDirty(page));
+	WARN_ON(folio_test_dirty(folio));
 	folio_detach_private(folio);
 	return NULL;
 }
@@ -2932,8 +2930,7 @@ static int attach_eb_folio_to_filemap(struct extent_buffer *eb, int i,
 	} else if (existing_folio) {
 		struct extent_buffer *existing_eb;
 
-		existing_eb = grab_extent_buffer(fs_info,
-						 folio_page(existing_folio, 0));
+		existing_eb = grab_extent_buffer(fs_info, existing_folio);
 		if (existing_eb) {
 			/* The extent buffer still exists, we can use it directly. */
 			*found_eb_ret = existing_eb;
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 13/18] btrfs: change return type to bool type of check_eb_alignment()
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (11 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 12/18] btrfs: switch grab_extent_buffer() to folios David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 14/18] btrfs: unwrap folio locking helpers David Sterba
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The check function pattern is supposed to return true/false, currently
there's only one error code.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index ad1e54ab665e..86f6a87665f5 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2844,11 +2844,14 @@ static struct extent_buffer *grab_extent_buffer(struct btrfs_fs_info *fs_info, s
 	return NULL;
 }
 
-static int check_eb_alignment(struct btrfs_fs_info *fs_info, u64 start)
+/*
+ * Validate alignment constraints of eb at logical address @start.
+ */
+static bool check_eb_alignment(struct btrfs_fs_info *fs_info, u64 start)
 {
 	if (!IS_ALIGNED(start, fs_info->sectorsize)) {
 		btrfs_err(fs_info, "bad tree block start %llu", start);
-		return -EINVAL;
+		return true;
 	}
 
 	if (fs_info->nodesize < PAGE_SIZE &&
@@ -2856,14 +2859,14 @@ static int check_eb_alignment(struct btrfs_fs_info *fs_info, u64 start)
 		btrfs_err(fs_info,
 		"tree block crosses page boundary, start %llu nodesize %u",
 			  start, fs_info->nodesize);
-		return -EINVAL;
+		return true;
 	}
 	if (fs_info->nodesize >= PAGE_SIZE &&
 	    !PAGE_ALIGNED(start)) {
 		btrfs_err(fs_info,
 		"tree block is not page aligned, start %llu nodesize %u",
 			  start, fs_info->nodesize);
-		return -EINVAL;
+		return true;
 	}
 	if (!IS_ALIGNED(start, fs_info->nodesize) &&
 	    !test_and_set_bit(BTRFS_FS_UNALIGNED_TREE_BLOCK, &fs_info->flags)) {
@@ -2871,10 +2874,9 @@ static int check_eb_alignment(struct btrfs_fs_info *fs_info, u64 start)
 "tree block not nodesize aligned, start %llu nodesize %u, can be resolved by a full metadata balance",
 			      start, fs_info->nodesize);
 	}
-	return 0;
+	return false;
 }
 
-
 /*
  * Return 0 if eb->folios[i] is attached to btree inode successfully.
  * Return >0 if there is already another extent buffer for the range,
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 14/18] btrfs: unwrap folio locking helpers
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (12 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 13/18] btrfs: change return type to bool type of check_eb_alignment() David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 15/18] btrfs: remove unused define WAIT_PAGE_LOCK for extent io David Sterba
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Another conversion to folio API, use the folio locking directly instead
of back and forth page <-> folio conversions.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 86f6a87665f5..bc232e990ce9 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3129,7 +3129,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
 	 * live buffer and won't free them prematurely.
 	 */
 	for (int i = 0; i < num_folios; i++)
-		unlock_page(folio_page(eb->folios[i], 0));
+		folio_unlock(eb->folios[i]);
 	return eb;
 
 out:
@@ -3153,7 +3153,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
 	for (int i = 0; i < attached; i++) {
 		ASSERT(eb->folios[i]);
 		detach_extent_buffer_folio(eb, eb->folios[i]);
-		unlock_page(folio_page(eb->folios[i], 0));
+		folio_unlock(eb->folios[i]);
 		folio_put(eb->folios[i]);
 		eb->folios[i] = NULL;
 	}
@@ -3362,12 +3362,12 @@ void set_extent_buffer_dirty(struct extent_buffer *eb)
 		 * the above race.
 		 */
 		if (subpage)
-			lock_page(folio_page(eb->folios[0], 0));
+			folio_lock(eb->folios[0]);
 		for (int i = 0; i < num_folios; i++)
 			btrfs_folio_set_dirty(eb->fs_info, eb->folios[i],
 					      eb->start, eb->len);
 		if (subpage)
-			unlock_page(folio_page(eb->folios[0], 0));
+			folio_unlock(eb->folios[0]);
 		percpu_counter_add_batch(&eb->fs_info->dirty_metadata_bytes,
 					 eb->len,
 					 eb->fs_info->dirty_metadata_batch);
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 15/18] btrfs: remove unused define WAIT_PAGE_LOCK for extent io
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (13 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 14/18] btrfs: unwrap folio locking helpers David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 16/18] btrfs: split waiting from read_extent_buffer_pages(), drop parameter wait David Sterba
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Last use was in the readahead code that got removed by f26c9238602856
("btrfs: remove reada infrastructure").

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 986f15022fef..ca09fc31e2de 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -263,7 +263,6 @@ void free_extent_buffer(struct extent_buffer *eb);
 void free_extent_buffer_stale(struct extent_buffer *eb);
 #define WAIT_NONE	0
 #define WAIT_COMPLETE	1
-#define WAIT_PAGE_LOCK	2
 int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
 			     const struct btrfs_tree_parent_check *parent_check);
 static inline void wait_on_extent_buffer_writeback(struct extent_buffer *eb)
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 16/18] btrfs: split waiting from read_extent_buffer_pages(), drop parameter wait
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (14 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 15/18] btrfs: remove unused define WAIT_PAGE_LOCK for extent io David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 17/18] btrfs: remove redundant variables from __process_folios_contig() and lock_delalloc_folios() David Sterba
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

There are only 2 WAIT_* values left for wait parameter, we can encode
this to the function name if the waiting functionality is split.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/disk-io.c   |  2 +-
 fs/btrfs/extent_io.c | 27 +++++++++++++++++----------
 fs/btrfs/extent_io.h |  7 ++++---
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 04d68f253940..cec38a192dfd 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -226,7 +226,7 @@ int btrfs_read_extent_buffer(struct extent_buffer *eb,
 
 	while (1) {
 		clear_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags);
-		ret = read_extent_buffer_pages(eb, WAIT_COMPLETE, mirror_num, check);
+		ret = read_extent_buffer_pages(eb, mirror_num, check);
 		if (!ret)
 			break;
 
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index bc232e990ce9..37f0ad389022 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3477,8 +3477,8 @@ static void end_bbio_meta_read(struct btrfs_bio *bbio)
 	bio_put(&bbio->bio);
 }
 
-int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
-			     const struct btrfs_tree_parent_check *check)
+int read_extent_buffer_pages_nowait(struct extent_buffer *eb, int mirror_num,
+				    const struct btrfs_tree_parent_check *check)
 {
 	struct btrfs_bio *bbio;
 	bool ret;
@@ -3496,7 +3496,7 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
 
 	/* Someone else is already reading the buffer, just wait for it. */
 	if (test_and_set_bit(EXTENT_BUFFER_READING, &eb->bflags))
-		goto done;
+		return 0;
 
 	/*
 	 * Between the initial test_bit(EXTENT_BUFFER_UPTODATE) and the above
@@ -3536,14 +3536,21 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
 		}
 	}
 	btrfs_submit_bbio(bbio, mirror_num);
+	return 0;
+}
 
-done:
-	if (wait == WAIT_COMPLETE) {
-		wait_on_bit_io(&eb->bflags, EXTENT_BUFFER_READING, TASK_UNINTERRUPTIBLE);
-		if (!test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags))
-			return -EIO;
-	}
+int read_extent_buffer_pages(struct extent_buffer *eb, int mirror_num,
+			     const struct btrfs_tree_parent_check *check)
+{
+	int ret;
 
+	ret = read_extent_buffer_pages_nowait(eb, mirror_num, check);
+	if (ret < 0)
+		return ret;
+
+	wait_on_bit_io(&eb->bflags, EXTENT_BUFFER_READING, TASK_UNINTERRUPTIBLE);
+	if (!test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags))
+		return -EIO;
 	return 0;
 }
 
@@ -4274,7 +4281,7 @@ void btrfs_readahead_tree_block(struct btrfs_fs_info *fs_info,
 		return;
 	}
 
-	ret = read_extent_buffer_pages(eb, WAIT_NONE, 0, &check);
+	ret = read_extent_buffer_pages_nowait(eb, 0, &check);
 	if (ret < 0)
 		free_extent_buffer_stale(eb);
 	else
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index ca09fc31e2de..6c5328bfabc2 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -261,10 +261,11 @@ struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info,
 					 u64 start);
 void free_extent_buffer(struct extent_buffer *eb);
 void free_extent_buffer_stale(struct extent_buffer *eb);
-#define WAIT_NONE	0
-#define WAIT_COMPLETE	1
-int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
+int read_extent_buffer_pages(struct extent_buffer *eb, int mirror_num,
 			     const struct btrfs_tree_parent_check *parent_check);
+int read_extent_buffer_pages_nowait(struct extent_buffer *eb, int mirror_num,
+				    const struct btrfs_tree_parent_check *parent_check);
+
 static inline void wait_on_extent_buffer_writeback(struct extent_buffer *eb)
 {
 	wait_on_bit_io(&eb->bflags, EXTENT_BUFFER_WRITEBACK,
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 17/18] btrfs: remove redundant variables from __process_folios_contig() and lock_delalloc_folios()
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (15 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 16/18] btrfs: split waiting from read_extent_buffer_pages(), drop parameter wait David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 10:24 ` [PATCH 18/18] btrfs: async-thread: rename DFT_THRESHOLD to DEFAULT_THRESHOLD David Sterba
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Same pattern in both functions, we really only use index, start_index is
redundant.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 37f0ad389022..0faa9e2f772a 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -198,9 +198,8 @@ static void __process_folios_contig(struct address_space *mapping,
 				    u64 end, unsigned long page_ops)
 {
 	struct btrfs_fs_info *fs_info = inode_to_fs_info(mapping->host);
-	pgoff_t start_index = start >> PAGE_SHIFT;
+	pgoff_t index = start >> PAGE_SHIFT;
 	pgoff_t end_index = end >> PAGE_SHIFT;
-	pgoff_t index = start_index;
 	struct folio_batch fbatch;
 	int i;
 
@@ -242,9 +241,8 @@ static noinline int lock_delalloc_folios(struct inode *inode,
 {
 	struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
 	struct address_space *mapping = inode->i_mapping;
-	pgoff_t start_index = start >> PAGE_SHIFT;
+	pgoff_t index = start >> PAGE_SHIFT;
 	pgoff_t end_index = end >> PAGE_SHIFT;
-	pgoff_t index = start_index;
 	u64 processed_end = start;
 	struct folio_batch fbatch;
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 18/18] btrfs: async-thread: rename DFT_THRESHOLD to DEFAULT_THRESHOLD
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (16 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 17/18] btrfs: remove redundant variables from __process_folios_contig() and lock_delalloc_folios() David Sterba
@ 2025-01-09 10:24 ` David Sterba
  2025-01-09 13:41 ` [PATCH 00/18] Random cleanups for 6.14 Johannes Thumshirn
  2025-01-09 16:45 ` Anand Jain
  19 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-09 10:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Rename the macro so it's obvious what it means.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/async-thread.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 361a866c1995..a4c51600a408 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -18,7 +18,7 @@ enum {
 };
 
 #define NO_THRESHOLD (-1)
-#define DFT_THRESHOLD (32)
+#define DEFAULT_THRESHOLD (32)
 
 struct btrfs_workqueue {
 	struct workqueue_struct *normal_wq;
@@ -94,9 +94,9 @@ struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info,
 
 	ret->limit_active = limit_active;
 	if (thresh == 0)
-		thresh = DFT_THRESHOLD;
+		thresh = DEFAULT_THRESHOLD;
 	/* For low threshold, disabling threshold is a better choice */
-	if (thresh < DFT_THRESHOLD) {
+	if (thresh < DEFAULT_THRESHOLD) {
 		ret->current_active = limit_active;
 		ret->thresh = NO_THRESHOLD;
 	} else {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH 02/18] btrfs: remove stray comment about SRCU
  2025-01-09 10:24 ` [PATCH 02/18] btrfs: remove stray comment about SRCU David Sterba
@ 2025-01-09 11:00   ` Daniel Vacek
  0 siblings, 0 replies; 26+ messages in thread
From: Daniel Vacek @ 2025-01-09 11:00 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs

On Thu, 9 Jan 2025 at 11:27, David Sterba <dsterba@suse.com> wrote:
>
> The subvol_sruce was removed in c75e839414d361 ("btrfs: kill the

subvol_sruce typo

> subvol_srcu") years ago.
>
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  fs/btrfs/disk-io.h | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
> index a7051e2570c1..587842991b24 100644
> --- a/fs/btrfs/disk-io.h
> +++ b/fs/btrfs/disk-io.h
> @@ -96,9 +96,6 @@ struct btrfs_root *btrfs_alloc_dummy_root(struct btrfs_fs_info *fs_info);
>  /*
>   * This function is used to grab the root, and avoid it is freed when we
>   * access it. But it doesn't ensure that the tree is not dropped.
> - *
> - * If you want to ensure the whole tree is safe, you should use
> - *     fs_info->subvol_srcu
>   */
>  static inline struct btrfs_root *btrfs_grab_root(struct btrfs_root *root)
>  {
> --
> 2.47.1
>
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 04/18] btrfs: rename __unlock_for_delalloc() and drop underscores
  2025-01-09 10:24 ` [PATCH 04/18] btrfs: rename __unlock_for_delalloc() and drop underscores David Sterba
@ 2025-01-09 12:07   ` Johannes Thumshirn
  2025-01-10 15:13     ` David Sterba
  0 siblings, 1 reply; 26+ messages in thread
From: Johannes Thumshirn @ 2025-01-09 12:07 UTC (permalink / raw)
  To: David Sterba, linux-btrfs@vger.kernel.org

On 09.01.25 11:27, David Sterba wrote:
> Drop the underscores as the naming scheme does not apply here and to
> have the unlock for parity with lock_delalloc_folios().

That sentence somehow doesn't sound good in my head, maybe

Drop the leading underscores in '__unlock_for_delalloc()' and rename it 
to 'unlock_delalloc_folio()'. This also ensures naming parity with 
'lock_delalloc_folios()'.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 12/18] btrfs: switch grab_extent_buffer() to folios
  2025-01-09 10:24 ` [PATCH 12/18] btrfs: switch grab_extent_buffer() to folios David Sterba
@ 2025-01-09 12:40   ` Johannes Thumshirn
  2025-01-10 16:02     ` David Sterba
  0 siblings, 1 reply; 26+ messages in thread
From: Johannes Thumshirn @ 2025-01-09 12:40 UTC (permalink / raw)
  To: David Sterba, linux-btrfs@vger.kernel.org

On 09.01.25 11:27, David Sterba wrote:
> -static struct extent_buffer *grab_extent_buffer(
> -		struct btrfs_fs_info *fs_info, struct page *page)
> +static struct extent_buffer *grab_extent_buffer(struct btrfs_fs_info *fs_info, struct folio *folio)

I'd personally break the line after fs_info so it fits nicely into 80 
chars. The 99 we have after folio seems excessive to me.


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 00/18] Random cleanups for 6.14
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (17 preceding siblings ...)
  2025-01-09 10:24 ` [PATCH 18/18] btrfs: async-thread: rename DFT_THRESHOLD to DEFAULT_THRESHOLD David Sterba
@ 2025-01-09 13:41 ` Johannes Thumshirn
  2025-01-09 16:45 ` Anand Jain
  19 siblings, 0 replies; 26+ messages in thread
From: Johannes Thumshirn @ 2025-01-09 13:41 UTC (permalink / raw)
  To: David Sterba, linux-btrfs@vger.kernel.org

On 09.01.25 11:26, David Sterba wrote:
> Unsorteed small cleanups and renames.
> 
> David Sterba (18):
>    btrfs: drop unused parameter fs_info to btrfs_delete_delayed_insertion_item()
>    btrfs: remove stray comment about SRCU
>    btrfs: use SECTOR_SIZE defines in btrfs_issue_discard()
>    btrfs: rename __unlock_for_delalloc() and drop underscores
>    btrfs: open code set_page_extent_mapped()
>    btrfs: rename __get_extent_map() and pass btrfs_inode
>    btrfs: use btrfs_inode in extent_writepage()
>    btrfs: make wait_on_extent_buffer_writeback() static inline
>    btrfs: drop one time used local variable in end_bbio_meta_write()
>    btrfs: open code __free_extent_buffer()
>    btrfs: rename btrfs_release_extent_buffer_pages() to mention folios
>    btrfs: switch grab_extent_buffer() to folios
>    btrfs: change return type to bool type of check_eb_alignment()
>    btrfs: unwrap folio locking helpers
>    btrfs: remove unused define WAIT_PAGE_LOCK for extent io
>    btrfs: split waiting from read_extent_buffer_pages(), drop parameter wait
>    btrfs: remove redundant variables from __process_folios_contig() and lock_delalloc_folios()
>    btrfs: async-thread: rename DFT_THRESHOLD to DEFAULT_THRESHOLD
> 
>   fs/btrfs/async-thread.c     |   6 +-
>   fs/btrfs/delayed-inode.c    |   5 +-
>   fs/btrfs/disk-io.c          |   2 +-
>   fs/btrfs/disk-io.h          |   3 -
>   fs/btrfs/extent-tree.c      |   4 +-
>   fs/btrfs/extent_io.c        | 143 ++++++++++++++++--------------------
>   fs/btrfs/extent_io.h        |  16 ++--
>   fs/btrfs/free-space-cache.c |   2 +-
>   fs/btrfs/relocation.c       |   2 +-
>   9 files changed, 84 insertions(+), 99 deletions(-)
> 

Apart from the small nitpicks

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

for the series.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 00/18] Random cleanups for 6.14
  2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
                   ` (18 preceding siblings ...)
  2025-01-09 13:41 ` [PATCH 00/18] Random cleanups for 6.14 Johannes Thumshirn
@ 2025-01-09 16:45 ` Anand Jain
  19 siblings, 0 replies; 26+ messages in thread
From: Anand Jain @ 2025-01-09 16:45 UTC (permalink / raw)
  To: David Sterba, linux-btrfs

On 9/1/25 15:53, David Sterba wrote:
> Unsorteed small cleanups and renames.
> 
> David Sterba (18):
>    btrfs: drop unused parameter fs_info to btrfs_delete_delayed_insertion_item()
>    btrfs: remove stray comment about SRCU
>    btrfs: use SECTOR_SIZE defines in btrfs_issue_discard()
>    btrfs: rename __unlock_for_delalloc() and drop underscores
>    btrfs: open code set_page_extent_mapped()
>    btrfs: rename __get_extent_map() and pass btrfs_inode
>    btrfs: use btrfs_inode in extent_writepage()
>    btrfs: make wait_on_extent_buffer_writeback() static inline
>    btrfs: drop one time used local variable in end_bbio_meta_write()
>    btrfs: open code __free_extent_buffer()
>    btrfs: rename btrfs_release_extent_buffer_pages() to mention folios
>    btrfs: switch grab_extent_buffer() to folios
>    btrfs: change return type to bool type of check_eb_alignment()
>    btrfs: unwrap folio locking helpers
>    btrfs: remove unused define WAIT_PAGE_LOCK for extent io
>    btrfs: split waiting from read_extent_buffer_pages(), drop parameter wait
>    btrfs: remove redundant variables from __process_folios_contig() and lock_delalloc_folios()
>    btrfs: async-thread: rename DFT_THRESHOLD to DEFAULT_THRESHOLD
> 

For the set.
Reviewed-by: Anand Jain <anand.jain@oracle.com>

Thx.

>   fs/btrfs/async-thread.c     |   6 +-
>   fs/btrfs/delayed-inode.c    |   5 +-
>   fs/btrfs/disk-io.c          |   2 +-
>   fs/btrfs/disk-io.h          |   3 -
>   fs/btrfs/extent-tree.c      |   4 +-
>   fs/btrfs/extent_io.c        | 143 ++++++++++++++++--------------------
>   fs/btrfs/extent_io.h        |  16 ++--
>   fs/btrfs/free-space-cache.c |   2 +-
>   fs/btrfs/relocation.c       |   2 +-
>   9 files changed, 84 insertions(+), 99 deletions(-)
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 04/18] btrfs: rename __unlock_for_delalloc() and drop underscores
  2025-01-09 12:07   ` Johannes Thumshirn
@ 2025-01-10 15:13     ` David Sterba
  0 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-10 15:13 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: David Sterba, linux-btrfs@vger.kernel.org

On Thu, Jan 09, 2025 at 12:07:43PM +0000, Johannes Thumshirn wrote:
> On 09.01.25 11:27, David Sterba wrote:
> > Drop the underscores as the naming scheme does not apply here and to
> > have the unlock for parity with lock_delalloc_folios().
> 
> That sentence somehow doesn't sound good in my head, maybe
> 
> Drop the leading underscores in '__unlock_for_delalloc()' and rename it 
> to 'unlock_delalloc_folio()'. This also ensures naming parity with 
> 'lock_delalloc_folios()'.

Right, I'll use that wording, thanks.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 12/18] btrfs: switch grab_extent_buffer() to folios
  2025-01-09 12:40   ` Johannes Thumshirn
@ 2025-01-10 16:02     ` David Sterba
  0 siblings, 0 replies; 26+ messages in thread
From: David Sterba @ 2025-01-10 16:02 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: David Sterba, linux-btrfs@vger.kernel.org

On Thu, Jan 09, 2025 at 12:40:27PM +0000, Johannes Thumshirn wrote:
> On 09.01.25 11:27, David Sterba wrote:
> > -static struct extent_buffer *grab_extent_buffer(
> > -		struct btrfs_fs_info *fs_info, struct page *page)
> > +static struct extent_buffer *grab_extent_buffer(struct btrfs_fs_info *fs_info, struct folio *folio)
> 
> I'd personally break the line after fs_info so it fits nicely into 80 
> chars. The 99 we have after folio seems excessive to me.

Yeah in this case it's a bit too much. The loose rule I use is if at
least part of the identifier is visible then the overflow is OK.

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2025-01-10 16:02 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-09 10:23 [PATCH 00/18] Random cleanups for 6.14 David Sterba
2025-01-09 10:23 ` [PATCH 01/18] btrfs: drop unused parameter fs_info to btrfs_delete_delayed_insertion_item() David Sterba
2025-01-09 10:24 ` [PATCH 02/18] btrfs: remove stray comment about SRCU David Sterba
2025-01-09 11:00   ` Daniel Vacek
2025-01-09 10:24 ` [PATCH 03/18] btrfs: use SECTOR_SIZE defines in btrfs_issue_discard() David Sterba
2025-01-09 10:24 ` [PATCH 04/18] btrfs: rename __unlock_for_delalloc() and drop underscores David Sterba
2025-01-09 12:07   ` Johannes Thumshirn
2025-01-10 15:13     ` David Sterba
2025-01-09 10:24 ` [PATCH 05/18] btrfs: open code set_page_extent_mapped() David Sterba
2025-01-09 10:24 ` [PATCH 06/18] btrfs: rename __get_extent_map() and pass btrfs_inode David Sterba
2025-01-09 10:24 ` [PATCH 07/18] btrfs: use btrfs_inode in extent_writepage() David Sterba
2025-01-09 10:24 ` [PATCH 08/18] btrfs: make wait_on_extent_buffer_writeback() static inline David Sterba
2025-01-09 10:24 ` [PATCH 09/18] btrfs: drop one time used local variable in end_bbio_meta_write() David Sterba
2025-01-09 10:24 ` [PATCH 10/18] btrfs: open code __free_extent_buffer() David Sterba
2025-01-09 10:24 ` [PATCH 11/18] btrfs: rename btrfs_release_extent_buffer_pages() to mention folios David Sterba
2025-01-09 10:24 ` [PATCH 12/18] btrfs: switch grab_extent_buffer() to folios David Sterba
2025-01-09 12:40   ` Johannes Thumshirn
2025-01-10 16:02     ` David Sterba
2025-01-09 10:24 ` [PATCH 13/18] btrfs: change return type to bool type of check_eb_alignment() David Sterba
2025-01-09 10:24 ` [PATCH 14/18] btrfs: unwrap folio locking helpers David Sterba
2025-01-09 10:24 ` [PATCH 15/18] btrfs: remove unused define WAIT_PAGE_LOCK for extent io David Sterba
2025-01-09 10:24 ` [PATCH 16/18] btrfs: split waiting from read_extent_buffer_pages(), drop parameter wait David Sterba
2025-01-09 10:24 ` [PATCH 17/18] btrfs: remove redundant variables from __process_folios_contig() and lock_delalloc_folios() David Sterba
2025-01-09 10:24 ` [PATCH 18/18] btrfs: async-thread: rename DFT_THRESHOLD to DEFAULT_THRESHOLD David Sterba
2025-01-09 13:41 ` [PATCH 00/18] Random cleanups for 6.14 Johannes Thumshirn
2025-01-09 16:45 ` Anand Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox