aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/cifs/cifsfs.c14
-rw-r--r--fs/cifs/misc.c25
2 files changed, 31 insertions, 8 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 2e9929dc2072..7a7cda9f7912 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -48,6 +48,9 @@
48#include <linux/key-type.h> 48#include <linux/key-type.h>
49#include "cifs_spnego.h" 49#include "cifs_spnego.h"
50#include "fscache.h" 50#include "fscache.h"
51#ifdef CONFIG_CIFS_SMB2
52#include "smb2pdu.h"
53#endif
51#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */ 54#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
52 55
53int cifsFYI = 0; 56int cifsFYI = 0;
@@ -980,6 +983,14 @@ cifs_destroy_inodecache(void)
980static int 983static int
981cifs_init_request_bufs(void) 984cifs_init_request_bufs(void)
982{ 985{
986 size_t max_hdr_size = MAX_CIFS_HDR_SIZE;
987#ifdef CONFIG_CIFS_SMB2
988 /*
989 * SMB2 maximum header size is bigger than CIFS one - no problems to
990 * allocate some more bytes for CIFS.
991 */
992 max_hdr_size = MAX_SMB2_HDR_SIZE;
993#endif
983 if (CIFSMaxBufSize < 8192) { 994 if (CIFSMaxBufSize < 8192) {
984 /* Buffer size can not be smaller than 2 * PATH_MAX since maximum 995 /* Buffer size can not be smaller than 2 * PATH_MAX since maximum
985 Unicode path name has to fit in any SMB/CIFS path based frames */ 996 Unicode path name has to fit in any SMB/CIFS path based frames */
@@ -991,8 +1002,7 @@ cifs_init_request_bufs(void)
991 } 1002 }
992/* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */ 1003/* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
993 cifs_req_cachep = kmem_cache_create("cifs_request", 1004 cifs_req_cachep = kmem_cache_create("cifs_request",
994 CIFSMaxBufSize + 1005 CIFSMaxBufSize + max_hdr_size, 0,
995 MAX_CIFS_HDR_SIZE, 0,
996 SLAB_HWCACHE_ALIGN, NULL); 1006 SLAB_HWCACHE_ALIGN, NULL);
997 if (cifs_req_cachep == NULL) 1007 if (cifs_req_cachep == NULL)
998 return -ENOMEM; 1008 return -ENOMEM;
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 64601146f157..ad2538a64c70 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -29,6 +29,9 @@
29#include "smberr.h" 29#include "smberr.h"
30#include "nterr.h" 30#include "nterr.h"
31#include "cifs_unicode.h" 31#include "cifs_unicode.h"
32#ifdef CONFIG_CIFS_SMB2
33#include "smb2pdu.h"
34#endif
32 35
33extern mempool_t *cifs_sm_req_poolp; 36extern mempool_t *cifs_sm_req_poolp;
34extern mempool_t *cifs_req_poolp; 37extern mempool_t *cifs_req_poolp;
@@ -143,17 +146,27 @@ struct smb_hdr *
143cifs_buf_get(void) 146cifs_buf_get(void)
144{ 147{
145 struct smb_hdr *ret_buf = NULL; 148 struct smb_hdr *ret_buf = NULL;
146 149 size_t buf_size = sizeof(struct smb_hdr);
147/* We could use negotiated size instead of max_msgsize - 150
148 but it may be more efficient to always alloc same size 151#ifdef CONFIG_CIFS_SMB2
149 albeit slightly larger than necessary and maxbuffersize 152 /*
150 defaults to this and can not be bigger */ 153 * SMB2 header is bigger than CIFS one - no problems to clean some
154 * more bytes for CIFS.
155 */
156 buf_size = sizeof(struct smb2_hdr);
157#endif
158 /*
159 * We could use negotiated size instead of max_msgsize -
160 * but it may be more efficient to always alloc same size
161 * albeit slightly larger than necessary and maxbuffersize
162 * defaults to this and can not be bigger.
163 */
151 ret_buf = mempool_alloc(cifs_req_poolp, GFP_NOFS); 164 ret_buf = mempool_alloc(cifs_req_poolp, GFP_NOFS);
152 165
153 /* clear the first few header bytes */ 166 /* clear the first few header bytes */
154 /* for most paths, more is cleared in header_assemble */ 167 /* for most paths, more is cleared in header_assemble */
155 if (ret_buf) { 168 if (ret_buf) {
156 memset(ret_buf, 0, sizeof(struct smb_hdr) + 3); 169 memset(ret_buf, 0, buf_size + 3);
157 atomic_inc(&bufAllocCount); 170 atomic_inc(&bufAllocCount);
158#ifdef CONFIG_CIFS_STATS2 171#ifdef CONFIG_CIFS_STATS2
159 atomic_inc(&totBufAllocCount); 172 atomic_inc(&totBufAllocCount);