Skip to content

Commit 5865985

Browse files
committed
smb3: extend fscache mount volume coherency check
It is better to check volume id and creation time, not just the root inode number to verify if the volume has changed when remounting. Reviewed-by: David Howells <dhowells@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 3803d5e commit 5865985

3 files changed

Lines changed: 26 additions & 9 deletions

File tree

fs/cifs/cache.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ const struct fscache_cookie_def cifs_fscache_server_index_def = {
5353
.type = FSCACHE_COOKIE_TYPE_INDEX,
5454
};
5555

56-
/*
57-
* Auxiliary data attached to CIFS superblock within the cache
58-
*/
59-
struct cifs_fscache_super_auxdata {
60-
u64 resource_id; /* unique server resource id */
61-
};
62-
6356
char *extract_sharename(const char *treename)
6457
{
6558
const char *src;
@@ -98,6 +91,8 @@ fscache_checkaux cifs_fscache_super_check_aux(void *cookie_netfs_data,
9891

9992
memset(&auxdata, 0, sizeof(auxdata));
10093
auxdata.resource_id = tcon->resource_id;
94+
auxdata.vol_create_time = tcon->vol_create_time;
95+
auxdata.vol_serial_number = tcon->vol_serial_number;
10196

10297
if (memcmp(data, &auxdata, datalen) != 0)
10398
return FSCACHE_CHECKAUX_OBSOLETE;

fs/cifs/fscache.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
9696
{
9797
struct TCP_Server_Info *server = tcon->ses->server;
9898
char *sharename;
99+
struct cifs_fscache_super_auxdata auxdata;
99100

100101
sharename = extract_sharename(tcon->treeName);
101102
if (IS_ERR(sharename)) {
@@ -104,11 +105,16 @@ void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
104105
return;
105106
}
106107

108+
memset(&auxdata, 0, sizeof(auxdata));
109+
auxdata.resource_id = tcon->resource_id;
110+
auxdata.vol_create_time = tcon->vol_create_time;
111+
auxdata.vol_serial_number = tcon->vol_serial_number;
112+
107113
tcon->fscache =
108114
fscache_acquire_cookie(server->fscache,
109115
&cifs_fscache_super_index_def,
110116
sharename, strlen(sharename),
111-
&tcon->resource_id, sizeof(tcon->resource_id),
117+
&auxdata, sizeof(auxdata),
112118
tcon, 0, true);
113119
kfree(sharename);
114120
cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",
@@ -117,8 +123,15 @@ void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
117123

118124
void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon)
119125
{
126+
struct cifs_fscache_super_auxdata auxdata;
127+
128+
memset(&auxdata, 0, sizeof(auxdata));
129+
auxdata.resource_id = tcon->resource_id;
130+
auxdata.vol_create_time = tcon->vol_create_time;
131+
auxdata.vol_serial_number = tcon->vol_serial_number;
132+
120133
cifs_dbg(FYI, "%s: (0x%p)\n", __func__, tcon->fscache);
121-
fscache_relinquish_cookie(tcon->fscache, &tcon->resource_id, false);
134+
fscache_relinquish_cookie(tcon->fscache, &auxdata, false);
122135
tcon->fscache = NULL;
123136
}
124137

fs/cifs/fscache.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727

2828
#ifdef CONFIG_CIFS_FSCACHE
2929

30+
/*
31+
* Auxiliary data attached to CIFS superblock within the cache
32+
*/
33+
struct cifs_fscache_super_auxdata {
34+
u64 resource_id; /* unique server resource id */
35+
__le64 vol_create_time;
36+
u32 vol_serial_number;
37+
} __packed;
38+
3039
/*
3140
* Auxiliary data attached to CIFS inode within the cache
3241
*/

0 commit comments

Comments
 (0)