Skip to content

Commit 6b1f86f

Browse files
committed
Merge tag 'folio-5.18b' of git://git.infradead.org/users/willy/pagecache
Pull filesystem folio updates from Matthew Wilcox: "Primarily this series converts some of the address_space operations to take a folio instead of a page. Notably: - a_ops->is_partially_uptodate() takes a folio instead of a page and changes the type of the 'from' and 'count' arguments to make it obvious they're bytes. - a_ops->invalidatepage() becomes ->invalidate_folio() and has a similar type change. - a_ops->launder_page() becomes ->launder_folio() - a_ops->set_page_dirty() becomes ->dirty_folio() and adds the address_space as an argument. There are a couple of other misc changes up front that weren't worth separating into their own pull request" * tag 'folio-5.18b' of git://git.infradead.org/users/willy/pagecache: (53 commits) fs: Remove aops ->set_page_dirty fb_defio: Use noop_dirty_folio() fs: Convert __set_page_dirty_no_writeback to noop_dirty_folio fs: Convert __set_page_dirty_buffers to block_dirty_folio nilfs: Convert nilfs_set_page_dirty() to nilfs_dirty_folio() mm: Convert swap_set_page_dirty() to swap_dirty_folio() ubifs: Convert ubifs_set_page_dirty to ubifs_dirty_folio f2fs: Convert f2fs_set_node_page_dirty to f2fs_dirty_node_folio f2fs: Convert f2fs_set_data_page_dirty to f2fs_dirty_data_folio f2fs: Convert f2fs_set_meta_page_dirty to f2fs_dirty_meta_folio afs: Convert afs_dir_set_page_dirty() to afs_dir_dirty_folio() btrfs: Convert extent_range_redirty_for_io() to use folios fs: Convert trivial uses of __set_page_dirty_nobuffers to filemap_dirty_folio btrfs: Convert from set_page_dirty to dirty_folio fscache: Convert fscache_set_page_dirty() to fscache_dirty_folio() fs: Add aops->dirty_folio fs: Remove aops->launder_page orangefs: Convert launder_page to launder_folio nfs: Convert from launder_page to launder_folio fuse: Convert from launder_page to launder_folio ...
2 parents 9030fb0 + 3a3bae5 commit 6b1f86f

Some content is hidden

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

94 files changed

+849
-875
lines changed

Documentation/filesystems/caching/netfs-api.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,16 +345,17 @@ The following facilities are provided to manage this:
345345

346346
To support this, the following functions are provided::
347347

348-
int fscache_set_page_dirty(struct page *page,
349-
struct fscache_cookie *cookie);
348+
bool fscache_dirty_folio(struct address_space *mapping,
349+
struct folio *folio,
350+
struct fscache_cookie *cookie);
350351
void fscache_unpin_writeback(struct writeback_control *wbc,
351352
struct fscache_cookie *cookie);
352353
void fscache_clear_inode_writeback(struct fscache_cookie *cookie,
353354
struct inode *inode,
354355
const void *aux);
355356

356357
The *set* function is intended to be called from the filesystem's
357-
``set_page_dirty`` address space operation. If ``I_PINNING_FSCACHE_WB`` is not
358+
``dirty_folio`` address space operation. If ``I_PINNING_FSCACHE_WB`` is not
358359
set, it sets that flag and increments the use count on the cookie (the caller
359360
must already have called ``fscache_use_cookie()``).
360361

