Skip to content

Commit fdaf9a5

Browse files
committed
Merge tag 'folio-5.19' of git://git.infradead.org/users/willy/pagecache
Pull page cache updates from Matthew Wilcox: - Appoint myself page cache maintainer - Fix how scsicam uses the page cache - Use the memalloc_nofs_save() API to replace AOP_FLAG_NOFS - Remove the AOP flags entirely - Remove pagecache_write_begin() and pagecache_write_end() - Documentation updates - Convert several address_space operations to use folios: - is_dirty_writeback - readpage becomes read_folio - releasepage becomes release_folio - freepage becomes free_folio - Change filler_t to require a struct file pointer be the first argument like ->read_folio * tag 'folio-5.19' of git://git.infradead.org/users/willy/pagecache: (107 commits) nilfs2: Fix some kernel-doc comments Appoint myself page cache maintainer fs: Remove aops->freepage secretmem: Convert to free_folio nfs: Convert to free_folio orangefs: Convert to free_folio fs: Add free_folio address space operation fs: Convert drop_buffers() to use a folio fs: Change try_to_free_buffers() to take a folio jbd2: Convert release_buffer_page() to use a folio jbd2: Convert jbd2_journal_try_to_free_buffers to take a folio reiserfs: Convert release_buffer_page() to use a folio fs: Remove last vestiges of releasepage ubifs: Convert to release_folio reiserfs: Convert to release_folio orangefs: Convert to release_folio ocfs2: Convert to release_folio nilfs2: Remove comment about releasepage nfs: Convert to release_folio jfs: Convert to release_folio ...
2 parents 8642174 + 516edb4 commit fdaf9a5

File tree

161 files changed

+1233
-1221
lines changed

Some content is hidden

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

161 files changed

+1233
-1221
lines changed

Documentation/filesystems/caching/netfs-api.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,11 @@ has done a write and then the page it wrote from has been released by the VM,
433433
after which it *has* to look in the cache.
434434

435435
To inform fscache that a page might now be in the cache, the following function
436-
should be called from the ``releasepage`` address space op::
436+
should be called from the ``release_folio`` address space op::
437437

438438
void fscache_note_page_release(struct fscache_cookie *cookie);
439439

440-
if the page has been released (ie. releasepage returned true).
440+
if the page has been released (ie. release_folio returned true).
441441

442442
Page release and page invalidation should also wait for any mark left on the
443443
page to say that a DIO write is underway from that page::

Documentation/filesystems/fscrypt.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ inline encryption hardware will encrypt/decrypt the file contents.
12561256
When inline encryption isn't used, filesystems must encrypt/decrypt
12571257
the file contents themselves, as described below:
12581258

1259-
For the read path (->readpage()) of regular files, filesystems can
1259+
For the read path (->read_folio()) of regular files, filesystems can
12601260
read the ciphertext into the page cache and decrypt it in-place. The
12611261
page lock must be held until decryption has finished, to prevent the
12621262
page from becoming visible to userspace prematurely.

Documentation/filesystems/fsverity.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ already verified). Below, we describe how filesystems implement this.
559559
Pagecache
560560
~~~~~~~~~
561561

562-
For filesystems using Linux's pagecache, the ``->readpage()`` and
562+
For filesystems using Linux's pagecache, the ``->read_folio()`` and
563563
``->readahead()`` methods must be modified to verify pages before they
564564
are marked Uptodate. Merely hooking ``->read_iter()`` would be
565565
insufficient, since ``->read_iter()`` is not used for memory maps.

Documentation/filesystems/locking.rst

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -237,20 +237,20 @@ address_space_operations
237237
prototypes::
238238

