From patchwork Wed Jan 18 14:57:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengen Du X-Patchwork-Id: 1728290 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=DNdXGFtZ; 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 4Nxpl82JJ5z23fT for ; Thu, 19 Jan 2023 01:57:24 +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 1pI9sL-0007JZ-0V; Wed, 18 Jan 2023 14:57:17 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pI9sJ-0007HO-3J for kernel-team@lists.ubuntu.com; Wed, 18 Jan 2023 14:57:15 +0000 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (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-0.canonical.com (Postfix) with ESMTPS id DE37C3F5D6 for ; Wed, 18 Jan 2023 14:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674053834; bh=jmGOesuVXIfYYriQz4WAkLAo6pIW7YEaHeWVcShMyEQ=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DNdXGFtZZNnh5Ta7Alf9JI84ivusKOvy/OtXxY7v1xYXzEmgci+UGZ5zPGYEP3YqL WzA+Cv9zZbe7c0Bz+7FCycKJdlgAIt0xtXQl34nGvvnNTD3XYcwItBEYj0EOvq7Ng1 sWdIXqZGrQqM30TZPi54P8g7hmXEdcb10pE3XnZxJ1gcDC1axYywHxBD1dJoM57QvK xbZR1LbR5I4bN28cbnRziBYMAWXljXJ9qYZ8ql3fbOa/s6Mr03l7GNMTDe6q9JxEkd jb2JPLz3n3JRRf+msHhj7H1ZR48KGX/m84gXWz1x1NatkMd7Ja0FNnh6azg+irqFhn AFjiE7lr4cdEw== Received: by mail-pl1-f197.google.com with SMTP id x10-20020a170902ec8a00b001949f64986bso4270027plg.12 for ; Wed, 18 Jan 2023 06:57:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=jmGOesuVXIfYYriQz4WAkLAo6pIW7YEaHeWVcShMyEQ=; b=do4Zt15ZfmlWFkjoIAwrccOxw7JXxxziB8OWE8wC3OVD0WfQZ7hU0KgvApjXypSedH OYi1PfgzO8zVFaEr5kFUqM2iE9DrRz+zFWF3dBg+3u3sG191g8UmzsAy4fdrCZP5VLPI HyoVnItFLACu5NqSq5iQnebD/4PrFVwx/lcU5E2c51Hnicuk0Ix1CHxeZ372K9ckAaOH PnB2GF1zyRbTAbeJTnK1+oIsjpObb93Mqv2AGhQwMVHV2Q+5GrPXUNE43CvaX0TbWM00 7TX3Rkj94jXnrgP5eIsS+MKwEqypPGmkRhQ7YjjYNRuLJxiXSdK3f9DIOVmMpiZW70GG UdnA== X-Gm-Message-State: AFqh2koqzadxIXXeNlD1Dna7ZhmOtNqW1+/wh9k/2+7WHEPjhuP2iN+V 92dcfjJ3GAZEMRY+JNh0s6rjbCcyrfacUhe//RB8tKjoUnB1LWDXVY7luyHdclSEeg92pavZGcO 9ZF4k7siXF7Jna5b7mmR+mgFn1WbM3wbluvGvULrStQ== X-Received: by 2002:a05:6a20:1450:b0:b5:e1f5:c72f with SMTP id a16-20020a056a20145000b000b5e1f5c72fmr9065636pzi.28.1674053833390; Wed, 18 Jan 2023 06:57:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXs0juSzvvmkw7NFsRZY4DFMT3Z4nRukM4jFFz1tK9BdpKnXgqmmblRS555p18fruZU5zthuhA== X-Received: by 2002:a05:6a20:1450:b0:b5:e1f5:c72f with SMTP id a16-20020a056a20145000b000b5e1f5c72fmr9065615pzi.28.1674053833076; Wed, 18 Jan 2023 06:57:13 -0800 (PST) Received: from chengendu.. (111-248-160-17.dynamic-ip.hinet.net. [111.248.160.17]) by smtp.gmail.com with ESMTPSA id a1-20020a63d201000000b004ae6e97ed10sm17437865pgg.17.2023.01.18.06.57.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 06:57:12 -0800 (PST) From: Chengen Du To: kernel-team@lists.ubuntu.com Subject: [SRU][Focal][PATCH 2/3] (upstream) NFS: Judge the file access cache's timestamp in rcu path Date: Wed, 18 Jan 2023 22:57:07 +0800 Message-Id: <20230118145708.35996-3-chengen.du@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230118145708.35996-1-chengen.du@canonical.com> References: <20230118145708.35996-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" BugLink: https://bugs.launchpad.net/bugs/2003053 If the user's login time is newer than the cache's timestamp, we expect the cache may be stale and need to clear. The stale cache will remain in the list's tail if no other users operate on that inode. Once the user accesses the inode, the stale cache will be returned in rcu path. Signed-off-by: Chengen Du Signed-off-by: Trond Myklebust (cherry picked from commit 029085b8949f5d269ae2bbd14915407dd0c7f902) Signed-off-by: Chengen Du --- fs/nfs/dir.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index f35b705d2351..951ec7ebde40 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2421,6 +2421,7 @@ static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre * but do it without locking. */ struct nfs_inode *nfsi = NFS_I(inode); + u64 login_time = nfs_access_login_time(current, cred); struct nfs_access_entry *cache; int err = -ECHILD; struct list_head *lh; @@ -2435,6 +2436,8 @@ static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre cache = NULL; if (cache == NULL) goto out; + if ((s64)(login_time - cache->timestamp) > 0) + goto out; if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS)) goto out; res->cred = cache->cred;