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

buffer: convert page_zero_new_buffers() to folio_zero_new_buffers()

Most of the callers already have a folio; convert reiserfs_write_end() to
have a folio. Removes a couple of hidden calls to compound_head().

Link: https://lkml.kernel.org/r/20230612210141.730128-10-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Bob Peterson <rpeterso@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
4a9622f2 8c6cb3e3

+21 -19
+14 -13
fs/buffer.c
··· 1927 1927 EXPORT_SYMBOL(__block_write_full_folio); 1928 1928 1929 1929 /* 1930 - * If a page has any new buffers, zero them out here, and mark them uptodate 1930 + * If a folio has any new buffers, zero them out here, and mark them uptodate 1931 1931 * and dirty so they'll be written out (in order to prevent uninitialised 1932 1932 * block data from leaking). And clear the new bit. 1933 1933 */ 1934 - void page_zero_new_buffers(struct page *page, unsigned from, unsigned to) 1934 + void folio_zero_new_buffers(struct folio *folio, size_t from, size_t to) 1935 1935 { 1936 - unsigned int block_start, block_end; 1936 + size_t block_start, block_end; 1937 1937 struct buffer_head *head, *bh; 1938 1938 1939 - BUG_ON(!PageLocked(page)); 1940 - if (!page_has_buffers(page)) 1939 + BUG_ON(!folio_test_locked(folio)); 1940 + head = folio_buffers(folio); 1941 + if (!head) 1941 1942 return; 1942 1943 1943 - bh = head = page_buffers(page); 1944 + bh = head; 1944 1945 block_start = 0; 1945 1946 do { 1946 1947 block_end = block_start + bh->b_size; 1947 1948 1948 1949 if (buffer_new(bh)) { 1949 1950 if (block_end > from && block_start < to) { 1950 - if (!PageUptodate(page)) { 1951 - unsigned start, size; 1951 + if (!folio_test_uptodate(folio)) { 1952 + size_t start, xend; 1952 1953 1953 1954 start = max(from, block_start); 1954 - size = min(to, block_end) - start; 1955 + xend = min(to, block_end); 1955 1956 1956 - zero_user(page, start, size); 1957 + folio_zero_segment(folio, start, xend); 1957 1958 set_buffer_uptodate(bh); 1958 1959 } 1959 1960 ··· 1967 1966 bh = bh->b_this_page; 1968 1967 } while (bh != head); 1969 1968 } 1970 - EXPORT_SYMBOL(page_zero_new_buffers); 1969 + EXPORT_SYMBOL(folio_zero_new_buffers); 1971 1970 1972 1971 static void 1973 1972 iomap_to_bh(struct inode *inode, sector_t block, struct buffer_head *bh, ··· 2105 2104 err = -EIO; 2106 2105 } 2107 2106 if (unlikely(err)) 2108 - page_zero_new_buffers(&folio->page, from, to); 2107 + folio_zero_new_buffers(folio, from, to); 2109 2108 return err; 2110 2109 } 2111 2110 ··· 2209 2208 if (!folio_test_uptodate(folio)) 2210 2209 copied = 0; 2211 2210 2212 - page_zero_new_buffers(&folio->page, start+copied, start+len); 2211 + folio_zero_new_buffers(folio, start+copied, start+len); 2213 2212 } 2214 2213 flush_dcache_folio(folio); 2215 2214
+2 -2
fs/ext4/inode.c
··· 1093 1093 err = -EIO; 1094 1094 } 1095 1095 if (unlikely(err)) { 1096 - page_zero_new_buffers(&folio->page, from, to); 1096 + folio_zero_new_buffers(folio, from, to); 1097 1097 } else if (fscrypt_inode_uses_fs_layer_crypto(inode)) { 1098 1098 for (i = 0; i < nr_wait; i++) { 1099 1099 int err2; ··· 1339 1339 } 1340 1340 1341 1341 /* 1342 - * This is a private version of page_zero_new_buffers() which doesn't 1342 + * This is a private version of folio_zero_new_buffers() which doesn't 1343 1343 * set the buffer to be dirty, since in data=journalled mode we need 1344 1344 * to call ext4_dirty_journalled_data() instead. 1345 1345 */
+4 -3
fs/reiserfs/inode.c
··· 2872 2872 loff_t pos, unsigned len, unsigned copied, 2873 2873 struct page *page, void *fsdata) 2874 2874 { 2875 + struct folio *folio = page_folio(page); 2875 2876 struct inode *inode = page->mapping->host; 2876 2877 int ret = 0; 2877 2878 int update_sd = 0; ··· 2888 2887 2889 2888 start = pos & (PAGE_SIZE - 1); 2890 2889 if (unlikely(copied < len)) { 2891 - if (!PageUptodate(page)) 2890 + if (!folio_test_uptodate(folio)) 2892 2891 copied = 0; 2893 2892 2894 - page_zero_new_buffers(page, start + copied, start + len); 2893 + folio_zero_new_buffers(folio, start + copied, start + len); 2895 2894 } 2896 - flush_dcache_page(page); 2895 + flush_dcache_folio(folio); 2897 2896 2898 2897 reiserfs_commit_page(inode, page, start, start + copied); 2899 2898
+1 -1
include/linux/buffer_head.h
··· 278 278 int generic_write_end(struct file *, struct address_space *, 279 279 loff_t, unsigned, unsigned, 280 280 struct page *, void *); 281 - void page_zero_new_buffers(struct page *page, unsigned from, unsigned to); 281 + void folio_zero_new_buffers(struct folio *folio, size_t from, size_t to); 282 282 void clean_page_buffers(struct page *page); 283 283 int cont_write_begin(struct file *, struct address_space *, loff_t, 284 284 unsigned, struct page **, void **,