* [PATCH] btrfs: Return right extent when fiemap gives unaligned offset and len.
@ 2014-07-18 1:55 Qu Wenruo
2014-07-24 12:17 ` David Sterba
0 siblings, 1 reply; 4+ messages in thread
From: Qu Wenruo @ 2014-07-18 1:55 UTC (permalink / raw)
To: linux-btrfs
When page aligned start and len passed to extent_fiemap(), the result is
good, but when start and len is not aligned, e.g. start = 1 and len =
4095 is passed to extent_fiemap(), it returns no extent.
The problem is that start and len is all rounded down which causes the
problem. This patch will round down start and round up (start + len) to
return right extent.
Reported-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
fs/btrfs/extent_io.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index a389820..1c70cff 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4213,8 +4213,8 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
return -ENOMEM;
path->leave_spinning = 1;
- start = ALIGN(start, BTRFS_I(inode)->root->sectorsize);
- len = ALIGN(len, BTRFS_I(inode)->root->sectorsize);
+ start = round_down(start, BTRFS_I(inode)->root->sectorsize);
+ len = round_up(max, BTRFS_I(inode)->root->sectorsize) - start;
/*
* lookup the last file extent. We're not using i_size here
--
2.0.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: Return right extent when fiemap gives unaligned offset and len.
2014-07-18 1:55 [PATCH] btrfs: Return right extent when fiemap gives unaligned offset and len Qu Wenruo
@ 2014-07-24 12:17 ` David Sterba
2014-07-25 1:29 ` Qu Wenruo
0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2014-07-24 12:17 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs
On Fri, Jul 18, 2014 at 09:55:43AM +0800, Qu Wenruo wrote:
> When page aligned start and len passed to extent_fiemap(), the result is
> good, but when start and len is not aligned, e.g. start = 1 and len =
> 4095 is passed to extent_fiemap(), it returns no extent.
>
> The problem is that start and len is all rounded down which causes the
> problem.
ALIGN rounds up, not down. So the wrong rounding will use incorrect start
(4096) and finds no extents if there's eg. only one [0,4095].
> This patch will round down start and round up (start + len) to
> return right extent.
>
> Reported-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: Return right extent when fiemap gives unaligned offset and len.
2014-07-24 12:17 ` David Sterba
@ 2014-07-25 1:29 ` Qu Wenruo
2014-07-29 12:30 ` David Sterba
0 siblings, 1 reply; 4+ messages in thread
From: Qu Wenruo @ 2014-07-25 1:29 UTC (permalink / raw)
To: dsterba, linux-btrfs
-------- Original Message --------
Subject: Re: [PATCH] btrfs: Return right extent when fiemap gives
unaligned offset and len.
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Date: 2014年07月24日 20:17
> On Fri, Jul 18, 2014 at 09:55:43AM +0800, Qu Wenruo wrote:
>> When page aligned start and len passed to extent_fiemap(), the result is
>> good, but when start and len is not aligned, e.g. start = 1 and len =
>> 4095 is passed to extent_fiemap(), it returns no extent.
>>
>> The problem is that start and len is all rounded down which causes the
>> problem.
> ALIGN rounds up, not down. So the wrong rounding will use incorrect start
> (4096) and finds no extents if there's eg. only one [0,4095].
Sorry for the wrong description in patch.
Should I reword the patch and send a v2 patch?
Thanks,
Qu
>
>> This patch will round down start and round up (start + len) to
>> return right extent.
>>
>> Reported-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
>> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
> Reviewed-by: David Sterba <dsterba@suse.cz>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: Return right extent when fiemap gives unaligned offset and len.
2014-07-25 1:29 ` Qu Wenruo
@ 2014-07-29 12:30 ` David Sterba
0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2014-07-29 12:30 UTC (permalink / raw)
To: Qu Wenruo; +Cc: dsterba, linux-btrfs
On Fri, Jul 25, 2014 at 09:29:05AM +0800, Qu Wenruo wrote:
>
> -------- Original Message --------
> Subject: Re: [PATCH] btrfs: Return right extent when fiemap gives unaligned
> offset and len.
> From: David Sterba <dsterba@suse.cz>
> To: Qu Wenruo <quwenruo@cn.fujitsu.com>
> Date: 2014年07月24日 20:17
> >On Fri, Jul 18, 2014 at 09:55:43AM +0800, Qu Wenruo wrote:
> >>When page aligned start and len passed to extent_fiemap(), the result is
> >>good, but when start and len is not aligned, e.g. start = 1 and len =
> >>4095 is passed to extent_fiemap(), it returns no extent.
> >>
> >>The problem is that start and len is all rounded down which causes the
> >>problem.
> >ALIGN rounds up, not down. So the wrong rounding will use incorrect start
> >(4096) and finds no extents if there's eg. only one [0,4095].
> Sorry for the wrong description in patch.
> Should I reword the patch and send a v2 patch?
You already did, but yes please.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-29 12:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-18 1:55 [PATCH] btrfs: Return right extent when fiemap gives unaligned offset and len Qu Wenruo
2014-07-24 12:17 ` David Sterba
2014-07-25 1:29 ` Qu Wenruo
2014-07-29 12:30 ` David Sterba
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).