I just ran into this exact error.
I believe it is related to
https://bugs.freenas.org/issues/4174
Recursively setting permissions or ownership on volumes that contain system datasets; specifically <volume name>/.samba4
The following fixed the issue for me:
Find and destroy the .samba4 dataset (mine is on 'volume1'):
- Select 'shell' ### or ssh, putty, etc
- execute the following commands
[root@flatline ~]# zfs list | grep .samba4
volume1/.samba4 2.61M 545G 2.61M /mnt/volume1/.samba4
[root@flatline ~]# zfs destroy volume1/.samba4
[root@flatline ~]# rm /var/db/samba4
- Restart CIFS
Select 'Services'
Toggle cifs to 'on' position
cifs should now be up and you should be able to access your shares again.
One can reproduce the failure scenario by the following:
Select 'Storage'
Select volume containing the '.samba4' dataset ### use zfs list to determine which volume; I think it defaults to the first volume
Select 'Change Permissions'
Change 'Owner (group)' to 'mail'
Change 'Type of ACL' to 'Unix' ### if it wasn't already
Check 'Set permission recursively'
Click 'change'
Select 'Services'
Toggle cifs to 'off' position
Toggle cifs to 'on' position ### this did not succeed for me and resulted in the same error as this bug description
The error also occurs when recursively changing the mode or owner (user) of the volume containing the .samba4 dataset such that the sanity check fails.
One could arguably try to set the permissions, user, group, etc of .samba4 and its children back to their original values, but i found just destroying
the dataset and deleting the symlink much easier.