Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 8876a37

Browse files
dhowellsSteve French
authored andcommitted
cifs: Fix duplicate fscache cookie warnings
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 <dhowells@redhat.com> Fixes: 70431bf ("cifs: Support fscache indexing rewrite") cc: Shyam Prasad N <nspmangalore@gmail.com> cc: Rohith Surabattula <rohiths.msft@gmail.com> cc: Jeff Layton <jlayton@kernel.org> cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent e9e9fbe commit 8876a37

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

fs/smb/client/fscache.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
#include "cifs_fs_sb.h"
1313
#include "cifsproto.h"
1414

15+
/*
16+
* Key for fscache inode. [!] Contents must match comparisons in cifs_find_inode().
17+
*/
18+
struct cifs_fscache_inode_key {
19+
20+
__le64 uniqueid; /* server inode number */
21+
__le64 createtime; /* creation time on server */
22+
u8 type; /* S_IFMT file type */
23+
} __packed;
24+
1525
static void cifs_fscache_fill_volume_coherency(
1626
struct cifs_tcon *tcon,
1727
struct cifs_fscache_volume_coherency_data *cd)
@@ -97,15 +107,19 @@ void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon)
97107
void cifs_fscache_get_inode_cookie(struct inode *inode)
98108
{
99109
struct cifs_fscache_inode_coherency_data cd;
110+
struct cifs_fscache_inode_key key;
100111
struct cifsInodeInfo *cifsi = CIFS_I(inode);
101112
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
102113
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
103114

115+
key.uniqueid = cpu_to_le64(cifsi->uniqueid);
116+
key.createtime = cpu_to_le64(cifsi->createtime);
117+
key.type = (inode->i_mode & S_IFMT) >> 12;
104118
cifs_fscache_fill_coherency(&cifsi->netfs.inode, &cd);
105119

106120
cifsi->netfs.cache =
107121
fscache_acquire_cookie(tcon->fscache, 0,
108-
&cifsi->uniqueid, sizeof(cifsi->uniqueid),
122+
&key, sizeof(key),
109123
&cd, sizeof(cd),
110124
i_size_read(&cifsi->netfs.inode));
111125
if (cifsi->netfs.cache)

fs/smb/client/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,8 @@ cifs_find_inode(struct inode *inode, void *opaque)
13511351
{
13521352
struct cifs_fattr *fattr = opaque;
13531353

1354+
/* [!] The compared values must be the same in struct cifs_fscache_inode_key. */
1355+
13541356
/* don't match inode with different uniqueid */
13551357
if (CIFS_I(inode)->uniqueid != fattr->cf_uniqueid)
13561358
return 0;

0 commit comments

Comments
 (0)