[PATCH][RFC] vfs: block_read_full_page allocates array depending on environment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <m.mizuma@xxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux