| @@ -1764,7 +1764,7 @@ static struct buffer_head *folio_create_buffers(struct folio *folio, · 1763 unmodified lines |
| 1764 | 1764 | * WB_SYNC_ALL, the writes are posted using REQ_SYNC; this |
| 1765 | 1765 | * causes the writes to be flagged as synchronous writes. |
| 1766 | 1766 | */ |
| 1767 | | −int __block_write_full_page(struct inode *inode, struct page *page, |
| 1767 | +int __block_write_full_folio(struct inode *inode, struct folio *folio, |
| 1768 | 1768 | get_block_t *get_block, struct writeback_control *wbc, |
| 1769 | 1769 | bh_end_io_t *handler) |
| 1770 | 1770 | { |
| @@ -1776,14 +1776,14 @@ int __block_write_full_page(struct inode *inode, struct page *page, · 5 unmodified lines |
| 1776 | 1776 | int nr_underway = 0; |
| 1777 | 1777 | blk_opf_t write_flags = wbc_to_write_flags(wbc); |
| 1778 | 1778 | |
| 1779 | | − head = folio_create_buffers(page_folio(page), inode, |
| 1779 | + head = folio_create_buffers(folio, inode, |
| 1780 | 1780 | (1 << BH_Dirty) | (1 << BH_Uptodate)); |
| 1781 | 1781 | |
| 1782 | 1782 | /* |
| 1783 | 1783 | * Be very careful. We have no exclusion from block_dirty_folio |
| 1784 | 1784 | * here, and the (potentially unmapped) buffers may become dirty at |
| 1785 | 1785 | * any time. If a buffer becomes dirty here after we've inspected it |
| 1786 | | − * then we just miss that fact, and the page stays dirty. |
| 1786 | + * then we just miss that fact, and the folio stays dirty. |
| 1787 | 1787 | * |
| 1788 | 1788 | * Buffers outside i_size may be dirtied by block_dirty_folio; |
| 1789 | 1789 | * handle that here by just cleaning them. |
| @@ -1793,7 +1793,7 @@ int __block_write_full_page(struct inode *inode, struct page *page, · 3 unmodified lines |
| 1793 | 1793 | blocksize = bh->b_size; |
| 1794 | 1794 | bbits = block_size_bits(blocksize); |
| 1795 | 1795 | |
| 1796 | | − block = (sector_t)page->index << (PAGE_SHIFT - bbits); |
| 1796 | + block = (sector_t)folio->index << (PAGE_SHIFT - bbits); |
| 1797 | 1797 | last_block = (i_size_read(inode) - 1) >> bbits; |
| 1798 | 1798 | |
| 1799 | 1799 | /* |
| @@ -1804,7 +1804,7 @@ int __block_write_full_page(struct inode *inode, struct page *page, · 4 unmodified lines |
| 1804 | 1804 | if (block > last_block) { |
| 1805 | 1805 | /* |
| 1806 | 1806 | * mapped buffers outside i_size will occur, because |
| 1807 | | − * this page can be outside i_size when there is a |
| 1807 | + * this folio can be outside i_size when there is a |
| 1808 | 1808 | * truncate in progress. |
| 1809 | 1809 | */ |
| 1810 | 1810 | /* |
| @@ -1834,7 +1834,7 @@ int __block_write_full_page(struct inode *inode, struct page *page, · 23 unmodified lines |
| 1834 | 1834 | continue; |
| 1835 | 1835 | /* |
| 1836 | 1836 | * If it's a fully non-blocking write attempt and we cannot |
| 1837 | | − * lock the buffer then redirty the page. Note that this can |
| 1837 | + * lock the buffer then redirty the folio. Note that this can |
| 1838 | 1838 | * potentially cause a busy-wait loop from writeback threads |
| 1839 | 1839 | * and kswapd activity, but those code paths have their own |
| 1840 | 1840 | * higher-level throttling. |
| @@ -1842,7 +1842,7 @@ int __block_write_full_page(struct inode *inode, struct page *page, · 1 unmodified line |
| 1842 | 1842 | if (wbc->sync_mode != WB_SYNC_NONE) { |
| 1843 | 1843 | lock_buffer(bh); |
| 1844 | 1844 | } else if (!trylock_buffer(bh)) { |
| 1845 | | − redirty_page_for_writepage(wbc, page); |
| 1845 | + folio_redirty_for_writepage(wbc, folio); |
| 1846 | 1846 | continue; |
| 1847 | 1847 | } |
| 1848 | 1848 | if (test_clear_buffer_dirty(bh)) { |
| @@ -1853,11 +1853,11 @@ int __block_write_full_page(struct inode *inode, struct page *page, · 4 unmodified lines |
| 1853 | 1853 | } while ((bh = bh->b_this_page) != head); |
| 1854 | 1854 | |
| 1855 | 1855 | /* |
| 1856 | | − * The page and its buffers are protected by PageWriteback(), so we can |
| 1857 | | − * drop the bh refcounts early. |
| 1856 | + * The folio and its buffers are protected by the writeback flag, |
| 1857 | + * so we can drop the bh refcounts early. |
| 1858 | 1858 | */ |
| 1859 | | − BUG_ON(PageWriteback(page)); |
| 1860 | | − set_page_writeback(page); |
| 1859 | + BUG_ON(folio_test_writeback(folio)); |
| 1860 | + folio_start_writeback(folio); |
| 1861 | 1861 | |
| 1862 | 1862 | do { |
| 1863 | 1863 | struct buffer_head *next = bh->b_this_page; |
| @@ -1867,20 +1867,20 @@ int __block_write_full_page(struct inode *inode, struct page *page, · 3 unmodified lines |
| 1867 | 1867 | } |
| 1868 | 1868 | bh = next; |
| 1869 | 1869 | } while (bh != head); |
| 1870 | | − unlock_page(page); |
| 1870 | + folio_unlock(folio); |
| 1871 | 1871 | |
| 1872 | 1872 | err = 0; |
| 1873 | 1873 | done: |
| 1874 | 1874 | if (nr_underway == 0) { |
| 1875 | 1875 | /* |
| 1876 | | − * The page was marked dirty, but the buffers were |
| 1876 | + * The folio was marked dirty, but the buffers were |
| 1877 | 1877 | * clean. Someone wrote them back by hand with |
| 1878 | 1878 | * write_dirty_buffer/submit_bh. A rare case. |
| 1879 | 1879 | */ |
| 1880 | | − end_page_writeback(page); |
| 1880 | + folio_end_writeback(folio); |
| 1881 | 1881 | |
| 1882 | 1882 | /* |
| 1883 | | − * The page and buffer_heads can be released at any time from |
| 1883 | + * The folio and buffer_heads can be released at any time from |
| 1884 | 1884 | * here on. |
| 1885 | 1885 | */ |
| 1886 | 1886 | } |
| @@ -1891,7 +1891,7 @@ recover: · 4 unmodified lines |
| 1891 | 1891 | * ENOSPC, or some other error. We may already have added some |
| 1892 | 1892 | * blocks to the file, so we need to write these out to avoid |
| 1893 | 1893 | * exposing stale data. |
| 1894 | | − * The page is currently locked and not marked for writeback |
| 1894 | + * The folio is currently locked and not marked for writeback |
| 1895 | 1895 | */ |
| 1896 | 1896 | bh = head; |
| 1897 | 1897 | /* Recovery: lock and submit the mapped buffers */ |
| @@ -1903,15 +1903,15 @@ recover: · 5 unmodified lines |
| 1903 | 1903 | } else { |
| 1904 | 1904 | /* |
| 1905 | 1905 | * The buffer may have been set dirty during |
| 1906 | | − * attachment to a dirty page. |
| 1906 | + * attachment to a dirty folio. |
| 1907 | 1907 | */ |
| 1908 | 1908 | clear_buffer_dirty(bh); |
| 1909 | 1909 | } |
| 1910 | 1910 | } while ((bh = bh->b_this_page) != head); |
| 1911 | | − SetPageError(page); |
| 1912 | | − BUG_ON(PageWriteback(page)); |
| 1913 | | − mapping_set_error(page->mapping, err); |
| 1914 | | − set_page_writeback(page); |
| 1911 | + folio_set_error(folio); |
| 1912 | + BUG_ON(folio_test_writeback(folio)); |
| 1913 | + mapping_set_error(folio->mapping, err); |
| 1914 | + folio_start_writeback(folio); |
| 1915 | 1915 | do { |
| 1916 | 1916 | struct buffer_head *next = bh->b_this_page; |
| 1917 | 1917 | if (buffer_async_write(bh)) { |
| @@ -1921,10 +1921,10 @@ recover: · 3 unmodified lines |
| 1921 | 1921 | } |
| 1922 | 1922 | bh = next; |
| 1923 | 1923 | } while (bh != head); |
| 1924 | | − unlock_page(page); |
| 1924 | + folio_unlock(folio); |
| 1925 | 1925 | goto done; |
| 1926 | 1926 | } |
| 1927 | | −EXPORT_SYMBOL(__block_write_full_page); |
| 1927 | +EXPORT_SYMBOL(__block_write_full_folio); |
| 1928 | 1928 | |
| 1929 | 1929 | /* |
| 1930 | 1930 | * If a page has any new buffers, zero them out here, and mark them uptodate |
| @@ -2677,6 +2677,7 @@ EXPORT_SYMBOL(block_truncate_page); · 746 unmodified lines |
| 2677 | 2677 | int block_write_full_page(struct page *page, get_block_t *get_block, |
| 2678 | 2678 | struct writeback_control *wbc) |
| 2679 | 2679 | { |
| 2680 | + struct folio *folio = page_folio(page); |
| 2680 | 2681 | struct inode * const inode = page->mapping->host; |
| 2681 | 2682 | loff_t i_size = i_size_read(inode); |
| 2682 | 2683 | const pgoff_t end_index = i_size >> PAGE_SHIFT; |
| @@ -2684,13 +2685,13 @@ int block_write_full_page(struct page *page, get_block_t *get_block, · 1 unmodified line |
| 2684 | 2685 | |
| 2685 | 2686 | /* Is the page fully inside i_size? */ |
| 2686 | 2687 | if (page->index < end_index) |
| 2687 | | − return __block_write_full_page(inode, page, get_block, wbc, |
| 2688 | + return __block_write_full_folio(inode, folio, get_block, wbc, |
| 2688 | 2689 | end_buffer_async_write); |
| 2689 | 2690 | |
| 2690 | 2691 | /* Is the page fully outside i_size? (truncate in progress) */ |
| 2691 | 2692 | offset = i_size & (PAGE_SIZE-1); |
| 2692 | 2693 | if (page->index >= end_index+1 || !offset) { |
| 2693 | | − unlock_page(page); |
| 2694 | + folio_unlock(folio); |
| 2694 | 2695 | return 0; /* don't care */ |
| 2695 | 2696 | } |
| 2696 | 2697 | |
| @@ -2702,7 +2703,7 @@ int block_write_full_page(struct page *page, get_block_t *get_block, · 5 unmodified lines |
| 2702 | 2703 | * writes to that region are not written out to the file." |
| 2703 | 2704 | */ |
| 2704 | 2705 | zero_user_segment(page, offset, PAGE_SIZE); |
| 2705 | | − return __block_write_full_page(inode, page, get_block, wbc, |
| 2706 | + return __block_write_full_folio(inode, folio, get_block, wbc, |
| 2706 | 2707 | end_buffer_async_write); |
| 2707 | 2708 | } |
| 2708 | 2709 | EXPORT_SYMBOL(block_write_full_page); |