Skip to content

Commit f046d71

Browse files
ematsumiyasmfrench
authored andcommitted
smb: client: insert compression check/call on write requests
On smb2_async_writev(), set CIFS_COMPRESS_REQ on request flags if should_compress() returns true. On smb_send_rqst() check the flags, and compress and send the request to the server. (*) If the compression fails with -EMSGSIZE (i.e. compressed size is >= uncompressed size), the original uncompressed request is sent instead. Signed-off-by: Enzo Matsumiya <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent d14bbff commit f046d71

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

fs/smb/client/smb2pdu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "dfs_cache.h"
4343
#endif
4444
#include "cached_dir.h"
45+
#include "compress.h"
4546

4647
/*
4748
* The following table defines the expected "StructureSize" of SMB2 requests
@@ -5020,6 +5021,10 @@ smb2_async_writev(struct cifs_io_subrequest *wdata)
50205021
flags |= CIFS_HAS_CREDITS;
50215022
}
50225023

5024+
/* XXX: compression + encryption is unsupported for now */
5025+
if (((flags & CIFS_TRANSFORM_REQ) != CIFS_TRANSFORM_REQ) && should_compress(tcon, &rqst))
5026+
flags |= CIFS_COMPRESS_REQ;
5027+
50235028
rc = cifs_call_async(server, &rqst, NULL, smb2_writev_callback, NULL,
50245029
wdata, flags, &wdata->credits);
50255030
/* Can't touch wdata if rc == 0 */

fs/smb/client/transport.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "cifs_debug.h"
2929
#include "smb2proto.h"
3030
#include "smbdirect.h"
31+
#include "compress.h"
3132

3233
/* Max number of iovectors we can use off the stack when sending requests. */
3334
#define CIFS_MAX_IOV_SIZE 8
@@ -432,6 +433,9 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
432433
struct kvec *iov;
433434
int rc;
434435

436+
if (flags & CIFS_COMPRESS_REQ)
437+
return smb_compress(server, &rqst[0], __smb_send_rqst);
438+
435439
if (!(flags & CIFS_TRANSFORM_REQ))
436440
return __smb_send_rqst(server, num_rqst, rqst);
437441

0 commit comments

Comments
 (0)