239239
int (*writepage)(struct page *page, struct writeback_control *wbc);
240-
int (*readpage)(struct file *, struct page *);
240+
int (*read_folio)(struct file *, struct folio *);
241241
int (*writepages)(struct address_space *, struct writeback_control *);
242242
bool (*dirty_folio)(struct address_space *, struct folio *folio);
243243
void (*readahead)(struct readahead_control *);
244244
int (*write_begin)(struct file *, struct address_space *mapping,
245-
loff_t pos, unsigned len, unsigned flags,
245+
loff_t pos, unsigned len,
246246
struct page **pagep, void **fsdata);
247247
int (*write_end)(struct file *, struct address_space *mapping,
248248
loff_t pos, unsigned len, unsigned copied,
249249
struct page *page, void *fsdata);
250250
sector_t (*bmap)(struct address_space *, sector_t);
251251
void (*invalidate_folio) (struct folio *, size_t start, size_t len);
252-
int (*releasepage) (struct page *, int);
253-
void (*freepage)(struct page *);
252+
bool (*release_folio)(struct folio *, gfp_t);
253+
void (*free_folio)(struct folio *);
254254
int (*direct_IO)(struct kiocb *, struct iov_iter *iter);
255255
bool (*isolate_page) (struct page *, isolate_mode_t);
256256
int (*migratepage)(struct address_space *, struct page *, struct page *);
@@ -262,22 +262,22 @@ prototypes::
262262
int (*swap_deactivate)(struct file *);
263263

264264
locking rules:
265-
All except dirty_folio and freepage may block
265+
All except dirty_folio and free_folio may block
266266

267267
====================== ======================== ========= ===============
268-
ops PageLocked(page) i_rwsem invalidate_lock
268+
ops folio locked i_rwsem invalidate_lock
269269
====================== ======================== ========= ===============
270270
writepage: yes, unlocks (see below)
271-
readpage: yes, unlocks shared
271+
read_folio: yes, unlocks shared
272272
writepages:
273-
dirty_folio maybe
273+
dirty_folio: maybe
274274
readahead: yes, unlocks shared
275275
write_begin: locks the page exclusive
276276
write_end: yes, unlocks exclusive
277277
bmap:
278278
invalidate_folio: yes exclusive
279-
releasepage: yes
280-
freepage: yes
279+
release_folio: yes
280+
free_folio: yes
281281
direct_IO:
282282
isolate_page: yes
283283
migratepage: yes (both)
@@ -289,13 +289,13 @@ swap_activate: no
289289
swap_deactivate: no
290290
====================== ======================== ========= ===============
291291

292-
->write_begin(), ->write_end() and ->readpage() may be called from
292+
->write_begin(), ->write_end() and ->read_folio() may be called from
293293
the request handler (/dev/loop).
294294

295-
->readpage() unlocks the page, either synchronously or via I/O
295+
->read_folio() unlocks the folio, either synchronously or via I/O
296296
completion.
297297

298-
->readahead() unlocks the pages that I/O is attempted on like ->readpage().
298+
->readahead() unlocks the folios that I/O is attempted on like ->read_folio().
299299

300300
->writepage() is used for two purposes: for "memory cleansing" and for
301301
"sync". These are quite different operations and the behaviour may differ
@@ -372,12 +372,12 @@ invalidate_lock before invalidating page cache in truncate / hole punch
372372
path (and thus calling into ->invalidate_folio) to block races between page
373373
cache invalidation and page cache filling functions (fault, read, ...).
374374

375-
->releasepage() is called when the kernel is about to try to drop the
376-
buffers from the page in preparation for freeing it. It returns zero to
377-
indicate that the buffers are (or may be) freeable. If ->releasepage is zero,
378-
the kernel assumes that the fs has no private interest in the buffers.
375+
->release_folio() is called when the kernel is about to try to drop the
376+
buffers from the folio in preparation for freeing it. It returns false to
377+
indicate that the buffers are (or may be) freeable. If ->release_folio is
378+
NULL, the kernel assumes that the fs has no private interest in the buffers.
379379

380-
->freepage() is called when the kernel is done dropping the page
380+
->free_folio() is called when the kernel has dropped the folio
381381
from the page cache.
382382

383383
->launder_folio() may be called prior to releasing a folio if

Documentation/filesystems/netfs_library.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ attached to an inode (or NULL if fscache is disabled)::
9696
Buffered Read Helpers
9797
=====================
9898

99-
The library provides a set of read helpers that handle the ->readpage(),
99+
The library provides a set of read helpers that handle the ->read_folio(),
100100
->readahead() and much of the ->write_begin() VM operations and translate them
101101
into a common call framework.
102102

@@ -136,20 +136,19 @@ Read Helper Functions
136136
Three read helpers are provided::
137137

