Skip to content

Commit a225800

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
fs: Convert aops->write_end to take a folio
Most callers have a folio, and most implementations operate on a folio, so remove the conversion from folio->page->folio to fit through this interface. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 3e5d37c commit a225800

File tree

45 files changed

+80
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+80
-102
lines changed

Documentation/filesystems/locking.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ prototypes::
254254
struct page **pagep, void **fsdata);
255255
int (*write_end)(struct file *, struct address_space *mapping,
256256
loff_t pos, unsigned len, unsigned copied,
257-
struct page *page, void *fsdata);
257+
struct folio *folio, void *fsdata);
258258
sector_t (*bmap)(struct address_space *, sector_t);
259259
void (*invalidate_folio) (struct folio *, size_t start, size_t len);
260260
bool (*release_folio)(struct folio *, gfp_t);

Documentation/filesystems/vfs.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ cache in your filesystem. The following members are defined:
810810
struct page **pagep, void **fsdata);
811811
int (*write_end)(struct file *, struct address_space *mapping,
812812
loff_t pos, unsigned len, unsigned copied,
813-
struct page *page, void *fsdata);
813+
struct folio *folio, void *fsdata);
814814
sector_t (*bmap)(struct address_space *, sector_t);
815815
void (*invalidate_folio) (struct folio *, size_t start, size_t len);
816816
bool (*release_folio)(struct folio *, gfp_t);
@@ -944,8 +944,8 @@ cache in your filesystem. The following members are defined:
944944
called. len is the original len passed to write_begin, and
945945
copied is the amount that was able to be copied.
946946

947-
The filesystem must take care of unlocking the page and
948-
releasing it refcount, and updating i_size.
947+
The filesystem must take care of unlocking the folio,
948+
decrementing its refcount, and updating i_size.
949949

950950
Returns < 0 on failure, otherwise the number of bytes (<=
951951
'copied') that were able to be copied into pagecache.

block/fops.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,9 @@ static int blkdev_write_begin(struct file *file, struct address_space *mapping,
457457
}
458458

