]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.1/cifs-fix-duplicate-fscache-cookie-warnings.patch
6.1-stable patches
[thirdparty/kernel/stable-queue.git] / queue-6.1 / cifs-fix-duplicate-fscache-cookie-warnings.patch
1 From e6e043fea89745690850cc98f6f0cd8d49c1a180 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Wed, 27 Mar 2024 14:13:24 +0000
4 Subject: cifs: Fix duplicate fscache cookie warnings
5
6 From: David Howells <dhowells@redhat.com>
7
8 [ Upstream commit 8876a37277cb832e1861c35f8c661825179f73f5 ]
9
10 fscache emits a lot of duplicate cookie warnings with cifs because the
11 index key for the fscache cookies does not include everything that the
12 cifs_find_inode() function does. The latter is used with iget5_locked() to
13 distinguish between inodes in the local inode cache.
14
15 Fix this by adding the creation time and file type to the fscache cookie
16 key.
17
18 Additionally, add a couple of comments to note that if one is changed the
19 other must be also.
20
21 Signed-off-by: David Howells <dhowells@redhat.com>
22 Fixes: 70431bfd825d ("cifs: Support fscache indexing rewrite")
23 cc: Shyam Prasad N <nspmangalore@gmail.com>
24 cc: Rohith Surabattula <rohiths.msft@gmail.com>
25 cc: Jeff Layton <jlayton@kernel.org>
26 cc: linux-cifs@vger.kernel.org
27 cc: netfs@lists.linux.dev
28 cc: linux-fsdevel@vger.kernel.org
29 Signed-off-by: Steve French <stfrench@microsoft.com>
30 Signed-off-by: Sasha Levin <sashal@kernel.org>
31 ---
32 fs/smb/client/fscache.c | 16 +++++++++++++++-
33 fs/smb/client/inode.c | 2 ++
34 2 files changed, 17 insertions(+), 1 deletion(-)
35
36 diff --git a/fs/smb/client/fscache.c b/fs/smb/client/fscache.c
37 index f64bad513ba6d..6df4ab2a6e5dc 100644
38 --- a/fs/smb/client/fscache.c
39 +++ b/fs/smb/client/fscache.c
40 @@ -12,6 +12,16 @@
41 #include "cifs_fs_sb.h"
42 #include "cifsproto.h"
43
44 +/*
45 + * Key for fscache inode. [!] Contents must match comparisons in cifs_find_inode().
46 + */
47 +struct cifs_fscache_inode_key {
48 +
49 + __le64 uniqueid; /* server inode number */
50 + __le64 createtime; /* creation time on server */
51 + u8 type; /* S_IFMT file type */
52 +} __packed;
53 +
54 static void cifs_fscache_fill_volume_coherency(
55 struct cifs_tcon *tcon,
56 struct cifs_fscache_volume_coherency_data *cd)
57 @@ -97,15 +107,19 @@ void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon)
58 void cifs_fscache_get_inode_cookie(struct inode *inode)
59 {
60 struct cifs_fscache_inode_coherency_data cd;
61 + struct cifs_fscache_inode_key key;
62 struct cifsInodeInfo *cifsi = CIFS_I(inode);
63 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
64 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
65
66 + key.uniqueid = cpu_to_le64(cifsi->uniqueid);
67 + key.createtime = cpu_to_le64(cifsi->createtime);
68 + key.type = (inode->i_mode & S_IFMT) >> 12;
69 cifs_fscache_fill_coherency(&cifsi->netfs.inode, &cd);
70
71 cifsi->netfs.cache =
72 fscache_acquire_cookie(tcon->fscache, 0,
73 - &cifsi->uniqueid, sizeof(cifsi->uniqueid),
74 + &key, sizeof(key),
75 &cd, sizeof(cd),
76 i_size_read(&cifsi->netfs.inode));
77 if (cifsi->netfs.cache)
78 diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
79 index 5343898bac8a6..634f28f0d331e 100644
80 --- a/fs/smb/client/inode.c
81 +++ b/fs/smb/client/inode.c
82 @@ -1274,6 +1274,8 @@ cifs_find_inode(struct inode *inode, void *opaque)
83 {
84 struct cifs_fattr *fattr = opaque;
85
86 + /* [!] The compared values must be the same in struct cifs_fscache_inode_key. */
87 +
88 /* don't match inode with different uniqueid */
89 if (CIFS_I(inode)->uniqueid != fattr->cf_uniqueid)
90 return 0;
91 --
92 2.43.0
93