aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2008-08-18 18:00:57 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-08-18 18:00:57 -0400
commit5e745b041f2ccad63077118b40468521306f3962 (patch)
tree2a4d53c884f92899ee8e4f541c32861a4a577e1d /fs/ext4/inode.c
parent91246c009094142f95ecc7573b7caed2bcef52c7 (diff)
ext4: Fix small file fragmentation
For small file block allocations, mballoc uses per cpu prealloc space. Use goal block when searching for the right prealloc space. Also make sure ext4_da_writepages tries to write all the pages for small files in single attempt Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d1906d9a22de..7e91913e325b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2282,13 +2282,12 @@ static int ext4_da_writepages_trans_blocks(struct inode *inode)
2282static int ext4_da_writepages(struct address_space *mapping, 2282static int ext4_da_writepages(struct address_space *mapping,
2283 struct writeback_control *wbc) 2283 struct writeback_control *wbc)
2284{ 2284{
2285 struct inode *inode = mapping->host;
2286 handle_t *handle = NULL; 2285 handle_t *handle = NULL;
2287 int needed_blocks;
2288 int ret = 0;
2289 long to_write;
2290 loff_t range_start = 0; 2286 loff_t range_start = 0;
2291 long pages_skipped = 0; 2287 struct inode *inode = mapping->host;
2288 int needed_blocks, ret = 0, nr_to_writebump = 0;
2289 long to_write, pages_skipped = 0;
2290 struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb);
2292 2291
2293 /* 2292 /*
2294 * No pages to write? This is mainly a kludge to avoid starting 2293 * No pages to write? This is mainly a kludge to avoid starting
@@ -2297,6 +2296,16 @@ static int ext4_da_writepages(struct address_space *mapping,
2297 */ 2296 */
2298 if (!mapping->nrpages || !mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) 2297 if (!mapping->nrpages || !mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
2299 return 0; 2298 return 0;
2299 /*
2300 * Make sure nr_to_write is >= sbi->s_mb_stream_request
2301 * This make sure small files blocks are allocated in
2302 * single attempt. This ensure that small files
2303 * get less fragmented.
2304 */
2305 if (wbc->nr_to_write < sbi->s_mb_stream_request) {
2306 nr_to_writebump = sbi->s_mb_stream_request - wbc->nr_to_write;
2307 wbc->nr_to_write = sbi->s_mb_stream_request;
2308 }
2300 2309
2301 if (!wbc->range_cyclic) 2310 if (!wbc->range_cyclic)
2302 /* 2311 /*
@@ -2377,7 +2386,7 @@ restart_loop:
2377 } 2386 }
2378 2387
2379out_writepages: 2388out_writepages:
2380 wbc->nr_to_write = to_write; 2389 wbc->nr_to_write = to_write - nr_to_writebump;
2381 wbc->range_start = range_start; 2390 wbc->range_start = range_start;
2382 return ret; 2391 return ret;
2383} 2392}