diff options
Diffstat (limited to 'fs/smb/client/compress.h')
| -rw-r--r-- | fs/smb/client/compress.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/smb/client/compress.h b/fs/smb/client/compress.h index ffc712fae45a..c5691c1db066 100644 --- a/fs/smb/client/compress.h +++ b/fs/smb/client/compress.h @@ -25,6 +25,9 @@ /* sizeof(smb2_compression_payload_hdr) - sizeof(OriginalPayloadSize) */ #define SMB_COMPRESS_PAYLOAD_HDR_LEN 8 #define SMB_COMPRESS_MIN_LEN PAGE_SIZE +/* follows Windows implementation (as per MS-SMB2) */ +#define SMB_COMPRESS_PAYLOAD_MIN_LEN 1024 +#define SMB_COMPRESS_PATTERN_MIN_LEN 64 #define SMB_DECOMPRESS_MAX_LEN(_srv) \ (256 + SMB_COMPRESS_HDR_LEN + \ max_t(size_t, (_srv)->maxBuf, max_t(size_t, (_srv)->max_read, (_srv)->max_write))) @@ -40,7 +43,7 @@ struct smb_compress_ctx { }; #ifdef CONFIG_CIFS_COMPRESSION -int smb_compress(void *buf, const void *data, size_t *len); +int smb_compress(void *buf, const void *data, size_t *len, bool chained); int smb_decompress(const void *src, size_t src_len, void *dst, size_t *dst_len); /** @@ -113,12 +116,15 @@ static __always_inline bool should_compress(const struct cifs_tcon *tcon, const static __always_inline size_t decompressed_size(const void *buf) { const struct smb2_compression_hdr *hdr = buf; + size_t size = le32_to_cpu(hdr->OriginalCompressedSegmentSize); - return le32_to_cpu(hdr->Offset) + - le32_to_cpu(hdr->OriginalCompressedSegmentSize); + if (hdr->Flags == SMB2_COMPRESSION_FLAG_CHAINED) + size += le32_to_cpu(hdr->Offset); + + return size; } #else /* CONFIG_CIFS_COMPRESSION */ -#define smb_compress(arg1, arg2, arg3) (-EOPNOTSUPP) +#define smb_compress(arg1, arg2, arg3, arg4) (-EOPNOTSUPP) #define smb_decompress(arg1, arg2, arg3, arg4) (-EOPNOTSUPP) #define smb_compress_alg_valid(arg1, arg2) (-EOPNOTSUPP) #define should_compress(arg1, arg2) (false) |
