How to fix VFS: cifs_mount failed w/return code = -22


When trying to mount a CIFS/SMB share, you see the following error log in dmesg:

[  139.680974] CIFS: Attempting to mount \\\test
[  139.686714] CIFS: VFS: cifs_mount failed w/return code = -22


This is a currently a bug in Samba or the Kernel but you can easily work around it by adding vers=2.0to the mount options, either in /etc/fstab or if using mount manually, by using the -o vers=2.0 option. This forces Samba to use SMB version 2.0 which does not have the bug.