Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Christian Brauner <christian@brauner.io>
Cc: David Howells <dhowells@redhat.com>,
	Paulo Alcantara <pc@manguebit.org>,
	Christoph Hellwig <hch@infradead.org>,
	netfs@lists.linux.dev, linux-afs@lists.infradead.org,
	linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+3c74b1f0c372e98efc32@syzkaller.appspotmail.com,
	hongao <hongao@uniontech.com>,
	ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Subject: [PATCH v3 15/15] netfs: Fix DIO write retry for filesystems without a ->prepare_write()
Date: Thu, 25 Jun 2026 15:06:33 +0100	[thread overview]
Message-ID: <20260625140640.3116900-16-dhowells@redhat.com> (raw)
In-Reply-To: <20260625140640.3116900-1-dhowells@redhat.com>

Fix netfs_unbuffered_write() so that it doesn't re-issue a write twice when
the filesystem doesn't have a ->prepare_write().  The resetting of the
iterator and the call to netfs_reissue_write() should just be removed as
almost everything it does is done again when the loop it's in goes back to
the top.

It does, however, still need the IN_PROGRESS flag setting, so that (and the
stat inc) are moved out of the if-statement.

Further, the MADE_PROGRESS flags should be cleared and wreq->transferred
should be updated, so fix those too.

Reported-by: syzbot+3c74b1f0c372e98efc32@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3c74b1f0c372e98efc32
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Paulo Alcantara <pc@manguebit.org>
cc: hongao <hongao@uniontech.com>
cc: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
---
 fs/netfs/direct_write.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c
index 25f8ceb15fad..c16fbad286a1 100644
--- a/fs/netfs/direct_write.c
+++ b/fs/netfs/direct_write.c
@@ -166,13 +166,16 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq)
 		 */
 		subreq->error = -EAGAIN;
 		trace_netfs_sreq(subreq, netfs_sreq_trace_retry);
-		if (subreq->transferred > 0)
+		if (subreq->transferred > 0) {
 			iov_iter_advance(&wreq->buffer.iter, subreq->transferred);
+			wreq->transferred += subreq->transferred;
+		}
 
 		if (stream->source == NETFS_UPLOAD_TO_SERVER &&
 		    wreq->netfs_ops->retry_request)
 			wreq->netfs_ops->retry_request(wreq, stream);
 
+		__clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags);
 		__clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags);
 		__clear_bit(NETFS_SREQ_BOUNDARY, &subreq->flags);
 		__clear_bit(NETFS_SREQ_FAILED, &subreq->flags);
@@ -186,17 +189,10 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq)
 
 		netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit);
 
-		if (stream->prepare_write) {
+		if (stream->prepare_write)
 			stream->prepare_write(subreq);
-			__set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags);
-			netfs_stat(&netfs_n_wh_retry_write_subreq);
-		} else {
-			struct iov_iter source;
-
-			netfs_reset_iter(subreq);
-			source = subreq->io_iter;
-			netfs_reissue_write(stream, subreq, &source);
-		}
+		__set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags);
+		netfs_stat(&netfs_n_wh_retry_write_subreq);
 	}
 
 	netfs_unbuffered_write_done(wreq);


      parent reply	other threads:[~2026-06-25 14:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-25 14:06 [PATCH v3 00/15] netfs: Miscellaneous fixes David Howells
2026-06-25 14:06 ` [PATCH v3 01/15] netfs: Fix decision whether to disallow write-streaming due to fscache use David Howells
2026-06-25 14:06 ` [PATCH v3 02/15] netfs: Fix netfs_create_write_req() to handle async cache object creation David Howells
2026-06-25 14:06 ` [PATCH v3 03/15] cachefiles: Fix double fput David Howells
2026-06-25 14:06 ` [PATCH v3 04/15] cachefiles: Fix file burial to take lock when unsetting S_KERNEL_FILE David Howells
2026-06-26  3:17   ` NeilBrown
2026-06-25 14:06 ` [PATCH v3 05/15] iov_iter: Fix potential underflow in iov_iter_extract_xarray_pages() David Howells
2026-06-26  5:49   ` Christoph Hellwig
2026-06-25 14:06 ` [PATCH v3 06/15] iov_iter: Fix missing alloc fail check in iov_iter_extract_bvec_pages() David Howells
2026-06-26  5:50   ` Christoph Hellwig
2026-06-25 14:06 ` [PATCH v3 07/15] iov_iter: Fix a memory leak in iov_iter_extract_user_pages() David Howells
2026-06-26  5:50   ` Christoph Hellwig
2026-06-25 14:06 ` [PATCH v3 08/15] iov_iter: Remove unused variable in kunit_iov_iter.c David Howells
2026-06-26  5:51   ` Christoph Hellwig
2026-06-25 14:06 ` [PATCH v3 09/15] scatterlist: Fix offset in folio calc in extract_xarray_to_sg() David Howells
2026-06-26  5:51   ` Christoph Hellwig
2026-06-25 14:06 ` [PATCH v3 10/15] netfs: Fix kdoc warning David Howells
2026-06-25 14:06 ` [PATCH v3 11/15] netfs: Replace wb_lock with a bit lock for asynchronicity David Howells
2026-06-25 14:06 ` [PATCH v3 12/15] netfs: Fix writethrough to use collection offload David Howells
2026-06-25 14:06 ` [PATCH v3 13/15] netfs: Fix writeback error handling David Howells
2026-06-25 14:06 ` [PATCH v3 14/15] netfs: Fix folio state after ENOMEM whilst under writeback iteration David Howells
2026-06-25 14:06 ` David Howells [this message]

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=20260625140640.3116900-16-dhowells@redhat.com \
    --to=dhowells@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=christian@brauner.io \
    --cc=hch@infradead.org \
    --cc=hongao@uniontech.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netfs@lists.linux.dev \
    --cc=pc@manguebit.org \
    --cc=syzbot+3c74b1f0c372e98efc32@syzkaller.appspotmail.com \
    /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