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

fs: Convert aops->write_begin to take a folio

Convert all callers from working on a page to working on one page
of a folio (support for working on an entire folio can come later).
Removes a lot of folio->page->folio conversions.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Matthew Wilcox (Oracle) and committed by
Christian Brauner
1da86618 a225800f

+190 -207
+2 -2
Documentation/filesystems/locking.rst
··· 251 251 void (*readahead)(struct readahead_control *); 252 252 int (*write_begin)(struct file *, struct address_space *mapping, 253 253 loff_t pos, unsigned len, 254 - struct page **pagep, void **fsdata); 254 + struct folio **foliop, void **fsdata); 255 255 int (*write_end)(struct file *, struct address_space *mapping, 256 256 loff_t pos, unsigned len, unsigned copied, 257 257 struct folio *folio, void *fsdata); ··· 280 280 writepages: 281 281 dirty_folio: maybe 282 282 readahead: yes, unlocks shared 283 - write_begin: locks the page exclusive 283 + write_begin: locks the folio exclusive 284 284 write_end: yes, unlocks exclusive 285 285 bmap: 286 286 invalidate_folio: yes exclusive
+3 -3
Documentation/filesystems/vfs.rst
··· 926 926 (if they haven't been read already) so that the updated blocks 927 927 can be written out properly. 928 928 929 - The filesystem must return the locked pagecache page for the 930 - specified offset, in ``*pagep``, for the caller to write into. 929 + The filesystem must return the locked pagecache folio for the 930 + specified offset, in ``*foliop``, for the caller to write into. 931 931 932 932 It must be able to cope with short writes (where the length 933 933 passed to write_begin is greater than the number of bytes copied 934 - into the page). 934 + into the folio). 935 935 936 936 A void * may be returned in fsdata, which then gets passed into 937 937 write_end.
+2 -2
block/fops.c
··· 451 451 } 452 452 453 453 static int blkdev_write_begin(struct file *file, struct address_space *mapping, 454 - loff_t pos, unsigned len, struct page **pagep, void **fsdata) 454 + loff_t pos, unsigned len, struct folio **foliop, void **fsdata) 455 455 { 456 - return block_write_begin(mapping, pos, len, pagep, blkdev_get_block); 456 + return block_write_begin(mapping, pos, len, foliop, blkdev_get_block); 457 457 } 458 458 459 459 static int blkdev_write_end(struct file *file, struct address_space *mapping,
+22 -25
drivers/gpu/drm/i915/gem/i915_gem_shmem.c
··· 424 424 struct address_space *mapping = obj->base.filp->f_mapping; 425 425 const struct address_space_operations *aops = mapping->a_ops; 426 426 char __user *user_data = u64_to_user_ptr(arg->data_ptr); 427 - u64 remain, offset; 427 + u64 remain; 428 + loff_t pos; 428 429 unsigned int pg; 429 430 430 431 /* Caller already validated user args */ ··· 458 457 */ 459 458 460 459 remain = arg->size; 461 - offset = arg->offset; 462 - pg = offset_in_page(offset); 460 + pos = arg->offset; 461 + pg = offset_in_page(pos); 463 462 464 463 do { 465 464 unsigned int len, unwritten; 466 - struct page *page; 465 + struct folio *folio; 467 466 void *data, *vaddr; 468 467 int err; 469 468 char __maybe_unused c; ··· 481 480 if (err) 482 481 return err; 483 482 484 - err = aops->write_begin(obj->base.filp, mapping, offset, len, 485 - &page, &data); 483 + err = aops->write_begin(obj->base.filp, mapping, pos, len, 484 + &folio, &data); 486 485 if (err < 0) 487 486 return err; 488 487 489 - vaddr = kmap_local_page(page); 488 + vaddr = kmap_local_folio(folio, offset_in_folio(folio, pos)); 490 489 pagefault_disable(); 491 - unwritten = __copy_from_user_inatomic(vaddr + pg, 492 - user_data, 493 - len); 490 + unwritten = __copy_from_user_inatomic(vaddr, user_data, len); 494 491 pagefault_enable(); 495 492 kunmap_local(vaddr); 496 493 497 - err = aops->write_end(obj->base.filp, mapping, offset, len, 498 - len - unwritten, page_folio(page), data); 494 + err = aops->write_end(obj->base.filp, mapping, pos, len, 495 + len - unwritten, folio, data); 499 496 if (err < 0) 500 497 return err; 501 498 ··· 503 504 504 505 remain -= len; 505 506 user_data += len; 506 - offset += len; 507 + pos += len; 507 508 pg = 0; 508 509 } while (remain); 509 510 ··· 659 660 struct drm_i915_gem_object *obj; 660 661 struct file *file; 661 662 const struct address_space_operations *aops; 662 - resource_size_t offset; 663 + loff_t pos; 663 664 int err; 664 665 665 666 GEM_WARN_ON(IS_DGFX(i915)); ··· 671 672 672 673 file = obj->base.filp; 673 674 aops = file->f_mapping->a_ops; 674 - offset = 0; 675 + pos = 0; 675 676 do { 676 677 unsigned int len = min_t(typeof(size), size, PAGE_SIZE); 677 - struct page *page; 678 - void *pgdata, *vaddr; 678 + struct folio *folio; 679 + void *fsdata; 679 680 680 - err = aops->write_begin(file, file->f_mapping, offset, len, 681 - &page, &pgdata); 681 + err = aops->write_begin(file, file->f_mapping, pos, len, 682 + &folio, &fsdata); 682 683 if (err < 0) 683 684 goto fail; 684 685 685 - vaddr = kmap(page); 686 - memcpy(vaddr, data, len); 687 - kunmap(page); 686 + memcpy_to_folio(folio, offset_in_folio(folio, pos), data, len); 688 687 689 - err = aops->write_end(file, file->f_mapping, offset, len, len, 690 - page_folio(page), pgdata); 688 + err = aops->write_end(file, file->f_mapping, pos, len, len, 689 + folio, fsdata); 691 690 if (err < 0) 692 691 goto fail; 693 692 694 693 size -= len; 695 694 data += len; 696 - offset += len; 695 + pos += len; 697 696 } while (size); 698 697 699 698 return obj;
+2 -3
fs/adfs/inode.c
··· 55 55 56 56 static int adfs_write_begin(struct file *file, struct address_space *mapping, 57 57 loff_t pos, unsigned len, 58 - struct page **pagep, void **fsdata) 58 + struct folio **foliop, void **fsdata) 59 59 { 60 60 int ret; 61 61 62 - *pagep = NULL; 63 - ret = cont_write_begin(file, mapping, pos, len, pagep, fsdata, 62 + ret = cont_write_begin(file, mapping, pos, len, foliop, fsdata, 64 63 adfs_get_block, 65 64 &ADFS_I(mapping->host)->mmu_private); 66 65 if (unlikely(ret))
+7 -8
fs/affs/file.c
··· 417 417 418 418 static int affs_write_begin(struct file *file, struct address_space *mapping, 419 419 loff_t pos, unsigned len, 420 - struct page **pagep, void **fsdata) 420 + struct folio **foliop, void **fsdata) 421 421 { 422 422 int ret; 423 423 424 - *pagep = NULL; 425 - ret = cont_write_begin(file, mapping, pos, len, pagep, fsdata, 424 + ret = cont_write_begin(file, mapping, pos, len, foliop, fsdata, 426 425 affs_get_block, 427 426 &AFFS_I(mapping->host)->mmu_private); 428 427 if (unlikely(ret)) ··· 647 648 648 649 static int affs_write_begin_ofs(struct file *file, struct address_space *mapping, 649 650 loff_t pos, unsigned len, 650 - struct page **pagep, void **fsdata) 651 + struct folio **foliop, void **fsdata) 651 652 { 652 653 struct inode *inode = mapping->host; 653 654 struct folio *folio; ··· 670 671 mapping_gfp_mask(mapping)); 671 672 if (IS_ERR(folio)) 672 673 return PTR_ERR(folio); 673 - *pagep = &folio->page; 674 + *foliop = folio; 674 675 675 676 if (folio_test_uptodate(folio)) 676 677 return 0; ··· 880 881 881 882 if (inode->i_size > AFFS_I(inode)->mmu_private) { 882 883 struct address_space *mapping = inode->i_mapping; 883 - struct page *page; 884 + struct folio *folio; 884 885 void *fsdata = NULL; 885 886 loff_t isize = inode->i_size; 886 887 int res; 887 888 888 - res = mapping->a_ops->write_begin(NULL, mapping, isize, 0, &page, &fsdata); 889 + res = mapping->a_ops->write_begin(NULL, mapping, isize, 0, &folio, &fsdata); 889 890 if (!res) 890 - res = mapping->a_ops->write_end(NULL, mapping, isize, 0, 0, page_folio(page), fsdata); 891 + res = mapping->a_ops->write_end(NULL, mapping, isize, 0, 0, folio, fsdata); 891 892 else 892 893 inode->i_size = AFFS_I(inode)->mmu_private; 893 894 mark_inode_dirty(inode);
+2 -3
fs/bcachefs/fs-io-buffered.c
··· 659 659 660 660 int bch2_write_begin(struct file *file, struct address_space *mapping, 661 661 loff_t pos, unsigned len, 662 - struct page **pagep, void **fsdata) 662 + struct folio **foliop, void **fsdata) 663 663 { 664 664 struct bch_inode_info *inode = to_bch_ei(mapping->host); 665 665 struct bch_fs *c = inode->v.i_sb->s_fs_info; ··· 728 728 goto err; 729 729 } 730 730 731 - *pagep = &folio->page; 731 + *foliop = folio; 732 732 return 0; 733 733 err: 734 734 folio_unlock(folio); 735 735 folio_put(folio); 736 - *pagep = NULL; 737 736 err_unlock: 738 737 bch2_pagecache_add_put(inode); 739 738 kfree(res);
+2 -2
fs/bcachefs/fs-io-buffered.h
··· 10 10 int bch2_writepages(struct address_space *, struct writeback_control *); 11 11 void bch2_readahead(struct readahead_control *); 12 12 13 - int bch2_write_begin(struct file *, struct address_space *, loff_t, 14 - unsigned, struct page **, void **); 13 + int bch2_write_begin(struct file *, struct address_space *, loff_t pos, 14 + unsigned len, struct folio **, void **); 15 15 int bch2_write_end(struct file *, struct address_space *, loff_t, 16 16 unsigned len, unsigned copied, struct folio *, void *); 17 17
+2 -2
fs/bfs/file.c
··· 172 172 173 173 static int bfs_write_begin(struct file *file, struct address_space *mapping, 174 174 loff_t pos, unsigned len, 175 - struct page **pagep, void **fsdata) 175 + struct folio **foliop, void **fsdata) 176 176 { 177 177 int ret; 178 178 179 - ret = block_write_begin(mapping, pos, len, pagep, bfs_get_block); 179 + ret = block_write_begin(mapping, pos, len, foliop, bfs_get_block); 180 180 if (unlikely(ret)) 181 181 bfs_write_failed(mapping, pos + len); 182 182
+14 -14
fs/buffer.c
··· 2222 2222 * The filesystem needs to handle block truncation upon failure. 2223 2223 */ 2224 2224 int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len, 2225 - struct page **pagep, get_block_t *get_block) 2225 + struct folio **foliop, get_block_t *get_block) 2226 2226 { 2227 2227 pgoff_t index = pos >> PAGE_SHIFT; 2228 2228 struct folio *folio; ··· 2240 2240 folio = NULL; 2241 2241 } 2242 2242 2243 - *pagep = &folio->page; 2243 + *foliop = folio; 2244 2244 return status; 2245 2245 } 2246 2246 EXPORT_SYMBOL(block_write_begin); ··· 2467 2467 { 2468 2468 struct address_space *mapping = inode->i_mapping; 2469 2469 const struct address_space_operations *aops = mapping->a_ops; 2470 - struct page *page; 2470 + struct folio *folio; 2471 2471 void *fsdata = NULL; 2472 2472 int err; 2473 2473 ··· 2475 2475 if (err) 2476 2476 goto out; 2477 2477 2478 - err = aops->write_begin(NULL, mapping, size, 0, &page, &fsdata); 2478 + err = aops->write_begin(NULL, mapping, size, 0, &folio, &fsdata); 2479 2479 if (err) 2480 2480 goto out; 2481 2481 2482 - err = aops->write_end(NULL, mapping, size, 0, 0, page_folio(page), fsdata); 2482 + err = aops->write_end(NULL, mapping, size, 0, 0, folio, fsdata); 2483 2483 BUG_ON(err > 0); 2484 2484 2485 2485 out: ··· 2493 2493 struct inode *inode = mapping->host; 2494 2494 const struct address_space_operations *aops = mapping->a_ops; 2495 2495 unsigned int blocksize = i_blocksize(inode); 2496 - struct page *page; 2496 + struct folio *folio; 2497 2497 void *fsdata = NULL; 2498 2498 pgoff_t index, curidx; 2499 2499 loff_t curpos; ··· 2512 2512 len = PAGE_SIZE - zerofrom; 2513 2513 2514 2514 err = aops->write_begin(file, mapping, curpos, len, 2515 - &page, &fsdata); 2515 + &folio, &fsdata); 2516 2516 if (err) 2517 2517 goto out; 2518 - zero_user(page, zerofrom, len); 2518 + folio_zero_range(folio, offset_in_folio(folio, curpos), len); 2519 2519 err = aops->write_end(file, mapping, curpos, len, len, 2520 - page_folio(page), fsdata); 2520 + folio, fsdata); 2521 2521 if (err < 0) 2522 2522 goto out; 2523 2523 BUG_ON(err != len); ··· 2545 2545 len = offset - zerofrom; 2546 2546 2547 2547 err = aops->write_begin(file, mapping, curpos, len, 2548 - &page, &fsdata); 2548 + &folio, &fsdata); 2549 2549 if (err) 2550 2550 goto out; 2551 - zero_user(page, zerofrom, len); 2551 + folio_zero_range(folio, offset_in_folio(folio, curpos), len); 2552 2552 err = aops->write_end(file, mapping, curpos, len, len, 2553 - page_folio(page), fsdata); 2553 + folio, fsdata); 2554 2554 if (err < 0) 2555 2555 goto out; 2556 2556 BUG_ON(err != len); ··· 2566 2566 */ 2567 2567 int cont_write_begin(struct file *file, struct address_space *mapping, 2568 2568 loff_t pos, unsigned len, 2569 - struct page **pagep, void **fsdata, 2569 + struct folio **foliop, void **fsdata, 2570 2570 get_block_t *get_block, loff_t *bytes) 2571 2571 { 2572 2572 struct inode *inode = mapping->host; ··· 2584 2584 (*bytes)++; 2585 2585 } 2586 2586 2587 - return block_write_begin(mapping, pos, len, pagep, get_block); 2587 + return block_write_begin(mapping, pos, len, foliop, get_block); 2588 2588 } 2589 2589 EXPORT_SYMBOL(cont_write_begin); 2590 2590
+4 -6
fs/ceph/addr.c
··· 1486 1486 */ 1487 1487 static int ceph_write_begin(struct file *file, struct address_space *mapping, 1488 1488 loff_t pos, unsigned len, 1489 - struct page **pagep, void **fsdata) 1489 + struct folio **foliop, void **fsdata) 1490 1490 { 1491 1491 struct inode *inode = file_inode(file); 1492 1492 struct ceph_inode_info *ci = ceph_inode(inode); 1493 - struct folio *folio = NULL; 1494 1493 int r; 1495 1494 1496 - r = netfs_write_begin(&ci->netfs, file, inode->i_mapping, pos, len, &folio, NULL); 1495 + r = netfs_write_begin(&ci->netfs, file, inode->i_mapping, pos, len, foliop, NULL); 1497 1496 if (r < 0) 1498 1497 return r; 1499 1498 1500 - folio_wait_private_2(folio); /* [DEPRECATED] */ 1501 - WARN_ON_ONCE(!folio_test_locked(folio)); 1502 - *pagep = &folio->page; 1499 + folio_wait_private_2(*foliop); /* [DEPRECATED] */ 1500 + WARN_ON_ONCE(!folio_test_locked(*foliop)); 1503 1501 return 0; 1504 1502 } 1505 1503
+3 -4
fs/ecryptfs/mmap.c
··· 255 255 * @mapping: The eCryptfs object 256 256 * @pos: The file offset at which to start writing 257 257 * @len: Length of the write 258 - * @pagep: Pointer to return the page 258 + * @foliop: Pointer to return the folio 259 259 * @fsdata: Pointer to return fs data (unused) 260 260 * 261 261 * This function must zero any hole we create ··· 265 265 static int ecryptfs_write_begin(struct file *file, 266 266 struct address_space *mapping, 267 267 loff_t pos, unsigned len, 268 - struct page **pagep, void **fsdata) 268 + struct folio **foliop, void **fsdata) 269 269 { 270 270 pgoff_t index = pos >> PAGE_SHIFT; 271 271 struct folio *folio; ··· 276 276 mapping_gfp_mask(mapping)); 277 277 if (IS_ERR(folio)) 278 278 return PTR_ERR(folio); 279 - *pagep = &folio->page; 279 + *foliop = folio; 280 280 281 281 prev_page_end_size = ((loff_t)index << PAGE_SHIFT); 282 282 if (!folio_test_uptodate(folio)) { ··· 365 365 if (unlikely(rc)) { 366 366 folio_unlock(folio); 367 367 folio_put(folio); 368 - *pagep = NULL; 369 368 } 370 369 return rc; 371 370 }
+4 -4
fs/exfat/file.c
··· 535 535 536 536 while (start < end) { 537 537 u32 zerofrom, len; 538 - struct page *page = NULL; 538 + struct folio *folio; 539 539 540 540 zerofrom = start & (PAGE_SIZE - 1); 541 541 len = PAGE_SIZE - zerofrom; 542 542 if (start + len > end) 543 543 len = end - start; 544 544 545 - err = ops->write_begin(file, mapping, start, len, &page, NULL); 545 + err = ops->write_begin(file, mapping, start, len, &folio, NULL); 546 546 if (err) 547 547 goto out; 548 548 549 - zero_user_segment(page, zerofrom, zerofrom + len); 549 + folio_zero_range(folio, offset_in_folio(folio, start), len); 550 550 551 - err = ops->write_end(file, mapping, start, len, len, page_folio(page), NULL); 551 + err = ops->write_end(file, mapping, start, len, len, folio, NULL); 552 552 if (err < 0) 553 553 goto out; 554 554 start += len;
+2 -3
fs/exfat/inode.c
··· 448 448 449 449 static int exfat_write_begin(struct file *file, struct address_space *mapping, 450 450 loff_t pos, unsigned int len, 451 - struct page **pagep, void **fsdata) 451 + struct folio **foliop, void **fsdata) 452 452 { 453 453 int ret; 454 454 455 - *pagep = NULL; 456 - ret = block_write_begin(mapping, pos, len, pagep, exfat_get_block); 455 + ret = block_write_begin(mapping, pos, len, foliop, exfat_get_block); 457 456 458 457 if (ret < 0) 459 458 exfat_write_failed(mapping, pos+len);
+2 -2
fs/ext2/inode.c
··· 916 916 917 917 static int 918 918 ext2_write_begin(struct file *file, struct address_space *mapping, 919 - loff_t pos, unsigned len, struct page **pagep, void **fsdata) 919 + loff_t pos, unsigned len, struct folio **foliop, void **fsdata) 920 920 { 921 921 int ret; 922 922 923 - ret = block_write_begin(mapping, pos, len, pagep, ext2_get_block); 923 + ret = block_write_begin(mapping, pos, len, foliop, ext2_get_block); 924 924 if (ret < 0) 925 925 ext2_write_failed(mapping, pos + len); 926 926 return ret;
+2 -2
fs/ext4/ext4.h
··· 3563 3563 extern int ext4_try_to_write_inline_data(struct address_space *mapping, 3564 3564 struct inode *inode, 3565 3565 loff_t pos, unsigned len, 3566 - struct page **pagep); 3566 + struct folio **foliop); 3567 3567 int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len, 3568 3568 unsigned copied, struct folio *folio); 3569 3569 extern int ext4_da_write_inline_data_begin(struct address_space *mapping, 3570 3570 struct inode *inode, 3571 3571 loff_t pos, unsigned len, 3572 - struct page **pagep, 3572 + struct folio **foliop, 3573 3573 void **fsdata); 3574 3574 extern int ext4_try_add_inline_entry(handle_t *handle, 3575 3575 struct ext4_filename *fname,
+4 -4
fs/ext4/inline.c
··· 660 660 int ext4_try_to_write_inline_data(struct address_space *mapping, 661 661 struct inode *inode, 662 662 loff_t pos, unsigned len, 663 - struct page **pagep) 663 + struct folio **foliop) 664 664 { 665 665 int ret; 666 666 handle_t *handle; ··· 708 708 goto out; 709 709 } 710 710 711 - *pagep = &folio->page; 711 + *foliop = folio; 712 712 down_read(&EXT4_I(inode)->xattr_sem); 713 713 if (!ext4_has_inline_data(inode)) { 714 714 ret = 0; ··· 891 891 int ext4_da_write_inline_data_begin(struct address_space *mapping, 892 892 struct inode *inode, 893 893 loff_t pos, unsigned len, 894 - struct page **pagep, 894 + struct folio **foliop, 895 895 void **fsdata) 896 896 { 897 897 int ret; ··· 954 954 goto out_release_page; 955 955 956 956 up_read(&EXT4_I(inode)->xattr_sem); 957 - *pagep = &folio->page; 957 + *foliop = folio; 958 958 brelse(iloc.bh); 959 959 return 1; 960 960 out_release_page:
+7 -7
fs/ext4/inode.c
··· 1145 1145 */ 1146 1146 static int ext4_write_begin(struct file *file, struct address_space *mapping, 1147 1147 loff_t pos, unsigned len, 1148 - struct page **pagep, void **fsdata) 1148 + struct folio **foliop, void **fsdata) 1149 1149 { 1150 1150 struct inode *inode = mapping->host; 1151 1151 int ret, needed_blocks; ··· 1170 1170 1171 1171 if (ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) { 1172 1172 ret = ext4_try_to_write_inline_data(mapping, inode, pos, len, 1173 - pagep); 1173 + foliop); 1174 1174 if (ret < 0) 1175 1175 return ret; 1176 1176 if (ret == 1) ··· 1270 1270 folio_put(folio); 1271 1271 return ret; 1272 1272 } 1273 - *pagep = &folio->page; 1273 + *foliop = folio; 1274 1274 return ret; 1275 1275 } 1276 1276 ··· 2924 2924 2925 2925 static int ext4_da_write_begin(struct file *file, struct address_space *mapping, 2926 2926 loff_t pos, unsigned len, 2927 - struct page **pagep, void **fsdata) 2927 + struct folio **foliop, void **fsdata) 2928 2928 { 2929 2929 int ret, retries = 0; 2930 2930 struct folio *folio; ··· 2939 2939 if (ext4_nonda_switch(inode->i_sb) || ext4_verity_in_progress(inode)) { 2940 2940 *fsdata = (void *)FALL_BACK_TO_NONDELALLOC; 2941 2941 return ext4_write_begin(file, mapping, pos, 2942 - len, pagep, fsdata); 2942 + len, foliop, fsdata); 2943 2943 } 2944 2944 *fsdata = (void *)0; 2945 2945 trace_ext4_da_write_begin(inode, pos, len); 2946 2946 2947 2947 if (ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) { 2948 2948 ret = ext4_da_write_inline_data_begin(mapping, inode, pos, len, 2949 - pagep, fsdata); 2949 + foliop, fsdata); 2950 2950 if (ret < 0) 2951 2951 return ret; 2952 2952 if (ret == 1) ··· 2981 2981 return ret; 2982 2982 } 2983 2983 2984 - *pagep = &folio->page; 2984 + *foliop = folio; 2985 2985 return ret; 2986 2986 } 2987 2987
+4 -4
fs/ext4/verity.c
··· 76 76 while (count) { 77 77 size_t n = min_t(size_t, count, 78 78 PAGE_SIZE - offset_in_page(pos)); 79 - struct page *page; 79 + struct folio *folio; 80 80 void *fsdata = NULL; 81 81 int res; 82 82 83 - res = aops->write_begin(NULL, mapping, pos, n, &page, &fsdata); 83 + res = aops->write_begin(NULL, mapping, pos, n, &folio, &fsdata); 84 84 if (res) 85 85 return res; 86 86 87 - memcpy_to_page(page, offset_in_page(pos), buf, n); 87 + memcpy_to_folio(folio, offset_in_folio(folio, pos), buf, n); 88 88 89 - res = aops->write_end(NULL, mapping, pos, n, n, page_folio(page), fsdata); 89 + res = aops->write_end(NULL, mapping, pos, n, n, folio, fsdata); 90 90 if (res < 0) 91 91 return res; 92 92 if (res != n)
+5 -3
fs/f2fs/data.c
··· 3552 3552 } 3553 3553 3554 3554 static int f2fs_write_begin(struct file *file, struct address_space *mapping, 3555 - loff_t pos, unsigned len, struct page **pagep, void **fsdata) 3555 + loff_t pos, unsigned len, struct folio **foliop, void **fsdata) 3556 3556 { 3557 3557 struct inode *inode = mapping->host; 3558 3558 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); ··· 3584 3584 #ifdef CONFIG_F2FS_FS_COMPRESSION 3585 3585 if (f2fs_compressed_file(inode)) { 3586 3586 int ret; 3587 + struct page *page; 3587 3588 3588 3589 *fsdata = NULL; 3589 3590 3590 3591 if (len == PAGE_SIZE && !(f2fs_is_atomic_file(inode))) 3591 3592 goto repeat; 3592 3593 3593 - ret = f2fs_prepare_compress_overwrite(inode, pagep, 3594 + ret = f2fs_prepare_compress_overwrite(inode, &page, 3594 3595 index, fsdata); 3595 3596 if (ret < 0) { 3596 3597 err = ret; 3597 3598 goto fail; 3598 3599 } else if (ret) { 3600 + *foliop = page_folio(page); 3599 3601 return 0; 3600 3602 } 3601 3603 } ··· 3617 3615 3618 3616 /* TODO: cluster can be compressed due to race with .writepage */ 3619 3617 3620 - *pagep = &folio->page; 3618 + *foliop = folio; 3621 3619 3622 3620 if (f2fs_is_atomic_file(inode)) 3623 3621 err = prepare_atomic_write_begin(sbi, &folio->page, pos, len,
+4 -4
fs/f2fs/super.c
··· 2677 2677 const struct address_space_operations *a_ops = mapping->a_ops; 2678 2678 int offset = off & (sb->s_blocksize - 1); 2679 2679 size_t towrite = len; 2680 - struct page *page; 2680 + struct folio *folio; 2681 2681 void *fsdata = NULL; 2682 2682 int err = 0; 2683 2683 int tocopy; ··· 2687 2687 towrite); 2688 2688 retry: 2689 2689 err = a_ops->write_begin(NULL, mapping, off, tocopy, 2690 - &page, &fsdata); 2690 + &folio, &fsdata); 2691 2691 if (unlikely(err)) { 2692 2692 if (err == -ENOMEM) { 2693 2693 f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); ··· 2697 2697 break; 2698 2698 } 2699 2699 2700 - memcpy_to_page(page, offset, data, tocopy); 2700 + memcpy_to_folio(folio, offset_in_folio(folio, off), data, tocopy); 2701 2701 2702 2702 a_ops->write_end(NULL, mapping, off, tocopy, tocopy, 2703 - page_folio(page), fsdata); 2703 + folio, fsdata); 2704 2704 offset = 0; 2705 2705 towrite -= tocopy; 2706 2706 off += tocopy;
+4 -4
fs/f2fs/verity.c
··· 80 80 while (count) { 81 81 size_t n = min_t(size_t, count, 82 82 PAGE_SIZE - offset_in_page(pos)); 83 - struct page *page; 83 + struct folio *folio; 84 84 void *fsdata = NULL; 85 85 int res; 86 86 87 - res = aops->write_begin(NULL, mapping, pos, n, &page, &fsdata); 87 + res = aops->write_begin(NULL, mapping, pos, n, &folio, &fsdata); 88 88 if (res) 89 89 return res; 90 90 91 - memcpy_to_page(page, offset_in_page(pos), buf, n); 91 + memcpy_to_folio(folio, offset_in_folio(folio, pos), buf, n); 92 92 93 - res = aops->write_end(NULL, mapping, pos, n, n, page_folio(page), fsdata); 93 + res = aops->write_end(NULL, mapping, pos, n, n, folio, fsdata); 94 94 if (res < 0) 95 95 return res; 96 96 if (res != n)
+2 -3
fs/fat/inode.c
··· 221 221 222 222 static int fat_write_begin(struct file *file, struct address_space *mapping, 223 223 loff_t pos, unsigned len, 224 - struct page **pagep, void **fsdata) 224 + struct folio **foliop, void **fsdata) 225 225 { 226 226 int err; 227 227 228 - *pagep = NULL; 229 228 err = cont_write_begin(file, mapping, pos, len, 230 - pagep, fsdata, fat_get_block, 229 + foliop, fsdata, fat_get_block, 231 230 &MSDOS_I(mapping->host)->mmu_private); 232 231 if (err < 0) 233 232 fat_write_failed(mapping, pos + len);
+2 -2
fs/fuse/file.c
··· 2387 2387 * but how to implement it without killing performance need more thinking. 2388 2388 */ 2389 2389 static int fuse_write_begin(struct file *file, struct address_space *mapping, 2390 - loff_t pos, unsigned len, struct page **pagep, void **fsdata) 2390 + loff_t pos, unsigned len, struct folio **foliop, void **fsdata) 2391 2391 { 2392 2392 pgoff_t index = pos >> PAGE_SHIFT; 2393 2393 struct fuse_conn *fc = get_fuse_conn(file_inode(file)); ··· 2421 2421 if (err) 2422 2422 goto cleanup; 2423 2423 success: 2424 - *pagep = &folio->page; 2424 + *foliop = folio; 2425 2425 return 0; 2426 2426 2427 2427 cleanup:
+3 -3
fs/hfs/extent.c
··· 487 487 if (inode->i_size > HFS_I(inode)->phys_size) { 488 488 struct address_space *mapping = inode->i_mapping; 489 489 void *fsdata = NULL; 490 - struct page *page; 490 + struct folio *folio; 491 491 492 492 /* XXX: Can use generic_cont_expand? */ 493 493 size = inode->i_size - 1; 494 - res = hfs_write_begin(NULL, mapping, size + 1, 0, &page, 494 + res = hfs_write_begin(NULL, mapping, size + 1, 0, &folio, 495 495 &fsdata); 496 496 if (!res) { 497 497 res = generic_write_end(NULL, mapping, size + 1, 0, 0, 498 - page_folio(page), fsdata); 498 + folio, fsdata); 499 499 } 500 500 if (res) 501 501 inode->i_size = HFS_I(inode)->phys_size;
+1 -1
fs/hfs/hfs_fs.h
··· 202 202 extern const struct address_space_operations hfs_btree_aops; 203 203 204 204 int hfs_write_begin(struct file *file, struct address_space *mapping, 205 - loff_t pos, unsigned len, struct page **pagep, void **fsdata); 205 + loff_t pos, unsigned len, struct folio **foliop, void **fsdata); 206 206 extern struct inode *hfs_new_inode(struct inode *, const struct qstr *, umode_t); 207 207 extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, __be32 *, __be32 *); 208 208 extern int hfs_write_inode(struct inode *, struct writeback_control *);
+2 -3
fs/hfs/inode.c
··· 45 45 } 46 46 47 47 int hfs_write_begin(struct file *file, struct address_space *mapping, 48 - loff_t pos, unsigned len, struct page **pagep, void **fsdata) 48 + loff_t pos, unsigned len, struct folio **foliop, void **fsdata) 49 49 { 50 50 int ret; 51 51 52 - *pagep = NULL; 53 - ret = cont_write_begin(file, mapping, pos, len, pagep, fsdata, 52 + ret = cont_write_begin(file, mapping, pos, len, foliop, fsdata, 54 53 hfs_get_block, 55 54 &HFS_I(mapping->host)->phys_size); 56 55 if (unlikely(ret))
+3 -3
fs/hfsplus/extents.c
··· 554 554 555 555 if (inode->i_size > hip->phys_size) { 556 556 struct address_space *mapping = inode->i_mapping; 557 - struct page *page; 557 + struct folio *folio; 558 558 void *fsdata = NULL; 559 559 loff_t size = inode->i_size; 560 560 561 561 res = hfsplus_write_begin(NULL, mapping, size, 0, 562 - &page, &fsdata); 562 + &folio, &fsdata); 563 563 if (res) 564 564 return; 565 565 res = generic_write_end(NULL, mapping, size, 0, 0, 566 - page_folio(page), fsdata); 566 + folio, fsdata); 567 567 if (res < 0) 568 568 return; 569 569 mark_inode_dirty(inode);
+1 -1
fs/hfsplus/hfsplus_fs.h
··· 472 472 extern const struct dentry_operations hfsplus_dentry_operations; 473 473 474 474 int hfsplus_write_begin(struct file *file, struct address_space *mapping, 475 - loff_t pos, unsigned len, struct page **pagep, void **fsdata); 475 + loff_t pos, unsigned len, struct folio **foliop, void **fsdata); 476 476 struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir, 477 477 umode_t mode); 478 478 void hfsplus_delete_inode(struct inode *inode);
+2 -3
fs/hfsplus/inode.c
··· 39 39 } 40 40 41 41 int hfsplus_write_begin(struct file *file, struct address_space *mapping, 42 - loff_t pos, unsigned len, struct page **pagep, void **fsdata) 42 + loff_t pos, unsigned len, struct folio **foliop, void **fsdata) 43 43 { 44 44 int ret; 45 45 46 - *pagep = NULL; 47 - ret = cont_write_begin(file, mapping, pos, len, pagep, fsdata, 46 + ret = cont_write_begin(file, mapping, pos, len, foliop, fsdata, 48 47 hfsplus_get_block, 49 48 &HFSPLUS_I(mapping->host)->phys_size); 50 49 if (unlikely(ret))
+4 -3
fs/hostfs/hostfs_kern.c
··· 465 465 466 466 static int hostfs_write_begin(struct file *file, struct address_space *mapping, 467 467 loff_t pos, unsigned len, 468 - struct page **pagep, void **fsdata) 468 + struct folio **foliop, void **fsdata) 469 469 { 470 470 pgoff_t index = pos >> PAGE_SHIFT; 471 471 472 - *pagep = grab_cache_page_write_begin(mapping, index); 473 - if (!*pagep) 472 + *foliop = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, 473 + mapping_gfp_mask(mapping)); 474 + if (!*foliop) 474 475 return -ENOMEM; 475 476 return 0; 476 477 }
+2 -3
fs/hpfs/file.c
··· 190 190 191 191 static int hpfs_write_begin(struct file *file, struct address_space *mapping, 192 192 loff_t pos, unsigned len, 193 - struct page **pagep, void **fsdata) 193 + struct folio **foliop, void **fsdata) 194 194 { 195 195 int ret; 196 196 197 - *pagep = NULL; 198 - ret = cont_write_begin(file, mapping, pos, len, pagep, fsdata, 197 + ret = cont_write_begin(file, mapping, pos, len, foliop, fsdata, 199 198 hpfs_get_block, 200 199 &hpfs_i(mapping->host)->mmu_private); 201 200 if (unlikely(ret))
+1 -1
fs/hugetlbfs/inode.c
··· 388 388 static int hugetlbfs_write_begin(struct file *file, 389 389 struct address_space *mapping, 390 390 loff_t pos, unsigned len, 391 - struct page **pagep, void **fsdata) 391 + struct folio **foliop, void **fsdata) 392 392 { 393 393 return -EINVAL; 394 394 }
+3 -3
fs/jffs2/file.c
··· 26 26 struct folio *folio, void *fsdata); 27 27 static int jffs2_write_begin(struct file *filp, struct address_space *mapping, 28 28 loff_t pos, unsigned len, 29 - struct page **pagep, void **fsdata); 29 + struct folio **foliop, void **fsdata); 30 30 static int jffs2_read_folio(struct file *filp, struct folio *folio); 31 31 32 32 int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync) ··· 125 125 126 126 static int jffs2_write_begin(struct file *filp, struct address_space *mapping, 127 127 loff_t pos, unsigned len, 128 - struct page **pagep, void **fsdata) 128 + struct folio **foliop, void **fsdata) 129 129 { 130 130 struct folio *folio; 131 131 struct inode *inode = mapping->host; ··· 212 212 ret = PTR_ERR(folio); 213 213 goto release_sem; 214 214 } 215 - *pagep = &folio->page; 215 + *foliop = folio; 216 216 217 217 /* 218 218 * Read in the folio if it wasn't already present. Cannot optimize away
+2 -2
fs/jfs/inode.c
··· 292 292 293 293 static int jfs_write_begin(struct file *file, struct address_space *mapping, 294 294 loff_t pos, unsigned len, 295 - struct page **pagep, void **fsdata) 295 + struct folio **foliop, void **fsdata) 296 296 { 297 297 int ret; 298 298 299 - ret = block_write_begin(mapping, pos, len, pagep, jfs_get_block); 299 + ret = block_write_begin(mapping, pos, len, foliop, jfs_get_block); 300 300 if (unlikely(ret)) 301 301 jfs_write_failed(mapping, pos + len); 302 302
+2 -2
fs/libfs.c
··· 901 901 902 902 int simple_write_begin(struct file *file, struct address_space *mapping, 903 903 loff_t pos, unsigned len, 904 - struct page **pagep, void **fsdata) 904 + struct folio **foliop, void **fsdata) 905 905 { 906 906 struct folio *folio; 907 907 ··· 910 910 if (IS_ERR(folio)) 911 911 return PTR_ERR(folio); 912 912 913 - *pagep = &folio->page; 913 + *foliop = folio; 914 914 915 915 if (!folio_test_uptodate(folio) && (len != folio_size(folio))) { 916 916 size_t from = offset_in_folio(folio, pos);
+2 -2
fs/minix/inode.c
··· 444 444 445 445 static int minix_write_begin(struct file *file, struct address_space *mapping, 446 446 loff_t pos, unsigned len, 447 - struct page **pagep, void **fsdata) 447 + struct folio **foliop, void **fsdata) 448 448 { 449 449 int ret; 450 450 451 - ret = block_write_begin(mapping, pos, len, pagep, minix_get_block); 451 + ret = block_write_begin(mapping, pos, len, foliop, minix_get_block); 452 452 if (unlikely(ret)) 453 453 minix_write_failed(mapping, pos + len); 454 454
+5 -5
fs/namei.c
··· 5304 5304 struct address_space *mapping = inode->i_mapping; 5305 5305 const struct address_space_operations *aops = mapping->a_ops; 5306 5306 bool nofs = !mapping_gfp_constraint(mapping, __GFP_FS); 5307 - struct page *page; 5307 + struct folio *folio; 5308 5308 void *fsdata = NULL; 5309 5309 int err; 5310 5310 unsigned int flags; ··· 5312 5312 retry: 5313 5313 if (nofs) 5314 5314 flags = memalloc_nofs_save(); 5315 - err = aops->write_begin(NULL, mapping, 0, len-1, &page, &fsdata); 5315 + err = aops->write_begin(NULL, mapping, 0, len-1, &folio, &fsdata); 5316 5316 if (nofs) 5317 5317 memalloc_nofs_restore(flags); 5318 5318 if (err) 5319 5319 goto fail; 5320 5320 5321 - memcpy(page_address(page), symname, len-1); 5321 + memcpy(folio_address(folio), symname, len - 1); 5322 5322 5323 - err = aops->write_end(NULL, mapping, 0, len-1, len-1, 5324 - page_folio(page), fsdata); 5323 + err = aops->write_end(NULL, mapping, 0, len - 1, len - 1, 5324 + folio, fsdata); 5325 5325 if (err < 0) 5326 5326 goto fail; 5327 5327 if (err < len-1)
+2 -2
fs/nfs/file.c
··· 336 336 * increment the page use counts until he is done with the page. 337 337 */ 338 338 static int nfs_write_begin(struct file *file, struct address_space *mapping, 339 - loff_t pos, unsigned len, struct page **pagep, 339 + loff_t pos, unsigned len, struct folio **foliop, 340 340 void **fsdata) 341 341 { 342 342 fgf_t fgp = FGP_WRITEBEGIN; ··· 353 353 mapping_gfp_mask(mapping)); 354 354 if (IS_ERR(folio)) 355 355 return PTR_ERR(folio); 356 - *pagep = &folio->page; 356 + *foliop = folio; 357 357 358 358 ret = nfs_flush_incompatible(file, folio); 359 359 if (ret) {
+2 -2
fs/nilfs2/inode.c
··· 250 250 251 251 static int nilfs_write_begin(struct file *file, struct address_space *mapping, 252 252 loff_t pos, unsigned len, 253 - struct page **pagep, void **fsdata) 253 + struct folio **foliop, void **fsdata) 254 254 255 255 { 256 256 struct inode *inode = mapping->host; ··· 259 259 if (unlikely(err)) 260 260 return err; 261 261 262 - err = block_write_begin(mapping, pos, len, pagep, nilfs_get_block); 262 + err = block_write_begin(mapping, pos, len, foliop, nilfs_get_block); 263 263 if (unlikely(err)) { 264 264 nilfs_write_failed(mapping, pos + len); 265 265 nilfs_transaction_abort(inode->i_sb);
+2 -4
fs/nilfs2/recovery.c
··· 498 498 struct inode *inode; 499 499 struct nilfs_recovery_block *rb, *n; 500 500 unsigned int blocksize = nilfs->ns_blocksize; 501 - struct page *page; 502 501 struct folio *folio; 503 502 loff_t pos; 504 503 int err = 0, err2 = 0; ··· 512 513 513 514 pos = rb->blkoff << inode->i_blkbits; 514 515 err = block_write_begin(inode->i_mapping, pos, blocksize, 515 - &page, nilfs_get_block); 516 + &folio, nilfs_get_block); 516 517 if (unlikely(err)) { 517 518 loff_t isize = inode->i_size; 518 519 ··· 522 523 goto failed_inode; 523 524 } 524 525 525 - folio = page_folio(page); 526 - err = nilfs_recovery_copy_block(nilfs, rb, pos, page); 526 + err = nilfs_recovery_copy_block(nilfs, rb, pos, &folio->page); 527 527 if (unlikely(err)) 528 528 goto failed_page; 529 529
+4 -5
fs/ntfs3/file.c
··· 182 182 183 183 for (;;) { 184 184 u32 zerofrom, len; 185 - struct page *page; 185 + struct folio *folio; 186 186 u8 bits; 187 187 CLST vcn, lcn, clen; 188 188 ··· 208 208 if (pos + len > new_valid) 209 209 len = new_valid - pos; 210 210 211 - err = ntfs_write_begin(file, mapping, pos, len, &page, NULL); 211 + err = ntfs_write_begin(file, mapping, pos, len, &folio, NULL); 212 212 if (err) 213 213 goto out; 214 214 215 - zero_user_segment(page, zerofrom, PAGE_SIZE); 215 + folio_zero_range(folio, zerofrom, folio_size(folio)); 216 216 217 - /* This function in any case puts page. */ 218 - err = ntfs_write_end(file, mapping, pos, len, len, page_folio(page), NULL); 217 + err = ntfs_write_end(file, mapping, pos, len, len, folio, NULL); 219 218 if (err < 0) 220 219 goto out; 221 220 pos += len;
+3 -4
fs/ntfs3/inode.c
··· 901 901 } 902 902 903 903 int ntfs_write_begin(struct file *file, struct address_space *mapping, 904 - loff_t pos, u32 len, struct page **pagep, void **fsdata) 904 + loff_t pos, u32 len, struct folio **foliop, void **fsdata) 905 905 { 906 906 int err; 907 907 struct inode *inode = mapping->host; ··· 910 910 if (unlikely(ntfs3_forced_shutdown(inode->i_sb))) 911 911 return -EIO; 912 912 913 - *pagep = NULL; 914 913 if (is_resident(ni)) { 915 914 struct folio *folio = __filemap_get_folio( 916 915 mapping, pos >> PAGE_SHIFT, FGP_WRITEBEGIN, ··· 925 926 ni_unlock(ni); 926 927 927 928 if (!err) { 928 - *pagep = &folio->page; 929 + *foliop = folio; 929 930 goto out; 930 931 } 931 932 folio_unlock(folio); ··· 935 936 goto out; 936 937 } 937 938 938 - err = block_write_begin(mapping, pos, len, pagep, 939 + err = block_write_begin(mapping, pos, len, foliop, 939 940 ntfs_get_block_write_begin); 940 941 941 942 out:
+1 -1
fs/ntfs3/ntfs_fs.h
··· 711 711 int ntfs_get_block(struct inode *inode, sector_t vbn, 712 712 struct buffer_head *bh_result, int create); 713 713 int ntfs_write_begin(struct file *file, struct address_space *mapping, 714 - loff_t pos, u32 len, struct page **pagep, void **fsdata); 714 + loff_t pos, u32 len, struct folio **foliop, void **fsdata); 715 715 int ntfs_write_end(struct file *file, struct address_space *mapping, loff_t pos, 716 716 u32 len, u32 copied, struct folio *folio, void *fsdata); 717 717 int ntfs3_write_inode(struct inode *inode, struct writeback_control *wbc);
+5 -5
fs/ocfs2/aops.c
··· 1643 1643 1644 1644 int ocfs2_write_begin_nolock(struct address_space *mapping, 1645 1645 loff_t pos, unsigned len, ocfs2_write_type_t type, 1646 - struct page **pagep, void **fsdata, 1646 + struct folio **foliop, void **fsdata, 1647 1647 struct buffer_head *di_bh, struct page *mmap_page) 1648 1648 { 1649 1649 int ret, cluster_of_pages, credits = OCFS2_INODE_UPDATE_CREDITS; ··· 1826 1826 ocfs2_free_alloc_context(meta_ac); 1827 1827 1828 1828 success: 1829 - if (pagep) 1830 - *pagep = wc->w_target_page; 1829 + if (foliop) 1830 + *foliop = page_folio(wc->w_target_page); 1831 1831 *fsdata = wc; 1832 1832 return 0; 1833 1833 out_quota: ··· 1879 1879 1880 1880 static int ocfs2_write_begin(struct file *file, struct address_space *mapping, 1881 1881 loff_t pos, unsigned len, 1882 - struct page **pagep, void **fsdata) 1882 + struct folio **foliop, void **fsdata) 1883 1883 { 1884 1884 int ret; 1885 1885 struct buffer_head *di_bh = NULL; ··· 1901 1901 down_write(&OCFS2_I(inode)->ip_alloc_sem); 1902 1902 1903 1903 ret = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_BUFFER, 1904 - pagep, fsdata, di_bh, NULL); 1904 + foliop, fsdata, di_bh, NULL); 1905 1905 if (ret) { 1906 1906 mlog_errno(ret); 1907 1907 goto out_fail;
+1 -1
fs/ocfs2/aops.h
··· 38 38 39 39 int ocfs2_write_begin_nolock(struct address_space *mapping, 40 40 loff_t pos, unsigned len, ocfs2_write_type_t type, 41 - struct page **pagep, void **fsdata, 41 + struct folio **foliop, void **fsdata, 42 42 struct buffer_head *di_bh, struct page *mmap_page); 43 43 44 44 int ocfs2_read_inline_data(struct inode *inode, struct page *page,
+3 -3
fs/ocfs2/mmap.c
··· 53 53 loff_t pos = page_offset(page); 54 54 unsigned int len = PAGE_SIZE; 55 55 pgoff_t last_index; 56 - struct page *locked_page = NULL; 56 + struct folio *locked_folio = NULL; 57 57 void *fsdata; 58 58 loff_t size = i_size_read(inode); 59 59 ··· 91 91 len = ((size - 1) & ~PAGE_MASK) + 1; 92 92 93 93 err = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_MMAP, 94 - &locked_page, &fsdata, di_bh, page); 94 + &locked_folio, &fsdata, di_bh, page); 95 95 if (err) { 96 96 if (err != -ENOSPC) 97 97 mlog_errno(err); ··· 99 99 goto out; 100 100 } 101 101 102 - if (!locked_page) { 102 + if (!locked_folio) { 103 103 ret = VM_FAULT_NOPAGE; 104 104 goto out; 105 105 }
+2 -2
fs/omfs/file.c
··· 312 312 313 313 static int omfs_write_begin(struct file *file, struct address_space *mapping, 314 314 loff_t pos, unsigned len, 315 - struct page **pagep, void **fsdata) 315 + struct folio **foliop, void **fsdata) 316 316 { 317 317 int ret; 318 318 319 - ret = block_write_begin(mapping, pos, len, pagep, omfs_get_block); 319 + ret = block_write_begin(mapping, pos, len, foliop, omfs_get_block); 320 320 if (unlikely(ret)) 321 321 omfs_write_failed(mapping, pos + len); 322 322
+2 -2
fs/orangefs/inode.c
··· 309 309 310 310 static int orangefs_write_begin(struct file *file, 311 311 struct address_space *mapping, loff_t pos, unsigned len, 312 - struct page **pagep, void **fsdata) 312 + struct folio **foliop, void **fsdata) 313 313 { 314 314 struct orangefs_write_range *wr; 315 315 struct folio *folio; ··· 320 320 if (IS_ERR(folio)) 321 321 return PTR_ERR(folio); 322 322 323 - *pagep = &folio->page; 323 + *foliop = folio; 324 324 325 325 if (folio_test_dirty(folio) && !folio_test_private(folio)) { 326 326 /*
+2 -2
fs/reiserfs/inode.c
··· 2735 2735 static int reiserfs_write_begin(struct file *file, 2736 2736 struct address_space *mapping, 2737 2737 loff_t pos, unsigned len, 2738 - struct page **pagep, void **fsdata) 2738 + struct folio **foliop, void **fsdata) 2739 2739 { 2740 2740 struct inode *inode; 2741 2741 struct folio *folio; ··· 2749 2749 mapping_gfp_mask(mapping)); 2750 2750 if (IS_ERR(folio)) 2751 2751 return PTR_ERR(folio); 2752 - *pagep = &folio->page; 2752 + *foliop = folio; 2753 2753 2754 2754 reiserfs_wait_on_write_block(inode->i_sb); 2755 2755 fix_tail_page_for_writing(&folio->page);
+2 -2
fs/sysv/itree.c
··· 483 483 484 484 static int sysv_write_begin(struct file *file, struct address_space *mapping, 485 485 loff_t pos, unsigned len, 486 - struct page **pagep, void **fsdata) 486 + struct folio **foliop, void **fsdata) 487 487 { 488 488 int ret; 489 489 490 - ret = block_write_begin(mapping, pos, len, pagep, get_block); 490 + ret = block_write_begin(mapping, pos, len, foliop, get_block); 491 491 if (unlikely(ret)) 492 492 sysv_write_failed(mapping, pos + len); 493 493
+5 -5
fs/ubifs/file.c
··· 211 211 } 212 212 213 213 static int write_begin_slow(struct address_space *mapping, 214 - loff_t pos, unsigned len, struct page **pagep) 214 + loff_t pos, unsigned len, struct folio **foliop) 215 215 { 216 216 struct inode *inode = mapping->host; 217 217 struct ubifs_info *c = inode->i_sb->s_fs_info; ··· 298 298 ubifs_release_dirty_inode_budget(c, ui); 299 299 } 300 300 301 - *pagep = &folio->page; 301 + *foliop = folio; 302 302 return 0; 303 303 } 304 304 ··· 414 414 */ 415 415 static int ubifs_write_begin(struct file *file, struct address_space *mapping, 416 416 loff_t pos, unsigned len, 417 - struct page **pagep, void **fsdata) 417 + struct folio **foliop, void **fsdata) 418 418 { 419 419 struct inode *inode = mapping->host; 420 420 struct ubifs_info *c = inode->i_sb->s_fs_info; ··· 483 483 folio_unlock(folio); 484 484 folio_put(folio); 485 485 486 - return write_begin_slow(mapping, pos, len, pagep); 486 + return write_begin_slow(mapping, pos, len, foliop); 487 487 } 488 488 489 489 /* ··· 492 492 * with @ui->ui_mutex locked if we are appending pages, and unlocked 493 493 * otherwise. This is an optimization (slightly hacky though). 494 494 */ 495 - *pagep = &folio->page; 495 + *foliop = folio; 496 496 return 0; 497 497 } 498 498
+3 -3
fs/udf/inode.c
··· 246 246 247 247 static int udf_write_begin(struct file *file, struct address_space *mapping, 248 248 loff_t pos, unsigned len, 249 - struct page **pagep, void **fsdata) 249 + struct folio **foliop, void **fsdata) 250 250 { 251 251 struct udf_inode_info *iinfo = UDF_I(file_inode(file)); 252 252 struct folio *folio; 253 253 int ret; 254 254 255 255 if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { 256 - ret = block_write_begin(mapping, pos, len, pagep, 256 + ret = block_write_begin(mapping, pos, len, foliop, 257 257 udf_get_block); 258 258 if (unlikely(ret)) 259 259 udf_write_failed(mapping, pos + len); ··· 265 265 mapping_gfp_mask(mapping)); 266 266 if (IS_ERR(folio)) 267 267 return PTR_ERR(folio); 268 - *pagep = &folio->page; 268 + *foliop = folio; 269 269 if (!folio_test_uptodate(folio)) 270 270 udf_adinicb_read_folio(folio); 271 271 return 0;
+2 -2
fs/ufs/inode.c
··· 498 498 499 499 static int ufs_write_begin(struct file *file, struct address_space *mapping, 500 500 loff_t pos, unsigned len, 501 - struct page **pagep, void **fsdata) 501 + struct folio **foliop, void **fsdata) 502 502 { 503 503 int ret; 504 504 505 - ret = block_write_begin(mapping, pos, len, pagep, ufs_getfrag_block); 505 + ret = block_write_begin(mapping, pos, len, foliop, ufs_getfrag_block); 506 506 if (unlikely(ret)) 507 507 ufs_write_failed(mapping, pos + len); 508 508
+2 -2
include/linux/buffer_head.h
··· 258 258 int block_read_full_folio(struct folio *, get_block_t *); 259 259 bool block_is_partially_uptodate(struct folio *, size_t from, size_t count); 260 260 int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len, 261 - struct page **pagep, get_block_t *get_block); 261 + struct folio **foliop, get_block_t *get_block); 262 262 int __block_write_begin(struct page *page, loff_t pos, unsigned len, 263 263 get_block_t *get_block); 264 264 int block_write_end(struct file *, struct address_space *, ··· 269 269 struct folio *, void *); 270 270 void folio_zero_new_buffers(struct folio *folio, size_t from, size_t to); 271 271 int cont_write_begin(struct file *, struct address_space *, loff_t, 272 - unsigned, struct page **, void **, 272 + unsigned, struct folio **, void **, 273 273 get_block_t *, loff_t *); 274 274 int generic_cont_expand_simple(struct inode *inode, loff_t size); 275 275 void block_commit_write(struct page *page, unsigned int from, unsigned int to);
+2 -2
include/linux/fs.h
··· 408 408 409 409 int (*write_begin)(struct file *, struct address_space *mapping, 410 410 loff_t pos, unsigned len, 411 - struct page **pagep, void **fsdata); 411 + struct folio **foliop, void **fsdata); 412 412 int (*write_end)(struct file *, struct address_space *mapping, 413 413 loff_t pos, unsigned len, unsigned copied, 414 414 struct folio *folio, void *fsdata); ··· 3331 3331 extern int simple_empty(struct dentry *); 3332 3332 extern int simple_write_begin(struct file *file, struct address_space *mapping, 3333 3333 loff_t pos, unsigned len, 3334 - struct page **pagep, void **fsdata); 3334 + struct folio **foliop, void **fsdata); 3335 3335 extern const struct address_space_operations ram_aops; 3336 3336 extern int always_delete_dentry(const struct dentry *); 3337 3337 extern struct inode *alloc_anon_inode(struct super_block *);
+1 -3
mm/filemap.c
··· 3987 3987 ssize_t written = 0; 3988 3988 3989 3989 do { 3990 - struct page *page; 3991 3990 struct folio *folio; 3992 3991 size_t offset; /* Offset into folio */ 3993 3992 size_t bytes; /* Bytes to write to folio */ ··· 4016 4017 } 4017 4018 4018 4019 status = a_ops->write_begin(file, mapping, pos, bytes, 4019 - &page, &fsdata); 4020 + &folio, &fsdata); 4020 4021 if (unlikely(status < 0)) 4021 4022 break; 4022 4023 4023 - folio = page_folio(page); 4024 4024 offset = offset_in_folio(folio, pos); 4025 4025 if (bytes > folio_size(folio) - offset) 4026 4026 bytes = folio_size(folio) - offset;
+4 -4
mm/shmem.c
··· 2882 2882 static int 2883 2883 shmem_write_begin(struct file *file, struct address_space *mapping, 2884 2884 loff_t pos, unsigned len, 2885 - struct page **pagep, void **fsdata) 2885 + struct folio **foliop, void **fsdata) 2886 2886 { 2887 2887 struct inode *inode = mapping->host; 2888 2888 struct shmem_inode_info *info = SHMEM_I(inode); ··· 2903 2903 if (ret) 2904 2904 return ret; 2905 2905 2906 - *pagep = folio_file_page(folio, index); 2907 - if (PageHWPoison(*pagep)) { 2906 + if (folio_test_hwpoison(folio) || 2907 + (folio_test_large(folio) && folio_test_has_hwpoisoned(folio))) { 2908 2908 folio_unlock(folio); 2909 2909 folio_put(folio); 2910 - *pagep = NULL; 2911 2910 return -EIO; 2912 2911 } 2913 2912 2913 + *foliop = folio; 2914 2914 return 0; 2915 2915 } 2916 2916