mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 12:21:22 -05:00
Make some preparatory cleanups prior to running a script to organise the
function declarations within the fs/smb/client/ headers. These include:
(1) Remove "inline" from the dummy cifs_proc_init/clean() functions as
they are in a .c file.
(2) Move should_compress()'s kdoc comment to the .c file and remove kdoc
markers from the comments.
(3) Rename CIFS_ALLOW_INSECURE_LEGACY in #endif comments to have CONFIG_
on the front to allow the script to recognise it.
(4) Don't let comments have bare words at the left margin as that confused
the simplistic function detection code in the script.
(5) Adjust some argument lists so that when and if the cleanup script is
run they don't end up over 100 chars.
(6) Fix a few comments to have missing '*' added or the "*/" moved to
their own lines so that checkpatch doesn't moan over the cleanup
script patch.
(7) Move struct cifs_calc_sig_ctx to cifsglob.h.
(8) Remove some __KERNEL__ conditionals.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
cc: linux-cifs@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
76 lines
2.3 KiB
C
76 lines
2.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2024, SUSE LLC
|
|
*
|
|
* Authors: Enzo Matsumiya <ematsumiya@suse.de>
|
|
*
|
|
* This file implements I/O compression support for SMB2 messages (SMB 3.1.1 only).
|
|
* See compress/ for implementation details of each algorithm.
|
|
*
|
|
* References:
|
|
* MS-SMB2 "3.1.4.4 Compressing the Message" - for compression details
|
|
* MS-SMB2 "3.1.5.3 Decompressing the Chained Message" - for decompression details
|
|
* MS-XCA - for details of the supported algorithms
|
|
*/
|
|
#ifndef _SMB_COMPRESS_H
|
|
#define _SMB_COMPRESS_H
|
|
|
|
#include <linux/uio.h>
|
|
#include <linux/kernel.h>
|
|
#include "../common/smb2pdu.h"
|
|
#include "cifsglob.h"
|
|
|
|
/* sizeof(smb2_compression_hdr) - sizeof(OriginalPayloadSize) */
|
|
#define SMB_COMPRESS_HDR_LEN 16
|
|
/* sizeof(smb2_compression_payload_hdr) - sizeof(OriginalPayloadSize) */
|
|
#define SMB_COMPRESS_PAYLOAD_HDR_LEN 8
|
|
#define SMB_COMPRESS_MIN_LEN PAGE_SIZE
|
|
|
|
#ifdef CONFIG_CIFS_COMPRESSION
|
|
typedef int (*compress_send_fn)(struct TCP_Server_Info *, int, struct smb_rqst *);
|
|
|
|
|
|
int smb_compress(struct TCP_Server_Info *server, struct smb_rqst *rq, compress_send_fn send_fn);
|
|
bool should_compress(const struct cifs_tcon *tcon, const struct smb_rqst *rq);
|
|
|
|
/*
|
|
* smb_compress_alg_valid() - Validate a compression algorithm.
|
|
* @alg: Compression algorithm to check.
|
|
* @valid_none: Conditional check whether NONE algorithm should be
|
|
* considered valid or not.
|
|
*
|
|
* If @alg is SMB3_COMPRESS_NONE, this function returns @valid_none.
|
|
*
|
|
* Note that 'NONE' (0) compressor type is considered invalid in protocol
|
|
* negotiation, as it's never requested to/returned from the server.
|
|
*
|
|
* Return: true if @alg is valid/supported, false otherwise.
|
|
*/
|
|
static __always_inline int smb_compress_alg_valid(__le16 alg, bool valid_none)
|
|
{
|
|
if (alg == SMB3_COMPRESS_NONE)
|
|
return valid_none;
|
|
|
|
if (alg == SMB3_COMPRESS_LZ77 || alg == SMB3_COMPRESS_PATTERN)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
#else /* !CONFIG_CIFS_COMPRESSION */
|
|
static inline int smb_compress(void *unused1, void *unused2, void *unused3)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
static inline bool should_compress(void *unused1, void *unused2)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline int smb_compress_alg_valid(__le16 unused1, bool unused2)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
#endif /* !CONFIG_CIFS_COMPRESSION */
|
|
#endif /* _SMB_COMPRESS_H */
|