Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: Convert ext4_write_inline_data_end() to use a folio

Convert the incoming page to a folio so that we call compound_head()
only once instead of seven times.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Link: https://lore.kernel.org/r/20230324180129.1220691-16-willy@infradead.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Matthew Wilcox and committed by
Theodore Ts'o
6b90d413 6b87fbe4

+15 -14
+15 -14
fs/ext4/inline.c
··· 732 732 int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len, 733 733 unsigned copied, struct page *page) 734 734 { 735 + struct folio *folio = page_folio(page); 735 736 handle_t *handle = ext4_journal_current_handle(); 736 737 int no_expand; 737 738 void *kaddr; 738 739 struct ext4_iloc iloc; 739 740 int ret = 0, ret2; 740 741 741 - if (unlikely(copied < len) && !PageUptodate(page)) 742 + if (unlikely(copied < len) && !folio_test_uptodate(folio)) 742 743 copied = 0; 743 744 744 745 if (likely(copied)) { 745 746 ret = ext4_get_inode_loc(inode, &iloc); 746 747 if (ret) { 747 - unlock_page(page); 748 - put_page(page); 748 + folio_unlock(folio); 749 + folio_put(folio); 749 750 ext4_std_error(inode->i_sb, ret); 750 751 goto out; 751 752 } ··· 760 759 */ 761 760 (void) ext4_find_inline_data_nolock(inode); 762 761 763 - kaddr = kmap_atomic(page); 762 + kaddr = kmap_local_folio(folio, 0); 764 763 ext4_write_inline_data(inode, &iloc, kaddr, pos, copied); 765 - kunmap_atomic(kaddr); 766 - SetPageUptodate(page); 767 - /* clear page dirty so that writepages wouldn't work for us. */ 768 - ClearPageDirty(page); 764 + kunmap_local(kaddr); 765 + folio_mark_uptodate(folio); 766 + /* clear dirty flag so that writepages wouldn't work for us. */ 767 + folio_clear_dirty(folio); 769 768 770 769 ext4_write_unlock_xattr(inode, &no_expand); 771 770 brelse(iloc.bh); 772 771 773 772 /* 774 - * It's important to update i_size while still holding page 773 + * It's important to update i_size while still holding folio 775 774 * lock: page writeout could otherwise come in and zero 776 775 * beyond i_size. 777 776 */ 778 777 ext4_update_inode_size(inode, pos + copied); 779 778 } 780 - unlock_page(page); 781 - put_page(page); 779 + folio_unlock(folio); 780 + folio_put(folio); 782 781 783 782 /* 784 - * Don't mark the inode dirty under page lock. First, it unnecessarily 785 - * makes the holding time of page lock longer. Second, it forces lock 786 - * ordering of page lock and transaction start for journaling 783 + * Don't mark the inode dirty under folio lock. First, it unnecessarily 784 + * makes the holding time of folio lock longer. Second, it forces lock 785 + * ordering of folio lock and transaction start for journaling 787 786 * filesystems. 788 787 */ 789 788 if (likely(copied))