]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: unexport and move extent_invalidate_folio()
authorQu Wenruo <wqu@suse.com>
Sun, 3 May 2026 09:47:50 +0000 (19:17 +0930)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jun 2026 13:53:31 +0000 (15:53 +0200)
The function extent_invalidate_folio() has only a single caller inside
btree_invalidate_folio().

There is no need to export such a function just for a single caller inside
another file.

Unexport extent_invalidate_folio() and move it to disk-io.c.

And since we're moving the code, update the commit to match the current
style, and remove the seemingly stale comment on the extent state
removal, it's better explained by the comment just before
btrfs_unlock_extent().

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h

index ffeb1d7d8ad9d5ed71e874209b9c4c74ed20bee3..c13a05a7e39a41f4026287f8a7a66bb8c4a54dcc 100644 (file)
@@ -488,6 +488,37 @@ static bool btree_release_folio(struct folio *folio, gfp_t gfp_flags)
        return try_release_extent_buffer(folio);
 }
 
+/*
+ * Basic invalidate_folio code, this waits on any locked or writeback
+ * ranges corresponding to the folio.
+ */
+static int extent_invalidate_folio(struct extent_io_tree *tree,
+                                  struct folio *folio, size_t offset)
+{
+       struct extent_state *cached_state = NULL;
+       u64 start = folio_pos(folio);
+       u64 end = start + folio_size(folio) - 1;
+       size_t blocksize = folio_to_fs_info(folio)->sectorsize;
+
+       /* This function is only called for the btree inode */
+       ASSERT(tree->owner == IO_TREE_BTREE_INODE_IO);
+
+       start += ALIGN(offset, blocksize);
+       if (start > end)
+               return 0;
+
+       btrfs_lock_extent(tree, start, end, &cached_state);
+       folio_wait_writeback(folio);
+
+       /*
+        * Currently for btree io tree, only EXTENT_LOCKED is utilized,
+        * so here we only need to unlock the extent range to free any
+        * existing extent state.
+        */
+       btrfs_unlock_extent(tree, start, end, &cached_state);
+       return 0;
+}
+
 static void btree_invalidate_folio(struct folio *folio, size_t offset,
                                 size_t length)
 {
index 1b7550b344ca5c3c96ec427dea2b217dda353913..cd957b23087e15d37ab98a65e0c1b67b2099de72 100644 (file)
@@ -2721,38 +2721,6 @@ void btrfs_readahead(struct readahead_control *rac)
        submit_one_bio(&bio_ctrl);
 }
 
-/*
- * basic invalidate_folio code, this waits on any locked or writeback
- * ranges corresponding to the folio, and then deletes any extent state
- * records from the tree
- */
-int extent_invalidate_folio(struct extent_io_tree *tree,
-                         struct folio *folio, size_t offset)
-{
-       struct extent_state *cached_state = NULL;
-       u64 start = folio_pos(folio);
-       u64 end = start + folio_size(folio) - 1;
-       size_t blocksize = folio_to_fs_info(folio)->sectorsize;
-
-       /* This function is only called for the btree inode */
-       ASSERT(tree->owner == IO_TREE_BTREE_INODE_IO);
-
-       start += ALIGN(offset, blocksize);
-       if (start > end)
-               return 0;
-
-       btrfs_lock_extent(tree, start, end, &cached_state);
-       folio_wait_writeback(folio);
-
-       /*
-        * Currently for btree io tree, only EXTENT_LOCKED is utilized,
-        * so here we only need to unlock the extent range to free any
-        * existing extent state.
-        */
-       btrfs_unlock_extent(tree, start, end, &cached_state);
-       return 0;
-}
-
 /*
  * A helper for struct address_space_operations::release_folio, this tests for
  * areas of the folio that are locked or under IO and drops the related state
index 7b4152387d886635d3abb2b3e04f7044dd0be2da..e4c2c1e01b7deb4803284d6641674631031c466e 100644 (file)
@@ -387,8 +387,6 @@ void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end,
                                  const struct folio *locked_folio,
                                  struct extent_state **cached,
                                  u32 bits_to_clear, unsigned long page_ops);
-int extent_invalidate_folio(struct extent_io_tree *tree,
-                           struct folio *folio, size_t offset);
 void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans,
                              struct extent_buffer *buf);