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>
This commit is contained in:
Steve French 2020-06-05 17:19:46 -05:00
parent 3803d5e4d3
commit 5865985416
3 changed files with 26 additions and 9 deletions

View File

@ -53,13 +53,6 @@ const struct fscache_cookie_def cifs_fscache_server_index_def = {
.type = FSCACHE_COOKIE_TYPE_INDEX, .type = FSCACHE_COOKIE_TYPE_INDEX,
}; };
/*
* Auxiliary data attached to CIFS superblock within the cache
*/
struct cifs_fscache_super_auxdata {
u64 resource_id; /* unique server resource id */
};
char *extract_sharename(const char *treename) char *extract_sharename(const char *treename)
{ {
const char *src; const char *src;
@ -98,6 +91,8 @@ fscache_checkaux cifs_fscache_super_check_aux(void *cookie_netfs_data,
memset(&auxdata, 0, sizeof(auxdata)); memset(&auxdata, 0, sizeof(auxdata));
auxdata.resource_id = tcon->resource_id; auxdata.resource_id = tcon->resource_id;
auxdata.vol_create_time = tcon->vol_create_time;
auxdata.vol_serial_number = tcon->vol_serial_number;
if (memcmp(data, &auxdata, datalen) != 0) if (memcmp(data, &auxdata, datalen) != 0)
return FSCACHE_CHECKAUX_OBSOLETE; return FSCACHE_CHECKAUX_OBSOLETE;

View File

@ -96,6 +96,7 @@ void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
{ {
struct TCP_Server_Info *server = tcon->ses->server; struct TCP_Server_Info *server = tcon->ses->server;
char *sharename; char *sharename;
struct cifs_fscache_super_auxdata auxdata;
sharename = extract_sharename(tcon->treeName); sharename = extract_sharename(tcon->treeName);
if (IS_ERR(sharename)) { if (IS_ERR(sharename)) {
@ -104,11 +105,16 @@ void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
return; return;
} }
memset(&auxdata, 0, sizeof(auxdata));
auxdata.resource_id = tcon->resource_id;
auxdata.vol_create_time = tcon->vol_create_time;
auxdata.vol_serial_number = tcon->vol_serial_number;
tcon->fscache = tcon->fscache =
fscache_acquire_cookie(server->fscache, fscache_acquire_cookie(server->fscache,
&cifs_fscache_super_index_def, &cifs_fscache_super_index_def,
sharename, strlen(sharename), sharename, strlen(sharename),
&tcon->resource_id, sizeof(tcon->resource_id), &auxdata, sizeof(auxdata),
tcon, 0, true); tcon, 0, true);
kfree(sharename); kfree(sharename);
cifs_dbg(FYI, "%s: (0x%p/0x%p)\n", cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",
@ -117,8 +123,15 @@ void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon) void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon)
{ {
struct cifs_fscache_super_auxdata auxdata;
memset(&auxdata, 0, sizeof(auxdata));
auxdata.resource_id = tcon->resource_id;
auxdata.vol_create_time = tcon->vol_create_time;
auxdata.vol_serial_number = tcon->vol_serial_number;
cifs_dbg(FYI, "%s: (0x%p)\n", __func__, tcon->fscache); cifs_dbg(FYI, "%s: (0x%p)\n", __func__, tcon->fscache);
fscache_relinquish_cookie(tcon->fscache, &tcon->resource_id, false); fscache_relinquish_cookie(tcon->fscache, &auxdata, false);
tcon->fscache = NULL; tcon->fscache = NULL;
} }

View File

@ -27,6 +27,15 @@
#ifdef CONFIG_CIFS_FSCACHE #ifdef CONFIG_CIFS_FSCACHE
/*
* Auxiliary data attached to CIFS superblock within the cache
*/
struct cifs_fscache_super_auxdata {
u64 resource_id; /* unique server resource id */
__le64 vol_create_time;
u32 vol_serial_number;
} __packed;
/* /*
* Auxiliary data attached to CIFS inode within the cache * Auxiliary data attached to CIFS inode within the cache
*/ */