diff options
author | Greg Harm <gharm@google.com> | 2011-10-31 18:41:47 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-10-31 18:41:47 -0400 |
commit | 3c6fe77017bc6ce489f231c35fed3220b6691836 (patch) | |
tree | b3ca4d00dcecaf146361fef04afd8135ff370a07 /fs/ext4/extents.c | |
parent | 4af835089984ce9e24c44a51be64c5524788e973 (diff) |
ext4: Don't normalize an falloc request if it can fit in 1 extent.
If an fallocate request fits in EXT_UNINIT_MAX_LEN, then set the
EXT4_GET_BLOCKS_NO_NORMALIZE flag. For larger fallocate requests,
let mballoc.c normalize the request.
This fixes a problem where large requests were being split into
non-contiguous extents due to commit 556b27abf73: ext4: do not
normalize block requests from fallocate.
Testing:
*) Checked that 8.x MB falloc'ed files are still laid down next to
each other (contiguously).
*) Checked that the maximum size extent (127.9MB) is allocated as 1
extent.
*) Checked that a 1GB file is somewhat contiguous (often 5-6
non-contiguous extents now).
*) Checked that a 120MB file can still be falloc'ed even if there are
no single extents large enough to hold it.
Signed-off-by: Greg Harm <gharm@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index a5c8caaaa099..2798945a1920 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -4337,10 +4337,16 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
4337 | trace_ext4_fallocate_exit(inode, offset, max_blocks, ret); | 4337 | trace_ext4_fallocate_exit(inode, offset, max_blocks, ret); |
4338 | return ret; | 4338 | return ret; |
4339 | } | 4339 | } |
4340 | flags = EXT4_GET_BLOCKS_CREATE_UNINIT_EXT | | 4340 | flags = EXT4_GET_BLOCKS_CREATE_UNINIT_EXT; |
4341 | EXT4_GET_BLOCKS_NO_NORMALIZE; | ||
4342 | if (mode & FALLOC_FL_KEEP_SIZE) | 4341 | if (mode & FALLOC_FL_KEEP_SIZE) |
4343 | flags |= EXT4_GET_BLOCKS_KEEP_SIZE; | 4342 | flags |= EXT4_GET_BLOCKS_KEEP_SIZE; |
4343 | /* | ||
4344 | * Don't normalize the request if it can fit in one extent so | ||
4345 | * that it doesn't get unnecessarily split into multiple | ||
4346 | * extents. | ||
4347 | */ | ||
4348 | if (len <= EXT_UNINIT_MAX_LEN << blkbits) | ||
4349 | flags |= EXT4_GET_BLOCKS_NO_NORMALIZE; | ||
4344 | retry: | 4350 | retry: |
4345 | while (ret >= 0 && ret < max_blocks) { | 4351 | while (ret >= 0 && ret < max_blocks) { |
4346 | map.m_lblk = map.m_lblk + ret; | 4352 | map.m_lblk = map.m_lblk + ret; |