btrfs: separate/simplify/unify subpage handling
v2 cover btrfs: separate/simplify/unify subpage handling
[CHANGELOG]
v2:
- Fix a crash in 4K page sized system caused by btrfs_clear_buffer_dirty()
It looks like using btrfs_meta_folio_set_writeback() and btrfs_meta_folio_clear_writeback() is screwing up the btree inode map.
Fix it by reverting to the old manually clearing of PAGECACHE_DIRTY_TAG.
[METADATA SUBPAGE CHECKS]
Currently we only have one btrfs_is_subpage() check, utilized by data and metadata.
But the truth is, btrfs_is_subpage() can return incorrect result if the target folio belongs to a dummy extent buffer.
This means we have quite some metadata call sites doing their own metadata specific subpage check.
[SUBPAGE SPECIFIC HANDLINGS]
There are several functions that split the metadata subpage handling into a dedicated path.
But the truth is, a lot of such paths only have minor differences compared to the regular routine.
[THIS SERIES]
This series address the above problems and prepare for the incoming data larger folio support by:
- Remove btrfs_fs_info::sectors_per_page
This is mostly a preparation for the future data larger folio support.
- Introduce a dedicated metadata specific subpage check
- Unify/simplify metadata subpage handling So that we have a single unified path for metadata
Qu Wenruo (8):
btrfs: remove btrfs_fs_info::sectors_per_page
btrfs: extract metadata subpage detection into a dedicated helper
btrfs: make subpage attach and detach to handle metadata properly
btrfs: use metadata specific helpers to simplify extent buffer helpers
btrfs: simplify btrfs_clear_buffer_dirty()
btrfs: simplify write_one_eb()
btrfs: simplify read_extent_buffer_pages_nowait()
btrfs: require strict data/metadata split for subpage check
fs/btrfs/disk-io.c | 5 +- fs/btrfs/extent_io.c | 184 +++++++++++++++------------------------- fs/btrfs/fs.h | 7 +- fs/btrfs/subpage.c | 196 +++++++++++++++++++++++++++---------------- fs/btrfs/subpage.h | 52 ++++++++++-- 5 files changed, 247 insertions(+), 197 deletions(-)
Signature · 1 line
2.48.1
PATCH v2 1/8 btrfs: remove btrfs_fs_info::sectors_per_page
For the future larger folio support, our filemap can have folios with different sizes, thus we can no longer rely on a fixed blocks_per_page value.
To prepare for that future, here we do:
- Remove btrfs_fs_info::sectors_per_page
- Introduce a helper, btrfs_blocks_per_folio()
Which uses the folio size to calculate the number of blocks for each folio.
- Migrate the existing btrfs_fs_info::sectors_per_page to use that helper
There are some exceptions:
* Metadata nodesize < page size support
In the future, even if we support larger folios, we will only allocate a folio that matches our nodesize.
Thus we won't have a folio covering multiple metadata unless nodesize < page size.
* Existing subpage bitmap dump
We use a single unsigned long to store the bitmap.
That means until we change the bitmap dumpping code, our upper limit for folio size will only be 256K (4K block size, 64 bit unsigned long).
* btrfs_is_subpage() check
This will be migrated into a future patch.
--- fs/btrfs/disk-io.c | 1 - fs/btrfs/extent_io.c | 26 ++++++----- fs/btrfs/fs.h | 7 ++- fs/btrfs/subpage.c | 105 ++++++++++++++++++++++++++----------------- 4 files changed, 85 insertions(+), 54 deletions(-)
fs/btrfs/disk-io.c +0 -1
@@ -3390,7 +3390,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device fs_info->nodesize = nodesize; fs_info->sectorsize = sectorsize; fs_info->sectorsize_bits =ilog2 (sectorsize); - fs_info->sectors_per_page = (PAGE_SIZE >> fs_info->sectorsize_bits); fs_info->csums_per_leaf =BTRFS_MAX_ITEM_SIZE (fs_info) / fs_info->csum_size; fs_info->stripesize = stripesize; fs_info->fs_devices->fs_info = fs_info;
fs/btrfs/extent_io.c +15 -11
@@ -1120,7 +1120,7 @@ static bool find_next_delalloc_bitmap(struct folio *folio, {struct btrfs_fs_info *fs_info =folio_to_fs_info (folio);const u64 folio_start =folio_pos (folio); -const unsigned int bitmap_size = fs_info->sectors_per_page; +const unsigned int bitmap_size =btrfs_blocks_per_folio (fs_info, folio);unsigned int start_bit;unsigned int first_zero;unsigned int first_set;
@@ -1162,6 +1162,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode,const bool is_subpage =btrfs_is_subpage (fs_info, folio->mapping);const u64 page_start =folio_pos (folio);const u64 page_end = page_start +folio_size (folio) -1 ; +const unsigned int blocks_per_folio =btrfs_blocks_per_folio (fs_info, folio);unsigned long delalloc_bitmap =0 ;/* * Save the last found delalloc end. As the delalloc end can go beyond
@@ -1187,13 +1188,13 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode,/* Save the dirty bitmap as our submission bitmap will be a subset of it. */ if (btrfs_is_subpage (fs_info, inode->vfs_inode.i_mapping)) { -ASSERT (fs_info->sectors_per_page >1 ); +ASSERT (blocks_per_folio >1 );btrfs_get_subpage_dirty_bitmap (fs_info, folio, &bio_ctrl->submit_bitmap); }else { bio_ctrl->submit_bitmap =1 ; } -for_each_set_bit (bit, &bio_ctrl->submit_bitmap, fs_info->sectors_per_page) { +for_each_set_bit (bit, &bio_ctrl->submit_bitmap, blocks_per_folio) {u64 start = page_start + (bit << fs_info->sectorsize_bits);btrfs_folio_set_lock (fs_info, folio, start, fs_info->sectorsize);
@@ -1266,7 +1267,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode,btrfs_root_id (inode->root),btrfs_ino (inode),folio_pos (folio), - fs_info->sectors_per_page, + blocks_per_folio, &bio_ctrl->submit_bitmap, found_start, found_len, ret); }else {
@@ -1311,7 +1312,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode,unsigned int bitmap_size =min ( (last_finished_delalloc_end - page_start) >> fs_info->sectorsize_bits, - fs_info->sectors_per_page); + blocks_per_folio);for_each_set_bit (bit, &bio_ctrl->submit_bitmap, bitmap_size) btrfs_mark_ordered_io_finished(inode, folio,
@@ -1335,7 +1336,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode,* If all ranges are submitted asynchronously, we just need to account * for them here. */ -if (bitmap_empty (&bio_ctrl->submit_bitmap, fs_info->sectors_per_page)) { +if (bitmap_empty (&bio_ctrl->submit_bitmap, blocks_per_folio)) { wbc->nr_to_write -= delalloc_to_write;return 1 ; }
@@ -1436,6 +1437,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,bool submitted_io = false;bool error = false;const u64 folio_start =folio_pos (folio); +const unsigned int blocks_per_folio =btrfs_blocks_per_folio (fs_info, folio);u64 cur;int bit;int ret =0 ;
@@ -1454,11 +1456,11 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,for (cur = start; cur < start + len; cur += fs_info->sectorsize)set_bit ((cur - folio_start) >> fs_info->sectorsize_bits, &range_bitmap);bitmap_and (&bio_ctrl->submit_bitmap, &bio_ctrl->submit_bitmap, &range_bitmap, - fs_info->sectors_per_page); + blocks_per_folio); bio_ctrl->end_io_func = end_bbio_data_write; -for_each_set_bit (bit, &bio_ctrl->submit_bitmap, fs_info->sectors_per_page) { +for_each_set_bit (bit, &bio_ctrl->submit_bitmap, blocks_per_folio) { cur =folio_pos (folio) + (bit << fs_info->sectorsize_bits);if (cur >= i_size) {
@@ -1532,6 +1534,7 @@ static int extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrlsize_t pg_offset;loff_t i_size =i_size_read (&inode->vfs_inode);unsigned long end_index = i_size >>PAGE_SHIFT ; +const unsigned int blocks_per_folio =btrfs_blocks_per_folio (fs_info, folio);trace_extent_writepage (folio, &inode->vfs_inode, bio_ctrl->wbc);
@@ -1571,7 +1574,7 @@ static int extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrlbtrfs_err_rl (fs_info,"failed to submit blocks, root=%lld inode=%llu folio=%llu submit_bitmap=%*pbl: %d" ,btrfs_root_id (inode->root),btrfs_ino (inode), -folio_pos (folio), fs_info->sectors_per_page, +folio_pos (folio), blocks_per_folio, &bio_ctrl->submit_bitmap, ret); bio_ctrl->wbc->nr_to_write--;
@@ -1851,9 +1854,10 @@ static int submit_eb_subpage(struct folio *folio, struct writeback_control *wbc)u64 folio_start =folio_pos (folio);int bit_start =0 ;int sectors_per_node = fs_info->nodesize >> fs_info->sectorsize_bits; +const unsigned int blocks_per_folio =btrfs_blocks_per_folio (fs_info, folio);/* Lock and write each dirty extent buffers in the range */ -while (bit_start < fs_info->sectors_per_page) { +while (bit_start < blocks_per_folio) {struct btrfs_subpage *subpage =folio_get_private (folio);struct extent_buffer *eb;unsigned long flags;
@@ -1869,7 +1873,7 @@ static int submit_eb_subpage(struct folio *folio, struct writeback_control *wbc)break ; }spin_lock_irqsave (&subpage->lock, flags); -if (!test_bit (bit_start + btrfs_bitmap_nr_dirty * fs_info->sectors_per_page, +if (!test_bit (bit_start + btrfs_bitmap_nr_dirty * blocks_per_folio, subpage->bitmaps)) {spin_unlock_irqrestore (&subpage->lock, flags);spin_unlock (&folio->mapping->i_private_lock);
fs/btrfs/fs.h +6 -1
@@ -709,7 +709,6 @@ struct btrfs_fs_info {* running. */ refcount_t scrub_workers_refcnt; -u32 sectors_per_page;struct workqueue_struct *scrub_workers;struct btrfs_discard_ctl discard_ctl;
@@ -981,6 +980,12 @@ static inline u32 count_max_extents(const struct btrfs_fs_info *fs_info, u64 sizreturn div_u64 (size + fs_info->max_extent_size -1 , fs_info->max_extent_size); } +static inline unsigned int btrfs_blocks_per_folio (const struct btrfs_fs_info *fs_info, +const struct folio *folio) +{ +return folio_size (folio) >> fs_info->sectorsize_bits; +} +bool btrfs_exclop_start (struct btrfs_fs_info *fs_info,enum btrfs_exclusive_operation type); bool btrfs_exclop_start_try_lock(struct btrfs_fs_info *fs_info,
fs/btrfs/subpage.c +64 -41
236 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v2 2/8 btrfs: extract metadata subpage detection into a dedicated helper
In reply to Qu WenruoCurrently we have only one btrfs_is_subpage() to cover both data and metadata.
But there is a special case for metadata:
- dummy extent buffer, sector size < PAGE_SIZE and node size >= PAGE_SIZE
In such case, btrfs_is_subpage() will return true for extent buffer folio.
But that is not correct, and that's exactly why we have some open-coded checks for functions like set_extent_buffer_uptodate() and clear_extent_buffer_uptodate().
Just extract the metadata specific checks into a helper, and replace those call sites.
--- fs/btrfs/extent_io.c | 28 ++++++++++++++-------------- fs/btrfs/subpage.c | 4 ++-- fs/btrfs/subpage.h | 19 ++++++++++++++++++- 3 files changed, 34 insertions(+), 17 deletions(-)
fs/btrfs/extent_io.c +14 -14
@@ -836,7 +836,7 @@ static int attach_extent_buffer_folio(struct extent_buffer *eb,if (folio->mapping)lockdep_assert_held (&folio->mapping->i_private_lock); -if (fs_info->nodesize >=PAGE_SIZE ) { +if (!btrfs_meta_is_subpage (fs_info)) {if (!folio_test_private (folio))folio_attach_private (folio, eb);else
@@ -1797,7 +1797,7 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,wbc_init_bio (wbc, &bbio->bio); bbio->inode =BTRFS_I (eb->fs_info->btree_inode); bbio->file_offset = eb->start; -if (fs_info->nodesize <PAGE_SIZE ) { +if (btrfs_meta_is_subpage (fs_info)) {struct folio *folio = eb->folios[0 ];bool ret;
@@ -1939,7 +1939,7 @@ static int submit_eb_page(struct folio *folio, struct btrfs_eb_write_context *ctif (!folio_test_private (folio))return 0 ; -if (folio_to_fs_info (folio)->nodesize <PAGE_SIZE ) +if (btrfs_meta_is_subpage (folio_to_fs_info (folio)))return submit_eb_subpage (folio, wbc);spin_lock (&mapping->i_private_lock);
@@ -2596,7 +2596,7 @@ static void detach_extent_buffer_folio(const struct extent_buffer *eb, struct foreturn ; } -if (fs_info->nodesize >=PAGE_SIZE ) { +if (!btrfs_meta_is_subpage (fs_info)) {/* * We do this since we'll remove the pages after we've * removed the eb from the radix tree, so we could race
@@ -2900,7 +2900,7 @@ static struct extent_buffer *grab_extent_buffer(struct btrfs_fs_info *fs_info,* don't try to insert two ebs for the same bytenr. So here we always * return NULL and just continue. */ -if (fs_info->nodesize <PAGE_SIZE ) +if (btrfs_meta_is_subpage (fs_info))return NULL ;/* Page not yet attached to an extent buffer */
@@ -3003,7 +3003,7 @@ static int attach_eb_folio_to_filemap(struct extent_buffer *eb, int i, finish:spin_lock (&mapping->i_private_lock); -if (existing_folio && fs_info->nodesize <PAGE_SIZE ) { +if (existing_folio &&btrfs_meta_is_subpage (fs_info)) {/* We're going to reuse the existing page, can drop our folio now. */ __free_page (folio_page (eb->folios[i],0 )); eb->folios[i] = existing_folio;
@@ -3094,7 +3094,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,* The memory will be freed by attach_extent_buffer_page() or freed * manually if we exit earlier. */ -if (fs_info->nodesize <PAGE_SIZE ) { +if (btrfs_meta_is_subpage (fs_info)) { prealloc =btrfs_alloc_subpage (fs_info,BTRFS_SUBPAGE_METADATA );if (IS_ERR (prealloc)) { ret =PTR_ERR (prealloc);
@@ -3395,7 +3395,7 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans,percpu_counter_add_batch (&fs_info->dirty_metadata_bytes, -eb->len, fs_info->dirty_metadata_batch); -if (eb->fs_info->nodesize <PAGE_SIZE ) +if (btrfs_meta_is_subpage (fs_info))return clear_subpage_extent_buffer_dirty (eb); num_folios =num_extent_folios (eb);
@@ -3426,7 +3426,7 @@ void set_extent_buffer_dirty(struct extent_buffer *eb)WARN_ON (test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags));if (!was_dirty) { -bool subpage = eb->fs_info->nodesize <PAGE_SIZE ; +bool subpage =btrfs_meta_is_subpage (eb->fs_info);/* * For subpage case, we can have other extent buffers in the
@@ -3472,7 +3472,7 @@ void clear_extent_buffer_uptodate(struct extent_buffer *eb)* This is special handling for metadata subpage, as regular * btrfs_is_subpage() can not handle cloned/dummy metadata. */ -if (fs_info->nodesize >=PAGE_SIZE ) +if (!btrfs_meta_is_subpage (fs_info))folio_clear_uptodate (folio);else btrfs_subpage_clear_uptodate(fs_info, folio,
@@ -3493,7 +3493,7 @@ void set_extent_buffer_uptodate(struct extent_buffer *eb)* This is special handling for metadata subpage, as regular * btrfs_is_subpage() can not handle cloned/dummy metadata. */ -if (fs_info->nodesize >=PAGE_SIZE ) +if (!btrfs_meta_is_subpage (fs_info))folio_mark_uptodate (folio);else btrfs_subpage_set_uptodate(fs_info, folio,
@@ -3583,7 +3583,7 @@ int read_extent_buffer_pages_nowait(struct extent_buffer *eb, int mirror_num, bbio->inode =BTRFS_I (eb->fs_info->btree_inode); bbio->file_offset = eb->start;memcpy (&bbio->parent_check, check,sizeof (*check)); -if (eb->fs_info->nodesize <PAGE_SIZE ) { +if (btrfs_meta_is_subpage (eb->fs_info)) { ret =bio_add_folio (&bbio->bio, eb->folios[0 ], eb->len, eb->start -folio_pos (eb->folios[0 ]));ASSERT (ret);
@@ -3784,7 +3784,7 @@ static void assert_eb_folio_uptodate(const struct extent_buffer *eb, int i)if (test_bit (EXTENT_BUFFER_WRITE_ERR , &eb->bflags))return ; - if (fs_info->nodesize < PAGE_SIZE) { + if (btrfs_meta_is_subpage(fs_info)) { folio = eb->folios[0]; ASSERT(i == 0); if (WARN_ON(!btrfs_subpage_test_uptodate(fs_info, folio,
@@ -4270,7 +4270,7 @@ int try_release_extent_buffer(struct folio *folio) {struct extent_buffer *eb; -if (folio_to_fs_info (folio)->nodesize <PAGE_SIZE ) +if (btrfs_meta_is_subpage (folio_to_fs_info (folio)))return try_release_subpage_extent_buffer (folio);/*
fs/btrfs/subpage.c +2 -2
@@ -169,7 +169,7 @@ void btrfs_folio_inc_eb_refs(const struct btrfs_fs_info *fs_info, struct folio * {struct btrfs_subpage *subpage; -if (!btrfs_is_subpage (fs_info, folio->mapping)) +if (!btrfs_meta_is_subpage (fs_info))return ;ASSERT (folio_test_private (folio) && folio->mapping);
@@ -183,7 +183,7 @@ void btrfs_folio_dec_eb_refs(const struct btrfs_fs_info *fs_info, struct folio * {struct btrfs_subpage *subpage; -if (!btrfs_is_subpage (fs_info, folio->mapping)) +if (!btrfs_meta_is_subpage (fs_info))return ;ASSERT (folio_test_private (folio) && folio->mapping);
fs/btrfs/subpage.h +18 -1
@@ -6,10 +6,10 @@#include <linux/spinlock.h> #include <linux/atomic.h> #include <linux/sizes.h> +#include "fs.h" struct address_space ;struct folio ; -struct btrfs_fs_info ;/* * Extra info for subpapge bitmap.
@@ -70,8 +70,25 @@ enum btrfs_subpage_type { };#if PAGE_SIZE >SZ_4K +/* +* For metadata it's more complex, as we can have dummy extent buffers, where +* folios have no mapping to determine the owning inode. +* +* Thankfully we only need to check if node size is smaller than page size. +* Even with larger folio support, we will only allocate a folio as large as +* node size. +* Thus if nodesize < PAGE_SIZE, we know metadata needs need to subpage routine. +*/ +static inline bool btrfs_meta_is_subpage (const struct btrfs_fs_info *fs_info) +{ +return fs_info->nodesize <PAGE_SIZE ; +}bool btrfs_is_subpage (const struct btrfs_fs_info *fs_info,struct address_space *mapping);#else +static inline bool btrfs_meta_is_subpage (const struct btrfs_fs_info *fs_info) +{ +return false; +}static inline bool btrfs_is_subpage (const struct btrfs_fs_info *fs_info,struct address_space *mapping) {
Signature · 1 line
2.48.1
PATCH v2 3/8 btrfs: make subpage attach and detach to handle metadata properly
In reply to Qu WenruoCurrently subpage attach/detach is not doing proper dummy extent buffer subpage check, as btrfs_is_subpage() is not reliable for dummy extent buffer folios.
Since we have a metadata specific check now, use that for btrfs_attach_subpage() first.
Then enhance btrfs_detach_subpage() to accept a type parameter, so that we can do extra checks for dummy extent buffers properly.
--- fs/btrfs/extent_io.c | 6 +++--- fs/btrfs/subpage.c | 15 ++++++++++++--- fs/btrfs/subpage.h | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-)
fs/btrfs/extent_io.c +3 -3
@@ -888,7 +888,7 @@ void clear_folio_extent_mapped(struct folio *folio) fs_info =folio_to_fs_info (folio);if (btrfs_is_subpage (fs_info, folio->mapping)) -return btrfs_detach_subpage (fs_info, folio); +return btrfs_detach_subpage (fs_info, folio,BTRFS_SUBPAGE_DATA );folio_detach_private (folio); }
@@ -2622,7 +2622,7 @@ static void detach_extent_buffer_folio(const struct extent_buffer *eb, struct fo* attached to one dummy eb, no sharing. */ if (!mapped) { -btrfs_detach_subpage (fs_info, folio); +btrfs_detach_subpage (fs_info, folio,BTRFS_SUBPAGE_METADATA );return ; }
@@ -2633,7 +2633,7 @@ static void detach_extent_buffer_folio(const struct extent_buffer *eb, struct fo* page range and no unfinished IO. */ if (!folio_range_has_eb (folio)) -btrfs_detach_subpage (fs_info, folio); +btrfs_detach_subpage (fs_info, folio,BTRFS_SUBPAGE_METADATA );spin_unlock (&folio->mapping->i_private_lock); }
fs/btrfs/subpage.c +12 -3
@@ -104,7 +104,11 @@ int btrfs_attach_subpage(const struct btrfs_fs_info *fs_info,ASSERT (folio_test_locked (folio));/* Either not subpage, or the folio already has private attached. */ -if (!btrfs_is_subpage (fs_info, folio->mapping) ||folio_test_private (folio)) +if (folio_test_private (folio)) +return 0 ; +if (type ==BTRFS_SUBPAGE_METADATA && !btrfs_meta_is_subpage (fs_info)) +return 0 ; +if (type ==BTRFS_SUBPAGE_DATA && !btrfs_is_subpage (fs_info, folio->mapping))return 0 ; subpage =btrfs_alloc_subpage (fs_info, type);
@@ -115,12 +119,17 @@ int btrfs_attach_subpage(const struct btrfs_fs_info *fs_info,return 0 ; } -void btrfs_detach_subpage (const struct btrfs_fs_info *fs_info,struct folio *folio) +void btrfs_detach_subpage (const struct btrfs_fs_info *fs_info,struct folio *folio, +enum btrfs_subpage_type type) {struct btrfs_subpage *subpage;/* Either not subpage, or the folio already has private attached. */ -if (!btrfs_is_subpage (fs_info, folio->mapping) || !folio_test_private (folio)) +if (!folio_test_private (folio)) +return ; +if (type ==BTRFS_SUBPAGE_METADATA && !btrfs_meta_is_subpage (fs_info)) +return ; +if (type ==BTRFS_SUBPAGE_DATA && !btrfs_is_subpage (fs_info, folio->mapping))return ; subpage =folio_detach_private (folio);
fs/btrfs/subpage.h +2 -1
@@ -98,7 +98,8 @@ static inline bool btrfs_is_subpage(const struct btrfs_fs_info *fs_info,int btrfs_attach_subpage (const struct btrfs_fs_info *fs_info,struct folio *folio,enum btrfs_subpage_type type); -void btrfs_detach_subpage (const struct btrfs_fs_info *fs_info,struct folio *folio); +void btrfs_detach_subpage (const struct btrfs_fs_info *fs_info,struct folio *folio, +enum btrfs_subpage_type type);/* Allocate additional data where page represents more than one sector */ struct btrfs_subpage *btrfs_alloc_subpage(const struct btrfs_fs_info *fs_info,
Signature · 1 line
2.48.1
PATCH v2 4/8 btrfs: use metadata specific helpers to simplify extent buffer helpers
In reply to Qu WenruoThe following functions are doing metadata specific checks:
- set_extent_buffer_uptodate()
- clear_extent_buffer_uptodate()
The reason why we do not use btrfs_folio_*() helpers for those helpers is, btrfs_is_subpage() can not handle dummy extent buffer if nodesize >= PAGE_SIZE but block size < PAGE_SIZE.
In that case, we do not need to attach extra bitmaps to the extent buffer folio. But since dummy extent buffer folios are not attached to btree inode, btrfs_is_subpage() will return true, causing problems.
And the following are using btrfs_folio_*() helpers for metadata, but in theory we should use metadata specific checks:
- set_extent_buffer_dirty()
This is not causing problems because a dummy extent buffer should never be marked dirty, thus we avoided the bullet.
To make code simpler, introduce btrfs_meta_folio_*() helpers, to do the metadata specific handling, so that we do not to open-code such checks in above involved functions.
--- fs/btrfs/extent_io.c | 24 ++++-------------------- fs/btrfs/subpage.c | 25 +++++++++++++++++++++++++ fs/btrfs/subpage.h | 15 ++++++++++++++- 3 files changed, 43 insertions(+), 21 deletions(-)
fs/btrfs/extent_io.c +4 -20
@@ -3442,8 +3442,8 @@ void set_extent_buffer_dirty(struct extent_buffer *eb)if (subpage)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); +btrfs_meta_folio_set_dirty (eb->fs_info, eb->folios[i], + eb->start, eb->len);if (subpage)folio_unlock (eb->folios[0 ]); percpu_counter_add_batch(&eb->fs_info->dirty_metadata_bytes,
@@ -3468,15 +3468,7 @@ void clear_extent_buffer_uptodate(struct extent_buffer *eb)if (!folio)continue ; -/* -* This is special handling for metadata subpage, as regular -* btrfs_is_subpage() can not handle cloned/dummy metadata. -*/ -if (!btrfs_meta_is_subpage (fs_info)) -folio_clear_uptodate (folio); -else -btrfs_subpage_clear_uptodate (fs_info, folio, - eb->start, eb->len); +btrfs_meta_folio_clear_uptodate (fs_info, folio, eb->start, eb->len); } }
@@ -3489,15 +3481,7 @@ void set_extent_buffer_uptodate(struct extent_buffer *eb)for (int i =0 ; i < num_folios; i++) {struct folio *folio = eb->folios[i]; -/* -* This is special handling for metadata subpage, as regular -* btrfs_is_subpage() can not handle cloned/dummy metadata. -*/ -if (!btrfs_meta_is_subpage (fs_info)) -folio_mark_uptodate (folio); -else -btrfs_subpage_set_uptodate (fs_info, folio, - eb->start, eb->len); +btrfs_meta_folio_set_uptodate (fs_info, folio, eb->start, eb->len); } }
fs/btrfs/subpage.c +25 -0
@@ -651,6 +651,31 @@ bool btrfs_folio_clamp_test_##name(const struct btrfs_fs_info *fs_info, \return folio_test_func (folio); \btrfs_subpage_clamp_range (folio, &start, &len); \ return btrfs_subpage_test_##name(fs_info, folio, start, len); \ +} \ +void btrfs_meta_folio_set_##name(const struct btrfs_fs_info *fs_info, \ + struct folio *folio, u64 start, u32 len) \ +{ \ + if (!btrfs_meta_is_subpage(fs_info)) { \ + folio_set_func(folio); \ + return; \ + } \ + btrfs_subpage_set_##name(fs_info, folio, start, len); \ +} \ +void btrfs_meta_folio_clear_##name(const struct btrfs_fs_info *fs_info, \ + struct folio *folio, u64 start, u32 len) \ +{ \ + if (!btrfs_meta_is_subpage(fs_info)) { \ + folio_clear_func(folio); \ + return; \ + } \ + btrfs_subpage_clear_##name(fs_info, folio, start, len); \ +} \ +bool btrfs_meta_folio_test_##name(const struct btrfs_fs_info *fs_info, \ + struct folio *folio, u64 start, u32 len) \ +{ \ + if (!btrfs_meta_is_subpage(fs_info)) \ + return folio_test_func(folio); \ + return btrfs_subpage_test_##name(fs_info, folio, start, len); \ }IMPLEMENT_BTRFS_PAGE_OPS (uptodate, folio_mark_uptodate, folio_clear_uptodate, folio_test_uptodate);
fs/btrfs/subpage.h +14 -1
@@ -128,6 +128,13 @@ void btrfs_folio_end_lock_bitmap(const struct btrfs_fs_info *fs_info,* btrfs_folio_clamp_*() are similar to btrfs_folio_*(), except the range doesn't * need to be inside the page. Those functions will truncate the range * automatically. +* +* Both btrfs_folio_*() and btrfs_folio_clamp_*() are for data folios. +* +* For metadata, one should use btrfs_meta_folio_*() helpers instead, and there +* is no clamp version for metadata helpers, as we either go subpage +* (nodesize < PAGE_SIZE) or go regular folio helpers (nodesize >= PAGE_SIZE, +* and our folio is never larger than nodesize). */ #define DECLARE_BTRFS_SUBPAGE_OPS (name) \ void btrfs_subpage_set_##name(const struct btrfs_fs_info *fs_info, \
@@ -147,7 +154,13 @@ void btrfs_folio_clamp_set_##name(const struct btrfs_fs_info *fs_info, \ void btrfs_folio_clamp_clear_##name(const struct btrfs_fs_info *fs_info, \ struct folio *folio, u64 start, u32 len); \ bool btrfs_folio_clamp_test_##name(const struct btrfs_fs_info *fs_info, \ - struct folio *folio, u64 start, u32 len); + struct folio *folio, u64 start, u32 len); \ +void btrfs_meta_folio_set_##name(const struct btrfs_fs_info *fs_info, \ + struct folio *folio, u64 start, u32 len); \ +void btrfs_meta_folio_clear_##name(const struct btrfs_fs_info *fs_info, \ + struct folio *folio, u64 start, u32 len); \ +bool btrfs_meta_folio_test_##name(const struct btrfs_fs_info *fs_info, \ + struct folio *folio, u64 start, u32 len); \DECLARE_BTRFS_SUBPAGE_OPS (uptodate);DECLARE_BTRFS_SUBPAGE_OPS (dirty);
Signature · 1 line
2.48.1
PATCH v2 5/8 btrfs: simplify btrfs_clear_buffer_dirty()
In reply to Qu WenruoThe function btrfs_clear_buffer_dirty() is called on dirty extent buffer that will not be written back.
The function will call btree_clear_folio_dirty() to clear the folio dirty flag and also clear PAGECACHE_TAG_DIRTY flag.
And we split the subpage and regular handlings, as for subpage cases we should only clear PAGECACHE_TAG_DIRTY if the last dirty extent buffer in the page is cleared.
So here we can simplify the function by:
- Use the newly introduced btrfs_meta_folio_clear_and_test_dirty() helper The helper will return true if we cleared the folio dirty flag. With that we can use the same helper for both subpage and regular cases.
- Rename btree_clear_folio_dirty() to btree_clear_folio_dirty_tag() As we move the folio dirty clearing in the btrfs_clear_buffer_dirty().
- Call btrfs_meta_folio_clear_and_test_dirty() to clear the dirty flags for both regular and subpage metadata cases
- Only call btree_clear_folio_dirty_tag() when the folio is no longer dirty
- Update the comment inside set_extent_buffer_dirty()
As there is no separate clear_subpage_extent_buffer_dirty() anymore.
--- fs/btrfs/extent_io.c | 36 ++++++++++-------------------------- fs/btrfs/subpage.c | 23 +++++++++++++++++++++++ fs/btrfs/subpage.h | 2 ++ 3 files changed, 35 insertions(+), 26 deletions(-)
fs/btrfs/extent_io.c +10 -26
@@ -3337,11 +3337,10 @@ void free_extent_buffer_stale(struct extent_buffer *eb)release_extent_buffer (eb); } -static void btree_clear_folio_dirty (struct folio *folio) +static void btree_clear_folio_dirty_tag (struct folio *folio) { -ASSERT (folio_test_dirty (folio)); +ASSERT (!folio_test_dirty (folio));ASSERT (folio_test_locked (folio)); -folio_clear_dirty_for_io (folio);xa_lock_irq (&folio->mapping->i_pages);if (!folio_test_dirty (folio)) __xa_clear_mark(&folio->mapping->i_pages,
@@ -3349,26 +3348,11 @@ static void btree_clear_folio_dirty(struct folio *folio)xa_unlock_irq (&folio->mapping->i_pages); } -static void clear_subpage_extent_buffer_dirty (const struct extent_buffer *eb) -{ -struct btrfs_fs_info *fs_info = eb->fs_info; -struct folio *folio = eb->folios[0 ]; -bool last; - -/* btree_clear_folio_dirty() needs page locked. */ -folio_lock (folio); - last =btrfs_subpage_clear_and_test_dirty (fs_info, folio, eb->start, eb->len); -if (last) -btree_clear_folio_dirty (folio); -folio_unlock (folio); -WARN_ON (atomic_read (&eb->refs) ==0 ); -} -void btrfs_clear_buffer_dirty (struct btrfs_trans_handle *trans,struct extent_buffer *eb) {struct btrfs_fs_info *fs_info = eb->fs_info; -int num_folios; +const int num_folios =num_extent_folios (eb);btrfs_assert_tree_write_locked (eb);
@@ -3395,17 +3379,17 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans,percpu_counter_add_batch (&fs_info->dirty_metadata_bytes, -eb->len, fs_info->dirty_metadata_batch); -if (btrfs_meta_is_subpage (fs_info)) -return clear_subpage_extent_buffer_dirty (eb); - - num_folios =num_extent_folios (eb);for (int i =0 ; i < num_folios; i++) {struct folio *folio = eb->folios[i]; +bool last;if (!folio_test_dirty (folio))continue ;folio_lock (folio); -btree_clear_folio_dirty (folio); + last =btrfs_meta_folio_clear_and_test_dirty (fs_info, folio, + eb->start, eb->len); +if (last) +btree_clear_folio_dirty_tag (folio);folio_unlock (folio); }WARN_ON (atomic_read (&eb->refs) ==0 );
@@ -3430,12 +3414,12 @@ void set_extent_buffer_dirty(struct extent_buffer *eb)/* * For subpage case, we can have other extent buffers in the -* same page, and in clear_subpage_extent_buffer_dirty() we +* same page, and in clear_extent_buffer_dirty() we * have to clear page dirty without subpage lock held. * This can cause race where our page gets dirty cleared after * we just set it. * -* Thankfully, clear_subpage_extent_buffer_dirty() has locked +* Thankfully, clear_extent_buffer_dirty() has locked * its page for other reasons, we can use page lock to prevent * the above race. */
fs/btrfs/subpage.c +23 -0
@@ -782,6 +782,29 @@ void btrfs_folio_set_lock(const struct btrfs_fs_info *fs_info,spin_unlock_irqrestore (&subpage->lock, flags); } +/* +* Clear the dirty flag for the folio. +* +* If the resulted folio is no longer dirty, return true. Otherwise return false. +*/ +bool btrfs_meta_folio_clear_and_test_dirty (const struct btrfs_fs_info *fs_info, +struct folio *folio,u64 start,u32 len) +{ +bool last; + +if (!btrfs_meta_is_subpage (fs_info)) { +folio_clear_dirty_for_io (folio); +return true; + } + + last =btrfs_subpage_clear_and_test_dirty (fs_info, folio, start, len); +if (last) { +folio_clear_dirty_for_io (folio); +return true; + } +return false; +} +void __cold btrfs_subpage_dump_bitmap (const struct btrfs_fs_info *fs_info,struct folio *folio,u64 start,u32 len) {
fs/btrfs/subpage.h +2 -0
@@ -186,6 +186,8 @@ bool btrfs_subpage_clear_and_test_dirty(const struct btrfs_fs_info *fs_info,void btrfs_folio_assert_not_dirty (const struct btrfs_fs_info *fs_info,struct folio *folio,u64 start,u32 len); +bool btrfs_meta_folio_clear_and_test_dirty (const struct btrfs_fs_info *fs_info, +struct folio *folio,u64 start,u32 len);void btrfs_get_subpage_dirty_bitmap (struct btrfs_fs_info *fs_info,struct folio *folio,unsigned long *ret_bitmap);
Signature · 1 line
2.48.1
PATCH v2 6/8 btrfs: simplify write_one_eb()
In reply to Qu WenruoCurrently inside write_one_eb() we have two different handling for subpage and regular metadata.
The differences are:
- Extra offset/length calculation when adding the folio range to bio for subpage cases
- Only decrease wbc->nr_to_write if the whole page is no longer dirty for subpage cases
- Use subpage helper for subpage cases
Merge those different handlings into a shared one by:
- Always calculate the to-be-queued range
So that bio_add_folio() can use the same calculated resulted length and offset for both cases.
- Use btrfs_meta_folio_clear_dirty() and
btrfs_meta_folio_set_writeback() helpers
This will cover both cases.
- Only decrease wbc->nr_to_write if the folio is no longer dirty Since we have the folio locked, no one else can modify the folio dirty flags (set_extent_buffer_dirty() will also lock the folio for subpage cases).
Thus after our btrfs_meta_folio_clear_dirty() call, if the whole folio is no longer dirty, we're submitting the last dirty eb of the folio, and can decrease wbc->nr_to_write properly.
--- fs/btrfs/extent_io.c | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-)
fs/btrfs/extent_io.c +13 -29
@@ -1786,6 +1786,7 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb, {struct btrfs_fs_info *fs_info = eb->fs_info;struct btrfs_bio *bbio; +const int num_folios =num_extent_folios (eb);prepare_eb_write (eb);
@@ -1797,38 +1798,21 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,wbc_init_bio (wbc, &bbio->bio); bbio->inode =BTRFS_I (eb->fs_info->btree_inode); bbio->file_offset = eb->start; -if (btrfs_meta_is_subpage (fs_info)) { -struct folio *folio = eb->folios[0 ]; -bool ret; +for (int i =0 ; i < num_folios; i++) { +struct folio *folio = eb->folios[i]; +u64 range_start =max_t (u64, eb->start,folio_pos (folio)); +u32 range_len =min_t (u64,folio_pos (folio) +folio_size (folio), + eb->start + eb->len) - range_start;folio_lock (folio); -btrfs_subpage_set_writeback (fs_info, folio, eb->start, eb->len); -if (btrfs_subpage_clear_and_test_dirty (fs_info, folio, eb->start, - eb->len)) { -folio_clear_dirty_for_io (folio); - wbc->nr_to_write--; - } - ret =bio_add_folio (&bbio->bio, folio, eb->len, - eb->start -folio_pos (folio)); -ASSERT (ret); -wbc_account_cgroup_owner (wbc, folio, eb->len); -folio_unlock (folio); - }else { -int num_folios =num_extent_folios (eb); - -for (int i =0 ; i < num_folios; i++) { -struct folio *folio = eb->folios[i]; -bool ret; - -folio_lock (folio); -folio_clear_dirty_for_io (folio); -folio_start_writeback (folio); - ret =bio_add_folio (&bbio->bio, folio, eb->folio_size,0 ); -ASSERT (ret); -wbc_account_cgroup_owner (wbc, folio, eb->folio_size); +btrfs_meta_folio_clear_dirty (fs_info, folio, eb->start, eb->len); +btrfs_meta_folio_set_writeback (fs_info, folio, eb->start, eb->len); +if (!folio_test_dirty (folio)) wbc->nr_to_write -=folio_nr_pages (folio); -folio_unlock (folio); - } +bio_add_folio_nofail (&bbio->bio, folio, range_len, +offset_in_folio (folio, range_start)); +wbc_account_cgroup_owner (wbc, folio, range_len); +folio_unlock (folio); }btrfs_submit_bbio (bbio,0 ); }
Signature · 1 line
2.48.1
PATCH v2 7/8 btrfs: simplify read_extent_buffer_pages_nowait()
In reply to Qu WenruoBy using a shared bio_add_folio_nofail() with calculated range_start/range_len, so no more explicit subpage routine needed.
--- fs/btrfs/extent_io.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
fs/btrfs/extent_io.c +8 -13
@@ -3494,8 +3494,8 @@ static void end_bbio_meta_read(struct btrfs_bio *bbio)int read_extent_buffer_pages_nowait (struct extent_buffer *eb,int mirror_num,const struct btrfs_tree_parent_check *check) { +const int num_folios =num_extent_folios (eb);struct btrfs_bio *bbio; -bool ret;if (test_bit (EXTENT_BUFFER_UPTODATE , &eb->bflags))return 0 ;
@@ -3535,19 +3535,14 @@ int read_extent_buffer_pages_nowait(struct extent_buffer *eb, int mirror_num, bbio->inode =BTRFS_I (eb->fs_info->btree_inode); bbio->file_offset = eb->start;memcpy (&bbio->parent_check, check,sizeof (*check)); -if (btrfs_meta_is_subpage (eb->fs_info)) { - ret =bio_add_folio (&bbio->bio, eb->folios[0 ], eb->len, - eb->start -folio_pos (eb->folios[0 ])); -ASSERT (ret); - }else { -int num_folios =num_extent_folios (eb); +for (int i =0 ; i < num_folios; i++) { +struct folio *folio = eb->folios[i]; +u64 range_start =max_t (u64, eb->start,folio_pos (folio)); +u32 range_len =min_t (u64,folio_pos (folio) +folio_size (folio), + eb->start + eb->len) - range_start; -for (int i =0 ; i < num_folios; i++) { -struct folio *folio = eb->folios[i]; - - ret =bio_add_folio (&bbio->bio, folio, eb->folio_size,0 ); -ASSERT (ret); - } +bio_add_folio_nofail (&bbio->bio, folio, range_len, +offset_in_folio (folio, range_start)); }btrfs_submit_bbio (bbio, mirror_num);return 0 ;
Signature · 1 line
2.48.1
PATCH v2 8/8 btrfs: require strict data/metadata split for subpage check
In reply to Qu WenruoSince we have btrfs_meta_is_subpage(), we should make btrfs_is_subpage() to be data inode specific.
This change involves:
- Simplify btrfs_is_subpage()
Now we only need to do a very simple sectorsize check against PAGE_SIZE.
And since the function is pretty simple now, just make it an inline function.
- Add an extra ASSERT() to make sure btrfs_is_subpage() is only called on data inode mapping
- Migrate btree_csum_one_bio() to use btrfs_meta_folio_*() helpers
- Migrate alloc_extent_buffer() to use btrfs_meta_folio_*() helpers
- Migrate end_bbio_meta_write() to use btrfs_meta_folio_*() helpers Or we will trigger the ASSERT() due to calling btrfs_folio_*() on metadata folios.
--- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent_io.c | 11 ++++------- fs/btrfs/subpage.c | 24 ------------------------ fs/btrfs/subpage.h | 11 ++++++++++- 4 files changed, 16 insertions(+), 34 deletions(-)
fs/btrfs/disk-io.c +2 -2
@@ -284,8 +284,8 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio)if (WARN_ON_ONCE (found_start != eb->start))return BLK_STS_IOERR ; -if (WARN_ON (!btrfs_folio_test_uptodate (fs_info, eb->folios[0 ], - eb->start, eb->len))) +if (WARN_ON (!btrfs_meta_folio_test_uptodate (fs_info, eb->folios[0 ], + eb->start, eb->len)))return BLK_STS_IOERR ; ASSERT(memcmp_extent_buffer(eb, fs_info->fs_devices->metadata_uuid,
fs/btrfs/extent_io.c +4 -7
@@ -1732,18 +1732,15 @@ 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;struct folio_iter fi; -u32 bio_offset =0 ;if (bbio->bio.bi_status !=BLK_STS_OK )set_btree_ioerr (eb);bio_for_each_folio_all (fi, &bbio->bio) { -u64 start = eb->start + bio_offset;struct folio *folio = fi.folio; -u32 len = fi.length; -btrfs_folio_clear_writeback (fs_info, folio, start, len); - bio_offset += len; +btrfs_meta_folio_clear_writeback (fs_info, folio, + eb->start, eb->len); }clear_bit (EXTENT_BUFFER_WRITEBACK , &eb->bflags);
@@ -3136,7 +3133,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,* and free the allocated page. */ folio = eb->folios[i]; -WARN_ON (btrfs_folio_test_dirty (fs_info, folio, eb->start, eb->len)); +WARN_ON (btrfs_meta_folio_test_dirty (fs_info, folio, eb->start, eb->len));/* * Check if the current page is physically contiguous with previous eb
@@ -3147,7 +3144,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,if (i &&folio_page (eb->folios[i -1 ],0 ) +1 !=folio_page (folio,0 )) page_contig = false; -if (!btrfs_folio_test_uptodate (fs_info, folio, eb->start, eb->len)) +if (!btrfs_meta_folio_test_uptodate (fs_info, folio, eb->start, eb->len)) uptodate =0 ;/*
fs/btrfs/subpage.c +0 -24
@@ -64,30 +64,6 @@* This means a slightly higher tree locking latency. */ -#if PAGE_SIZE >SZ_4K -bool btrfs_is_subpage (const struct btrfs_fs_info *fs_info,struct address_space *mapping) -{ -if (fs_info->sectorsize >=PAGE_SIZE ) -return false; - -/* -* Only data pages (either through DIO or compression) can have no -* mapping. And if mapping->host is data inode, it's subpage. -* As we have ruled our sectorsize >= PAGE_SIZE case already. -*/ -if (!mapping || !mapping->host ||is_data_inode (BTRFS_I (mapping->host))) -return true; - -/* -* Now the only remaining case is metadata, which we only go subpage -* routine if nodesize < PAGE_SIZE. -*/ -if (fs_info->nodesize <PAGE_SIZE ) -return true; -return false; -} -#endif -int btrfs_attach_subpage (const struct btrfs_fs_info *fs_info,struct folio *folio,enum btrfs_subpage_type type) {
fs/btrfs/subpage.h +10 -1
@@ -6,6 +6,7 @@#include <linux/spinlock.h> #include <linux/atomic.h> #include <linux/sizes.h> +#include "btrfs_inode.h" #include "fs.h" struct address_space ;
@@ -83,7 +84,13 @@ static inline bool btrfs_meta_is_subpage(const struct btrfs_fs_info *fs_info) {return fs_info->nodesize <PAGE_SIZE ; } -bool btrfs_is_subpage (const struct btrfs_fs_info *fs_info,struct address_space *mapping); +static inline bool btrfs_is_subpage (const struct btrfs_fs_info *fs_info, +struct address_space *mapping) +{ +if (mapping && mapping->host) +ASSERT (is_data_inode (BTRFS_I (mapping->host))); +return fs_info->sectorsize <PAGE_SIZE ; +}#else static inline bool btrfs_meta_is_subpage (const struct btrfs_fs_info *fs_info) {
@@ -92,6 +99,8 @@ static inline bool btrfs_meta_is_subpage(const struct btrfs_fs_info *fs_info)static inline bool btrfs_is_subpage (const struct btrfs_fs_info *fs_info,struct address_space *mapping) { +if (mapping && mapping->host) +ASSERT (is_data_inode (BTRFS_I (mapping->host)));return false; }#endif
Signature · 1 line
2.48.1
Quoted 39 lines · Qu Wenruo
[CHANGELOG]
v2:
- Fix a crash in 4K page sized system caused bybtrfs_clear_buffer_dirty()
It looks like usingbtrfs_meta_folio_set_writeback()andbtrfs_meta_folio_clear_writeback()is screwing up the btree inode map.Fix it by reverting to the old manually clearing of
PAGECACHE_DIRTY_TAG.[METADATA SUBPAGE CHECKS]
Currently we only have onebtrfs_is_subpage()check, utilized by data and metadata.But the truth is,
btrfs_is_subpage()can return incorrect result if the target folio belongs to a dummy extent buffer.This means we have quite some metadata call sites doing their own metadata specific subpage check.
[SUBPAGE SPECIFIC HANDLINGS]
There are several functions that split the metadata subpage handling into a dedicated path.But the truth is, a lot of such paths only have minor differences compared to the regular routine.
[THIS SERIES]
This series address the above problems and prepare for the incoming data larger folio support by:- Remove
btrfs_fs_info::sectors_per_page
This is mostly a preparation for the future data larger folio support.- Introduce a dedicated metadata specific subpage check
- Unify/simplify metadata subpage handling So that we have a single unified path for metadata
Quoted 9 lines
Qu Wenruo (8):
btrfs: removebtrfs_fs_info::sectors_per_page
btrfs: extract metadata subpage detection into a dedicated helper
btrfs: make subpage attach and detach to handle metadata properly
btrfs: use metadata specific helpers to simplify extent buffer helpers
btrfs: simplifybtrfs_clear_buffer_dirty()
btrfs: simplifywrite_one_eb()
btrfs: simplifyread_extent_buffer_pages_nowait()
btrfs: require strict data/metadata split for subpage check
All look good to me.
Please update the subjects in the simplify patches in what regard they simplify the functions. For example "sipmlify subpage handling in ...". Thanks.