Documentation/filesystems/locking.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ prototypes::
239239
int (*writepage)(struct page *page, struct writeback_control *wbc);
240240
int (*readpage)(struct file *, struct page *);
241241
int (*writepages)(struct address_space *, struct writeback_control *);
242-
int (*set_page_dirty)(struct page *page);
242+
bool (*dirty_folio)(struct address_space *, struct folio *folio);
243243
void (*readahead)(struct readahead_control *);
244244
int (*readpages)(struct file *filp, struct address_space *mapping,
245245
struct list_head *pages, unsigned nr_pages);
@@ -250,42 +250,42 @@ prototypes::
250250
loff_t pos, unsigned len, unsigned copied,
251251
struct page *page, void *fsdata);
252252
sector_t (*bmap)(struct address_space *, sector_t);
253-
void (*invalidatepage) (struct page *, unsigned int, unsigned int);
253+
void (*invalidate_folio) (struct folio *, size_t start, size_t len);
254254
int (*releasepage) (struct page *, int);
255255
void (*freepage)(struct page *);
256256
int (*direct_IO)(struct kiocb *, struct iov_iter *iter);
257257
bool (*isolate_page) (struct page *, isolate_mode_t);
258258
int (*migratepage)(struct address_space *, struct page *, struct page *);
259259
void (*putback_page) (struct page *);
260-
int (*launder_page)(struct page *);
261-
int (*is_partially_uptodate)(struct page *, unsigned long, unsigned long);
260+
int (*launder_folio)(struct folio *);
261+
bool (*is_partially_uptodate)(struct folio *, size_t from, size_t count);
262262
int (*error_remove_page)(struct address_space *, struct page *);
263263
int (*swap_activate)(struct file *);
264264
int (*swap_deactivate)(struct file *);
265265

266266
locking rules:
267-
All except set_page_dirty and freepage may block
267+
All except dirty_folio and freepage may block
268268

269269
====================== ======================== ========= ===============
270270
ops PageLocked(page) i_rwsem invalidate_lock
271271
====================== ======================== ========= ===============
272272
writepage: yes, unlocks (see below)
273273
readpage: yes, unlocks shared
274274
writepages:
275-
set_page_dirty no
275+
dirty_folio maybe
276276
readahead: yes, unlocks shared
277277
readpages: no shared
278278
write_begin: locks the page exclusive
279279
write_end: yes, unlocks exclusive
280280
bmap:
281-
invalidatepage: yes exclusive
281+
invalidate_folio: yes exclusive
282282
releasepage: yes
283283
freepage: yes
284284
direct_IO:
285285
isolate_page: yes
286286
migratepage: yes (both)
287287
putback_page: yes
288-
launder_page: yes
288+
launder_folio: yes
289289
is_partially_uptodate: yes
290290
error_remove_page: yes
291291
swap_activate: no
@@ -361,22 +361,22 @@ If nr_to_write is NULL, all dirty pages must be written.
361361
writepages should _only_ write pages which are present on
362362
mapping->io_pages.
363363

364-
->set_page_dirty() is called from various places in the kernel
365-
when the target page is marked as needing writeback. It may be called
366-
under spinlock (it cannot block) and is sometimes called with the page
367-
not locked.
364+
->dirty_folio() is called from various places in the kernel when
365+
the target folio is marked as needing writeback. The folio cannot be
366+
truncated because either the caller holds the folio lock, or the caller
367+
has found the folio while holding the page table lock which will block
368+
truncation.
368369

369370
->bmap() is currently used by legacy ioctl() (FIBMAP) provided by some
370371
filesystems and by the swapper. The latter will eventually go away. Please,
371372
keep it that way and don't breed new callers.
372373

373-
->invalidatepage() is called when the filesystem must attempt to drop
374+
->invalidate_folio() is called when the filesystem must attempt to drop
374375
some or all of the buffers from the page when it is being truncated. It
375-
returns zero on success. If ->invalidatepage is zero, the kernel uses
376-
block_invalidatepage() instead. The filesystem must exclusively acquire
377-
invalidate_lock before invalidating page cache in truncate / hole punch path
378-
(and thus calling into ->invalidatepage) to block races between page cache
379-
invalidation and page cache filling functions (fault, read, ...).
376+
returns zero on success. The filesystem must exclusively acquire
377+
invalidate_lock before invalidating page cache in truncate / hole punch
378+
path (and thus calling into ->invalidate_folio) to block races between page
379+
cache invalidation and page cache filling functions (fault, read, ...).
380380

381381
->releasepage() is called when the kernel is about to try to drop the
382382
buffers from the page in preparation for freeing it. It returns zero to
@@ -386,9 +386,9 @@ the kernel assumes that the fs has no private interest in the buffers.
386386
->freepage() is called when the kernel is done dropping the page
387387
from the page cache.
388388