138138
void netfs_readahead(struct readahead_control *ractl);
139-
int netfs_readpage(struct file *file,
140-
struct page *page);
139+
int netfs_read_folio(struct file *file,
140+
struct folio *folio);
141141
int netfs_write_begin(struct file *file,
142142
struct address_space *mapping,
143143
loff_t pos,
144144
unsigned int len,
145-
unsigned int flags,
146145
struct folio **_folio,
147146
void **_fsdata);
148147

149148
Each corresponds to a VM address space operation. These operations use the
150149
state in the per-inode context.
151150

152-
For ->readahead() and ->readpage(), the network filesystem just point directly
151+
For ->readahead() and ->read_folio(), the network filesystem just point directly
153152
at the corresponding read helper; whereas for ->write_begin(), it may be a
154153
little more complicated as the network filesystem might want to flush
155154
conflicting writes or track dirty data and needs to put the acquired folio if

Documentation/filesystems/porting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ any symlink that might use page_follow_link_light/page_put_link() must
624624
have inode_nohighmem(inode) called before anything might start playing with
625625
its pagecache. No highmem pages should end up in the pagecache of such
626626
symlinks. That includes any preseeding that might be done during symlink
627-
creation. __page_symlink() will honour the mapping gfp flags, so once
627+
creation. page_symlink() will honour the mapping gfp flags, so once
628628
you've done inode_nohighmem() it's safe to use, but if you allocate and
629629
insert the page manually, make sure to use the right gfp flags.
630630

Documentation/filesystems/vfs.rst

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,9 @@ Writeback.
620620
The first can be used independently to the others. The VM can try to
621621
either write dirty pages in order to clean them, or release clean pages
622622
in order to reuse them. To do this it can call the ->writepage method
623-
on dirty pages, and ->releasepage on clean pages with PagePrivate set.
624-
Clean pages without PagePrivate and with no external references will be
625-
released without notice being given to the address_space.
623+
on dirty pages, and ->release_folio on clean folios with the private
624+
flag set. Clean pages without PagePrivate and with no external references
625+
will be released without notice being given to the address_space.
626626

627627
To achieve this functionality, pages need to be placed on an LRU with
628628
lru_cache_add and mark_page_active needs to be called whenever the page
@@ -656,7 +656,7 @@ by memory-mapping the page. Data is written into the address space by
656656
the application, and then written-back to storage typically in whole
657657
pages, however the address_space has finer control of write sizes.
658658

659-
The read process essentially only requires 'readpage'. The write
659+
The read process essentially only requires 'read_folio'. The write
660660
process is more complicated and uses write_begin/write_end or
661661
dirty_folio to write data into the address_space, and writepage and
662662
writepages to writeback data to storage.
@@ -722,20 +722,20 @@ cache in your filesystem. The following members are defined:
722722
723723
struct address_space_operations {
724724
int (*writepage)(struct page *page, struct writeback_control *wbc);
725-
int (*readpage)(struct file *, struct page *);
725+
int (*read_folio)(struct file *, struct folio *);
726726
int (*writepages)(struct address_space *, struct writeback_control *);
727727
bool (*dirty_folio)(struct address_space *, struct folio *);
728728
void (*readahead)(struct readahead_control *);
729729
int (*write_begin)(struct file *, struct address_space *mapping,
730-
loff_t pos, unsigned len, unsigned flags,
730+
loff_t pos, unsigned len,
731731
struct page **pagep, void **fsdata);
732732
int (*write_end)(struct file *, struct address_space *mapping,
733733
loff_t pos, unsigned len, unsigned copied,
734734
struct page *page, void *fsdata);
735735
sector_t (*bmap)(struct address_space *, sector_t);
736736
void (*invalidate_folio) (struct folio *, size_t start, size_t len);
737-
int (*releasepage) (struct page *, int);
738-
void (*freepage)(struct page *);
737+
bool (*release_folio)(struct folio *, gfp_t);
738+
void (*free_folio)(struct folio *);
739739
ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *iter);
740740
/* isolate a page for migration */
741741
bool (*isolate_page) (struct page *, isolate_mode_t);
@@ -747,7 +747,7 @@ cache in your filesystem. The following members are defined:
747747
748748
bool (*is_partially_uptodate) (struct folio *, size_t from,
749749
size_t count);
750-
void (*is_dirty_writeback) (struct page *, bool *, bool *);
750+
void (*is_dirty_writeback)(struct folio *, bool *, bool *);
751751
int (*error_remove_page) (struct mapping *mapping, struct page *page);
752752
int (*swap_activate)(struct file *);
753753
int (*swap_deactivate)(struct file *);
@@ -772,14 +772,14 @@ cache in your filesystem. The following members are defined:
772772

