Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp100102lqo; Wed, 27 Mar 2024 08:00:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBclYIJh8bKsGq63iDQnJipPkbhPWmOu9SRVw7uQk32TP18tGV7T1GkW7Oh5xBVB7C4uT/PH6P2+qE89HC8+dGX/1n7NyJm0NQeYsRkA== X-Google-Smtp-Source: AGHT+IHsVyugQQTZk3FTfnVYbQot8hSkrfoIhFITQbAveruM4FiB3or4sVggF75g4wURxiDR5uh+ X-Received: by 2002:a05:620a:4008:b0:78a:e5f:1595 with SMTP id h8-20020a05620a400800b0078a0e5f1595mr1591992qko.45.1711551648601; Wed, 27 Mar 2024 08:00:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711551648; cv=pass; d=google.com; s=arc-20160816; b=o7EerKJ4lo1YfOuC4ARH94axq7iPcbuDmS40o2SA5yTGZPywuEP7dPySwDfaXh/k3j Cc4brrKYpXJUlhRfbbKB6CZ98qXVXKttnT0Iiv6WRdBcWE08WbL5gmK76AVoLF9QrkTE 2uGZEADdISf3zLicJ2FXU1XQEQFQDbB0XjgefTve/DGs0G2Vph9zCbZOIsBRMV85hyUE TdvKu8PReJQNEKP2DbbettCMOLmzh0ejNJA9arNEjLUvDKJiANlYP4O8rjferRPYBDpN ykC1OanTbhGAkIMXfauTMxN9wT603CIsRS5P9U5lhoXX+Pf4GyccAjPxDQBC/WtRHEoQ boJQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-transfer-encoding:content-id:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:cc:to :from:organization:dkim-signature; bh=Qut9wqKpTNwmM2gET59mhKtRBrovobZzNxOyH6sbgc8=; fh=aC5JJVPtHys305VmFu82i5kE1e+QqVTw2NUVBOcHa2g=; b=Slya86nn6LVWzGuDHiuGLWLkgIRlYl6poyhLIMi3YiqHV7BG39CjSfmVLhS566c/ZN J8IDP57SJXZqPkbwqakk7b3praA4E5FrX5Tozttyie0OKsB/TZDs1eTHzP7e5RKzs5bh A/fQKCql0KTEe06BU7vgNBua++oz+F0/15j6zsq7xyGqVxPR07+9trzJ80+dvsevWPsm sEyl4zT9BK7h7Z5N5OCevTKWVyohIGLVxIfrapiEsJO0P4A1JvcTJuNGIXB0Rk2j3z1g au/gjomeYvnp2Ft2HROhPRa5xBA4hxjUfb5i0UlB1LBZJG/b3zZzI0Su1JSylddD7Pf7 8N1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JyrFiSTj; 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-121411-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121411-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. [147.75.199.223]) by mx.google.com with ESMTPS id n8-20020a05620a222800b0078a0e622dbdsi9882329qkh.599.2024.03.27.08.00.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:00:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121411-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JyrFiSTj; 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-121411-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121411-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 546241C2F22D for ; Wed, 27 Mar 2024 15:00:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 929B913DBB2; Wed, 27 Mar 2024 14:13:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JyrFiSTj" 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 DB41E12E1FB for ; Wed, 27 Mar 2024 14:13:33 +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=1711548815; cv=none; b=oyrCtKRQq7h5U4sc2NJDtGY+A3AzJhaC2pLSkshycMilvHEq58TasdNPfaRhpsKjQ9PMrwYDXXhiyx9IBVUYnQGRsJm/kCFh3FfTUEhL8wZmzT4oVohxnI3916M5N8bTtsAOMVRqcnyPACsAIvQkOJplgI/0ZFxkhCR2MHKDa14= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711548815; c=relaxed/simple; bh=7stkxD8LcUkgd6MZgtGDEXBV8+4CKxCvxSZFtRvHSQ8=; h=From:To:cc:Subject:MIME-Version:Content-Type:Date:Message-ID; b=ZDKJAylO/tj/Ds/Hc+aw4HW05rRdVUq2WAvP8C8KiZUKnGlGueGd1R+waE6jlhZVwOZYNwF2c+SC0PVtYEm9pTB67XiaeUELO8h15w+gNppukeavO1TLim9w5m1aL5f3juTCKvgZWge5nOwmPYLZSKZZ8hAsh3hbtXH9NTk0MTU= 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=JyrFiSTj; 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=1711548812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Qut9wqKpTNwmM2gET59mhKtRBrovobZzNxOyH6sbgc8=; b=JyrFiSTjW6iAAvHn41oDKpbdfcMolebdLuZVQ89CCN9aI+m3kAD6EqhFN8gvpcvXojp3/s PyiJctclzUw2lhwiBC9eg685l4ivnRvK80wZGVACGliyrZQ67JoDbfdJIDU6YByhh7fzbs R2QOujetqTkMHcETdoUrPaxdQ1UnTos= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-10nbk4m5PIa1cEig9JI9nw-1; Wed, 27 Mar 2024 10:13:31 -0400 X-MC-Unique: 10nbk4m5PIa1cEig9JI9nw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 7EDB928000A0; Wed, 27 Mar 2024 14:13:30 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CA0D492BC8; Wed, 27 Mar 2024 14:13:28 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells To: Steve French cc: dhowells@redhat.com, Shyam Prasad N , Rohith Surabattula , Jeff Layton , Christian Brauner , linux-cifs@vger.kernel.org, netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cifs: Fix duplicate fscache cookie warnings Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2305514.1711548804.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Wed, 27 Mar 2024 14:13:24 +0000 Message-ID: <2305515.1711548804@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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() t= o 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_fi= nd_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_tc= on *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 =3D CIFS_I(inode); struct cifs_sb_info *cifs_sb =3D CIFS_SB(inode->i_sb); struct cifs_tcon *tcon =3D cifs_sb_master_tcon(cifs_sb); = + key.uniqueid =3D cpu_to_le64(cifsi->uniqueid); + key.createtime =3D cpu_to_le64(cifsi->createtime); + key.type =3D (inode->i_mode & S_IFMT) >> 12; cifs_fscache_fill_coherency(&cifsi->netfs.inode, &cd); = cifsi->netfs.cache =3D 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 =3D 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 !=3D fattr->cf_uniqueid) return 0;