From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388279; b=ogyKZ6f4OJY8cuw1cko08ewZeC4ka2A++UAu+bAs6RsMg/sPGtoywC41SNpZomJppbrd vTlreGKCZ0Wll/tICZsY4kD5QofHtZeXjm/1VMIGPYC++7Rx5vlHWZMb9cs92tp7w8D6w 90eexKlZY3gXGmhG3Anr36fVLxR+Qhyd/rBW4NBCfSN2vT01zNrqS5ZOy7aXVNrJ5RPlC sIr30K53WPiAmjZ8N4fnbLcnXu6F7u0ma+oPtwooK3qVxRx2j0FZ8xF9xpRI73sB4QeYj DXd2GSmuB/izUkOxnCD8vGL8RVu60HJa+sxV4Eoe94wkTJO7OEIyBSoW1c9RhhZUxow== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388279; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=hWSA7hZI6M3tJCx0Yoa0qUJugkAwmp14LI110a7pKrs=; b=s5hppydp+o9fHbgqJHqYhN3ise+NRcSDQdEAlQd238+1LWXfqcPH+230XOekFyyVcgab tDQ9xPl6jYqs1g0zuSv3MPQNnaCepim8wT+j/sxcymFsnntVByigc/dsAItg/7s4212f9 vemNHQQHFBsKXCPkfJKlVcrW5aLHTUAoPNf6aXhyAhXx0L9IcehCrmkH8274BAkCVH8hX 0W1H2GAcUjTJxa9J9Hp5/9FS6iaAb88Yc3du5bA7afr6F849H1d4FH3saUHGhPDkIsEPs 9KVslMl9r4Mx+wgGtkcqz/Ha37InQk6KnEU0JSnf9UOKLntN6rpByc+lVe2W5vr5dhA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=vGLPt9nO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9609F606A32D; Fri, 4 Dec 2026 12:44:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=vGLPt9nO Received: by smtp.kernel.org (Postfix) with ESMTPSA id C92F41F00897; Fri, 4 Dec 2026 12:44:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388279; bh=hWSA7hZI6M3tJCx0Yoa0qUJugkAwmp14LI110a7pKrs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vGLPt9nO2K48aRcy9jzisVyt1unpi6wn0PwVBk7JTnka/PZ0Z5xnbNgovd9psLs2+ JVgredmBjxeLotXDCLI5fpYQpYzoURcDHimfJK3zQLVZN0vB8ej5No8UB87ETa/CFC fLRD76i8hNj6iXDPAsK9KV+D13TonyLkZTlAGnBE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Paulo Alcantara Subject: [PATCH 6.1 0555/1059] smb: client: dont block dying tasks waiting for writeback on close Date: Fri, 4 Dec 2026 19:01:26 +0900 Message-ID: <20261204100658.563325621@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paulo Alcantara commit 15ea186abbcd04157c62e0901701870b812bb2bd upstream. 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 Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/file.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -3148,17 +3148,44 @@ fsync_exit: 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) {