* Re: [PATCH] btrfs/direct-IO: fix a bug of btrfs_dio_read
2010-05-06 2:12 [PATCH] btrfs/direct-IO: fix a bug of btrfs_dio_read liubo
@ 2010-05-06 2:11 ` Josef Bacik
2010-05-06 2:24 ` liubo
0 siblings, 1 reply; 3+ messages in thread
From: Josef Bacik @ 2010-05-06 2:11 UTC (permalink / raw)
To: liubo; +Cc: linux-btrfs, Josef Bacik, jim owens, Chris Mason, Yan, Zheng
On Thu, May 06, 2010 at 10:12:10AM +0800, liubo wrote:
> As I mentioned in the bug-report, when the file size is
> not n * BUFFERSIZE, this file cannot be read correctly
> and the system will crash or hang up.
>
> After investigation, I fount that data_len should be
> checked before lock_extent, in order to prevent the
> situation that when it comes to the file end,
> diocb->lockstart changes to lockend+1, then lock_extent
> will cause system's crash or hang.
>
> So move the data_len's check ahead.
>
Please read my previous email, DIO has been refactored, this code isn't going to
be used anymore. Thanks,
Josef
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] btrfs/direct-IO: fix a bug of btrfs_dio_read
@ 2010-05-06 2:12 liubo
2010-05-06 2:11 ` Josef Bacik
0 siblings, 1 reply; 3+ messages in thread
From: liubo @ 2010-05-06 2:12 UTC (permalink / raw)
To: linux-btrfs; +Cc: Josef Bacik, jim owens, Chris Mason, Yan, Zheng
As I mentioned in the bug-report, when the file size is
not n * BUFFERSIZE, this file cannot be read correctly
and the system will crash or hang up.
After investigation, I fount that data_len should be
checked before lock_extent, in order to prevent the
situation that when it comes to the file end,
diocb->lockstart changes to lockend+1, then lock_extent
will cause system's crash or hang.
So move the data_len's check ahead.
Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
fs/btrfs/dio.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/dio.c b/fs/btrfs/dio.c
index c930ff5..7178a25 100644
--- a/fs/btrfs/dio.c
+++ b/fs/btrfs/dio.c
@@ -517,11 +517,6 @@ static void btrfs_dio_read(struct btrfs_diocb *diocb)
lockend = ALIGN(end, blocksize) - 1;
getlock:
- /* writeout everything we read for checksum or compressed extents */
- filemap_write_and_wait_range(diocb->inode->i_mapping,
- diocb->lockstart, lockend);
- lock_extent(io_tree, diocb->lockstart, lockend, GFP_NOFS);
-
data_len = min_t(u64, end, i_size_read(diocb->inode));
if (data_len <= diocb->start) {
/* whatever we finished (or 0) is returned past EOF */
@@ -529,6 +524,11 @@ getlock:
}
data_len -= diocb->start;
+ /* writeout everything we read for checksum or compressed extents */
+ filemap_write_and_wait_range(diocb->inode->i_mapping,
+ diocb->lockstart, lockend);
+ lock_extent(io_tree, diocb->lockstart, lockend, GFP_NOFS);
+
safe_to_read = 0;
while (data_len && !diocb->error) { /* error in reaper stops submit */
struct extent_map *em;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs/direct-IO: fix a bug of btrfs_dio_read
2010-05-06 2:11 ` Josef Bacik
@ 2010-05-06 2:24 ` liubo
0 siblings, 0 replies; 3+ messages in thread
From: liubo @ 2010-05-06 2:24 UTC (permalink / raw)
To: Josef Bacik; +Cc: linux-btrfs, jim owens, Chris Mason, Yan, Zheng
On 05/06/2010 10:11 AM, Josef Bacik wrote:
>
> Please read my previous email, DIO has been refactored, this code isn't going to
> be used anymore. Thanks,
>
> Josef
>
>
>
All right, I'll look into new DIO. :-)
Thanks,
LiuBo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-06 2:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-06 2:12 [PATCH] btrfs/direct-IO: fix a bug of btrfs_dio_read liubo
2010-05-06 2:11 ` Josef Bacik
2010-05-06 2:24 ` liubo
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).