From: Masayoshi MIZUMA Subject: [PATCH][RFC] vfs: block_read_full_page allocates array depending on environment Date: Fri, 29 Jan 2010 09:53:58 +0900 Message-ID: <20100129095356.265D.61FB500B@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org To: Alexander Viro Return-path: Received: from fgwmail7.fujitsu.co.jp ([192.51.44.37]:51769 "EHLO fgwmail7.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755355Ab0A2Axg (ORCPT ); Thu, 28 Jan 2010 19:53:36 -0500 Received: from m3.gw.fujitsu.co.jp ([10.0.50.73]) by fgwmail7.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id o0T0rYgY001111 for (envelope-from m.mizuma@jp.fujitsu.com); Fri, 29 Jan 2010 09:53:34 +0900 Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id 2AA4245DE4F for ; Fri, 29 Jan 2010 09:53:34 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id EF08545DE51 for ; Fri, 29 Jan 2010 09:53:33 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id D8E57E08001 for ; Fri, 29 Jan 2010 09:53:33 +0900 (JST) Received: from m106.s.css.fujitsu.com (m106.s.css.fujitsu.com [10.249.87.106]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 8F5861DB803B for ; Fri, 29 Jan 2010 09:53:33 +0900 (JST) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hi, In block_read_full_page(), buffer_head pointer array is allocated more than the necessity. For example, the system's page cache size = 16k and filesystem's block size = 4k, the necessary number of pointer array is 4, but it is allocated as 32. This patch allocates the buffer_head pointer array depending on the system's page cache size and filesystem's block size. Signed-off-by: Masayoshi MIZUMA --- fs/buffer.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 6fa5302..acdedb8 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2146,13 +2146,12 @@ int block_read_full_page(struct page *page, get_block_t *get_block) { struct inode *inode = page->mapping->host; sector_t iblock, lblock; - struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE]; - unsigned int blocksize; + unsigned int blocksize = 1 << inode->i_blkbits; + struct buffer_head *bh, *head, *arr[PAGE_CACHE_SIZE / blocksize]; int nr, i; int fully_mapped = 1; BUG_ON(!PageLocked(page)); - blocksize = 1 << inode->i_blkbits; if (!page_has_buffers(page)) create_empty_buffers(page, blocksize, 0); head = page_buffers(page); -- 1.6.2.5 Thanks, Masayoshi