FAILED: patch "[PATCH] NFS: O_DIRECT writes must check and adjust the file length" failed to apply to 6.6-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.6-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 <[email protected]>.
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.6.y
git checkout FETCH_HEAD
git cherry-pick -x fcf857ee1958e9247298251f7615d0c76f1e9b38
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025030408-dentist-overrun-a8ea@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From fcf857ee1958e9247298251f7615d0c76f1e9b38 Mon Sep 17 00:00:00 2001
From: Trond Myklebust <[email protected]>
Date: Sat, 1 Feb 2025 14:59:02 -0500
Subject: [PATCH] NFS: O_DIRECT writes must check and adjust the file length
While it is uncommon for delegations to be held while O_DIRECT writes are in progress, it is possible. The xfstests generic/647 and generic/729 both end up triggering that state, and end up failing due to the fact that the file size is not adjusted.
fs/nfs/direct.c +19 -0
@@ -130,6 +130,20 @@ static void nfs_direct_truncate_request(struct nfs_direct_req *dreq, dreq->count = req_start; } +static void nfs_direct_file_adjust_size_locked (struct inode *inode, +loff_t offset,size_t count) +{ +loff_t newsize = offset + (loff_t )count; +loff_t oldsize =i_size_read (inode); + +if (newsize > oldsize) { +i_size_write (inode, newsize); +NFS_I (inode)->cache_validity &= ~NFS_INO_INVALID_SIZE ; +trace_nfs_size_grow (inode, newsize); +nfs_inc_stats (inode,NFSIOS_EXTENDWRITE ); + } +} +/** * nfs_swap_rw - NFS address space operation for swap I/O * @iocb: target I/O control block
@@ -741,6 +755,7 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr)struct nfs_direct_req *dreq = hdr->dreq;struct nfs_commit_info cinfo;struct nfs_page *req =nfs_list_entry (hdr->pages.next); +struct inode *inode = dreq->inode;int flags =NFS_ODIRECT_DONE ;trace_nfs_direct_write_completion (dreq);
@@ -762,6 +777,10 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr) }spin_unlock (&dreq->lock); +spin_lock (&inode->i_lock); +nfs_direct_file_adjust_size_locked (inode, dreq->io_start, dreq->count); +spin_unlock (&inode->i_lock); +while (!list_empty (&hdr->pages)) { req =nfs_list_entry (hdr->pages.next);