Random cleanups for 6.14
David Sterba
maintainercover Random cleanups for 6.14
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(-)
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 1/18 btrfs: drop unused parameter fs_info to btrfs_delete_delayed_insertion_item()
--- fs/btrfs/delayed-inode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/delayed-inode.c +2 -3
@@ -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;
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 2/18 btrfs: remove stray comment about SRCU
In reply to David SterbaThe subvol_sruce was removed in c75e839414d361 ("btrfs: kill the subvol_srcu") years ago.
--- fs/btrfs/disk-io.h | 3 --- 1 file changed, 3 deletions(-)
fs/btrfs/disk-io.h +0 -3
@@ -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) {
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 3/18 btrfs: use SECTOR_SIZE defines in btrfs_issue_discard()
In reply to David SterbaUse the existing define for single sector size.
--- fs/btrfs/extent-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/extent-tree.c +2 -2
@@ -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; }
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 4/18 btrfs: rename __unlock_for_delalloc() and drop underscores
In reply to David SterbaDrop the underscores as the naming scheme does not apply here and to have the unlock for parity with lock_delalloc_folios().
--- fs/btrfs/extent_io.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/btrfs/extent_io.c +4 -5
@@ -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 ); }
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 5/18 btrfs: open code set_page_extent_mapped()
In reply to David SterbaThe function set_page_extent_mapped() is now a simple wrapper so use the folio helper.
--- 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(-)
fs/btrfs/extent_io.c +0 -5
@@ -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;
fs/btrfs/extent_io.h +0 -1
@@ -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,
fs/btrfs/free-space-cache.c +1 -1
@@ -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);
fs/btrfs/relocation.c +1 -1
@@ -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);
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 6/18 btrfs: rename __get_extent_map() and pass btrfs_inode
In reply to David SterbaThe 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.
--- fs/btrfs/extent_io.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
fs/btrfs/extent_io.c +7 -8
@@ -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);
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 7/18 btrfs: use btrfs_inode in extent_writepage()
In reply to David SterbaAs extent_writepage() is internal helper we should use our inode type, so change it from struct inode.
--- fs/btrfs/extent_io.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
fs/btrfs/extent_io.c +7 -7
@@ -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_ctrlif (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); }
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 8/18 btrfs: make wait_on_extent_buffer_writeback() static inline
In reply to David SterbaThe simple helper can be inlined, no need for the separate function.
--- fs/btrfs/extent_io.c | 6 ------ fs/btrfs/extent_io.h | 7 ++++++- 2 files changed, 6 insertions(+), 7 deletions(-)
fs/btrfs/extent_io.c +0 -6
@@ -1518,12 +1518,6 @@ static int extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrlreturn 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. *
fs/btrfs/extent_io.h +6 -1
@@ -266,7 +266,12 @@ void free_extent_buffer_stale(struct extent_buffer *eb);#define WAIT_PAGE_LOCK 2int 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);
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 9/18 btrfs: drop one time used local variable in end_bbio_meta_write()
In reply to David Sterba--- fs/btrfs/extent_io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/extent_io.c +1 -2
@@ -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) {
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 10/18 btrfs: open code __free_extent_buffer()
In reply to David SterbaUsing the kmem cache freeing directly is clear enough, we don't need to wrap it. All the users are in the same file.
--- fs/btrfs/extent_io.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
fs/btrfs/extent_io.c +4 -9
@@ -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
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 11/18 btrfs: rename btrfs_release_extent_buffer_pages() to mention folios
In reply to David SterbaContinue page to folio updates, sync what the function does with it's name.
--- fs/btrfs/extent_io.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/extent_io.c +5 -5
@@ -2561,8 +2561,8 @@ static void detach_extent_buffer_folio(const struct extent_buffer *eb, struct fospin_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);
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 12/18 btrfs: switch grab_extent_buffer() to folios
In reply to David SterbaUse the folio API, remove page_folio/folio_page conversions.
--- fs/btrfs/extent_io.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
fs/btrfs/extent_io.c +5 -8
@@ -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;
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 13/18 btrfs: change return type to bool type of check_eb_alignment()
In reply to David SterbaThe check function pattern is supposed to return true/false, currently there's only one error code.
--- fs/btrfs/extent_io.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
fs/btrfs/extent_io.c +8 -6
@@ -2844,11 +2844,14 @@ static struct extent_buffer *grab_extent_buffer(struct btrfs_fs_info *fs_info, sreturn 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,
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 14/18 btrfs: unwrap folio locking helpers
In reply to David SterbaAnother conversion to folio API, use the folio locking directly instead of back and forth page <-> folio conversions.
--- fs/btrfs/extent_io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/extent_io.c +4 -4
@@ -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);
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 15/18 btrfs: remove unused define WAIT_PAGE_LOCK for extent io
In reply to David SterbaLast use was in the readahead code that got removed by f26c9238602856 ("btrfs: remove reada infrastructure").
--- fs/btrfs/extent_io.h | 1 - 1 file changed, 1 deletion(-)
fs/btrfs/extent_io.h +0 -1
@@ -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 2int 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)
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 16/18 btrfs: split waiting from read_extent_buffer_pages(), drop parameter wait
In reply to David SterbaThere are only 2 WAIT_* values left for wait parameter, we can encode this to the function name if the waiting functionality is split.
--- 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(-)
fs/btrfs/disk-io.c +1 -1
@@ -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 ;
fs/btrfs/extent_io.c +17 -10
@@ -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
fs/btrfs/extent_io.h +4 -3
@@ -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,
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 17/18 btrfs: remove redundant variables from __process_folios_contig() and lock_delalloc_folios()
In reply to David SterbaSame pattern in both functions, we really only use index, start_index is redundant.
--- fs/btrfs/extent_io.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/btrfs/extent_io.c +2 -4
@@ -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;
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 18/18 btrfs: async-thread: rename DFT_THRESHOLD to DEFAULT_THRESHOLD
In reply to David SterbaRename the macro so it's obvious what it means.
--- fs/btrfs/async-thread.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/async-thread.c +3 -3
@@ -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 {
Signature · 1 line
2.47.1
Re: [PATCH 02/18] btrfs: remove stray comment about SRCU
In reply to David SterbaQuoted 2 lines · David Sterba
The
subvol_srucewas removed inc75e839414d361("btrfs: kill the
subvol_sruce typo
Quoted 25 lines
subvol_srcu") years ago.Signed-off-by David Sterba <[email protected]>--- fs/btrfs/disk-io.h | 3 --- 1 file changed, 3 deletions(-)fs/btrfs/disk-io.h +0
-4@@ -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
Re: [PATCH 04/18] btrfs: rename __unlock_for_delalloc() and drop underscores
In reply to David SterbaQuoted 2 lines · David Sterba
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()'.
Re: [PATCH 12/18] btrfs: switch grab_extent_buffer() to folios
In reply to David Sterbafs/btrfs/extent_io.c struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, · line 2814
Quoted 3 lines · David Sterba
fs/btrfs/extent_io.c +1
-2-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.
Quoted 22 lines · David Sterba
Unsorteed small cleanups and renames.
David Sterba (18):
btrfs: drop unused parameterfs_infotobtrfs_delete_delayed_insertion_item()
btrfs: remove stray comment about SRCU
btrfs: useSECTOR_SIZEdefines inbtrfs_issue_discard()
btrfs: rename__unlock_for_delalloc()and drop underscores
btrfs: open codeset_page_extent_mapped()
btrfs: rename__get_extent_map()and passbtrfs_inode
btrfs: usebtrfs_inodeinextent_writepage()
btrfs: makewait_on_extent_buffer_writeback()static inline
btrfs: drop one time used local variable inend_bbio_meta_write()
btrfs: open code__free_extent_buffer()
btrfs: renamebtrfs_release_extent_buffer_pages()to mention folios
btrfs: switchgrab_extent_buffer()to folios
btrfs: change return type to bool type ofcheck_eb_alignment()
btrfs: unwrap folio locking helpers
btrfs: remove unused defineWAIT_PAGE_LOCKfor extent io
btrfs: split waiting fromread_extent_buffer_pages(), drop parameter wait
btrfs: remove redundant variables from__process_folios_contig()andlock_delalloc_folios()
btrfs: async-thread: renameDFT_THRESHOLDtoDEFAULT_THRESHOLD
Quoted 11 lines
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
for the series.
Quoted 13 lines · David Sterba
Unsorteed small cleanups and renames.
David Sterba (18):
btrfs: drop unused parameterfs_infotobtrfs_delete_delayed_insertion_item()
btrfs: remove stray comment about SRCU
btrfs: useSECTOR_SIZEdefines inbtrfs_issue_discard()
btrfs: rename__unlock_for_delalloc()and drop underscores
btrfs: open codeset_page_extent_mapped()
btrfs: rename__get_extent_map()and passbtrfs_inode
btrfs: usebtrfs_inodeinextent_writepage()
btrfs: makewait_on_extent_buffer_writeback()static inline
btrfs: drop one time used local variable inend_bbio_meta_write()
btrfs: open code__free_extent_buffer()
Quoted 9 lines
btrfs: rename
btrfs_release_extent_buffer_pages()to mention folios
btrfs: switchgrab_extent_buffer()to folios
btrfs: change return type to bool type ofcheck_eb_alignment()
btrfs: unwrap folio locking helpers
btrfs: remove unused defineWAIT_PAGE_LOCKfor extent io
btrfs: split waiting fromread_extent_buffer_pages(), drop parameter wait
btrfs: remove redundant variables from__process_folios_contig()andlock_delalloc_folios()
btrfs: async-thread: renameDFT_THRESHOLDtoDEFAULT_THRESHOLD
For the set.
Thx.
Quoted 11 lines
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(-)
Re: [PATCH 04/18] btrfs: rename __unlock_for_delalloc() and drop underscores
In reply to Johannes ThumshirnQuoted 9 lines · Johannes Thumshirn
Quoted 2 lines · David Sterba
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.
Re: [PATCH 12/18] btrfs: switch grab_extent_buffer() to folios
In reply to Johannes ThumshirnQuoted 7 lines · Johannes Thumshirn
fs/btrfs/extent_io.c struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, · line 2814
Quoted 3 lines · David Sterba
fs/btrfs/extent_io.c +1
-2-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_infoso 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.