aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/misc.c')
-rw-r--r--fs/cifs/misc.c25
1 files changed, 19 insertions, 6 deletions
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);