From patchwork Fri Jul 13 07:53:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1194141 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 9D1703FC4C for ; Fri, 13 Jul 2012 07:55:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754970Ab2GMHz3 (ORCPT ); Fri, 13 Jul 2012 03:55:29 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:49057 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754942Ab2GMHz2 (ORCPT ); Fri, 13 Jul 2012 03:55:28 -0400 Received: by mail-lb0-f174.google.com with SMTP id gm6so5433132lbb.19 for ; Fri, 13 Jul 2012 00:55:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=pxu4RS42NcoIdft5HjTtAnw99VsIJqSJ4yh4p/bgARs=; b=xY0mk71d1Ovy1io9SgB/SsFhyRiqmecgC0ghsvsfU3oftI41O0e4dq6r8hNYhg7cFz iqV69l0zqk0lMIwj52jSVIt9nkl5IE9mIVt6qnCOIxI4/3wr1X4eY23LjfT9FentzlYQ lKHN8q5+SXM6qeP6VVaV6JtFIUc8rkgnUJbr1m6HK3RfY9YkKYiuJ2NzDYBkHusC+Hza 32gu0dC87uAYPznG5EEHy0/fkAvmdqUoxigQdpmjy3qFG6mvnsn4HPVB42+un6ouLFcL oEXfS/vW5KPeL2kkunZOtWcAHFoH9GzHfWyfG3UR9haJUo2Jhi4V1ktF6NTbZT7p0f8e jN0Q== Received: by 10.152.104.77 with SMTP id gc13mr154836lab.31.1342166127823; Fri, 13 Jul 2012 00:55:27 -0700 (PDT) Received: from localhost.localdomain ([178.45.132.158]) by mx.google.com with ESMTPS id er3sm1595545lbb.16.2012.07.13.00.55.25 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 Jul 2012 00:55:27 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Cc: Pavel Shilovsky Subject: [PATCH v3 14/32] CIFS: Respect SMB2 header/max header size Date: Fri, 13 Jul 2012 11:53:27 +0400 Message-Id: <1342166025-29377-15-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1342166025-29377-1-git-send-email-pshilovsky@samba.org> References: <1342166025-29377-1-git-send-email-pshilovsky@samba.org> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Pavel Shilovsky Use SMB2 header size values for allocation and memset because they are bigger and suitable for both CIFS and SMB2. Signed-off-by: Pavel Shilovsky Reviewed-by: Jeff Layton --- fs/cifs/cifsfs.c | 14 ++++++++++++-- fs/cifs/misc.c | 25 +++++++++++++++++++------ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 8dc1492..5cf9299 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -48,6 +48,9 @@ #include #include "cifs_spnego.h" #include "fscache.h" +#ifdef CONFIG_CIFS_SMB2 +#include "smb2pdu.h" +#endif #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */ int cifsFYI = 0; @@ -981,6 +984,14 @@ cifs_destroy_inodecache(void) static int cifs_init_request_bufs(void) { + size_t max_hdr_size = MAX_CIFS_HDR_SIZE; +#ifdef CONFIG_CIFS_SMB2 + /* + * SMB2 maximum header size is bigger than CIFS one - no problems to + * allocate some more bytes for CIFS. + */ + max_hdr_size = MAX_SMB2_HDR_SIZE; +#endif if (CIFSMaxBufSize < 8192) { /* Buffer size can not be smaller than 2 * PATH_MAX since maximum Unicode path name has to fit in any SMB/CIFS path based frames */ @@ -992,8 +1003,7 @@ cifs_init_request_bufs(void) } /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */ cifs_req_cachep = kmem_cache_create("cifs_request", - CIFSMaxBufSize + - MAX_CIFS_HDR_SIZE, 0, + CIFSMaxBufSize + max_hdr_size, 0, SLAB_HWCACHE_ALIGN, NULL); if (cifs_req_cachep == NULL) return -ENOMEM; diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 6460114..ad2538a 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c @@ -29,6 +29,9 @@ #include "smberr.h" #include "nterr.h" #include "cifs_unicode.h" +#ifdef CONFIG_CIFS_SMB2 +#include "smb2pdu.h" +#endif extern mempool_t *cifs_sm_req_poolp; extern mempool_t *cifs_req_poolp; @@ -143,17 +146,27 @@ struct smb_hdr * cifs_buf_get(void) { struct smb_hdr *ret_buf = NULL; - -/* We could use negotiated size instead of max_msgsize - - but it may be more efficient to always alloc same size - albeit slightly larger than necessary and maxbuffersize - defaults to this and can not be bigger */ + size_t buf_size = sizeof(struct smb_hdr); + +#ifdef CONFIG_CIFS_SMB2 + /* + * SMB2 header is bigger than CIFS one - no problems to clean some + * more bytes for CIFS. + */ + buf_size = sizeof(struct smb2_hdr); +#endif + /* + * We could use negotiated size instead of max_msgsize - + * but it may be more efficient to always alloc same size + * albeit slightly larger than necessary and maxbuffersize + * defaults to this and can not be bigger. + */ ret_buf = mempool_alloc(cifs_req_poolp, GFP_NOFS); /* clear the first few header bytes */ /* for most paths, more is cleared in header_assemble */ if (ret_buf) { - memset(ret_buf, 0, sizeof(struct smb_hdr) + 3); + memset(ret_buf, 0, buf_size + 3); atomic_inc(&bufAllocCount); #ifdef CONFIG_CIFS_STATS2 atomic_inc(&totBufAllocCount);