From patchwork Tue Aug 14 22:47:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 1323861 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2BFFFE0003 for ; Tue, 14 Aug 2012 22:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752721Ab2HNWru (ORCPT ); Tue, 14 Aug 2012 18:47:50 -0400 Received: from mx2.netapp.com ([216.240.18.37]:20483 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752698Ab2HNWru (ORCPT ); Tue, 14 Aug 2012 18:47:50 -0400 X-IronPort-AV: E=Sophos;i="4.77,769,1336374000"; d="scan'208";a="676620177" Received: from smtp2.corp.netapp.com ([10.57.159.114]) by mx2-out.netapp.com with ESMTP; 14 Aug 2012 15:47:34 -0700 Received: from lade.trondhjem.org.com (lade.trondhjem.org [10.63.232.149] (may be forged)) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id q7EMlUS9029587; Tue, 14 Aug 2012 15:47:33 -0700 (PDT) From: Trond Myklebust To: Dros Adamson Cc: Sachin Prabhu , Andy Adamson , linux-nfs@vger.kernel.org Subject: [PATCH 2/3] NFSv4: Fix the acl cache size calculation Date: Tue, 14 Aug 2012 18:47:26 -0400 Message-Id: <1344984447-17804-2-git-send-email-Trond.Myklebust@netapp.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1344984447-17804-1-git-send-email-Trond.Myklebust@netapp.com> References: <1344984447-17804-1-git-send-email-Trond.Myklebust@netapp.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Currently, we do not take into account the size of the 16 byte struct nfs4_cached_acl header, when deciding whether or not we should cache the acl data. Consequently, we will end up allocating an 8k buffer in order to fit a maximum size 4k acl. This patch adjusts the calculation so that we limit the cache size to 4k for the acl header+data. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 286ab70..6352741 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3737,9 +3737,10 @@ out: static void nfs4_write_cached_acl(struct inode *inode, struct page **pages, size_t pgbase, size_t acl_len) { struct nfs4_cached_acl *acl; + size_t buflen = sizeof(*acl) + acl_len; - if (pages && acl_len <= PAGE_SIZE) { - acl = kmalloc(sizeof(*acl) + acl_len, GFP_KERNEL); + if (pages && buflen <= PAGE_SIZE) { + acl = kmalloc(buflen, GFP_KERNEL); if (acl == NULL) goto out; acl->cached = 1;