773773
See the file "Locking" for more details.
774774

775-
``readpage``
776-
called by the VM to read a page from backing store. The page
777-
will be Locked when readpage is called, and should be unlocked
778-
and marked uptodate once the read completes. If ->readpage
779-
discovers that it needs to unlock the page for some reason, it
780-
can do so, and then return AOP_TRUNCATED_PAGE. In this case,
781-
the page will be relocated, relocked and if that all succeeds,
782-
->readpage will be called again.
775+
``read_folio``
776+
called by the VM to read a folio from backing store. The folio
777+
will be locked when read_folio is called, and should be unlocked
778+
and marked uptodate once the read completes. If ->read_folio
779+
discovers that it cannot perform the I/O at this time, it can
780+
unlock the folio and return AOP_TRUNCATED_PAGE. In this case,
781+
the folio will be looked up again, relocked and if that all succeeds,
782+
->read_folio will be called again.
783783

784784
``writepages``
785785
called by the VM to write out pages associated with the
@@ -832,9 +832,6 @@ cache in your filesystem. The following members are defined:
832832
passed to write_begin is greater than the number of bytes copied
833833
into the page).
834834

835-
flags is a field for AOP_FLAG_xxx flags, described in
836-
include/linux/fs.h.
837-
838835
A void * may be returned in fsdata, which then gets passed into
839836
write_end.
840837

@@ -867,36 +864,35 @@ cache in your filesystem. The following members are defined:
867864
address space. This generally corresponds to either a
868865
truncation, punch hole or a complete invalidation of the address
869866
space (in the latter case 'offset' will always be 0 and 'length'
870-
will be folio_size()). Any private data associated with the page
867+
will be folio_size()). Any private data associated with the folio
871868
should be updated to reflect this truncation. If offset is 0
872869
and length is folio_size(), then the private data should be
873-
released, because the page must be able to be completely
874-
discarded. This may be done by calling the ->releasepage
870+
released, because the folio must be able to be completely
871+
discarded. This may be done by calling the ->release_folio
875872
function, but in this case the release MUST succeed.
876873

877-
``releasepage``
878-
releasepage is called on PagePrivate pages to indicate that the
879-
page should be freed if possible. ->releasepage should remove
880-
any private data from the page and clear the PagePrivate flag.
881-
If releasepage() fails for some reason, it must indicate failure
882-
with a 0 return value. releasepage() is used in two distinct
883-
though related cases. The first is when the VM finds a clean
884-
page with no active users and wants to make it a free page. If
885-
->releasepage succeeds, the page will be removed from the
886-
address_space and become free.
874+
``release_folio``
875+
release_folio is called on folios with private data to tell the
876+
filesystem that the folio is about to be freed. ->release_folio
877+
should remove any private data from the folio and clear the
878+
private flag. If release_folio() fails, it should return false.
879+
release_folio() is used in two distinct though related cases.
880+
The first is when the VM wants to free a clean folio with no
881+
active users. If ->release_folio succeeds, the folio will be
882+
removed from the address_space and be freed.
887883

