* [PATCH] Ext4: Don't normalize an falloc request if it can fit in 1 extent.
@ 2011-10-28 18:01 Greg Harm
2011-10-28 18:47 ` Andreas Dilger
2011-10-31 22:42 ` Ted Ts'o
0 siblings, 2 replies; 4+ messages in thread
From: Greg Harm @ 2011-10-28 18:01 UTC (permalink / raw)
To: Theodore Ts'o, Andreas Dilger; +Cc: linux-ext4, Greg Harm
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 haldar@google.com's
"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>
---
fs/ext4/extents.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 57cf568..9819216 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3761,6 +3761,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
int ret2 = 0;
int retries = 0;
struct ext4_map_blocks map;
+ int map_blocks_flags;
unsigned int credits, blkbits = inode->i_blkbits;
/*
@@ -3805,9 +3806,15 @@ retry:
ret = PTR_ERR(handle);
break;
}
- ret = ext4_map_blocks(handle, inode, &map,
- EXT4_GET_BLOCKS_CREATE_UNINIT_EXT |
- EXT4_GET_BLOCKS_NO_NORMALIZE);
+ map_blocks_flags = EXT4_GET_BLOCKS_CREATE_UNINIT_EXT;
+ /*
+ * Don't normalize the request if it can fit in one extent so
+ * that it doesn't get unnecessarily split into multiple
+ * extents.
+ */
+ if (len <= EXT_UNINIT_MAX_LEN << blkbits)
+ map_blocks_flags |= EXT4_GET_BLOCKS_NO_NORMALIZE;
+ ret = ext4_map_blocks(handle, inode, &map, map_blocks_flags);
if (ret <= 0) {
#ifdef EXT4FS_DEBUG
WARN_ON(ret <= 0);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Ext4: Don't normalize an falloc request if it can fit in 1 extent.
2011-10-28 18:01 [PATCH] Ext4: Don't normalize an falloc request if it can fit in 1 extent Greg Harm
@ 2011-10-28 18:47 ` Andreas Dilger
2011-10-28 19:05 ` Greg Harm
2011-10-31 22:42 ` Ted Ts'o
1 sibling, 1 reply; 4+ messages in thread
From: Andreas Dilger @ 2011-10-28 18:47 UTC (permalink / raw)
To: Greg Harm
Cc: Theodore Ts'o, Andreas Dilger, linux-ext4@vger.kernel.org,
Greg Harm
On 2011-10-28, at 12:01 PM, Greg Harm <gharm@google.com> wrote:
> 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 haldar@google.com's
> "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.
It would be great to add these test cases to xfstests so that this doesn't break in the future.
> Signed-off-by: Greg Harm <gharm@google.com>
> ---
> fs/ext4/extents.c | 13 ++++++++++---
> 1 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 57cf568..9819216 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -3761,6 +3761,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> int ret2 = 0;
> int retries = 0;
> struct ext4_map_blocks map;
> + int map_blocks_flags;
> unsigned int credits, blkbits = inode->i_blkbits;
>
> /*
> @@ -3805,9 +3806,15 @@ retry:
> ret = PTR_ERR(handle);
> break;
> }
> - ret = ext4_map_blocks(handle, inode, &map,
> - EXT4_GET_BLOCKS_CREATE_UNINIT_EXT |
> - EXT4_GET_BLOCKS_NO_NORMALIZE);
> + map_blocks_flags = EXT4_GET_BLOCKS_CREATE_UNINIT_EXT;
> + /*
> + * Don't normalize the request if it can fit in one extent so
> + * that it doesn't get unnecessarily split into multiple
> + * extents.
> + */
> + if (len <= EXT_UNINIT_MAX_LEN << blkbits)
> + map_blocks_flags |= EXT4_GET_BLOCKS_NO_NORMALIZE;
> + ret = ext4_map_blocks(handle, inode, &map, map_blocks_flags);
> if (ret <= 0) {
> #ifdef EXT4FS_DEBUG
> WARN_ON(ret <= 0);
> --
> 1.7.3.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Ext4: Don't normalize an falloc request if it can fit in 1 extent.
2011-10-28 18:47 ` Andreas Dilger
@ 2011-10-28 19:05 ` Greg Harm
0 siblings, 0 replies; 4+ messages in thread
From: Greg Harm @ 2011-10-28 19:05 UTC (permalink / raw)
To: Andreas Dilger
Cc: Theodore Ts'o, Andreas Dilger, linux-ext4@vger.kernel.org
On Fri, Oct 28, 2011 at 11:47 AM, Andreas Dilger <aedilger@gmail.com> wrote:
> On 2011-10-28, at 12:01 PM, Greg Harm <gharm@google.com> wrote:
>> 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 haldar@google.com's
>> "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.
>
> It would be great to add these test cases to xfstests so that this doesn't break in the future.
Hi Andreas,
I totally agree. I have that on my TODO list (but no current ETA).
Thanks,
Greg
>> Signed-off-by: Greg Harm <gharm@google.com>
>> ---
>> fs/ext4/extents.c | 13 ++++++++++---
>> 1 files changed, 10 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
>> index 57cf568..9819216 100644
>> --- a/fs/ext4/extents.c
>> +++ b/fs/ext4/extents.c
>> @@ -3761,6 +3761,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
>> int ret2 = 0;
>> int retries = 0;
>> struct ext4_map_blocks map;
>> + int map_blocks_flags;
>> unsigned int credits, blkbits = inode->i_blkbits;
>>
>> /*
>> @@ -3805,9 +3806,15 @@ retry:
>> ret = PTR_ERR(handle);
>> break;
>> }
>> - ret = ext4_map_blocks(handle, inode, &map,
>> - EXT4_GET_BLOCKS_CREATE_UNINIT_EXT |
>> - EXT4_GET_BLOCKS_NO_NORMALIZE);
>> + map_blocks_flags = EXT4_GET_BLOCKS_CREATE_UNINIT_EXT;
>> + /*
>> + * Don't normalize the request if it can fit in one extent so
>> + * that it doesn't get unnecessarily split into multiple
>> + * extents.
>> + */
>> + if (len <= EXT_UNINIT_MAX_LEN << blkbits)
>> + map_blocks_flags |= EXT4_GET_BLOCKS_NO_NORMALIZE;
>> + ret = ext4_map_blocks(handle, inode, &map, map_blocks_flags);
>> if (ret <= 0) {
>> #ifdef EXT4FS_DEBUG
>> WARN_ON(ret <= 0);
>> --
>> 1.7.3.1
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Ext4: Don't normalize an falloc request if it can fit in 1 extent.
2011-10-28 18:01 [PATCH] Ext4: Don't normalize an falloc request if it can fit in 1 extent Greg Harm
2011-10-28 18:47 ` Andreas Dilger
@ 2011-10-31 22:42 ` Ted Ts'o
1 sibling, 0 replies; 4+ messages in thread
From: Ted Ts'o @ 2011-10-31 22:42 UTC (permalink / raw)
To: Greg Harm; +Cc: Andreas Dilger, linux-ext4
On Fri, Oct 28, 2011 at 11:01:57AM -0700, Greg Harm wrote:
> 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 haldar@google.com's
> "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>
Thanks, I had to tweak the patch slightly to make it apply given the
current ext4 tree.
- Ted
commit 5f11e7c457769808bafe5048a98c5cfd624e85f3
Author: Greg Harm <gharm@google.com>
Date: Mon Oct 31 18:41:47 2011 -0400
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>
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index e585caa..9dfdf8f 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4336,10 +4336,16 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
return ret;
}
- flags = EXT4_GET_BLOCKS_CREATE_UNINIT_EXT |
- EXT4_GET_BLOCKS_NO_NORMALIZE;
+ flags = EXT4_GET_BLOCKS_CREATE_UNINIT_EXT;
if (mode & FALLOC_FL_KEEP_SIZE)
flags |= EXT4_GET_BLOCKS_KEEP_SIZE;
+ /*
+ * Don't normalize the request if it can fit in one extent so
+ * that it doesn't get unnecessarily split into multiple
+ * extents.
+ */
+ if (len <= EXT_UNINIT_MAX_LEN << blkbits)
+ flags |= EXT4_GET_BLOCKS_NO_NORMALIZE;
retry:
while (ret >= 0 && ret < max_blocks) {
map.m_lblk = map.m_lblk + ret;
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-10-31 22:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-28 18:01 [PATCH] Ext4: Don't normalize an falloc request if it can fit in 1 extent Greg Harm
2011-10-28 18:47 ` Andreas Dilger
2011-10-28 19:05 ` Greg Harm
2011-10-31 22:42 ` Ted Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).