From patchwork Fri Mar 17 02:19:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1758046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=i1Y1bwDV; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pd7B40rGXz2473 for ; Fri, 17 Mar 2023 13:19:40 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pczgq-0004kl-Fl; Fri, 17 Mar 2023 02:19:32 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pczgn-0004jV-Cr for kernel-team@lists.ubuntu.com; Fri, 17 Mar 2023 02:19:29 +0000 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (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 smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 1D07D3F1A0 for ; Fri, 17 Mar 2023 02:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1679019569; bh=lbxstTFbhsWfrt/8YUUfxpANqRu6LSe+tGX93KOZri4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=i1Y1bwDVUZcm3uOWBqeweTkBljiv9OhL4/OS/Mb9KE1T6w5aQdFge2jmJT3IqvkyC Nztyc/z2NSPJr580eBV8oVpYYd+n8DmYrRby8H/ag+6FvvbuYn1nTVx6llWofrdzml evpyvCYO7XwQ9/SVhdPQSs0dmc4Sa+16Jm8/qJ1hnylyNmdfHDrCPM+FrrT/rH37nn ZOCGThENrmHz8CYb1gAPXYLZSIUTufG75OokRow9Yi6YsRGGLgedstWkiW9TlXDVpC cn8mTQ/VtzZSfyPOkL2w3dgly0+T4hSOwLd72+5LtB1j0I1PxBgFxdZQ05cgYhAvEm QBtcys1FwfJzw== Received: by mail-pg1-f199.google.com with SMTP id d34-20020a630e22000000b005039e28b68cso942373pgl.13 for ; Thu, 16 Mar 2023 19:19:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679019567; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lbxstTFbhsWfrt/8YUUfxpANqRu6LSe+tGX93KOZri4=; b=cb3dUUntxFzK2VUYPzXyQXJa6XqqpDDspndHvx5O1vSI3YPJCOb22j2rN0/VI42P+I DDnV9lYbX7PD+R/EVYFLKjzHMQAm7OEM5CJpPbomNgBDpuVXsy7sg3tb6KBdl2yswf3N NAOZZM8qclVKIFPqNlg6IboCFR1mNp5WJW337kFknWILmuHNeJuQ1s5CgOH1zv3F5ceJ nbUpY6urxp36uaoUJe5b8HLJO4JorRKTxt2xJP9VqPRq4YtFwaJGWoV7lw6UGRnkQnGV OXOdyCEbdc/8hRCrC2yVOSEYzUrvf9eOPTiAZ5sR9KUK0HGVhXimaqYbXLGskUNx1izn Iz5Q== X-Gm-Message-State: AO0yUKUoV+yvDEywmHj4dK/aE7Nq6nkOmRAC/+j8gBfRwVdwssRgf8+d 6CCh1MP5DV4rfhS+A1YULrwCwHwP0zFBTZWrD+4vVMsLsJrofLyYezwrG0wXpKnidh1afLBOV4q J/zQxU7ArR54rc7EUvHXY1xXeGzcioFPacEVP4i+wnzb8h5Imkw== X-Received: by 2002:aa7:9830:0:b0:625:55e5:afe4 with SMTP id q16-20020aa79830000000b0062555e5afe4mr5176852pfl.26.1679019567625; Thu, 16 Mar 2023 19:19:27 -0700 (PDT) X-Google-Smtp-Source: AK7set+ExYzrjK9vmr1ezz8RaWQHZSfuWiaCrsdznSYvCkc8xWY6k8KpeCbxakahj+TtuE2ohWlXag== X-Received: by 2002:aa7:9830:0:b0:625:55e5:afe4 with SMTP id q16-20020aa79830000000b0062555e5afe4mr5176844pfl.26.1679019567333; Thu, 16 Mar 2023 19:19:27 -0700 (PDT) Received: from chengendu.. (111-248-125-11.dynamic-ip.hinet.net. [111.248.125.11]) by smtp.gmail.com with ESMTPSA id q11-20020a63cc4b000000b004e8f7f23c4bsm305938pgi.76.2023.03.16.19.19.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:19:27 -0700 (PDT) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Focal][PATCH 1/1] NFS: Correct timing for assigning access cache timestamp Date: Fri, 17 Mar 2023 10:19:23 +0800 Message-Id: <20230317021923.23466-2-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230317021923.23466-1-chengen.du@canonical.com> References: <20230317021923.23466-1-chengen.du@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Chengen Du BugLink: https://bugs.launchpad.net/bugs/2009325 When the user's login time is newer than the cache's timestamp, the original entry in the RB-tree will be replaced by a new entry. Currently, the timestamp is only set if the entry is not found in the RB-tree, which can cause the timestamp to be undefined when the entry exists. This may result in a significant increase in ACCESS operations if the timestamp is set to zero. Signed-off-by: Chengen Du Fixes: 0eb43812c027 ("NFS: Clear the file access cache upon login”) Reviewed-by: Benjamin Coddington Signed-off-by: Anna Schumaker (cherry picked from commit 21fd9e8700de86d1169f6336e97d7a74916ed04a) Signed-off-by: Chengen Du --- fs/nfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index da431e7d18d9..7caed3275e22 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2472,7 +2472,6 @@ static void nfs_access_add_rbtree(struct inode *inode, struct nfs_access_entry * else goto found; } - set->timestamp = ktime_get_ns(); rb_link_node(&set->rb_node, parent, p); rb_insert_color(&set->rb_node, root_node); list_add_tail(&set->lru, &nfsi->access_cache_entry_lru); @@ -2494,6 +2493,7 @@ void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set) RB_CLEAR_NODE(&cache->rb_node); cache->cred = get_cred(set->cred); cache->mask = set->mask; + cache->timestamp = ktime_get_ns(); /* The above field assignments must be visible * before this item appears on the lru. We cannot easily