From nobody Sun Sep 14 22:49:45 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C008BC6FA89 for ; Tue, 13 Sep 2022 14:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234343AbiIMOh3 (ORCPT ); Tue, 13 Sep 2022 10:37:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234221AbiIMOfx (ORCPT ); Tue, 13 Sep 2022 10:35:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 637A56B16D; Tue, 13 Sep 2022 07:20:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 34540B80F4B; Tue, 13 Sep 2022 14:19:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CD35C433C1; Tue, 13 Sep 2022 14:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078766; bh=7J50k5lVIiQUUlOZRAAt0VZ/oyCjFX+wSEU4/oyLKlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qCa1hl+HajKB7UGhjuUNQAG2KX77BNgw1Sory8fgzS+D16h1H9W9asTk88rtY0mc1 HULhiEQfwdVLbQhl1UZ+JIlYBnDzSmg1ZCIeRt5kv/xNQW5kl0GF6WnS8Atxwg474G yuDS6qenNXNvOZvrAXHgu8NAGtkiK5+NKoHeFHws= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeffrey E Altman , David Howells , Sasha Levin Subject: [PATCH 5.15 075/121] afs: Use the operation issue time instead of the reply time for callbacks Date: Tue, 13 Sep 2022 16:04:26 +0200 Message-Id: <20220913140400.597019915@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: David Howells [ Upstream commit 7903192c4b4a82d792cb0dc5e2779a2efe60d45b ] rxrpc and kafs between them try to use the receive timestamp on the first data packet (ie. the one with sequence number 1) as a base from which to calculate the time at which callback promise and lock expiration occurs. However, we don't know how long it took for the server to send us the reply from it having completed the basic part of the operation - it might then, for instance, have to send a bunch of a callback breaks, depending on the particular operation. Fix this by using the time at which the operation is issued on the client as a base instead. That should never be longer than the server's idea of the expiry time. Fixes: 781070551c26 ("afs: Fix calculation of callback expiry time") Fixes: 2070a3e44962 ("rxrpc: Allow the reply time to be obtained on a clien= t call") Suggested-by: Jeffrey E Altman Signed-off-by: David Howells Signed-off-by: Sasha Levin --- fs/afs/flock.c | 2 +- fs/afs/fsclient.c | 2 +- fs/afs/internal.h | 3 +-- fs/afs/rxrpc.c | 7 +------ fs/afs/yfsclient.c | 3 +-- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/fs/afs/flock.c b/fs/afs/flock.c index c4210a3964d8b..bbcc5afd15760 100644 --- a/fs/afs/flock.c +++ b/fs/afs/flock.c @@ -76,7 +76,7 @@ void afs_lock_op_done(struct afs_call *call) if (call->error =3D=3D 0) { spin_lock(&vnode->lock); trace_afs_flock_ev(vnode, NULL, afs_flock_timestamp, 0); - vnode->locked_at =3D call->reply_time; + vnode->locked_at =3D call->issue_time; afs_schedule_lock_extension(vnode); spin_unlock(&vnode->lock); } diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c index 4943413d9c5f7..7d37f63ef0f09 100644 --- a/fs/afs/fsclient.c +++ b/fs/afs/fsclient.c @@ -131,7 +131,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_b= p, =20 static time64_t xdr_decode_expiry(struct afs_call *call, u32 expiry) { - return ktime_divns(call->reply_time, NSEC_PER_SEC) + expiry; + return ktime_divns(call->issue_time, NSEC_PER_SEC) + expiry; } =20 static void xdr_decode_AFSCallBack(const __be32 **_bp, diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 0ad97a8fc0d49..567e61b553f56 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -138,7 +138,6 @@ struct afs_call { bool need_attention; /* T if RxRPC poked us */ bool async; /* T if asynchronous */ bool upgrade; /* T to request service upgrade */ - bool have_reply_time; /* T if have got reply_time */ bool intr; /* T if interruptible */ bool unmarshalling_error; /* T if an unmarshalling error occurred */ u16 service_id; /* Actual service ID (after upgrade) */ @@ -152,7 +151,7 @@ struct afs_call { } __attribute__((packed)); __be64 tmp64; }; - ktime_t reply_time; /* Time of first reply packet */ + ktime_t issue_time; /* Time of issue of operation */ }; =20 struct afs_call_type { diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c index a5434f3e57c68..e3de7fea36435 100644 --- a/fs/afs/rxrpc.c +++ b/fs/afs/rxrpc.c @@ -347,6 +347,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct a= fs_call *call, gfp_t gfp) if (call->max_lifespan) rxrpc_kernel_set_max_life(call->net->socket, rxcall, call->max_lifespan); + call->issue_time =3D ktime_get_real(); =20 /* send the request */ iov[0].iov_base =3D call->request; @@ -497,12 +498,6 @@ static void afs_deliver_to_call(struct afs_call *call) return; } =20 - if (!call->have_reply_time && - rxrpc_kernel_get_reply_time(call->net->socket, - call->rxcall, - &call->reply_time)) - call->have_reply_time =3D true; - ret =3D call->type->deliver(call); state =3D READ_ONCE(call->state); if (ret =3D=3D 0 && call->unmarshalling_error) diff --git a/fs/afs/yfsclient.c b/fs/afs/yfsclient.c index 2b35cba8ad62b..88ea20e79ae27 100644 --- a/fs/afs/yfsclient.c +++ b/fs/afs/yfsclient.c @@ -239,8 +239,7 @@ static void xdr_decode_YFSCallBack(const __be32 **_bp, struct afs_callback *cb =3D &scb->callback; ktime_t cb_expiry; =20 - cb_expiry =3D call->reply_time; - cb_expiry =3D ktime_add(cb_expiry, xdr_to_u64(x->expiration_time) * 100); + cb_expiry =3D ktime_add(call->issue_time, xdr_to_u64(x->expiration_time) = * 100); cb->expires_at =3D ktime_divns(cb_expiry, NSEC_PER_SEC); scb->have_cb =3D true; *_bp +=3D xdr_size(x); --=20 2.35.1