From: <gregkh@linuxfoundation.org>
To: pc@manguebit.org
Cc: <stable@vger.kernel.org>
Subject: FAILED: patch "[PATCH] smb: client: don't block dying tasks waiting for writeback on" failed to apply to 5.15-stable tree
Date: Wed, 25 Nov 2026 12:10:34 +0100 [thread overview]
Message-ID: <2026112534-exorcism-shirt-2fa2@gregkh> (raw)
The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 15ea186abbcd04157c62e0901701870b812bb2bd
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026112534-exorcism-shirt-2fa2@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 15ea186abbcd04157c62e0901701870b812bb2bd Mon Sep 17 00:00:00 2001
From: Paulo Alcantara <pc@manguebit.org>
Date: Wed, 28 Oct 2026 20:35:11 -0300
Subject: [PATCH] smb: client: don't block dying tasks waiting for writeback on
close
cifs_flush() waits uninterruptibly for the writeback it starts. A task
that gets killed while closing a file on a hard mount with an
unresponsive server is stuck in D state until the server comes back. It
also consumes any writeback error for a caller that is about to exit,
hiding it from everyone else.
Wait killably instead. If the closer gets killed, stop waiting and leave
the error bits in the mapping for others to see; writeback already in
flight completes on its own. Don't wait at all, nor check for errors,
if it is already dying.
This is also needed before letting dying tasks issue their writes from a
worker, which would otherwise make them wait for every one of them.
Fixes: d3f1322af8f8 ("cifs: wait for writeback to complete in cifs_flush")
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index e8557c670dc3..03e179c30d5a 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -3043,17 +3043,44 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
return rc;
}
+static int cifs_wait_writeback_killable(struct address_space *mapping)
+{
+ struct folio_batch fbatch;
+ pgoff_t index = 0;
+ int rc = 0;
+
+ folio_batch_init(&fbatch);
+ while (!rc &&
+ filemap_get_folios_tag(mapping, &index, (pgoff_t)-1,
+ PAGECACHE_TAG_WRITEBACK, &fbatch)) {
+ for (unsigned int i = 0;
+ !rc && i < folio_batch_count(&fbatch); i++)
+ rc = folio_wait_writeback_killable(fbatch.folios[i]);
+ folio_batch_release(&fbatch);
+ cond_resched();
+ }
+ return rc;
+}
+
/*
* As file closes, flush all cached write data for this inode checking
* for write behind errors.
*/
int cifs_flush(struct file *file, fl_owner_t id)
{
+ struct address_space *mapping = file->f_mapping;
struct inode *inode = file_inode(file);
- int rc = 0;
+ int rc = 0, rc2;
- if (file->f_mode & FMODE_WRITE)
- rc = filemap_write_and_wait(inode->i_mapping);
+ if (file->f_mode & FMODE_WRITE) {
+ rc = filemap_fdatawrite(mapping);
+ if (fatal_signal_pending(current) ||
+ cifs_wait_writeback_killable(mapping))
+ return 0;
+ rc2 = filemap_check_errors(mapping);
+ if (!rc)
+ rc = rc2;
+ }
cifs_dbg(FYI, "Flush inode %p file %p rc %d\n", inode, file, rc);
if (rc) {
reply other threads:[~2026-11-25 11:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=2026112534-exorcism-shirt-2fa2@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=pc@manguebit.org \
--cc=stable@vger.kernel.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