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,
	Matthew Wilcox <willy@infradead.org>
Subject: [PATCH v3 13/15] netfs: Fix writeback error handling
Date: Thu, 25 Jun 2026 15:06:31 +0100	[thread overview]
Message-ID: <20260625140640.3116900-14-dhowells@redhat.com> (raw)
In-Reply-To: <20260625140640.3116900-1-dhowells@redhat.com>

Fix the error handling in writeback_iter() loop.  If an error occurs,
writeback_iter() needs to be called again with *error set to the error so
that it can clean up iteration state.  Further, the current folio needs
unlocking and redirtying.

Fixes: 288ace2f57c9 ("netfs: New writeback implementation")
Link: https://sashiko.dev/#/patchset/20260619140646.2633762-1-dhowells%40redhat.com
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Paulo Alcantara <pc@manguebit.org>
cc: Matthew Wilcox <willy@infradead.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
---
 fs/netfs/write_issue.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c
index 3b363ce12f3f..3682896c3fdf 100644
--- a/fs/netfs/write_issue.c
+++ b/fs/netfs/write_issue.c
@@ -582,8 +582,6 @@ int netfs_writepages(struct address_space *mapping,
 		}
 
 		error = netfs_write_folio(wreq, wbc, folio);
-		if (error < 0)
-			break;
 	} while ((folio = writeback_iter(mapping, wbc, folio, &error)));
 
 	netfs_end_issue_write(wreq);
@@ -594,7 +592,14 @@ int netfs_writepages(struct address_space *mapping,
 	return error;
 
 couldnt_start:
-	netfs_kill_dirty_pages(mapping, wbc, folio);
+	if (error == -ENOMEM) {
+		folio_redirty_for_writepage(wbc, folio);
+		folio_unlock(folio);
+		folio = writeback_iter(mapping, wbc, folio, &error);
+		WARN_ON_ONCE(folio != NULL);
+	} else {
+		netfs_kill_dirty_pages(mapping, wbc, folio);
+	}
 out:
 	netfs_wb_end(ictx);
 	_leave(" = %d", error);


  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 ` David Howells [this message]
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 ` [PATCH v3 15/15] netfs: Fix DIO write retry for filesystems without a ->prepare_write() David Howells

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-14-dhowells@redhat.com \
    --to=dhowells@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=christian@brauner.io \
    --cc=hch@infradead.org \
    --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=willy@infradead.org \
    /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