From fa1b4122ad6c202a27f3da98bcf0aa648d25e094 Mon Sep 17 00:00:00 2001 From: Kazuya Mio Date: Mon, 10 Jan 2011 12:12:28 -0500 Subject: [PATCH] --- yaml --- r: 229123 b: refs/heads/master c: ad4fb9cafe100a4a9de6e0529015e584d94ac8dc h: refs/heads/master i: 229121: 10abf5a50d4aaadc3acb9006a87f5dfc541bc331 229119: a77a20668cb84fb01a5e93eb346e441c0ff751df v: v3 --- [refs] | 2 +- trunk/fs/ext4/extents.c | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index f7684de119bc..a373e61e414b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: dabd991f9d8e3232bb4531c920daddac8d10d313 +refs/heads/master: ad4fb9cafe100a4a9de6e0529015e584d94ac8dc diff --git a/trunk/fs/ext4/extents.c b/trunk/fs/ext4/extents.c index 0554c48cb1fd..d53e20f53103 100644 --- a/trunk/fs/ext4/extents.c +++ b/trunk/fs/ext4/extents.c @@ -117,11 +117,33 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode, struct ext4_extent *ex; depth = path->p_depth; - /* try to predict block placement */ + /* + * Try to predict block placement assuming that we are + * filling in a file which will eventually be + * non-sparse --- i.e., in the case of libbfd writing + * an ELF object sections out-of-order but in a way + * the eventually results in a contiguous object or + * executable file, or some database extending a table + * space file. However, this is actually somewhat + * non-ideal if we are writing a sparse file such as + * qemu or KVM writing a raw image file that is going + * to stay fairly sparse, since it will end up + * fragmenting the file system's free space. Maybe we + * should have some hueristics or some way to allow + * userspace to pass a hint to file system, + * especiially if the latter case turns out to be + * common. + */ ex = path[depth].p_ext; - if (ex) - return (ext4_ext_pblock(ex) + - (block - le32_to_cpu(ex->ee_block))); + if (ex) { + ext4_fsblk_t ext_pblk = ext4_ext_pblock(ex); + ext4_lblk_t ext_block = le32_to_cpu(ex->ee_block); + + if (block > ext_block) + return ext_pblk + (block - ext_block); + else + return ext_pblk - (ext_block - block); + } /* it looks like index is empty; * try to find starting block from index itself */