From: sashiko-bot@kernel.org
To: "David Howells" <dhowells@redhat.com>
Cc: v9fs@lists.linux.dev, "Chuck Lever" <cel@kernel.org>,
"Jeff Layton" <jlayton@kernel.org>,
"Anna Schumaker" <anna@kernel.org>
Subject: Re: [PATCH v18 09/17] netfs: Change netfs_writeback_single() to not look inside the iterator
Date: Tue, 17 Nov 2026 17:53:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-219291@kernel.org> (raw)
In-Reply-To: <20261117171958.2982801-10-dhowells@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] netfs: netfs_write_collection() wakes waiter before
netfs_wb_end()
--
commit 90dc9674df74e46678b038bf8aa77c3be41e113a
Author: David Howells <dhowells@redhat.com>
netfs: Change netfs_writeback_single() to not look inside the iterator
This commit changes netfs_writeback_single() to pass the data buffer
iterator directly to the cache as a single write subrequest and wait for
the write to complete before returning.
> diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c
> index 63b0e2599c3c6..0fcfb5ab49bdd 100644
> --- a/fs/netfs/write_issue.c
> +++ b/fs/netfs/write_issue.c
[ ... ]
> @@ -789,36 +667,42 @@ int netfs_writeback_single(struct address_space *mapping,
> goto couldnt_start;
> }
>
> + wreq->buffer.iter = *iter;
> + wreq->len = len;
> + wreq->submitted = wreq->len;
> +
> __set_bit(NETFS_RREQ_OFFLOAD_COLLECTION, &wreq->flags);
> trace_netfs_write(wreq, netfs_write_trace_writeback_single);
> netfs_stat(&netfs_n_wh_writepages);
>
> - if (__test_and_set_bit(NETFS_RREQ_UPLOAD_TO_SERVER, &wreq->flags))
> - wreq->netfs_ops->begin_writeback(wreq);
> + for (int s = 0; s < NR_IO_STREAMS; s++) {
> + struct netfs_io_subrequest *subreq;
> + struct netfs_io_stream *stream = &wreq->io_streams[s];
> +
> + if (!stream->avail)
> + continue;
>
> - for (fq = (struct folio_queue *)iter->folioq; fq; fq = fq->next) {
> - for (int slot = 0; slot < folioq_count(fq); slot++) {
> - struct folio *folio = folioq_folio(fq, slot);
> - size_t part = umin(folioq_folio_size(fq, slot), size);
> + netfs_prepare_write(wreq, stream, 0);
> + /* Allocation not allowed to fail in writeback. */
>
> - _debug("wbiter %lx %llx", folio->index, atomic64_read(&wreq->issued_to));
> + subreq = stream->construct;
> + subreq->len = wreq->len;
> + stream->submit_len = subreq->len;
> + stream->submit_extendable_to = iov_iter_count(iter) - len;
>
> - ret = netfs_write_folio_single(wreq, folio);
> - if (ret < 0)
> - goto stop;
> - size -= part;
> - if (size <= 0)
> - goto stop;
> - }
> + netfs_issue_write(wreq, stream);
> }
>
> -stop:
> - for (int s = 0; s < NR_IO_STREAMS; s++)
> - netfs_issue_write(wreq, &wreq->io_streams[s]);
> netfs_all_subreqs_queued(wreq);
> -
> netfs_wake_collector(wreq);
>
> + /* TODO: Might want to be async here if WB_SYNC_NONE, but then need to
> + * wait before modifying.
> + */
> + ret = netfs_wait_for_write(wreq);
> + if (ret > 0)
> + ret = 0;
[Severity: Medium]
Can netfs_writeback_single() return to its caller before the collector
worker releases NETFS_ICTX_WB_LOCK?
Because NETFS_RREQ_OFFLOAD_COLLECTION is set, netfs_wait_for_write()
sleeps on wreq->waitq while the collector runs on system_dfl_wq, and
netfs_write_collection() wakes NETFS_RREQ_IN_PROGRESS before calling
netfs_wb_end():
fs/netfs/write_collect.c:netfs_write_collection() {
...
netfs_wake_rreq_flag(wreq, NETFS_RREQ_IN_PROGRESS, netfs_rreq_trace_wake_ip);
/* As we cleared NETFS_RREQ_IN_PROGRESS, we acquired its ref. */
switch (wreq->origin) {
case NETFS_WRITEBACK:
case NETFS_WRITEBACK_SINGLE:
netfs_wb_end(ictx);
break;
...
}
CPU0 kworker
netfs_writeback_single()
netfs_wb_begin(ictx, ...)
...
netfs_wake_collector(wreq)
netfs_wait_for_write(wreq)
netfs_write_collection()
netfs_wake_rreq_flag(wreq,
NETFS_RREQ_IN_PROGRESS, ...)
return 0;
/* next WB_SYNC_NONE writeback */
netfs_wb_begin(ictx, true)
--> false (NETFS_ICTX_WB_LOCK still held)
netfs_wb_end(ictx)
An immediate subsequent WB_SYNC_NONE writeback on the same inode (such as
a second afs_dir_writepages() pass after dropping validate_lock) can see
NETFS_ICTX_WB_LOCK still set, re-dirty the inode, and abort writeback.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117171958.2982801-1-dhowells@redhat.com?part=9
next prev parent reply other threads:[~2026-11-17 17:53 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 17:18 [PATCH v18 00/17] netfs, iov_iter: Use a chain of bio_vec arrays instead of folio_queue David Howells
2026-11-17 17:18 ` [PATCH v18 01/17] iov_iter: Fix kunit test to remove __init and __refdata marks David Howells
2026-11-17 17:34 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 02/17] Add a function to kmap one page of a multipage bio_vec David Howells
2026-11-17 17:28 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 03/17] iov_iter: Add a segmented queue of bio_vec[] David Howells
2026-11-17 17:56 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 04/17] netfs: Add some tools for managing bvecq chains David Howells
2026-11-17 17:51 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 05/17] iov_iter: Add an API document for the bvecq structure David Howells
2026-11-17 17:32 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 06/17] iov_iter: Add a bvecq kunit test David Howells
2026-11-17 17:30 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 07/17] afs: Fix an inconsistency in the symlink code David Howells
2026-11-17 17:38 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 08/17] netfs: Explicitly pass tail padding to netfs_writeback_single() David Howells
2026-11-17 17:58 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 09/17] netfs: Change netfs_writeback_single() to not look inside the iterator David Howells
2026-11-17 17:53 ` sashiko-bot [this message]
2026-11-17 17:19 ` [PATCH v18 10/17] netfs: Pass the write length to request creation where appropriate David Howells
2026-11-17 17:28 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 11/17] afs: Use a bvecq to hold dir content rather than folioq David Howells
2026-11-17 18:05 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 12/17] cifs: Use a bvecq for buffering instead of a folioq David Howells
2026-11-17 17:45 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 13/17] smbdirect: Support ITER_BVECQ in smbdirect_map_sges_from_iter() David Howells
2026-11-17 17:36 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 14/17] netfs: Switch folioq to bvecq David Howells
2026-11-17 18:19 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 15/17] smbdirect: Remove support for ITER_FOLIOQ from smbdirect_map_sges_from_iter() David Howells
2026-11-17 17:35 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 16/17] iov_iter: Remove ITER_FOLIOQ David Howells
2026-11-17 17:41 ` sashiko-bot
2026-11-17 17:19 ` [PATCH v18 17/17] netfs: Remove folio_queue David Howells
2026-11-17 17:37 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-219291@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=anna@kernel.org \
--cc=cel@kernel.org \
--cc=dhowells@redhat.com \
--cc=jlayton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=v9fs@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox