smb/server: implement compression fattr handler
Subsystems (2)
[email protected]
reviewerv4 cover smb/server: implement compression fattr handler
From: ChenXiaoSong <[email protected]>
v3->v4: use min(stat.size, stat.blocks << 9) as the compressed file size.
v3: https://lore.kernel.org/linux-cifs/[email protected]/
The following patches from v3 have already been merged into ksmbd.git ksmbd-for-next-next:
- smb/server: get compression format in get_file_compression_info()
- smb/server: implement FSCTL_SET_COMPRESSION ioctl handler
- smb/server: implement FSCTL_GET_COMPRESSION ioctl handler
- smb/server: get compression file attribute on open
- smb: move compression definitions into common/fscc.h
- smb: remove duplicate server/smbfsctl.h
ChenXiaoSong (1):
smb/server: fix incorrect file size in get_file_compression_info()
fs/smb/server/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.54.0
[email protected]
reviewerPATCH v4 1/1 smb/server: fix incorrect file size in get_file_compression_info()
From: ChenXiaoSong <[email protected]>
Before this patch, we got the wrong file size:
- client: touch /mnt/file
- client: smbinfo setcompression default /mnt/file
- client: dd if=/dev/zero of=/mnt/file bs=1 count=1000
- client: smbinfo filecompressioninfo /mnt/file Compressed File Size: 4096 Compression Format: 2 (LZNT1)
After this patch, we get the correct file size:
- client: smbinfo filecompressioninfo /mnt/file
Compressed File Size: 1000
Compression Format: 2 (LZNT1)
Note that the actual compressed file size must be got by other methods. For Btrfs, use the following command to get actual compressed file size:
- server: compsize /export/file
Processed 1 file, 0 regular extents (0 refs), 1 inline.
Type Perc Disk Usage Uncompressed Referenced
TOTAL 4% 47B 1000B 1000B
zlib 4% 47B 1000B 1000B
--- fs/smb/server/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +1 -1
@@ -5291,7 +5291,7 @@ static int get_file_compression_info(struct smb2_query_info_rsp *rsp,return ret; file_info = (struct smb2_file_comp_info *)rsp->Buffer; - file_info->CompressedFileSize =cpu_to_le64 (stat.blocks <<9 ); + file_info->CompressedFileSize =cpu_to_le64 (min_t (u64, stat.blocks <<9 , stat.size)); file_info->CompressionFormat =cpu_to_le16 (fmt); file_info->CompressionUnitShift =0 ; file_info->ChunkShift =0 ;
Signature · 1 line
2.54.0
Re: [PATCH v4 1/1] smb/server: fix incorrect file size in get_file_compression_info()
Quoted 21 lines · On Tue, Jun 9, 2026 at 3:11 PM <[email protected]> wrote:
From: ChenXiaoSong <[email protected]>
Before this patch, we got the wrong file size:
- client: touch
/mnt/file
- client: smbinfo setcompression default/mnt/file
- client: dd if=/dev/zero of=/mnt/file bs=1 count=1000
- client: smbinfo filecompressioninfo/mnt/fileCompressed File Size: 4096 Compression Format: 2 (LZNT1)After this patch, we get the correct file size:
- client: smbinfo filecompressioninfo
/mnt/file
Compressed File Size: 1000
Compression Format: 2 (LZNT1)Note that the actual compressed file size must be got by other methods. For Btrfs, use the following command to get actual compressed file size:
Quoted 7 lines
- server: compsize /export/file
Processed 1 file, 0 regular extents (0 refs), 1 inline.
Type Perc Disk Usage Uncompressed Referenced
TOTAL 4% 47B 1000B 1000B
zlib 4% 47B 1000B 1000BSigned-off-by ChenXiaoSong <[email protected]>
Applied it to #ksmbd-for-next-next.
Thanks!