Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btrfs: Directories in subvolumes appear as files on SMB client #596

Open
riobard opened this issue Jul 30, 2023 · 3 comments
Open

btrfs: Directories in subvolumes appear as files on SMB client #596

riobard opened this issue Jul 30, 2023 · 3 comments

Comments

@riobard
Copy link

riobard commented Jul 30, 2023

Symptom

Some (not all) directories in btrfs subvolumes on ksmbd servers appear as files when mounted over SMB on Windows and macOS clients.

On ksmbd server

# cat /etc/ksmbd/ksmbd.conf
[global]
	guest account = nobody
	map to guest = never
	server min protocol = SMB3
	smb3 encryption = mandatory

[Public]
	path = /mnt/raid/shares/Public
	guest ok = yes

[root]
	path = /
	read only = yes
# ls -lh /mnt/raid/shares/Public
drwxr-sr-x 1 smbuser  smbuser 1.3K Jul 22 01:21  Dir1
drwxr-sr-x 1 smbuser  smbuser 1.1K Jan 30  2022  Dir2

Note that the leading d indicates both Dir1 and Dir2 are (real) directories, however their parent /mnt/raid/shares/Public and grandparent /mnt/raid/shares are both btrfs subvolumes. The root of the btrfs filesystem is mounted at /mnt/raid.

# btrfs subvolume list /mnt/raid
ID 32501 gen 3395407 top level 5 path shares
ID 52405 gen 3483274 top level 32501 path shares/Public

On Windows/macOS client after mounting the share over SMB3, Dir2 somehow becomes a file, e.g. on macOS

% ls -lh /Volumes/Public
drwx------  1 test  staff    16K Jul 22 01:21 Dir1
-rwx------  1 test  staff     0B Jan 30  2022 Dir2

Note the missing leading d for Dir2. Additionally on macOS, attempting to list /Volumes/root/mnt/raid causes Terminal.app to stuck and Finder.app to beachball (application not responding).

None of the above happens with Samba server.

Environment

  • Server: tested on Debian 12 and Alpine 3.18
  • Client: tested on Windows 10 and macOS 13.5

Related

#556 looks related and also involves btrfs subvolumes, but its symptom is different from this one.

https://lwn.net/Articles/866582/ might give some clues but I don't really understand the underlying mechanisms.

Please let me know how I could further investigate and provide additional information to pinpoint the root cause.

Thanks very much!

@namjaejeon
Copy link
Member

If you could simply tell me how to configure the btrfs subvolume, it would be very helpful for me to quickly reproduce this problem.

@riobard
Copy link
Author

riobard commented Jul 31, 2023

You could find many tutorials online to setup btrfs filesystem and subvolumes, e.g. https://linuxhint.com/create-mount-btrfs-subvolumes/

The difficult part is that I'm unable to reliably reproduce the behavior. The directory-shown-as-file symptom seems a result of interaction between btrfs subvolumes with snapshots and ksmbd (recall that samba does not have this problem), but I cannot just create new directories to reproduce the symptom (though existing problematic directories can reliably be shown as files on clients). It might have something to do with non-unique inode numbers as the article (https://lwn.net/Articles/866582/) suggests, or it might be some other problems.

I was hoping you could provide me some directions or tools to further investigate, as the issue seems pretty intricate to trigger.

@namjaejeon
Copy link
Member

Okay. Let me check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants