From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0DBC27F4F2 for ; Tue, 4 Mar 2025 16:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741106543; cv=none; b=bys5HqE0DuaolbU4VTPy4Uwb3FZ6JEhDtLuwpb9ch1pUWOAvSAEAA1uGaegQ0K7phOdAO3fVPyeE7YfnyAy5A+C6TlpL9x8QCQDg3TRPI82CzG+v45rhpg1hPzPYzI555xkgPLEKjZb2K2VeQtdD943ysQ/xZwhYVukiM6UhSDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741106543; c=relaxed/simple; bh=Xo7nxWeh2V6e99SNgm2sifMkmc6J8X3xok6R+KyAtfU=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=OSGdP1y1/aii65rbG2uzGCo5iHaskivn6b6i0UNi1mtlcH2Y2Xt1m/FLj9GUKHW4Ti9stONIf7dA5gHa0QY3HR1zqAvsyEkrThp5lFsEnysaB6B8n/g2UQJYTA7dss8cmlLcMq9K5VrMjiLt/bvrjct4HeXwA/eUxd+0HOVDjTs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GT2ajaUU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GT2ajaUU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1391CC4CEE5; Tue, 4 Mar 2025 16:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741106542; bh=Xo7nxWeh2V6e99SNgm2sifMkmc6J8X3xok6R+KyAtfU=; h=Subject:To:Cc:From:Date:From; b=GT2ajaUUBFOEHj+5gdacOlSRTo6WlCDX0nugh1On2FvKCGc3iUtKEzxIzd11FjC0f ocLZeqfyFOZSfqUgglb3q7XZAoQwjjyNCXXp1R6FP/NtdgzAmrYQ6DStuO9RjUk1ER TMKNnooEEzlaognDKKUio1tgQt1ywgD/yQ1O53rw= Subject: FAILED: patch "[PATCH] NFS: O_DIRECT writes must check and adjust the file length" failed to apply to 5.15-stable tree To: trond.myklebust@hammerspace.com,anna.schumaker@oracle.com,chuck.lever@oracle.com Cc: From: Date: Tue, 04 Mar 2025 17:42:09 +0100 Message-ID: <2025030409-landline-uptake-7b9c@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit 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 . 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 fcf857ee1958e9247298251f7615d0c76f1e9b38 # git commit -s git send-email --to '' --in-reply-to '2025030409-landline-uptake-7b9c@gregkh' --subject-prefix 'PATCH 5.15.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 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. Reported-by: Chuck Lever Link: https://bugzilla.kernel.org/show_bug.cgi?id=219738 Cc: stable@vger.kernel.org Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index f45beea92d03..40e13c9a2873 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -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);