From patchwork Thu Mar 28 16:33:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13608968 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDC66CD11DD for ; Thu, 28 Mar 2024 16:34:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 560336B0099; Thu, 28 Mar 2024 12:34:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E9D86B009B; Thu, 28 Mar 2024 12:34:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33BBA6B009C; Thu, 28 Mar 2024 12:34:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0CDF56B0099 for ; Thu, 28 Mar 2024 12:34:51 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A0320140E92 for ; Thu, 28 Mar 2024 16:34:50 +0000 (UTC) X-FDA: 81946996740.03.C00CED3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id E3ABC2001B for ; Thu, 28 Mar 2024 16:34:48 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H4Hdd0Vu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711643689; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UGun0xTYAiYXpHAgnS9fdzLLkhmr8x7z9WYy+PlL9DM=; b=Raw03wa7KVn0sKmxDKnDAyaGjpxR542zKjh9lGo2x6tiGrNuZfeYuLHjI9naaqDMV+msgB upQLeOiG/oYxvvjAniFQLTrbWzKW36N8DyR1UHhUD6pshIc+0N2PfHaQTBiBgsJ1Epfjvd jpHVcy8TFWxANY32D8wtkNGq9heK+fU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H4Hdd0Vu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711643689; a=rsa-sha256; cv=none; b=v/SEhdVwXRtvI/geSOxyXv4bc++rj2fykKq96FdQ/g3c011J5lKES3oTI6C6Rjg0Omw8vm SMgPHc3CocStewSh3jNAOH7OZ+kvbCiuTp+bkK7XiDfRxPKfxFBKR/jC0Bh+pTt5YBwZVc MJUACFxvsTwgnDDyvMUwZxwU+jcKYYM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711643688; 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: in-reply-to:in-reply-to:references:references; bh=UGun0xTYAiYXpHAgnS9fdzLLkhmr8x7z9WYy+PlL9DM=; b=H4Hdd0Vud1iC0ETVObcHX2Z0di0EVtz7YSHRcs4VJDIHywmvB/sjHZq5O1tmA0DPbtLgTj QPpUyCww4ukmwgdIVZQNBcU9m1nu1IKl9WjeR/mPSHAdwgnvEYYI+QfBohd4mHZN+FKquy a3yRUlhfDlBA1WWvjmdW09hoFF8bao0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-267-6uNN7mfqOreex-w6B3hmWQ-1; Thu, 28 Mar 2024 12:34:44 -0400 X-MC-Unique: 6uNN7mfqOreex-w6B3hmWQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C30E185A781; Thu, 28 Mar 2024 16:34:43 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA93D17AAE; Thu, 28 Mar 2024 16:34:39 +0000 (UTC) From: David Howells To: Christian Brauner , Jeff Layton , Gao Xiang , Dominique Martinet Cc: David Howells , Matthew Wilcox , Steve French , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French , Shyam Prasad N , Rohith Surabattula Subject: [PATCH 01/26] cifs: Fix duplicate fscache cookie warnings Date: Thu, 28 Mar 2024 16:33:53 +0000 Message-ID: <20240328163424.2781320-2-dhowells@redhat.com> In-Reply-To: <20240328163424.2781320-1-dhowells@redhat.com> References: <20240328163424.2781320-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspam-User: X-Stat-Signature: k9joykga6j4sk6jtmbi7puhpki9uucbf X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E3ABC2001B X-HE-Tag: 1711643688-299746 X-HE-Meta: U2FsdGVkX1/+tluO0C3m4jMpBH6ZCfROwOyrwqPpeRatPB2I8p9nd2xmSxqBlt+sQXbGvC87w95FTz/3T+i1b54+NKlg7YgdJMJxHfG8J8lyOH46aNPukbMu9UYeDsSZ7XxKb5UbZOM0QYAr3/E7YMECkxO16l0kWJH5SPLKdow6jEhzKOWHrANdpUUCcubPQbIstmPVH4HsNy4mppl7s+qwV99uTJ5lJr9MpJfF6pCezFxJy83NnbUl45uDoIjxOrLJDSr2DZ6IWbQTezyKyBx35eZmakcQrLyOUMl0VactZH0QQfwG3DN75pKZR/Q8vpQtfkc/UDcJtUUwISG1rI9afeHd2Bv1iQvd18CjUzue+k+VFFDjCxJVSU/yDUKx8NhFggCP0zht2HNZFqFI8c0tG5wXpD0v9f8pXRpBdmJOUGNio4kNZLMiTTB7vO30hegWpihCHpSrOlg0i6Y7SYmIfQYKhdaVc3K3Di/w1WF/mDjJQkm4kV9TQJqmY38pDX0OCKu9exZeHm439L45+Ph7A+Q3A3QBhHu49+T2h/b/m+TVMvMXuMw21BQPBBRw8MiEpPNH6QXELj5vQhF3JXh0pA5+oYn/XPTkwH4onRdFOMs0ARNwyHKECuuV/HAjSZT+58ZfOUlOu1m1+8e1F8CKtHTpAN9Fk7gCwAoQ92PXVxtG5wMiKXhgTj1c+NdNqP7TAKfUESTOO2KjQD2Pt+yItCPMJBXhuvDVVyCMVDryH7OY4BBBi3fMzUeyTPCxig2fZnT3MlEzRoX1quPiHBX4XsStW6BMSiMu4mvLCfpusyOX/pupjXPxMNiLMwQiPSra7NP3UzjvaGVhsu9YZMf5YNsjQtarUQhIllRSp+i6+8SAIbUbJ8colcILFyzVxsvhRD+A4uBjzxsba5L75Mt+J5j4UoRn9AlcGep2fnwqSr+D31tYumEs8ZoLDLopaWJUp+WEOXSoliyAHcZ WDsQ7sMJ +qycbD9Z5BxmAP1Pryc3sbC2xqyvDhqnZ33amIHOXQiIC7pmMgEPj10VrmoSeMCTHd2T4ZIFgu4vOOrRUEcfZGpzJA+uernuj/2MvsmBBxLx4YXCIWh9YxO9kWqAKjOklkpDILUsxvJVS0pIbJaiXeTqN8TXT7CxzzFTYfw+nziZRKxk3RhL5f5CrLGIWNuMaAZVKYZtmbrQe2ISGtkLNIX7swz/mf5pJdFDvEoySoHa+tsM71bLWq48vBqjFF6kR68TwIQaTxLQ+GjvbyYuZVSF1hC9ESxFXjxsctBncYa9dbI/YHwQnT1JekkKZaCtEue3AMo1XfWoB31QEuKQV2MNnGWKI0cFm/2Y2EJHxjhZ8bUDg8sjpFs4m/E8UwIuAR+0q X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: fscache emits a lot of duplicate cookie warnings with cifs because the index key for the fscache cookies does not include everything that the cifs_find_inode() function does. The latter is used with iget5_locked() to distinguish between inodes in the local inode cache. Fix this by adding the creation time and file type to the fscache cookie key. Additionally, add a couple of comments to note that if one is changed the other must be also. Signed-off-by: David Howells cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Reviewed-by: Jeff Layton --- fs/smb/client/fscache.c | 16 +++++++++++++++- fs/smb/client/inode.c | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/fscache.c b/fs/smb/client/fscache.c index c4a3cb736881..340efce8f052 100644 --- a/fs/smb/client/fscache.c +++ b/fs/smb/client/fscache.c @@ -12,6 +12,16 @@ #include "cifs_fs_sb.h" #include "cifsproto.h" +/* + * Key for fscache inode. [!] Contents must match comparisons in cifs_find_inode(). + */ +struct cifs_fscache_inode_key { + + __le64 uniqueid; /* server inode number */ + __le64 createtime; /* creation time on server */ + u8 type; /* S_IFMT file type */ +} __packed; + static void cifs_fscache_fill_volume_coherency( struct cifs_tcon *tcon, struct cifs_fscache_volume_coherency_data *cd) @@ -97,15 +107,19 @@ void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon) void cifs_fscache_get_inode_cookie(struct inode *inode) { struct cifs_fscache_inode_coherency_data cd; + struct cifs_fscache_inode_key key; struct cifsInodeInfo *cifsi = CIFS_I(inode); struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); + key.uniqueid = cpu_to_le64(cifsi->uniqueid); + key.createtime = cpu_to_le64(cifsi->createtime); + key.type = (inode->i_mode & S_IFMT) >> 12; cifs_fscache_fill_coherency(&cifsi->netfs.inode, &cd); cifsi->netfs.cache = fscache_acquire_cookie(tcon->fscache, 0, - &cifsi->uniqueid, sizeof(cifsi->uniqueid), + &key, sizeof(key), &cd, sizeof(cd), i_size_read(&cifsi->netfs.inode)); if (cifsi->netfs.cache) diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index d28ab0af6049..91b07ef9e25c 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -1351,6 +1351,8 @@ cifs_find_inode(struct inode *inode, void *opaque) { struct cifs_fattr *fattr = opaque; + /* [!] The compared values must be the same in struct cifs_fscache_inode_key. */ + /* don't match inode with different uniqueid */ if (CIFS_I(inode)->uniqueid != fattr->cf_uniqueid) return 0;