cifs: serialize all mount attempts
[linux-block.git] / fs / cifs / fs_context.c
index e3ed25dc6f3f6c4225273b5fe8839d9be3545433..7ec35f3f0a5fcb20d874e616b2bbf75dc8322d56 100644 (file)
@@ -37,6 +37,8 @@
 #include "rfc1002pdu.h"
 #include "fs_context.h"
 
+static DEFINE_MUTEX(cifs_mount_mutex);
+
 static const match_table_t cifs_smb_version_tokens = {
        { Smb_1, SMB1_VERSION_STRING },
        { Smb_20, SMB20_VERSION_STRING},
@@ -707,10 +709,14 @@ static int smb3_get_tree_common(struct fs_context *fc)
 static int smb3_get_tree(struct fs_context *fc)
 {
        int err = smb3_fs_context_validate(fc);
+       int ret;
 
        if (err)
                return err;
-       return smb3_get_tree_common(fc);
+       mutex_lock(&cifs_mount_mutex);
+       ret = smb3_get_tree_common(fc);
+       mutex_unlock(&cifs_mount_mutex);
+       return ret;
 }
 
 static void smb3_fs_context_free(struct fs_context *fc)