888884
The second case is when a request has been made to invalidate
889-
some or all pages in an address_space. This can happen through
890-
the fadvise(POSIX_FADV_DONTNEED) system call or by the
891-
filesystem explicitly requesting it as nfs and 9fs do (when they
885+
some or all folios in an address_space. This can happen
886+
through the fadvise(POSIX_FADV_DONTNEED) system call or by the
887+
filesystem explicitly requesting it as nfs and 9p do (when they
892888
believe the cache may be out of date with storage) by calling
893889
invalidate_inode_pages2(). If the filesystem makes such a call,
894-
and needs to be certain that all pages are invalidated, then its
895-
releasepage will need to ensure this. Possibly it can clear the
896-
PageUptodate bit if it cannot free private data yet.
890+
and needs to be certain that all folios are invalidated, then
891+
its release_folio will need to ensure this. Possibly it can
892+
clear the uptodate flag if it cannot free private data yet.
897893

898-
``freepage``
899-
freepage is called once the page is no longer visible in the
894+
``free_folio``
895+
free_folio is called once the folio is no longer visible in the
900896
page cache in order to allow the cleanup of any private data.
901897
Since it may be called by the memory reclaimer, it should not
902898
assume that the original address_space mapping still exists, and
@@ -935,14 +931,14 @@ cache in your filesystem. The following members are defined:
935931
without needing I/O to bring the whole page up to date.
936932

937933
``is_dirty_writeback``
938-
Called by the VM when attempting to reclaim a page. The VM uses
934+
Called by the VM when attempting to reclaim a folio. The VM uses
939935
dirty and writeback information to determine if it needs to
940936
stall to allow flushers a chance to complete some IO.
941-
Ordinarily it can use PageDirty and PageWriteback but some
942-
filesystems have more complex state (unstable pages in NFS
937+
Ordinarily it can use folio_test_dirty and folio_test_writeback but
938+
some filesystems have more complex state (unstable folios in NFS
943939
prevent reclaim) or do not set those flags due to locking
944940
problems. This callback allows a filesystem to indicate to the
945-
VM if a page should be treated as dirty or writeback for the
941+
VM if a folio should be treated as dirty or writeback for the
946942
purposes of stalling.
947943

948944
``error_remove_page``

MAINTAINERS

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14878,6 +14878,19 @@ F: Documentation/core-api/padata.rst
1487814878
F: include/linux/padata.h
1487914879
F: kernel/padata.c
1488014880

14881+
PAGE CACHE
14882+
M: Matthew Wilcox (Oracle) <willy@infradead.org>
14883+
L: linux-fsdevel@vger.kernel.org
14884+
S: Supported
14885+
T: git git://git.infradead.org/users/willy/pagecache.git
14886+
F: Documentation/filesystems/locking.rst
14887+
F: Documentation/filesystems/vfs.rst
14888+
F: include/linux/pagemap.h
14889+
F: mm/filemap.c
14890+
F: mm/page-writeback.c
14891+
F: mm/readahead.c
14892+
F: mm/truncate.c
14893+
1488114894
PAGE POOL
1488214895
M: Jesper Dangaard Brouer <hawk@kernel.org>
1488314896
M: Ilias Apalodimas <ilias.apalodimas@linaro.org>

block/fops.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ static int blkdev_writepage(struct page *page, struct writeback_control *wbc)
372372
return block_write_full_page(page, blkdev_get_block, wbc);
373373
}
374374

375-
static int blkdev_readpage(struct file * file, struct page * page)
375+
static int blkdev_read_folio(struct file *file, struct folio *folio)
376376
{
377-
return block_read_full_page(page, blkdev_get_block);
377+
return block_read_full_folio(folio, blkdev_get_block);
378378
}
379379

380380
static void blkdev_readahead(struct readahead_control *rac)
@@ -383,11 +383,9 @@ static void blkdev_readahead(struct readahead_control *rac)
383383
}
384384

385385
static int blkdev_write_begin(struct file *file, struct address_space *mapping,
386-
loff_t pos, unsigned len, unsigned flags, struct page **pagep,
387-
void **fsdata)
386+
loff_t pos, unsigned len, struct page **pagep, void **fsdata)
388387
{
389-
return block_write_begin(mapping, pos, len, flags, pagep,
390-
blkdev_get_block);
388+
return block_write_begin(mapping, pos, len, pagep, blkdev_get_block);
391389
}
392390

393391
static int blkdev_write_end(struct file *file, struct address_space *mapping,
@@ -412,7 +410,7 @@ static int blkdev_writepages(struct address_space *mapping,
412410
const struct address_space_operations def_blk_aops = {
413411
.dirty_folio = block_dirty_folio,
414412
.invalidate_folio = block_invalidate_folio,
415-
.readpage = blkdev_readpage,
413+
.read_folio = blkdev_read_folio,
416414
.readahead = blkdev_readahead,
417415
.writepage = blkdev_writepage,
418416
.write_begin = blkdev_write_begin,

0 commit comments

Comments
 (0)