~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/smb/client/compress.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/smb/client/compress.h (Architecture sparc64) and /fs/smb/client/compress.h (Architecture alpha)


  1 /* SPDX-License-Identifier: GPL-2.0-only */         1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*                                                  2 /*
  3  * Copyright (C) 2024, SUSE LLC                     3  * Copyright (C) 2024, SUSE LLC
  4  *                                                  4  *
  5  * Authors: Enzo Matsumiya <ematsumiya@suse.de      5  * Authors: Enzo Matsumiya <ematsumiya@suse.de>
  6  *                                                  6  *
  7  * This file implements I/O compression suppor      7  * This file implements I/O compression support for SMB2 messages (SMB 3.1.1 only).
  8  * See compress/ for implementation details of      8  * See compress/ for implementation details of each algorithm.
  9  *                                                  9  *
 10  * References:                                     10  * References:
 11  * MS-SMB2 "3.1.4.4 Compressing the Message" -     11  * MS-SMB2 "3.1.4.4 Compressing the Message" - for compression details
 12  * MS-SMB2 "3.1.5.3 Decompressing the Chained      12  * MS-SMB2 "3.1.5.3 Decompressing the Chained Message" - for decompression details
 13  * MS-XCA - for details of the supported algor     13  * MS-XCA - for details of the supported algorithms
 14  */                                                14  */
 15 #ifndef _SMB_COMPRESS_H                            15 #ifndef _SMB_COMPRESS_H
 16 #define _SMB_COMPRESS_H                            16 #define _SMB_COMPRESS_H
 17                                                    17 
 18 #include <linux/uio.h>                             18 #include <linux/uio.h>
 19 #include <linux/kernel.h>                          19 #include <linux/kernel.h>
 20 #include "../common/smb2pdu.h"                     20 #include "../common/smb2pdu.h"
 21 #include "cifsglob.h"                              21 #include "cifsglob.h"
 22                                                    22 
 23 /* sizeof(smb2_compression_hdr) - sizeof(Origi     23 /* sizeof(smb2_compression_hdr) - sizeof(OriginalPayloadSize) */
 24 #define SMB_COMPRESS_HDR_LEN            16         24 #define SMB_COMPRESS_HDR_LEN            16
 25 /* sizeof(smb2_compression_payload_hdr) - size     25 /* sizeof(smb2_compression_payload_hdr) - sizeof(OriginalPayloadSize) */
 26 #define SMB_COMPRESS_PAYLOAD_HDR_LEN    8          26 #define SMB_COMPRESS_PAYLOAD_HDR_LEN    8
 27 #define SMB_COMPRESS_MIN_LEN            PAGE_S     27 #define SMB_COMPRESS_MIN_LEN            PAGE_SIZE
 28                                                    28 
 29 #ifdef CONFIG_CIFS_COMPRESSION                     29 #ifdef CONFIG_CIFS_COMPRESSION
 30 typedef int (*compress_send_fn)(struct TCP_Ser     30 typedef int (*compress_send_fn)(struct TCP_Server_Info *, int, struct smb_rqst *);
 31                                                    31 
 32 int smb_compress(struct TCP_Server_Info *serve     32 int smb_compress(struct TCP_Server_Info *server, struct smb_rqst *rq, compress_send_fn send_fn);
 33                                                    33 
 34 /**                                                34 /**
 35  * should_compress() - Determines if a request     35  * should_compress() - Determines if a request (write) or the response to a
 36  *                     request (read) should b     36  *                     request (read) should be compressed.
 37  * @tcon: tcon of the request is being sent to     37  * @tcon: tcon of the request is being sent to
 38  * @rqst: request to evaluate                      38  * @rqst: request to evaluate
 39  *                                                 39  *
 40  * Return: true iff:                               40  * Return: true iff:
 41  * - compression was successfully negotiated w     41  * - compression was successfully negotiated with server
 42  * - server has enabled compression for the sh     42  * - server has enabled compression for the share
 43  * - it's a read or write request                  43  * - it's a read or write request
 44  * - (write only) request length is >= SMB_COM     44  * - (write only) request length is >= SMB_COMPRESS_MIN_LEN
 45  * - (write only) is_compressible() returns 1      45  * - (write only) is_compressible() returns 1
 46  *                                                 46  *
 47  * Return false otherwise.                         47  * Return false otherwise.
 48  */                                                48  */
 49 bool should_compress(const struct cifs_tcon *t     49 bool should_compress(const struct cifs_tcon *tcon, const struct smb_rqst *rq);
 50                                                    50 
 51 /**                                                51 /**
 52  * smb_compress_alg_valid() - Validate a compr     52  * smb_compress_alg_valid() - Validate a compression algorithm.
 53  * @alg: Compression algorithm to check.           53  * @alg: Compression algorithm to check.
 54  * @valid_none: Conditional check whether NONE     54  * @valid_none: Conditional check whether NONE algorithm should be
 55  *              considered valid or not.           55  *              considered valid or not.
 56  *                                                 56  *
 57  * If @alg is SMB3_COMPRESS_NONE, this functio     57  * If @alg is SMB3_COMPRESS_NONE, this function returns @valid_none.
 58  *                                                 58  *
 59  * Note that 'NONE' (0) compressor type is con     59  * Note that 'NONE' (0) compressor type is considered invalid in protocol
 60  * negotiation, as it's never requested to/ret     60  * negotiation, as it's never requested to/returned from the server.
 61  *                                                 61  *
 62  * Return: true if @alg is valid/supported, fa     62  * Return: true if @alg is valid/supported, false otherwise.
 63  */                                                63  */
 64 static __always_inline int smb_compress_alg_va     64 static __always_inline int smb_compress_alg_valid(__le16 alg, bool valid_none)
 65 {                                                  65 {
 66         if (alg == SMB3_COMPRESS_NONE)             66         if (alg == SMB3_COMPRESS_NONE)
 67                 return valid_none;                 67                 return valid_none;
 68                                                    68 
 69         if (alg == SMB3_COMPRESS_LZ77 || alg =     69         if (alg == SMB3_COMPRESS_LZ77 || alg == SMB3_COMPRESS_PATTERN)
 70                 return true;                       70                 return true;
 71                                                    71 
 72         return false;                              72         return false;
 73 }                                                  73 }
 74 #else /* !CONFIG_CIFS_COMPRESSION */               74 #else /* !CONFIG_CIFS_COMPRESSION */
 75 static inline int smb_compress(void *unused1,      75 static inline int smb_compress(void *unused1, void *unused2, void *unused3)
 76 {                                                  76 {
 77         return -EOPNOTSUPP;                        77         return -EOPNOTSUPP;
 78 }                                                  78 }
 79                                                    79 
 80 static inline bool should_compress(void *unuse     80 static inline bool should_compress(void *unused1, void *unused2)
 81 {                                                  81 {
 82         return false;                              82         return false;
 83 }                                                  83 }
 84                                                    84 
 85 static inline int smb_compress_alg_valid(__le1     85 static inline int smb_compress_alg_valid(__le16 unused1, bool unused2)
 86 {                                                  86 {
 87         return -EOPNOTSUPP;                        87         return -EOPNOTSUPP;
 88 }                                                  88 }
 89 #endif /* !CONFIG_CIFS_COMPRESSION */              89 #endif /* !CONFIG_CIFS_COMPRESSION */
 90 #endif /* _SMB_COMPRESS_H */                       90 #endif /* _SMB_COMPRESS_H */
 91                                                    91 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php