* [PATCH 0/3] Random netfs folio fixes
@ 2024-10-05 18:23 Matthew Wilcox (Oracle)
2024-10-05 18:23 ` [PATCH 1/3] netfs: Remove call to folio_index() Matthew Wilcox (Oracle)
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-05 18:23 UTC (permalink / raw)
To: David Howells; +Cc: Matthew Wilcox (Oracle), netfs, linux-fsdevel
A few minor fixes; nothing earth-shattering.
Matthew Wilcox (Oracle) (3):
netfs: Remove call to folio_index()
netfs: Fix a few minor bugs in netfs_page_mkwrite()
netfs: Remove unnecessary references to pages
fs/netfs/buffered_read.c | 8 +++----
fs/netfs/buffered_write.c | 41 ++++++++++++++++++------------------
include/trace/events/netfs.h | 2 +-
3 files changed, 25 insertions(+), 26 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] netfs: Remove call to folio_index()
2024-10-05 18:23 [PATCH 0/3] Random netfs folio fixes Matthew Wilcox (Oracle)
@ 2024-10-05 18:23 ` Matthew Wilcox (Oracle)
2024-10-05 18:23 ` [PATCH 2/3] netfs: Fix a few minor bugs in netfs_page_mkwrite() Matthew Wilcox (Oracle)
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-05 18:23 UTC (permalink / raw)
To: David Howells; +Cc: Matthew Wilcox (Oracle), netfs, linux-fsdevel
Calling folio_index() is pointless overhead; directly dereferencing
folio->index is fine.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/trace/events/netfs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/trace/events/netfs.h b/include/trace/events/netfs.h
index 1d7c52821e55..72a208fd4496 100644
--- a/include/trace/events/netfs.h
+++ b/include/trace/events/netfs.h
@@ -451,7 +451,7 @@ TRACE_EVENT(netfs_folio,
struct address_space *__m = READ_ONCE(folio->mapping);
__entry->ino = __m ? __m->host->i_ino : 0;
__entry->why = why;
- __entry->index = folio_index(folio);
+ __entry->index = folio->index;
__entry->nr = folio_nr_pages(folio);
),
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] netfs: Fix a few minor bugs in netfs_page_mkwrite()
2024-10-05 18:23 [PATCH 0/3] Random netfs folio fixes Matthew Wilcox (Oracle)
2024-10-05 18:23 ` [PATCH 1/3] netfs: Remove call to folio_index() Matthew Wilcox (Oracle)
@ 2024-10-05 18:23 ` Matthew Wilcox (Oracle)
2024-10-05 18:23 ` [PATCH 3/3] netfs: Remove unnecessary references to pages Matthew Wilcox (Oracle)
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-05 18:23 UTC (permalink / raw)
To: David Howells; +Cc: Matthew Wilcox (Oracle), netfs, linux-fsdevel
We can't return with VM_FAULT_SIGBUS | VM_FAULT_LOCKED; the core
code will not unlock the folio in this instance. Introduce a new
"unlock" error exit to handle this case. Use it to handle
the "folio is truncated" check, and change the "writeback interrupted
by a fatal signal" to do a NOPAGE exit instead of letting the core
code install the folio currently under writeback before killing the
process.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/netfs/buffered_write.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c
index b3910dfcb56d..ff2814da88b1 100644
--- a/fs/netfs/buffered_write.c
+++ b/fs/netfs/buffered_write.c
@@ -491,7 +491,9 @@ EXPORT_SYMBOL(netfs_file_write_iter);
/*
* Notification that a previously read-only page is about to become writable.
- * Note that the caller indicates a single page of a multipage folio.
+ * The caller indicates the precise page that needs to be written to, but
+ * we only track group on a per-folio basis, so we block more often than
+ * we might otherwise.
*/
vm_fault_t netfs_page_mkwrite(struct vm_fault *vmf, struct netfs_group *netfs_group)
{
@@ -501,7 +503,7 @@ vm_fault_t netfs_page_mkwrite(struct vm_fault *vmf, struct netfs_group *netfs_gr
struct address_space *mapping = file->f_mapping;
struct inode *inode = file_inode(file);
struct netfs_inode *ictx = netfs_inode(inode);
- vm_fault_t ret = VM_FAULT_RETRY;
+ vm_fault_t ret = VM_FAULT_NOPAGE;
int err;
_enter("%lx", folio->index);
@@ -510,21 +512,15 @@ vm_fault_t netfs_page_mkwrite(struct vm_fault *vmf, struct netfs_group *netfs_gr
if (folio_lock_killable(folio) < 0)
goto out;
- if (folio->mapping != mapping) {
- folio_unlock(folio);
- ret = VM_FAULT_NOPAGE;
- goto out;
- }
-
- if (folio_wait_writeback_killable(folio)) {
- ret = VM_FAULT_LOCKED;
- goto out;
- }
+ if (folio->mapping != mapping)
+ goto unlock;
+ if (folio_wait_writeback_killable(folio) < 0)
+ goto unlock;
/* Can we see a streaming write here? */
if (WARN_ON(!folio_test_uptodate(folio))) {
- ret = VM_FAULT_SIGBUS | VM_FAULT_LOCKED;
- goto out;
+ ret = VM_FAULT_SIGBUS;
+ goto unlock;
}
group = netfs_folio_group(folio);
@@ -559,5 +555,8 @@ vm_fault_t netfs_page_mkwrite(struct vm_fault *vmf, struct netfs_group *netfs_gr
out:
sb_end_pagefault(inode->i_sb);
return ret;
+unlock:
+ folio_unlock(folio);
+ goto out;
}
EXPORT_SYMBOL(netfs_page_mkwrite);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] netfs: Remove unnecessary references to pages
2024-10-05 18:23 [PATCH 0/3] Random netfs folio fixes Matthew Wilcox (Oracle)
2024-10-05 18:23 ` [PATCH 1/3] netfs: Remove call to folio_index() Matthew Wilcox (Oracle)
2024-10-05 18:23 ` [PATCH 2/3] netfs: Fix a few minor bugs in netfs_page_mkwrite() Matthew Wilcox (Oracle)
@ 2024-10-05 18:23 ` Matthew Wilcox (Oracle)
2024-10-07 11:46 ` [PATCH 0/3] Random netfs folio fixes Christian Brauner
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-05 18:23 UTC (permalink / raw)
To: David Howells; +Cc: Matthew Wilcox (Oracle), netfs, linux-fsdevel
These places should all use folios instead of pages.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/netfs/buffered_read.c | 8 ++++----
fs/netfs/buffered_write.c | 14 +++++++-------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c
index c40e226053cc..17aaec00002b 100644
--- a/fs/netfs/buffered_read.c
+++ b/fs/netfs/buffered_read.c
@@ -646,7 +646,7 @@ static bool netfs_skip_folio_read(struct folio *folio, loff_t pos, size_t len,
if (unlikely(always_fill)) {
if (pos - offset + len <= i_size)
return false; /* Page entirely before EOF */
- zero_user_segment(&folio->page, 0, plen);
+ folio_zero_segment(folio, 0, plen);
folio_mark_uptodate(folio);
return true;
}
@@ -665,7 +665,7 @@ static bool netfs_skip_folio_read(struct folio *folio, loff_t pos, size_t len,
return false;
zero_out:
- zero_user_segments(&folio->page, 0, offset, offset + len, plen);
+ folio_zero_segments(folio, 0, offset, offset + len, plen);
return true;
}
@@ -732,7 +732,7 @@ int netfs_write_begin(struct netfs_inode *ctx,
if (folio_test_uptodate(folio))
goto have_folio;
- /* If the page is beyond the EOF, we want to clear it - unless it's
+ /* If the folio is beyond the EOF, we want to clear it - unless it's
* within the cache granule containing the EOF, in which case we need
* to preload the granule.
*/
@@ -792,7 +792,7 @@ int netfs_write_begin(struct netfs_inode *ctx,
EXPORT_SYMBOL(netfs_write_begin);
/*
- * Preload the data into a page we're proposing to write into.
+ * Preload the data into a folio we're proposing to write into.
*/
int netfs_prefetch_for_write(struct file *file, struct folio *folio,
size_t offset, size_t len)
diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c
index ff2814da88b1..b4826360a411 100644
--- a/fs/netfs/buffered_write.c
+++ b/fs/netfs/buffered_write.c
@@ -83,13 +83,13 @@ static void netfs_update_i_size(struct netfs_inode *ctx, struct inode *inode,
* netfs_perform_write - Copy data into the pagecache.
* @iocb: The operation parameters
* @iter: The source buffer
- * @netfs_group: Grouping for dirty pages (eg. ceph snaps).
+ * @netfs_group: Grouping for dirty folios (eg. ceph snaps).
*
- * Copy data into pagecache pages attached to the inode specified by @iocb.
+ * Copy data into pagecache folios attached to the inode specified by @iocb.
* The caller must hold appropriate inode locks.
*
- * Dirty pages are tagged with a netfs_folio struct if they're not up to date
- * to indicate the range modified. Dirty pages may also be tagged with a
+ * Dirty folios are tagged with a netfs_folio struct if they're not up to date
+ * to indicate the range modified. Dirty folios may also be tagged with a
* netfs-specific grouping such that data from an old group gets flushed before
* a new one is started.
*/
@@ -223,11 +223,11 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
* we try to read it.
*/
if (fpos >= ctx->zero_point) {
- zero_user_segment(&folio->page, 0, offset);
+ folio_zero_segment(folio, 0, offset);
copied = copy_folio_from_iter_atomic(folio, offset, part, iter);
if (unlikely(copied == 0))
goto copy_failed;
- zero_user_segment(&folio->page, offset + copied, flen);
+ folio_zero_segment(folio, offset + copied, flen);
__netfs_set_group(folio, netfs_group);
folio_mark_uptodate(folio);
trace_netfs_folio(folio, netfs_modify_and_clear);
@@ -407,7 +407,7 @@ EXPORT_SYMBOL(netfs_perform_write);
* netfs_buffered_write_iter_locked - write data to a file
* @iocb: IO state structure (file, offset, etc.)
* @from: iov_iter with data to write
- * @netfs_group: Grouping for dirty pages (eg. ceph snaps).
+ * @netfs_group: Grouping for dirty folios (eg. ceph snaps).
*
* This function does all the work needed for actually writing data to a
* file. It does all basic checks, removes SUID from the file, updates
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] Random netfs folio fixes
2024-10-05 18:23 [PATCH 0/3] Random netfs folio fixes Matthew Wilcox (Oracle)
` (2 preceding siblings ...)
2024-10-05 18:23 ` [PATCH 3/3] netfs: Remove unnecessary references to pages Matthew Wilcox (Oracle)
@ 2024-10-07 11:46 ` Christian Brauner
2024-10-07 14:13 ` [PATCH 1/3] netfs: Remove call to folio_index() David Howells
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Christian Brauner @ 2024-10-07 11:46 UTC (permalink / raw)
To: David Howells, Matthew Wilcox (Oracle)
Cc: Christian Brauner, netfs, linux-fsdevel
On Sat, 05 Oct 2024 19:23:02 +0100, Matthew Wilcox (Oracle) wrote:
> A few minor fixes; nothing earth-shattering.
>
> Matthew Wilcox (Oracle) (3):
> netfs: Remove call to folio_index()
> netfs: Fix a few minor bugs in netfs_page_mkwrite()
> netfs: Remove unnecessary references to pages
>
> [...]
Applied to the vfs.netfs branch of the vfs/vfs.git tree.
Patches in the vfs.netfs branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.netfs
[1/3] netfs: Remove call to folio_index()
https://git.kernel.org/vfs/vfs/c/fcd4904e2f69
[2/3] netfs: Fix a few minor bugs in netfs_page_mkwrite()
https://git.kernel.org/vfs/vfs/c/c6a90fe7f080
[3/3] netfs: Remove unnecessary references to pages
https://git.kernel.org/vfs/vfs/c/e995e8b60026
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] netfs: Remove call to folio_index()
2024-10-05 18:23 [PATCH 0/3] Random netfs folio fixes Matthew Wilcox (Oracle)
` (3 preceding siblings ...)
2024-10-07 11:46 ` [PATCH 0/3] Random netfs folio fixes Christian Brauner
@ 2024-10-07 14:13 ` David Howells
2024-10-07 14:14 ` [PATCH 2/3] netfs: Fix a few minor bugs in netfs_page_mkwrite() David Howells
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2024-10-07 14:13 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: dhowells, netfs, linux-fsdevel
Matthew Wilcox (Oracle) <willy@infradead.org> wrote:
> Calling folio_index() is pointless overhead; directly dereferencing
> folio->index is fine.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Fixes: c38f4e96e605 ("netfs: Provide func to copy data to pagecache for buffered write")
Acked-by: David Howells <dhowells@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] netfs: Fix a few minor bugs in netfs_page_mkwrite()
2024-10-05 18:23 [PATCH 0/3] Random netfs folio fixes Matthew Wilcox (Oracle)
` (4 preceding siblings ...)
2024-10-07 14:13 ` [PATCH 1/3] netfs: Remove call to folio_index() David Howells
@ 2024-10-07 14:14 ` David Howells
2024-10-07 14:14 ` [PATCH 3/3] netfs: Remove unnecessary references to pages David Howells
2024-10-07 14:15 ` [PATCH 0/3] Random netfs folio fixes David Howells
7 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2024-10-07 14:14 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: dhowells, netfs, linux-fsdevel
Matthew Wilcox (Oracle) <willy@infradead.org> wrote:
> We can't return with VM_FAULT_SIGBUS | VM_FAULT_LOCKED; the core
> code will not unlock the folio in this instance. Introduce a new
> "unlock" error exit to handle this case. Use it to handle
> the "folio is truncated" check, and change the "writeback interrupted
> by a fatal signal" to do a NOPAGE exit instead of letting the core
> code install the folio currently under writeback before killing the
> process.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Fixes: 102a7e2c598c ("netfs: Allow buffered shared-writeable mmap through netfs_page_mkwrite()")
Acked-by: David Howells <dhowells@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] netfs: Remove unnecessary references to pages
2024-10-05 18:23 [PATCH 0/3] Random netfs folio fixes Matthew Wilcox (Oracle)
` (5 preceding siblings ...)
2024-10-07 14:14 ` [PATCH 2/3] netfs: Fix a few minor bugs in netfs_page_mkwrite() David Howells
@ 2024-10-07 14:14 ` David Howells
2024-10-07 14:15 ` [PATCH 0/3] Random netfs folio fixes David Howells
7 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2024-10-07 14:14 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: dhowells, netfs, linux-fsdevel
Matthew Wilcox (Oracle) <willy@infradead.org> wrote:
> These places should all use folios instead of pages.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: David Howells <dhowells@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] Random netfs folio fixes
2024-10-05 18:23 [PATCH 0/3] Random netfs folio fixes Matthew Wilcox (Oracle)
` (6 preceding siblings ...)
2024-10-07 14:14 ` [PATCH 3/3] netfs: Remove unnecessary references to pages David Howells
@ 2024-10-07 14:15 ` David Howells
7 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2024-10-07 14:15 UTC (permalink / raw)
To: Christian Brauner; +Cc: dhowells, Matthew Wilcox (Oracle), netfs, linux-fsdevel
Hi Christian,
Could you add these patches to vfs.fixes?
Thanks,
David
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-10-07 14:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-05 18:23 [PATCH 0/3] Random netfs folio fixes Matthew Wilcox (Oracle)
2024-10-05 18:23 ` [PATCH 1/3] netfs: Remove call to folio_index() Matthew Wilcox (Oracle)
2024-10-05 18:23 ` [PATCH 2/3] netfs: Fix a few minor bugs in netfs_page_mkwrite() Matthew Wilcox (Oracle)
2024-10-05 18:23 ` [PATCH 3/3] netfs: Remove unnecessary references to pages Matthew Wilcox (Oracle)
2024-10-07 11:46 ` [PATCH 0/3] Random netfs folio fixes Christian Brauner
2024-10-07 14:13 ` [PATCH 1/3] netfs: Remove call to folio_index() David Howells
2024-10-07 14:14 ` [PATCH 2/3] netfs: Fix a few minor bugs in netfs_page_mkwrite() David Howells
2024-10-07 14:14 ` [PATCH 3/3] netfs: Remove unnecessary references to pages David Howells
2024-10-07 14:15 ` [PATCH 0/3] Random netfs folio fixes David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).