389-
->launder_page() may be called prior to releasing a page if
390-
it is still found to be dirty. It returns zero if the page was successfully
391-
cleaned, or an error value if not. Note that in order to prevent the page
389+
->launder_folio() may be called prior to releasing a folio if
390+
it is still found to be dirty. It returns zero if the folio was successfully
391+
cleaned, or an error value if not. Note that in order to prevent the folio
392392
getting mapped back in and redirtied, it needs to be kept locked
393393
across the entire operation.
394394

Documentation/filesystems/vfs.rst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ pages, however the address_space has finer control of write sizes.
658658

659659
The read process essentially only requires 'readpage'. The write
660660
process is more complicated and uses write_begin/write_end or
661-
set_page_dirty to write data into the address_space, and writepage and
661+
dirty_folio to write data into the address_space, and writepage and
662662
writepages to writeback data to storage.
663663

664664
Adding and removing pages to/from an address_space is protected by the
@@ -724,7 +724,7 @@ cache in your filesystem. The following members are defined:
724724
int (*writepage)(struct page *page, struct writeback_control *wbc);
725725
int (*readpage)(struct file *, struct page *);
726726
int (*writepages)(struct address_space *, struct writeback_control *);
727-
int (*set_page_dirty)(struct page *page);
727+
bool (*dirty_folio)(struct address_space *, struct folio *);
728728
void (*readahead)(struct readahead_control *);
729729
int (*readpages)(struct file *filp, struct address_space *mapping,
730730
struct list_head *pages, unsigned nr_pages);
@@ -735,7 +735,7 @@ cache in your filesystem. The following members are defined:
735735
loff_t pos, unsigned len, unsigned copied,
736736
struct page *page, void *fsdata);
737737
sector_t (*bmap)(struct address_space *, sector_t);
738-
void (*invalidatepage) (struct page *, unsigned int, unsigned int);
738+
void (*invalidate_folio) (struct folio *, size_t start, size_t len);
739739
int (*releasepage) (struct page *, int);
740740
void (*freepage)(struct page *);
741741
ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *iter);
@@ -745,10 +745,10 @@ cache in your filesystem. The following members are defined:
745745
int (*migratepage) (struct page *, struct page *);
746746
/* put migration-failed page back to right list */
747747
void (*putback_page) (struct page *);
748-
int (*launder_page) (struct page *);
748+
int (*launder_folio) (struct folio *);
749749
750-
int (*is_partially_uptodate) (struct page *, unsigned long,
751-
unsigned long);
750+
bool (*is_partially_uptodate) (struct folio *, size_t from,
751+
size_t count);
752752
void (*is_dirty_writeback) (struct page *, bool *, bool *);
753753
int (*error_remove_page) (struct mapping *mapping, struct page *page);
754754
int (*swap_activate)(struct file *);
@@ -793,13 +793,13 @@ cache in your filesystem. The following members are defined:
793793
This will choose pages from the address space that are tagged as
794794
DIRTY and will pass them to ->writepage.
795795

796-
``set_page_dirty``
797-
called by the VM to set a page dirty. This is particularly
798-
needed if an address space attaches private data to a page, and
799-
that data needs to be updated when a page is dirtied. This is
796+
``dirty_folio``
797+
called by the VM to mark a folio as dirty. This is particularly
798+
needed if an address space attaches private data to a folio, and
799+
that data needs to be updated when a folio is dirtied. This is
800800
called, for example, when a memory mapped page gets modified.
801-
If defined, it should set the PageDirty flag, and the
802-
PAGECACHE_TAG_DIRTY tag in the radix tree.
801+
If defined, it should set the folio dirty flag, and the
802+
PAGECACHE_TAG_DIRTY search mark in i_pages.
803803

804804
``readahead``
805805
Called by the VM to read pages associated with the address_space
@@ -872,15 +872,15 @@ cache in your filesystem. The following members are defined:
872872
to find out where the blocks in the file are and uses those
873873
addresses directly.
874874

