Skip to content

Commit 4d5cdd7

Browse files
Matthew Wilcox (Oracle)tytso
authored andcommitted
ext4: convert ext4_da_do_write_end() to take a folio
There's nothing page-specific happening in ext4_da_do_write_end(); it's merely used for its refcount & lock, both of which are folio properties. Saves four calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 7c784d6 commit 4d5cdd7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

fs/ext4/inode.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,7 +2947,7 @@ static int ext4_da_should_update_i_disksize(struct folio *folio,
29472947

29482948
static int ext4_da_do_write_end(struct address_space *mapping,
29492949
loff_t pos, unsigned len, unsigned copied,
2950-
struct page *page)
2950+
struct folio *folio)
29512951
{
29522952
struct inode *inode = mapping->host;
29532953
loff_t old_size = inode->i_size;
@@ -2958,12 +2958,13 @@ static int ext4_da_do_write_end(struct address_space *mapping,
29582958
* block_write_end() will mark the inode as dirty with I_DIRTY_PAGES
29592959
* flag, which all that's needed to trigger page writeback.
29602960
*/
2961-
copied = block_write_end(NULL, mapping, pos, len, copied, page, NULL);
2961+
copied = block_write_end(NULL, mapping, pos, len, copied,
2962+
&folio->page, NULL);
29622963
new_i_size = pos + copied;
29632964

29642965
/*
2965-
* It's important to update i_size while still holding page lock,
2966-
* because page writeout could otherwise come in and zero beyond
2966+
* It's important to update i_size while still holding folio lock,
2967+
* because folio writeout could otherwise come in and zero beyond
29672968
* i_size.
29682969
*
29692970
* Since we are holding inode lock, we are sure i_disksize <=
@@ -2981,14 +2982,14 @@ static int ext4_da_do_write_end(struct address_space *mapping,
29812982

29822983
i_size_write(inode, new_i_size);
29832984
end = (new_i_size - 1) & (PAGE_SIZE - 1);
2984-
if (copied && ext4_da_should_update_i_disksize(page_folio(page), end)) {
2985+
if (copied && ext4_da_should_update_i_disksize(folio, end)) {
29852986
ext4_update_i_disksize(inode, new_i_size);
29862987
disksize_changed = true;
29872988
}
29882989
}
29892990

2990-
unlock_page(page);
2991-
put_page(page);
2991+
folio_unlock(folio);
2992+
folio_put(folio);
29922993

29932994
if (old_size < pos)
29942995
pagecache_isize_extended(inode, old_size, pos);
@@ -3027,10 +3028,10 @@ static int ext4_da_write_end(struct file *file,
30273028
return ext4_write_inline_data_end(inode, pos, len, copied,
30283029
folio);
30293030

3030-
if (unlikely(copied < len) && !PageUptodate(page))
3031+
if (unlikely(copied < len) && !folio_test_uptodate(folio))
30313032
copied = 0;
30323033

3033-
return ext4_da_do_write_end(mapping, pos, len, copied, &folio->page);
3034+
return ext4_da_do_write_end(mapping, pos, len, copied, folio);
30343035
}
30353036

30363037
/*

0 commit comments

Comments
 (0)