* FAILED: patch "[PATCH] smb: client: don't write back through O_DIRECT handles" failed to apply to 6.12-stable tree
@ 2026-11-25 11:14 gregkh
2026-11-26 4:34 ` [PATCH 6.12.y] smb: client: don't write back through O_DIRECT handles Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2026-11-25 11:14 UTC (permalink / raw)
To: pc, dhowells; +Cc: stable
The patch below does not apply to the 6.12-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-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 0e85145af984f7cae2aadaa694cb8612009027ac
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026112512-blazer-polish-8b61@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0e85145af984f7cae2aadaa694cb8612009027ac Mon Sep 17 00:00:00 2001
From: Paulo Alcantara <pc@manguebit.org>
Date: Sun, 1 Nov 2026 13:02:11 -0300
Subject: [PATCH] smb: client: don't write back through O_DIRECT handles
Writeback uses the first writable handle of the inode, which may have
been opened with O_DIRECT. Such handles are opened with
FILE_NO_INTERMEDIATE_BUFFERING, for which Windows rejects any unaligned
I/O with STATUS_INVALID_PARAMETER. Writeback of partly dirty pages and
of the unaligned tail of a file through one of them fails, so netfs ends
it with the folios clean and the data never reaches the server.
xfstests generic/051, where fsstress mixes both kinds of opens, loses
about 1% of its writes this way:
smb3_write_err: ... offset=0xde90d7 len=0xbd0b rc=-22
All the rejected writes in a network capture were unaligned writes on a
no-buffering handle; none of the aligned ones, and none of the unaligned
ones on regular handles, were.
Prefer a handle that was not opened with O_DIRECT, and use one that was
only if there is no other.
Fixes: 1013e760d10e ("SMB3: Don't ignore O_SYNC/O_DSYNC and O_DIRECT flags")
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index d3ca688b6aba..dbf980fcf05b 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1891,6 +1891,7 @@ enum cifs_find_flags {
FIND_WITH_DELETE = (1U << 1),
FIND_NO_PENDING_DELETE = (1U << 2),
FIND_OPEN_FLAGS = (1U << 3),
+ FIND_NO_DIRECT = (1U << 4),
};
#define MID_FREE 0
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 0767eb5f4687..aa2d09dac44c 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -255,9 +255,15 @@ static void cifs_begin_writeback(struct netfs_io_request *wreq)
struct cifs_io_request *req = container_of(wreq, struct cifs_io_request, rreq);
int ret;
- ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_ANY, &req->cfile);
+ ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_NO_DIRECT,
+ &req->cfile);
if (ret) {
- cifs_dbg(VFS, "No writable handle in writepages ret=%d\n", ret);
+ ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_ANY,
+ &req->cfile);
+ }
+ if (ret) {
+ cifs_dbg(VFS, "%s: couldn't find writable handle: %d\n",
+ __func__, ret);
return;
}
@@ -2722,7 +2728,7 @@ int __cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
}
if (test_bit(CIFS_INO_TMPFILE, &cifs_inode->flags))
- find_flags = FIND_ANY;
+ find_flags &= FIND_NO_DIRECT;
cifs_sb = CIFS_SB(cifs_inode);
@@ -2752,6 +2758,9 @@ int __cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
!open_flags_match(cifs_inode, open_flags,
open_file->f_flags))
continue;
+ if ((find_flags & FIND_NO_DIRECT) &&
+ (open_file->f_flags & O_DIRECT))
+ continue;
if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) {
if (!open_file->invalidHandle) {
/* found a good writable file */
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 6.12.y] smb: client: don't write back through O_DIRECT handles
2026-11-25 11:14 FAILED: patch "[PATCH] smb: client: don't write back through O_DIRECT handles" failed to apply to 6.12-stable tree gregkh
@ 2026-11-26 4:34 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-11-26 4:34 UTC (permalink / raw)
To: stable; +Cc: Paulo Alcantara, David Howells, Sasha Levin
From: Paulo Alcantara <pc@manguebit.org>
[ Upstream commit 0e85145af984f7cae2aadaa694cb8612009027ac ]
Writeback uses the first writable handle of the inode, which may have
been opened with O_DIRECT. Such handles are opened with
FILE_NO_INTERMEDIATE_BUFFERING, for which Windows rejects any unaligned
I/O with STATUS_INVALID_PARAMETER. Writeback of partly dirty pages and
of the unaligned tail of a file through one of them fails, so netfs ends
it with the folios clean and the data never reaches the server.
xfstests generic/051, where fsstress mixes both kinds of opens, loses
about 1% of its writes this way:
smb3_write_err: ... offset=0xde90d7 len=0xbd0b rc=-22
All the rejected writes in a network capture were unaligned writes on a
no-buffering handle; none of the aligned ones, and none of the unaligned
ones on regular handles, were.
Prefer a handle that was not opened with O_DIRECT, and use one that was
only if there is no other.
Fixes: 1013e760d10e ("SMB3: Don't ignore O_SYNC/O_DSYNC and O_DIRECT flags")
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
[ sashal: Renamed the FIND_ANY flag to FIND_WR_ANY and added FIND_WR_NO_DIRECT as a #define instead of an enum entry, and dropped the tmpfile hunk since this tree has no tmpfile handling. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/client/cifsglob.h | 1 +
fs/smb/client/file.c | 13 +++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 27bdb50751852..3fe2144b00d2e 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1815,6 +1815,7 @@ static inline bool is_replayable_error(int error)
#define FIND_WR_ANY 0
#define FIND_WR_FSUID_ONLY 1
#define FIND_WR_WITH_DELETE 2
+#define FIND_WR_NO_DIRECT 4
#define MID_FREE 0
#define MID_REQUEST_ALLOCATED 1
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 4a62787891292..5aaa77ef527ab 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -267,9 +267,15 @@ static void cifs_begin_writeback(struct netfs_io_request *wreq)
struct cifs_io_request *req = container_of(wreq, struct cifs_io_request, rreq);
int ret;
- ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_WR_ANY, &req->cfile);
+ ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_WR_NO_DIRECT,
+ &req->cfile);
if (ret) {
- cifs_dbg(VFS, "No writable handle in writepages ret=%d\n", ret);
+ ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_WR_ANY,
+ &req->cfile);
+ }
+ if (ret) {
+ cifs_dbg(VFS, "%s: couldn't find writable handle: %d\n",
+ __func__, ret);
return;
}
@@ -2554,6 +2560,9 @@ cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, int flags,
continue;
if (with_delete && !(open_file->fid.access & DELETE))
continue;
+ if ((flags & FIND_WR_NO_DIRECT) &&
+ (open_file->f_flags & O_DIRECT))
+ continue;
if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) {
if (!open_file->invalidHandle) {
/* found a good writable file */
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-26 4:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 11:14 FAILED: patch "[PATCH] smb: client: don't write back through O_DIRECT handles" failed to apply to 6.12-stable tree gregkh
2026-11-26 4:34 ` [PATCH 6.12.y] smb: client: don't write back through O_DIRECT handles Sasha Levin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.