875-
``invalidatepage``
876-
If a page has PagePrivate set, then invalidatepage will be
877-
called when part or all of the page is to be removed from the
875+
``invalidate_folio``
876+
If a folio has private data, then invalidate_folio will be
877+
called when part or all of the folio is to be removed from the
878878
address space. This generally corresponds to either a
879879
truncation, punch hole or a complete invalidation of the address
880880
space (in the latter case 'offset' will always be 0 and 'length'
881-
will be PAGE_SIZE). Any private data associated with the page
881+
will be folio_size()). Any private data associated with the page
882882
should be updated to reflect this truncation. If offset is 0
883-
and length is PAGE_SIZE, then the private data should be
883+
and length is folio_size(), then the private data should be
884884
released, because the page must be able to be completely
885885
discarded. This may be done by calling the ->releasepage
886886
function, but in this case the release MUST succeed.
@@ -934,16 +934,16 @@ cache in your filesystem. The following members are defined:
934934
``putback_page``
935935
Called by the VM when isolated page's migration fails.
936936

937-
``launder_page``
938-
Called before freeing a page - it writes back the dirty page.
939-
To prevent redirtying the page, it is kept locked during the
937+
``launder_folio``
938+
Called before freeing a folio - it writes back the dirty folio.
939+
To prevent redirtying the folio, it is kept locked during the
940940
whole operation.
941941

942942
``is_partially_uptodate``
943943
Called by the VM when reading a file through the pagecache when
944-
the underlying blocksize != pagesize. If the required block is
945-
up to date then the read can complete without needing the IO to
946-
bring the whole page up to date.
944+
the underlying blocksize is smaller than the size of the folio.
945+
If the required block is up to date then the read can complete
946+
without needing I/O to bring the whole page up to date.
947947

948948
``is_dirty_writeback``
949949
Called by the VM when attempting to reclaim a page. The VM uses

block/fops.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ static int blkdev_writepages(struct address_space *mapping,
428428
}
429429

430430
const struct address_space_operations def_blk_aops = {
431-
.set_page_dirty = __set_page_dirty_buffers,
431+
.dirty_folio = block_dirty_folio,
432+
.invalidate_folio = block_invalidate_folio,
432433
.readpage = blkdev_readpage,
433434
.readahead = blkdev_readahead,
434435
.writepage = blkdev_writepage,

drivers/dax/device.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@ static unsigned long dax_get_unmapped_area(struct file *filp,
346346
}
347347

348348
static const struct address_space_operations dev_dax_aops = {
349-
.set_page_dirty = __set_page_dirty_no_writeback,
350-
.invalidatepage = noop_invalidatepage,
349+
.dirty_folio = noop_dirty_folio,
351350
};
352351

353352
static int dax_open(struct inode *inode, struct file *filp)

drivers/video/fbdev/core/fb_defio.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,8 @@ static const struct vm_operations_struct fb_deferred_io_vm_ops = {
151151
.page_mkwrite = fb_deferred_io_mkwrite,
152152
};
153153

154-
static int fb_deferred_io_set_page_dirty(struct page *page)
155-
{
156-
if (!PageDirty(page))
157-
SetPageDirty(page);
158-
return 0;
159-
}
160-
161154
static const struct address_space_operations fb_deferred_io_aops = {
162-
.set_page_dirty = fb_deferred_io_set_page_dirty,
155+
.dirty_folio = noop_dirty_folio,
163156
};
164157

165158
int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma)

fs/9p/vfs_addr.c

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,9 @@ static int v9fs_release_page(struct page *page, gfp_t gfp)
158158
return 1;
159159
}
160160

161-
/**
162-
* v9fs_invalidate_page - Invalidate a page completely or partially
163-
* @page: The page to be invalidated
164-
* @offset: offset of the invalidated region
165-
* @length: length of the invalidated region
166-
*/
167-
168-
static void v9fs_invalidate_page(struct page *page, unsigned int offset,
169-
unsigned int length)
161+
static void v9fs_invalidate_folio(struct folio *folio, size_t offset,
162+
size_t length)
170163
{
171-
struct folio *folio = page_folio(page);
172-
173164
folio_wait_fscache(folio);
174165
}
175166

