From: "Anna Schumaker" <anna@kernel.org>
To: "Joseph Qi" <joseph.qi@linux.alibaba.com>,
"Trond Myklebust" <trondmy@kernel.org>
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] NFS: don't raise i_size for DEALLOCATE in _nfs42_proc_fallocate()
Date: Fri, 13 Nov 2026 16:27:22 -0500 [thread overview]
Message-ID: <1e807af5-e5f0-4a02-8e3a-312f4d394669@app.fastmail.com> (raw)
In-Reply-To: <4f83b93d-3173-4e04-9b79-df2413c3be18@linux.alibaba.com>
Hi Joseph,
On Thu, Nov 12, 2026, at 8:02 PM, Joseph Qi wrote:
> Ping...
I have this patch applied to a private branch for my own testing and it
seems okay to me so far. I'm planning to test with it for a bit before
sending it in to a v7.4-rc.
Anna
>
> On 11/9/26 7:32 PM, Joseph Qi wrote:
>> _nfs42_proc_fallocate() raises i_size to offset + len on success, so
>> that the cached size is not left stale when a delegation blocks the
>> post-op attribute refresh. The helper is shared by all three
>> fallocate modes, but DEALLOCATE always carries FALLOC_FL_KEEP_SIZE
>> and never extends the file on the server, so punching a hole that
>> reaches past EOF now wrongly enlarges the cached i_size.
>>
>> The post-op update would normally restore the size from the returned
>> attributes, but nfs_update_inode() applies a differing size only when
>> no delegation is held, and then only when no write is in flight or the
>> new size is larger:
>>
>> if (new_isize != cur_isize && !have_delegation) {
>> if (!nfs_have_writebacks(inode) || new_isize > cur_isize)
>> i_size_write(inode, new_isize);
>> }
>>
>> With a concurrent mmap writer (nrequests != 0) or any outstanding
>> delegation, the shrinking server size is therefore ignored and the
>> client keeps reporting a file larger than the server has, in violation
>> of KEEP_SIZE, until some later revalidation without writebacks happens
>> to fix it up.
>>
>> Skip the i_size bump for the DEALLOCATE procedure. ALLOCATE (mode 0)
>> and ZERO_RANGE (which nfs42_fallocate() accepts only without
>> FALLOC_FL_KEEP_SIZE) do extend the file when the range reaches past
>> EOF, so they keep the update.
>>
>> Fixes: 35168eb947f2 ("NFS: fix eof updates after NFSv4.2 fallocate/zero-range")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
>> ---
>> fs/nfs/nfs42proc.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
>> index ab86246fc364f..d76bface87f74 100644
>> --- a/fs/nfs/nfs42proc.c
>> +++ b/fs/nfs/nfs42proc.c
>> @@ -84,7 +84,9 @@ static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
>> loff_t newsize = offset + len;
>>
>> spin_lock(&inode->i_lock);
>> - if (newsize > i_size_read(inode))
>> + /* DEALLOCATE implies KEEP_SIZE, so don't extend i_size */
>> + if (msg->rpc_proc != &nfs4_procedures[NFSPROC4_CLNT_DEALLOCATE] &&
>> + newsize > i_size_read(inode))
>> i_size_write(inode, newsize);
>> nfs_set_cache_invalid(inode, NFS_INO_INVALID_BLOCKS);
>> if (nfs_should_remove_suid(inode))
prev parent reply other threads:[~2026-11-13 21:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 6:16 [PATCH] " Joseph Qi
2026-11-03 20:11 ` Anna Schumaker
2026-11-04 1:45 ` Joseph Qi
2026-11-09 11:32 ` [PATCH v2] " Joseph Qi
2026-11-13 1:02 ` Joseph Qi
2026-11-13 21:27 ` Anna Schumaker [this message]
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=1e807af5-e5f0-4a02-8e3a-312f4d394669@app.fastmail.com \
--to=anna@kernel.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=trondmy@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
all inboxes | Powered by JetHome®