From: "Chuck Lever" <cel@kernel.org>
To: "Olga Kornievskaia" <okorniev@redhat.com>,
"Chuck Lever" <chuck.lever@oracle.com>,
"Jeff Layton" <jlayton@kernel.org>
Cc: linux-nfs@vger.kernel.org, neilb@brown.name,
"Dai Ngo" <Dai.Ngo@oracle.com>, "Tom Talpey" <tom@talpey.com>
Subject: Re: [PATCH v2 3/3] nfsd: update mtime/ctime on asynchronous COPY with delegated attributes
Date: Wed, 08 Apr 2026 19:11:48 -0400 [thread overview]
Message-ID: <d81b1bc3-4e1b-43cc-9596-8a5c753ca9fc@app.fastmail.com> (raw)
In-Reply-To: <20260408190008.85082-4-okorniev@redhat.com>
On Wed, Apr 8, 2026, at 3:00 PM, Olga Kornievskaia wrote:
> Asynchronous COPY should update destination file's mtime/ctime upon
> completion of copy work (not COPY compound processing).
>
> Fixes: e5e9b24ab8fa ("nfsd: freeze c/mtime updates with outstanding
> WRITE_ATTRS delegation")
> Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index ac47cddef384..b6490167e78b 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -2132,8 +2132,19 @@ static int nfsd4_do_async_copy(void *data)
>
> set_bit(NFSD4_COPY_F_COMPLETED, ©->cp_flags);
> trace_nfsd_copy_async_done(copy);
> - nfsd4_send_cb_offload(copy);
> atomic_dec(©->cp_nn->pending_async_copies);
> + /*
> + * choosing to check for existence of set dentry pointer to indicate
> + * that we need to update the attributes and do a dput because the
> + * file flag could be cleared by a DELEGRETURN and then we'd lose
> + * that copy was started with file opened with NOCMTIME and we got
> + * a reference on the dentry.
> + */
> + if (copy->d_dst && copy->cp_res.wr_bytes_written > 0) {
> + nfsd_update_cmtime_attr(copy->d_dst);
> + dput(copy->d_dst);
> + }
> + nfsd4_send_cb_offload(copy);
> return 0;
> }
>
There might be another potential dentry reference underflow here.
If the async copy fails before writing any bytes
(wr_bytes_written == 0), the dput is skipped but the dget taken
in nfsd4_copy() is never released elsewhere.
This might happen when _nfsd_copy_file_range() fails on the first
iteration, when nfs42_ssc_open() fails for inter-SSC copies, or
when kthread_should_stop() fires before any bytes are copied.
Rearranging the logic a little might avoid the issue:
if (copy->d_dst) {
if (copy->cp_res.wr_bytes_written > 0)
nfsd_update_cmtime_attr(copy->d_dst);
dput(copy->d_dst);
}
--
Chuck Lever
prev parent reply other threads:[~2026-04-08 23:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 19:00 [PATCH v2 0/3] nfsd update mtime/ctime on CLONE/COPY with delegated attritutes Olga Kornievskaia
2026-04-08 19:00 ` [PATCH v2 1/3] nfsd: update mtime/ctime on CLONE in presense of delegated attributes Olga Kornievskaia
2026-04-08 23:07 ` Chuck Lever
2026-04-09 14:12 ` Olga Kornievskaia
2026-04-08 19:00 ` [PATCH v2 2/3] nfsd: update mtime/ctime on synchronous COPY with " Olga Kornievskaia
2026-04-08 19:00 ` [PATCH v2 3/3] nfsd: update mtime/ctime on asynchronous " Olga Kornievskaia
2026-04-08 23:11 ` Chuck Lever [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=d81b1bc3-4e1b-43cc-9596-8a5c753ca9fc@app.fastmail.com \
--to=cel@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).