@@ -249,16 +240,8 @@ static int v9fs_vfs_writepage(struct page *page, struct writeback_control *wbc)
249240
return retval;
250241
}
251242

252-
/**
253-
* v9fs_launder_page - Writeback a dirty page
254-
* @page: The page to be cleaned up
255-
*
256-
* Returns 0 on success.
257-
*/
258-
259-
static int v9fs_launder_page(struct page *page)
243+
static int v9fs_launder_folio(struct folio *folio)
260244
{
261-
struct folio *folio = page_folio(page);
262245
int retval;
263246

264247
if (folio_clear_dirty_for_io(folio)) {
@@ -376,25 +359,25 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
376359
* Mark a page as having been made dirty and thus needing writeback. We also
377360
* need to pin the cache object to write back to.
378361
*/
379-
static int v9fs_set_page_dirty(struct page *page)
362+
static bool v9fs_dirty_folio(struct address_space *mapping, struct folio *folio)
380363
{
381-
struct v9fs_inode *v9inode = V9FS_I(page->mapping->host);
364+
struct v9fs_inode *v9inode = V9FS_I(mapping->host);
382365

383-
return fscache_set_page_dirty(page, v9fs_inode_cookie(v9inode));
366+
return fscache_dirty_folio(mapping, folio, v9fs_inode_cookie(v9inode));
384367
}
385368
#else
386-
#define v9fs_set_page_dirty __set_page_dirty_nobuffers
369+
#define v9fs_dirty_folio filemap_dirty_folio
387370
#endif
388371

389372
const struct address_space_operations v9fs_addr_operations = {
390373
.readpage = v9fs_vfs_readpage,
391374
.readahead = v9fs_vfs_readahead,
392-
.set_page_dirty = v9fs_set_page_dirty,
375+
.dirty_folio = v9fs_dirty_folio,
393376
.writepage = v9fs_vfs_writepage,
394377
.write_begin = v9fs_write_begin,
395378
.write_end = v9fs_write_end,
396379
.releasepage = v9fs_release_page,
397-
.invalidatepage = v9fs_invalidate_page,
398-
.launder_page = v9fs_launder_page,
380+
.invalidate_folio = v9fs_invalidate_folio,
381+
.launder_folio = v9fs_launder_folio,
399382
.direct_IO = v9fs_direct_IO,
400383
};

fs/adfs/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ static sector_t _adfs_bmap(struct address_space *mapping, sector_t block)
7373
}
7474

7575
static const struct address_space_operations adfs_aops = {
76-
.set_page_dirty = __set_page_dirty_buffers,
76+
.dirty_folio = block_dirty_folio,
77+
.invalidate_folio = block_invalidate_folio,
7778
.readpage = adfs_readpage,
7879
.writepage = adfs_writepage,
7980
.write_begin = adfs_write_begin,

fs/affs/file.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,8 @@ static sector_t _affs_bmap(struct address_space *mapping, sector_t block)
453453
}
454454

455455
const struct address_space_operations affs_aops = {
456-
.set_page_dirty = __set_page_dirty_buffers,
456+
.dirty_folio = block_dirty_folio,
457+
.invalidate_folio = block_invalidate_folio,
457458
.readpage = affs_readpage,
458459
.writepage = affs_writepage,
459460
.write_begin = affs_write_begin,
@@ -834,7 +835,8 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
834835
}
835836

836837
const struct address_space_operations affs_aops_ofs = {
837-
.set_page_dirty = __set_page_dirty_buffers,
838+
.dirty_folio = block_dirty_folio,
839+
.invalidate_folio = block_invalidate_folio,
838840
.readpage = affs_readpage_ofs,
839841
//.writepage = affs_writepage_ofs,
840842
.write_begin = affs_write_begin_ofs,

0 commit comments

Comments
 (0)