Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp565113lqh; Thu, 28 Mar 2024 09:35:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVltYEl09hWTxMs6nxy+dYX0jfrFoDTOzvBoSTSMIqx/vLly17Qfz/X4fJVGD87ou9j13uy+CIARI5beVG5k0ryHNGU+29lpxoL3rL5CQ== X-Google-Smtp-Source: AGHT+IEUwX8RqHtN6LJLMpYhp/V4pKHbKKmkmBsR/CtTTbu202q4SdDcTcqaGLO7+skML5pqX12O X-Received: by 2002:a9d:65d2:0:b0:6e5:34a6:4b8c with SMTP id z18-20020a9d65d2000000b006e534a64b8cmr4152954oth.0.1711643722022; Thu, 28 Mar 2024 09:35:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711643721; cv=pass; d=google.com; s=arc-20160816; b=IqOi2j2nkoDe5PXDenRjP5hnhopeYtV0fZ9jk95HEePingVhmsOYuNUS1Yqk6dWn7y Y/Gc2t5sMuy95H5l0+4esHvSa0e8trW8f3aKpEvg+xH/jP/o8cAuFKePQ+X+V+TaBwQm EZD0f4ItKc3hc8Ap2k2ipbdwSaNlNfm/BtADVGSN5BmuiiRSXUi2hTLDbEg6enVIsKAz +8wXKdyvq9N8XpaPN6yzLqjA1QJv73KQwe3+tPpmz/JKjPO0TnMnc6TiJy+sOdAjjmGt LksXarBn4K9ZolGf1FlRsdOt6QVDUuSjDXd3JIkXeXSqZXNrKcAOLrdJ1N/Ti4o6ISc3 hAMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=UGun0xTYAiYXpHAgnS9fdzLLkhmr8x7z9WYy+PlL9DM=; fh=D72SRyTeGTT5e8cHVnWso1+T4PfZOoBdL/zxY6by6YI=; b=dYxbePYi0Gm7fgsOU9+gVrng7cuMgd4p7uIYmP9ez85Tf2Q3HUyY8AMYTsZTTEI0kU czJQRO9AvtxTj1S5RYpMbL3TZqaD9cueInJBkP/JQp4HpI8R1RVbn7aZIgmDVz3vYrtS xRljXV1vgY2JkkIgyctq35dvhVmoLhxWWFrkCJluvqkNP8Mu4AACofv+sqtFQITUtoin 70QSXl+IqEURdY6flNyDi0KQIkaWkI7k3YwDAJYxNETF0Ba6eHBVJ5D6AI5tJKGkrdsb BAfkKmwssKTHd6aTGHMZLkBaNgxp/9Ad3qQKuNfHDjjJjzN49zOo0JkzVfHfyK1+I0T1 NROg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i5DsXNVB; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123257-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o7-20020a05620a2a0700b0078a46d1adebsi2016262qkp.623.2024.03.28.09.35.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 09:35:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i5DsXNVB; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123257-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B8DAC1C2F8FA for ; Thu, 28 Mar 2024 16:35:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A6CD40851; Thu, 28 Mar 2024 16:34:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i5DsXNVB" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 5EF873A1BA for ; Thu, 28 Mar 2024 16:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711643692; cv=none; b=LuGh5QwDn8FDSWMqp4JZyDnuOQrXm/eEX2f3AlDVXAJzow29S2A4WuVqK795mwvddBI3BltoOlc5VKB40as1Hp66QeRk5cKMDUbTZ7VNJbkAoyLC8Prsn5EV5nEoFxygSMcwF+qPy99pNAVvE8+oxs3TJBa7qeS6YTit1k3LIWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711643692; c=relaxed/simple; bh=+8ZDgsWPyPdZyeuS7QhzhZ8T1ds652XhSpy7jeivk6U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O2hDH641raQlc912KARc3pok1H3GZT/1KqZXFRKuU6vGhvKumT4zgt42eq2CxdOC5lah7gDFSmQSVCcHhYDETxIMTdoGZImiwsub8n/tGVQussFsBUwXv3b7ezVocCkeXP8NCf+L647WDjMmP17BCJH9WOWTuMn1NFJfSeUHh3k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=i5DsXNVB; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711643687; 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=i5DsXNVBs1f5O0D/sbBf8ABh1wMFs10iANUv44n+c5xwdpAZGf5oHeTLPftDowYbo65OD0 PCCmyRenr0OYdXqkrtwlJtUASMTwszvovIjnCGvjW19kPWUqa5UlI9LSGZhL/XAA8s8PMU ZkBip779Uow0CYNUBa2MKr8viOKqS98= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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 --- 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;