Commit 8fe7062b authored by Enzo Matsumiya's avatar Enzo Matsumiya Committed by Steve French
Browse files

smb: client: negotiate compression algorithms



Change "compress=" mount option to a boolean flag, that, if set,
will enable negotiating compression algorithms with the server.

Do not de/compress anything for now.

Signed-off-by: default avatarEnzo Matsumiya <ematsumiya@suse.de>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 073dd87c
Loading
Loading
Loading
Loading
+26 −6
Original line number Diff line number Diff line
@@ -278,6 +278,24 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
	return 0;
}

static __always_inline const char *compression_alg_str(__le16 alg)
{
	switch (alg) {
	case SMB3_COMPRESS_NONE:
		return "NONE";
	case SMB3_COMPRESS_LZNT1:
		return "LZNT1";
	case SMB3_COMPRESS_LZ77:
		return "LZ77";
	case SMB3_COMPRESS_LZ77_HUFF:
		return "LZ77-Huffman";
	case SMB3_COMPRESS_PATTERN:
		return "Pattern_V1";
	default:
		return "invalid";
	}
}

static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
{
	struct mid_q_entry *mid_entry;
@@ -423,12 +441,6 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
			server->echo_credits,
			server->oplock_credits,
			server->dialect);
		if (server->compress_algorithm == SMB3_COMPRESS_LZNT1)
			seq_printf(m, " COMPRESS_LZNT1");
		else if (server->compress_algorithm == SMB3_COMPRESS_LZ77)
			seq_printf(m, " COMPRESS_LZ77");
		else if (server->compress_algorithm == SMB3_COMPRESS_LZ77_HUFF)
			seq_printf(m, " COMPRESS_LZ77_HUFF");
		if (server->sign)
			seq_printf(m, " signed");
		if (server->posix_ext_supported)
@@ -460,6 +472,14 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
				   server->leaf_fullpath);
		}

		seq_puts(m, "\nCompression: ");
		if (!server->compression.requested)
			seq_puts(m, "disabled on mount");
		else if (server->compression.enabled)
			seq_printf(m, "enabled (%s)", compression_alg_str(server->compression.alg));
		else
			seq_puts(m, "disabled (not supported by this server)");

		seq_printf(m, "\n\n\tSessions: ");
		i = 0;
		list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
+5 −1
Original line number Diff line number Diff line
@@ -769,7 +769,11 @@ struct TCP_Server_Info {
	unsigned int	max_write;
	unsigned int	min_offload;
	unsigned int	retrans;
	__le16	compress_algorithm;
	struct {
		bool requested; /* "compress" mount option set*/
		bool enabled; /* actually negotiated with server */
		__le16 alg; /* preferred alg negotiated with server */
	} compression;
	__u16	signing_algorithm;
	__le16	cipher_type;
	 /* save initital negprot hash */
+1 −1
Original line number Diff line number Diff line
@@ -1736,7 +1736,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,
	tcp_ses->channel_sequence_num = 0; /* only tracked for primary channel */
	tcp_ses->reconnect_instance = 1;
	tcp_ses->lstrp = jiffies;
	tcp_ses->compress_algorithm = cpu_to_le16(ctx->compression);
	tcp_ses->compression.requested = ctx->compress;
	spin_lock_init(&tcp_ses->req_lock);
	spin_lock_init(&tcp_ses->srv_lock);
	spin_lock_init(&tcp_ses->mid_lock);
+1 −1
Original line number Diff line number Diff line
@@ -963,7 +963,7 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,

	switch (opt) {
	case Opt_compress:
		ctx->compression = UNKNOWN_TYPE;
		ctx->compress = true;
		cifs_dbg(VFS,
			"SMB3 compression support is experimental\n");
		break;
+1 −1
Original line number Diff line number Diff line
@@ -273,7 +273,7 @@ struct smb3_fs_context {
	unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
	unsigned int max_channels;
	unsigned int max_cached_dirs;
	__u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
	bool compress; /* enable SMB2 messages (READ/WRITE) de/compression */
	bool rootfs:1; /* if it's a SMB root file system */
	bool witness:1; /* use witness protocol */
	char *leaf_fullpath;
Loading