Skip to content

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

Open
@riobard

Description

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!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions