Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 387D13CEB85 for ; Fri, 3 Apr 2026 16:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775235227; cv=none; b=aFjljkKJ9lkWX0xNRAmZ6UleVPjQT8Hd9HHek6AYBIb+LALoVPdyg+En9bEMsMWW+jQHn+cXCJbQtP21GGEAFQTlnLCJYZGfLyPZ3NVnzL4WGIGqPyeNU9sHTIZlqCJeak+5HO3v6CEgOADzVHO8j8cB/1/aD/sdlWNMOWhCBGE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775235227; c=relaxed/simple; bh=we8d7BVjAzdab18lXNSKfeQrA9R9F6zQWiIW747SN4U=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TKvvUxF4kIZfLA/NOKDaV1pUkdR07h8Kyz10/UC6TO3H6iNPeE3yUpFRTHPcMgn/BHuezJVVry+ds12yxwEmTqvm3jKYtTgNNbHDUCtr3zAZbGEENtmaLzpQ9+EHBFeKVThN+y4QAqBLJM8dfPdLKxev8iMDXm4CL3dzl8SneAc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dJc2AP+8; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dJc2AP+8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775235223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=EfkY1fnT5EgFnfzax5+gLmhkflGdbDLwJgHY3NHVt78=; b=dJc2AP+8bz2gqc8LABPGx8XyDxNU4IY0Go7T1YtBlktM4evz90+d/aB7mB4GHZumLOU9Zf +bvEScoW4RNgWulEaU8d+OsUA3oOVUT357uBGEi9jqoDze9usKByzjieFxV5nnhbdXz5Fr ff4XOHz8cZzcX6vTojqK310dDwaNn4Y= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-508-QNFNxQSUPdOF0LRNA4w-nA-1; Fri, 03 Apr 2026 12:53:38 -0400 X-MC-Unique: QNFNxQSUPdOF0LRNA4w-nA-1 X-Mimecast-MFC-AGG-ID: QNFNxQSUPdOF0LRNA4w-nA_1775235217 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 97EF119560B0; Fri, 3 Apr 2026 16:53:37 +0000 (UTC) Received: from okorniev-mac.redhat.com (unknown [10.22.89.67]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 752CB19560A6; Fri, 3 Apr 2026 16:53:36 +0000 (UTC) From: Olga Kornievskaia To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org, neilb@brown.name, Dai.Ngo@oracle.com, tom@talpey.com Subject: [PATCH 1/1] nfsd: update mtime/ctime on CLONE and COPY in presence of delegated attributes Date: Fri, 3 Apr 2026 12:53:35 -0400 Message-ID: <20260403165335.73070-1-okorniev@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 When delegated attributes are given on open the file is opened with NOCMTIME and modifying operations do not update mtime/ctime as to not get out-of-sync with the client's delegated view. However, for operations CLONE/COPY server should update its view of mtime/ctime and reflect that in any GETATTR queries. Fixes: e5e9b24ab8fa ("nfsd: freeze c/mtime updates with outstanding WRITE_ATTRS delegation") Signed-off-by: Olga Kornievskaia --- fs/nfsd/nfs4proc.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 99b44b6ec056..66bde3732b03 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1396,6 +1396,24 @@ nfsd4_verify_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, goto out; } +static bool nfsd4_clear_nocmtime(struct file *f) +{ + if ((READ_ONCE(f->f_mode) & FMODE_NOCMTIME) != 0) { + spin_lock(&f->f_lock); + f->f_mode &= ~FMODE_NOCMTIME; + spin_unlock(&f->f_lock); + return true; + } + return false; +} + +static void nfsd4_restore_nocmtime(struct file *f) +{ + spin_lock(&f->f_lock); + f->f_mode |= FMODE_NOCMTIME; + spin_unlock(&f->f_lock); +} + static __be32 nfsd4_clone(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, union nfsd4_op_u *u) @@ -1403,16 +1421,19 @@ nfsd4_clone(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_clone *clone = &u->clone; struct nfsd_file *src, *dst; __be32 status; + bool restore_nocmtime = false; status = nfsd4_verify_copy(rqstp, cstate, &clone->cl_src_stateid, &src, &clone->cl_dst_stateid, &dst); if (status) goto out; + restore_nocmtime = nfsd4_clear_nocmtime(dst->nf_file); status = nfsd4_clone_file_range(rqstp, src, clone->cl_src_pos, dst, clone->cl_dst_pos, clone->cl_count, EX_ISSYNC(cstate->current_fh.fh_export)); - + if (restore_nocmtime) + nfsd4_restore_nocmtime(dst->nf_file); nfsd_file_put(dst); nfsd_file_put(src); out: @@ -2132,6 +2153,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_copy *copy = &u->copy; struct nfsd42_write_res *result; __be32 status; + bool restore_nocmtime = false; result = ©->cp_res; nfsd_copy_write_verifier((__be32 *)&result->wr_verifier.data, nn); @@ -2157,6 +2179,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, } } + restore_nocmtime = nfsd4_clear_nocmtime(copy->nf_dst->nf_file); memcpy(©->fh, &cstate->current_fh.fh_handle, sizeof(struct knfsd_fh)); if (nfsd4_copy_is_async(copy)) { @@ -2199,6 +2222,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, copy->nf_dst->nf_file, true); } out: + if (restore_nocmtime) + nfsd4_restore_nocmtime(copy->nf_dst->nf_file); trace_nfsd_copy_done(copy, status); release_copy_files(copy); return status; -- 2.52.0