Cleanups for extent_page_data
David Sterba
maintainercover Cleanups for extent_page_data
David Sterba (4):
btrfs: merge two flush_write_bio helpers
btrfs: sink flush_fn to extent_write_cache_pages
btrfs: sink writepage parameter to extent_write_cache_pages
btrfs: unify extent_page_data type passed as void
fs/btrfs/extent_io.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-)
Signature · 1 line
2.15.1
David Sterba
maintainerPATCH 1/4 btrfs: merge two flush_write_bio helpers
flush_epd_write_bio is same as flush_write_bio, no point having two such functions. Merge them to flush_write_bio. The 'noinline' attribute is removed as it does not have any meaning.
--- fs/btrfs/extent_io.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
fs/btrfs/extent_io.c +8 -11
@@ -138,7 +138,8 @@ static void add_extent_changeset(struct extent_state *state, unsigned bits,BUG_ON (ret <0 ); } -static noinline void flush_write_bio(void *data); +static void flush_write_bio (void *data); +static inline struct btrfs_fs_info *tree_fs_info (struct extent_io_tree *tree) {
@@ -4039,8 +4040,10 @@ static int extent_write_cache_pages(struct address_space *mapping,return ret; } -static void flush_epd_write_bio (struct extent_page_data *epd) +static void flush_write_bio (void *data) { +struct extent_page_data *epd = data; +if (epd->bio) {int ret;
@@ -4050,12 +4053,6 @@ static void flush_epd_write_bio(struct extent_page_data *epd) } } -static noinline void flush_write_bio(void *data) -{ -struct extent_page_data *epd = data; -flush_epd_write_bio (epd); -} -int extent_write_full_page (struct extent_io_tree *tree,struct page *page,struct writeback_control *wbc) {
@@ -4069,7 +4066,7 @@ int extent_write_full_page(struct extent_io_tree *tree, struct page *page, ret =__extent_writepage (page, wbc, &epd); -flush_epd_write_bio (&epd); +flush_write_bio (&epd);return ret; }
@@ -4110,7 +4107,7 @@ int extent_write_locked_range(struct extent_io_tree *tree, struct inode *inode, start +=PAGE_SIZE ; } -flush_epd_write_bio (&epd); +flush_write_bio (&epd);return ret; }
@@ -4128,7 +4125,7 @@ int extent_writepages(struct extent_io_tree *tree, ret =extent_write_cache_pages (mapping, wbc, __extent_writepage, &epd, flush_write_bio); -flush_epd_write_bio (&epd); +flush_write_bio (&epd);return ret; }
Signature · 1 line
2.15.1
David Sterba
maintainerPATCH 2/4 btrfs: sink flush_fn to extent_write_cache_pages
In reply to David SterbaAll callers pass the same value flush_write_bio.
--- fs/btrfs/extent_io.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/btrfs/extent_io.c +4 -6
@@ -3906,8 +3906,7 @@ int btree_write_cache_pages(struct address_space *mapping,*/ static int extent_write_cache_pages (struct address_space *mapping,struct writeback_control *wbc, -writepage_t writepage,void *data, -void (*flush_fn)(void *)) +writepage_t writepage,void *data) {struct inode *inode = mapping->host;int ret =0 ;
@@ -3971,7 +3970,7 @@ static int extent_write_cache_pages(struct address_space *mapping,* mapping */ if (!trylock_page (page)) { -flush_fn (data); +flush_write_bio (data);lock_page (page); }
@@ -3982,7 +3981,7 @@ static int extent_write_cache_pages(struct address_space *mapping,if (wbc->sync_mode !=WB_SYNC_NONE ) {if (PageWriteback (page)) -flush_fn (data); +flush_write_bio (data);wait_on_page_writeback (page); }
@@ -4123,8 +4122,7 @@ int extent_writepages(struct extent_io_tree *tree, .sync_io = wbc->sync_mode == WB_SYNC_ALL, }; - ret =extent_write_cache_pages (mapping, wbc, __extent_writepage, &epd, - flush_write_bio); + ret =extent_write_cache_pages (mapping, wbc, __extent_writepage, &epd);flush_write_bio (&epd);return ret; }
Signature · 1 line
2.15.1
David Sterba
maintainerPATCH 3/4 btrfs: sink writepage parameter to extent_write_cache_pages
In reply to David SterbaThe function extent_write_cache_pages is modelled after write_cache_pages which is a generic interface and the writepage parameter makes sense there. In btrfs we know exactly which callback we're going to use, so we can pass it directly.
--- fs/btrfs/extent_io.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/btrfs/extent_io.c +4 -5
@@ -3893,8 +3893,7 @@ int btree_write_cache_pages(struct address_space *mapping,* write_cache_pages - walk the list of dirty pages of the given address space and write all of them. * @mapping: address space structure to write * @wbc: subtract the number of written pages from *@wbc->nr_to_write -* @writepage: function called for each page -* @data: data passed to writepage function +* @data: data passed to __extent_writepage function * * If a page is already under I/O, write_cache_pages() skips it, even * if it's dirty. This is desirable behaviour for memory-cleaning writeback,
@@ -3906,7 +3905,7 @@ int btree_write_cache_pages(struct address_space *mapping,*/ static int extent_write_cache_pages (struct address_space *mapping,struct writeback_control *wbc, -writepage_t writepage,void *data) +void *data) {struct inode *inode = mapping->host;int ret =0 ;
@@ -3991,7 +3990,7 @@ static int extent_write_cache_pages(struct address_space *mapping,continue ; } - ret = (*writepage)(page, wbc, data); + ret =__extent_writepage (page, wbc, data);if (unlikely (ret ==AOP_WRITEPAGE_ACTIVATE )) {unlock_page (page);
@@ -4122,7 +4121,7 @@ int extent_writepages(struct extent_io_tree *tree, .sync_io = wbc->sync_mode == WB_SYNC_ALL, }; - ret =extent_write_cache_pages (mapping, wbc, __extent_writepage, &epd); + ret =extent_write_cache_pages (mapping, wbc, &epd);flush_write_bio (&epd);return ret; }
Signature · 1 line
2.15.1
David Sterba
maintainerPATCH 4/4 btrfs: unify extent_page_data type passed as void
In reply to David SterbaFunctions called from extent_write_cache_pages used void* as generic callback data, but all of them convert it to extent_page_data, or use it directly.
--- fs/btrfs/extent_io.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
fs/btrfs/extent_io.c +7 -10
@@ -138,7 +138,7 @@ static void add_extent_changeset(struct extent_state *state, unsigned bits,BUG_ON (ret <0 ); } -static void flush_write_bio (void *data); +static void flush_write_bio (struct extent_page_data *epd);static inline struct btrfs_fs_info *tree_fs_info (struct extent_io_tree *tree)
@@ -3456,10 +3456,9 @@ static noinline_for_stack int __extent_writepage_io(struct inode *inode,* and the end_io handler clears the writeback ranges */ static int __extent_writepage (struct page *page,struct writeback_control *wbc, -void *data) +struct extent_page_data *epd) {struct inode *inode = page->mapping->host; -struct extent_page_data *epd = data;u64 start =page_offset (page);u64 page_end = start +PAGE_SIZE -1 ;int ret;
@@ -3905,7 +3904,7 @@ int btree_write_cache_pages(struct address_space *mapping,*/ static int extent_write_cache_pages (struct address_space *mapping,struct writeback_control *wbc, -void *data) +struct extent_page_data *epd) {struct inode *inode = mapping->host;int ret =0 ;
@@ -3969,7 +3968,7 @@ static int extent_write_cache_pages(struct address_space *mapping,* mapping */ if (!trylock_page (page)) { -flush_write_bio (data); +flush_write_bio (epd);lock_page (page); }
@@ -3980,7 +3979,7 @@ static int extent_write_cache_pages(struct address_space *mapping,if (wbc->sync_mode !=WB_SYNC_NONE ) {if (PageWriteback (page)) -flush_write_bio (data); +flush_write_bio (epd);wait_on_page_writeback (page); }
@@ -3990,7 +3989,7 @@ static int extent_write_cache_pages(struct address_space *mapping,continue ; } - ret =__extent_writepage (page, wbc, data); + ret =__extent_writepage (page, wbc, epd);if (unlikely (ret ==AOP_WRITEPAGE_ACTIVATE )) {unlock_page (page);
@@ -4038,10 +4037,8 @@ static int extent_write_cache_pages(struct address_space *mapping,return ret; } -static void flush_write_bio (void *data) +static void flush_write_bio (struct extent_page_data *epd) { -struct extent_page_data *epd = data; -if (epd->bio) {int ret;
Signature · 1 line
2.15.1