459459
static int blkdev_write_end(struct file *file, struct address_space *mapping,
460-
loff_t pos, unsigned len, unsigned copied, struct page *page,
460+
loff_t pos, unsigned len, unsigned copied, struct folio *folio,
461461
void *fsdata)
462462
{
463-
struct folio *folio = page_folio(page);
464463
int ret;
465464
ret = block_write_end(file, mapping, pos, len, copied, folio, fsdata);
466465

drivers/gpu/drm/i915/gem/i915_gem_shmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ shmem_pwrite(struct drm_i915_gem_object *obj,
494494
kunmap_local(vaddr);
495495

496496
err = aops->write_end(obj->base.filp, mapping, offset, len,
497-
len - unwritten, page, data);
497+
len - unwritten, page_folio(page), data);
498498
if (err < 0)
499499
return err;
500500

@@ -688,7 +688,7 @@ i915_gem_object_create_shmem_from_data(struct drm_i915_private *i915,
688688
kunmap(page);
689689

690690
err = aops->write_end(file, file->f_mapping, offset, len, len,
691-
page, pgdata);
691+
page_folio(page), pgdata);
692692
if (err < 0)
693693
goto fail;
694694

fs/affs/file.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,12 @@ static int affs_write_begin(struct file *file, struct address_space *mapping,
433433

434434
static int affs_write_end(struct file *file, struct address_space *mapping,
435435
loff_t pos, unsigned int len, unsigned int copied,
436-
struct page *page, void *fsdata)
436+
struct folio *folio, void *fsdata)
437437
{
438438
struct inode *inode = mapping->host;
439439
int ret;
440440

441-
ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata);
441+
ret = generic_write_end(file, mapping, pos, len, copied, folio, fsdata);
442442

443443
/* Clear Archived bit on file writes, as AmigaOS would do */
444444
if (AFFS_I(inode)->i_protect & FIBF_ARCHIVED) {
@@ -687,9 +687,8 @@ static int affs_write_begin_ofs(struct file *file, struct address_space *mapping
687687

688688
static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
689689
loff_t pos, unsigned len, unsigned copied,
690-
struct page *page, void *fsdata)
690+
struct folio *folio, void *fsdata)
691691
{
692-
struct folio *folio = page_folio(page);
693692
struct inode *inode = mapping->host;
694693
struct super_block *sb = inode->i_sb;
695694
struct buffer_head *bh, *prev_bh;
@@ -889,7 +888,7 @@ affs_truncate(struct inode *inode)
889888

890889
res = mapping->a_ops->write_begin(NULL, mapping, isize, 0, &page, &fsdata);
891890
if (!res)
892-
res = mapping->a_ops->write_end(NULL, mapping, isize, 0, 0, page, fsdata);
891+
res = mapping->a_ops->write_end(NULL, mapping, isize, 0, 0, page_folio(page), fsdata);
893892
else
894893
inode->i_size = AFFS_I(inode)->mmu_private;
895894
mark_inode_dirty(inode);

fs/bcachefs/fs-io-buffered.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,12 +743,11 @@ int bch2_write_begin(struct file *file, struct address_space *mapping,
743743

744744
int bch2_write_end(struct file *file, struct address_space *mapping,
745745
loff_t pos, unsigned len, unsigned copied,
746-
struct page *page, void *fsdata)
746+
struct folio *folio, void *fsdata)
747747
{
748748
struct bch_inode_info *inode = to_bch_ei(mapping->host);
749749
struct bch_fs *c = inode->v.i_sb->s_fs_info;
750750
struct bch2_folio_reservation *res = fsdata;
751-
struct folio *folio = page_folio(page);
752751
unsigned offset = pos - folio_pos(folio);
753752

754753
lockdep_assert_held(&inode->v.i_rwsem);

fs/bcachefs/fs-io-buffered.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void bch2_readahead(struct readahead_control *);
1313
int bch2_write_begin(struct file *, struct address_space *, loff_t,
1414
unsigned, struct page **, void **);
1515
int bch2_write_end(struct file *, struct address_space *, loff_t,
16-
unsigned, unsigned, struct page *, void *);
16+
unsigned len, unsigned copied, struct folio *, void *);
1717

1818
ssize_t bch2_write_iter(struct kiocb *, struct iov_iter *);
1919

fs/buffer.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,9 +2280,8 @@ EXPORT_SYMBOL(block_write_end);
22802280

22812281
int generic_write_end(struct file *file, struct address_space *mapping,
22822282
loff_t pos, unsigned len, unsigned copied,
2283-
struct page *page, void *fsdata)
2283+
struct folio *folio, void *fsdata)
22842284
{
2285-
struct folio *folio = page_folio(page);
22862285
struct inode *inode = mapping->host;
22872286
loff_t old_size = inode->i_size;
22882287
bool i_size_changed = false;
@@ -2480,7 +2479,7 @@ int generic_cont_expand_simple(struct inode *inode, loff_t size)
24802479
if (err)
24812480
goto out;
24822481

2483-
err = aops->write_end(NULL, mapping, size, 0, 0, page, fsdata);
2482+
err = aops->write_end(NULL, mapping, size, 0, 0, page_folio(page), fsdata);
24842483
BUG_ON(err > 0);
24852484

24862485
out:
@@ -2518,7 +2517,7 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
25182517
goto out;
25192518
zero_user(page, zerofrom, len);
25202519
err = aops->write_end(file, mapping, curpos, len, len,
2521-
page, fsdata);
2520+
page_folio(page), fsdata);
25222521
if (err < 0)
25232522
goto out;
25242523
BUG_ON(err != len);
@@ -2551,7 +2550,7 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
25512550
goto out;
25522551
zero_user(page, zerofrom, len);
25532552
err = aops->write_end(file, mapping, curpos, len, len,
2554-
page, fsdata);
2553+
page_folio(page), fsdata);
25552554
if (err < 0)
25562555
goto out;
25572556
BUG_ON(err != len);

fs/ceph/addr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,9 +1509,8 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
15091509
*/
15101510
static int ceph_write_end(struct file *file, struct address_space *mapping,
15111511
loff_t pos, unsigned len, unsigned copied,
1512-
struct page *subpage, void *fsdata)
1512+
struct folio *folio, void *fsdata)
15131513
{
1514-
struct folio *folio = page_folio(subpage);
15151514
struct inode *inode = file_inode(file);
15161515
struct ceph_client *cl = ceph_inode_to_client(inode);
15171516
bool check_cap = false;

fs/ecryptfs/mmap.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,14 @@ int ecryptfs_write_inode_size_to_metadata(struct inode *ecryptfs_inode)
458458
* @pos: The file position
459459
* @len: The length of the data (unused)
460460
* @copied: The amount of data copied
461-
* @page: The eCryptfs page
461+
* @folio: The eCryptfs folio
462462
* @fsdata: The fsdata (unused)
463463
*/
464464
static int ecryptfs_write_end(struct file *file,
465465
struct address_space *mapping,
466466
loff_t pos, unsigned len, unsigned copied,
467-
struct page *page, void *fsdata)
467+
struct folio *folio, void *fsdata)
468468
{
469-
struct folio *folio = page_folio(page);
470469
pgoff_t index = pos >> PAGE_SHIFT;
471470
unsigned from = pos & (PAGE_SIZE - 1);
472471
unsigned to = from + copied;

0 commit comments

Comments
 (0)