Bug 208775

Summary: CIFS: fallocate can't change file system disk space usage
Product: File System Reporter: Xiaoli Feng (fengxiaoli0714)
Component: CIFSAssignee: fs_cifs (fs_cifs)
Status: RESOLVED WILL_NOT_FIX    
Severity: normal CC: smfrench
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 5.8.0-rc7+ Subsystem:
Regression: No Bisected commit-id:

Description Xiaoli Feng 2020-08-03 02:13:54 UTC
Samba server and client are on the same host. Mount the samba share with the option "-o user=root,password=$testPasswd,cache=none". Use "df -h" to check the space usage. Then use fallocate to preallocate 1G file. Finally use df to check again the space usage. But it doesn't change. Test xfs filesystem. fallocate can change the space usage.

# cat /etc/samba/smb.conf
[cifs]
path=/mnt/cifs
writeable=yes
# mount //localhost/cifs cifs -o user=root,password=redhat,cache=none,actimeo=0
# df -h cifs
Filesystem        Size  Used Avail Use% Mounted on
//localhost/cifs   36G   23G   13G  66% /root/cifs
#  fallocate -o 0 -l 2g /root/cifs/file1
# df -h cifs
Filesystem        Size  Used Avail Use% Mounted on
//localhost/cifs   36G   23G   13G  66% /root/cifs

Test xfs filesystem.
# mount -o loop /home/xfs.img  xfs
# df -h xfs
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0     1014M   40M  975M   4% /root/xfs
# fallocate -o 0 -l 200M xfs/file
# df -h xfs
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0     1014M  240M  775M  24% /root/xfs
Comment 1 Steve French 2020-08-03 22:27:22 UTC
There is a probably Samba server bug here - since it didn't mark the file as a sparse file (so we in the client can't know to unsparse it to fix this) but ... the easiest way to fix this is to use a recommended Samba server config setting for xfs/btrfs/ext4 which is "strict allocate = yes" in the server's smb.conf file.

When I tried with that update to smb.conf - seems to work fine.
Comment 2 Xiaoli Feng 2021-08-30 03:00:42 UTC
close it by comment 1.