smb3: do not setup the fscache_super_cookie until fsinfo initialized
authorSteve French <stfrench@microsoft.com>
Wed, 10 Nov 2021 09:15:29 +0000 (03:15 -0600)
committerSteve French <stfrench@microsoft.com>
Mon, 7 Feb 2022 21:47:59 +0000 (15:47 -0600)
We were calling cifs_fscache_get_super_cookie after tcon but before
we queried the info (QFS_Info) we need to initialize the cookie
properly.  Also includes an additional check suggested by Paulo
to make sure we don't initialize super cookie twice.

Suggested-by: David Howells <dhowells@redhat.com>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/connect.c
fs/cifs/fscache.c

index 5c506f6ecd65edd9ede4abc53ee6d68fff6d5e9b..084605f7ce966f7b6414807f66eb3371883ef45d 100644 (file)
@@ -2350,8 +2350,6 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
        list_add(&tcon->tcon_list, &ses->tcon_list);
        spin_unlock(&cifs_tcp_ses_lock);
 
-       cifs_fscache_get_super_cookie(tcon);
-
        return tcon;
 
 out_fail:
@@ -3003,6 +3001,12 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx)
                                cifs_dbg(VFS, "read only mount of RW share\n");
                        /* no need to log a RW mount of a typical RW share */
                }
+               /*
+                * The cookie is initialized from volume info returned above.
+                * Inside cifs_fscache_get_super_cookie it checks
+                * that we do not get super cookie twice.
+                */
+               cifs_fscache_get_super_cookie(tcon);
        }
 
        /*
index 8eedd20c44abdefa0f9155a8713469030800198e..7e409a38a2d7c184abf3ab0c1afbea2ccbfe9f6f 100644 (file)
@@ -87,6 +87,14 @@ void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
        char *sharename;
        struct cifs_fscache_super_auxdata auxdata;
 
+       /*
+        * Check if cookie was already initialized so don't reinitialize it.
+        * In the future, as we integrate with newer fscache features,
+        * we may want to instead add a check if cookie has changed
+        */
+       if (tcon->fscache == NULL)
+               return;
+
        sharename = extract_sharename(tcon->treeName);
        if (IS_ERR(sharename)) {
                cifs_dbg(FYI, "%s: couldn't extract sharename\n", __func__);