Skip to content

Commit 2c22199

Browse files
adam900710gregkh
authored andcommitted
btrfs: rename btrfs_subpage structure
[ Upstream commit 582cd4b ] With the incoming large data folios support, the structure name btrfs_subpage is no longer correct, as for we can have multiple blocks inside a large folio, and the block size is still page size. So to follow the schema of iomap, rename btrfs_subpage to btrfs_folio_state, along with involved enums. There are still exported functions with "btrfs_subpage_" prefix, and I believe for metadata the name "subpage" will stay forever as we will never allocate a folio larger than nodesize anyway. The full cleanup of the word "subpage" will happen in much smaller steps in the future. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Stable-dep-of: b151136 ("btrfs: subpage: keep TOWRITE tag until folio is cleaned") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e4a82c1 commit 2c22199

File tree

4 files changed

+156
-150
lines changed

4 files changed

+156
-150
lines changed

fs/btrfs/extent_io.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ static void submit_extent_folio(struct btrfs_bio_ctrl *bio_ctrl,
782782

783783
static int attach_extent_buffer_folio(struct extent_buffer *eb,
784784
struct folio *folio,
785-
struct btrfs_subpage *prealloc)
785+
struct btrfs_folio_state *prealloc)
786786
{
787787
struct btrfs_fs_info *fs_info = eb->fs_info;
788788
int ret = 0;
@@ -806,7 +806,7 @@ static int attach_extent_buffer_folio(struct extent_buffer *eb,
806806

807807
/* Already mapped, just free prealloc */
808808
if (folio_test_private(folio)) {
809-
btrfs_free_subpage(prealloc);
809+
btrfs_free_folio_state(prealloc);
810810
return 0;
811811
}
812812

@@ -815,7 +815,7 @@ static int attach_extent_buffer_folio(struct extent_buffer *eb,
815815
folio_attach_private(folio, prealloc);
816816
else
817817
/* Do new allocation to attach subpage */
818-
ret = btrfs_attach_subpage(fs_info, folio, BTRFS_SUBPAGE_METADATA);
818+
ret = btrfs_attach_folio_state(fs_info, folio, BTRFS_SUBPAGE_METADATA);
819819
return ret;
820820
}
821821

@@ -831,7 +831,7 @@ int set_folio_extent_mapped(struct folio *folio)
831831
fs_info = folio_to_fs_info(folio);
832832

833833
if (btrfs_is_subpage(fs_info, folio))
834-
return btrfs_attach_subpage(fs_info, folio, BTRFS_SUBPAGE_DATA);
834+
return btrfs_attach_folio_state(fs_info, folio, BTRFS_SUBPAGE_DATA);
835835

836836
folio_attach_private(folio, (void *)EXTENT_FOLIO_PRIVATE);
837837
return 0;
@@ -848,7 +848,7 @@ void clear_folio_extent_mapped(struct folio *folio)
848848

849849
fs_info = folio_to_fs_info(folio);
850850
if (btrfs_is_subpage(fs_info, folio))
851-
return btrfs_detach_subpage(fs_info, folio, BTRFS_SUBPAGE_DATA);
851+
return btrfs_detach_folio_state(fs_info, folio, BTRFS_SUBPAGE_DATA);
852852

853853
folio_detach_private(folio);
854854
}
@@ -2731,13 +2731,13 @@ static int extent_buffer_under_io(const struct extent_buffer *eb)
27312731

27322732
static bool folio_range_has_eb(struct folio *folio)
27332733
{
2734-
struct btrfs_subpage *subpage;
2734+
struct btrfs_folio_state *bfs;
27352735

27362736
lockdep_assert_held(&folio->mapping->i_private_lock);
27372737

27382738
if (folio_test_private(folio)) {
2739-
subpage = folio_get_private(folio);
2740-
if (atomic_read(&subpage->eb_refs))
2739+
bfs = folio_get_private(folio);
2740+
if (atomic_read(&bfs->eb_refs))
27412741
return true;
27422742
}
27432743
return false;
@@ -2787,7 +2787,7 @@ static void detach_extent_buffer_folio(const struct extent_buffer *eb, struct fo
27872787
* attached to one dummy eb, no sharing.
27882788
*/
27892789
if (!mapped) {
2790-
btrfs_detach_subpage(fs_info, folio, BTRFS_SUBPAGE_METADATA);
2790+
btrfs_detach_folio_state(fs_info, folio, BTRFS_SUBPAGE_METADATA);
27912791
return;
27922792
}
27932793

@@ -2798,7 +2798,7 @@ static void detach_extent_buffer_folio(const struct extent_buffer *eb, struct fo
27982798
* page range and no unfinished IO.
27992799
*/
28002800
if (!folio_range_has_eb(folio))
2801-
btrfs_detach_subpage(fs_info, folio, BTRFS_SUBPAGE_METADATA);
2801+
btrfs_detach_folio_state(fs_info, folio, BTRFS_SUBPAGE_METADATA);
28022802

28032803
spin_unlock(&mapping->i_private_lock);
28042804
}
@@ -3141,7 +3141,7 @@ static bool check_eb_alignment(struct btrfs_fs_info *fs_info, u64 start)
31413141
* The caller needs to free the existing folios and retry using the same order.
31423142
*/
31433143
static int attach_eb_folio_to_filemap(struct extent_buffer *eb, int i,
3144-
struct btrfs_subpage *prealloc,
3144+
struct btrfs_folio_state *prealloc,
31453145
struct extent_buffer **found_eb_ret)
31463146
{
31473147

@@ -3224,7 +3224,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
32243224
int attached = 0;
32253225
struct extent_buffer *eb;
32263226
struct extent_buffer *existing_eb = NULL;
3227-
struct btrfs_subpage *prealloc = NULL;
3227+
struct btrfs_folio_state *prealloc = NULL;
32283228
u64 lockdep_owner = owner_root;
32293229
bool page_contig = true;
32303230
int uptodate = 1;
@@ -3269,7 +3269,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
32693269
* manually if we exit earlier.
32703270
*/
32713271
if (btrfs_meta_is_subpage(fs_info)) {
3272-
prealloc = btrfs_alloc_subpage(fs_info, PAGE_SIZE, BTRFS_SUBPAGE_METADATA);
3272+
prealloc = btrfs_alloc_folio_state(fs_info, PAGE_SIZE, BTRFS_SUBPAGE_METADATA);
32733273
if (IS_ERR(prealloc)) {
32743274
ret = PTR_ERR(prealloc);
32753275
goto out;
@@ -3280,7 +3280,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
32803280
/* Allocate all pages first. */
32813281
ret = alloc_eb_folio_array(eb, true);
32823282
if (ret < 0) {
3283-
btrfs_free_subpage(prealloc);
3283+
btrfs_free_folio_state(prealloc);
32843284
goto out;
32853285
}
32863286

fs/btrfs/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7364,13 +7364,13 @@ struct extent_map *btrfs_create_io_em(struct btrfs_inode *inode, u64 start,
73647364
static void wait_subpage_spinlock(struct folio *folio)
73657365
{
73667366
struct btrfs_fs_info *fs_info = folio_to_fs_info(folio);
7367-
struct btrfs_subpage *subpage;
7367+
struct btrfs_folio_state *bfs;
73687368

73697369
if (!btrfs_is_subpage(fs_info, folio))
73707370
return;
73717371

73727372
ASSERT(folio_test_private(folio) && folio_get_private(folio));
7373-
subpage = folio_get_private(folio);
7373+
bfs = folio_get_private(folio);
73747374

73757375
/*
73767376
* This may look insane as we just acquire the spinlock and release it,
@@ -7383,8 +7383,8 @@ static void wait_subpage_spinlock(struct folio *folio)
73837383
* Here we just acquire the spinlock so that all existing callers
73847384
* should exit and we're safe to release/invalidate the page.
73857385
*/
7386-
spin_lock_irq(&subpage->lock);
7387-
spin_unlock_irq(&subpage->lock);
7386+
spin_lock_irq(&bfs->lock);
7387+
spin_unlock_irq(&bfs->lock);
73887388
}
73897389

73907390
static int btrfs_launder_folio(struct folio *folio)

0 commit comments

Comments
 (0)