namjaejeon / ksmbd

ksmbd kernel server(SMB/CIFS server)
https://github.com/cifsd-team/ksmbd
270 stars 62 forks source link

ksmbd detect disk space incorrect #400

Open ptpt52 opened 2 years ago

ptpt52 commented 2 years ago

step to produce the issue:

mkdir /mnt
# mount tmpfs with size limit on 1MB on /mnt
mount -o size=1M -t tmpfs tmpfs /mnt

mkdir /mnt/sda4
mount -t ext4 /dev/sda4 /mnt/sda4
chmod 777 /mnt/sda4

smb config:

[mnt]
    path = /mnt
    create mask = 0666
    directory mask = 0777
    read only = no
    guest ok = yes

disk part sda4 size is 64GB and then I open \\192.168.16.1\mnt in windows 11 copy one 1GB-big-file to \\192.168.16.1\mnt\sda4\

then it displays no space enough error.

namjaejeon commented 2 years ago

Windows is checking disk space before writing file. but mount point is tmpfs(1MB size), not ext4(64GB). Same error will happen with samba server. Are there any other smb servers that don't have this problem?

ptpt52 commented 2 years ago

@namjaejeon could you tell me where to report the disk size to windows client? I prefer change something here to report all directories cap disksize instead of the root dir only this may be an workaroud for this issue

namjaejeon commented 2 years ago

could you tell me where to report the disk size to windows client?

ksmbd report disk size of root share to windows client.

I prefer change something here to report all directories cap disksize instead of the root dir only

Sorry, Impossible. If we have tens of thousands of directories in share, the cost of a directory lookup is too high whenever be called from statfs.

ptpt52 commented 2 years ago

@namjaejeon could we provide an fake option? say, fake return an config size to windows, this could be setup by manual

fake disksize = 1TB
namjaejeon commented 2 years ago

@ptpt52 Sorry, I can't. Because this option will cause other issues. I think that you need it for auto usb mount directory in tmpfs. right ? You need to add new share using ksmbd.addshare whenever plugging usb storage.