diff options
author | Tao Ma <boyu.mt@taobao.com> | 2011-08-13 12:30:59 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-08-13 12:30:59 -0400 |
commit | 32c80b32c053dc52712dedac5e4d0aa7c93fc353 (patch) | |
tree | 857375faae2d6c562741d14ed13a1411b197baf5 /fs | |
parent | 2581fdc810889fdea97689cb62481201d579c796 (diff) |
ext4: Resolve the hang of direct i/o read in handling EXT4_IO_END_UNWRITTEN.
EXT4_IO_END_UNWRITTEN flag set and the increase of i_aiodio_unwritten
should be done simultaneously since ext4_end_io_nolock always clear
the flag and decrease the counter in the same time.
We don't increase i_aiodio_unwritten when setting
EXT4_IO_END_UNWRITTEN so it will go nagative and causes some process
to wait forever.
Part of the patch came from Eric in his e-mail, but it doesn't fix the
problem met by Michael actually.
http://marc.info/?l=linux-ext4&m=131316851417460&w=2
Reported-and-Tested-by: Michael Tokarev<mjt@tls.msk.ru>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@kernel.org
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/inode.c | 9 | ||||
-rw-r--r-- | fs/ext4/page-io.c | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 7dd698107822..762e8037c888 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -2678,8 +2678,15 @@ static void ext4_end_io_buffer_write(struct buffer_head *bh, int uptodate) | |||
2678 | goto out; | 2678 | goto out; |
2679 | } | 2679 | } |
2680 | 2680 | ||
2681 | io_end->flag = EXT4_IO_END_UNWRITTEN; | 2681 | /* |
2682 | * It may be over-defensive here to check EXT4_IO_END_UNWRITTEN now, | ||
2683 | * but being more careful is always safe for the future change. | ||
2684 | */ | ||
2682 | inode = io_end->inode; | 2685 | inode = io_end->inode; |
2686 | if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) { | ||
2687 | io_end->flag |= EXT4_IO_END_UNWRITTEN; | ||
2688 | atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten); | ||
2689 | } | ||
2683 | 2690 | ||
2684 | /* Add the io_end to per-inode completed io list*/ | 2691 | /* Add the io_end to per-inode completed io list*/ |
2685 | spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags); | 2692 | spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags); |
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 430c401d0895..78839af7ce29 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c | |||
@@ -334,8 +334,10 @@ submit_and_retry: | |||
334 | if ((io_end->num_io_pages >= MAX_IO_PAGES) && | 334 | if ((io_end->num_io_pages >= MAX_IO_PAGES) && |
335 | (io_end->pages[io_end->num_io_pages-1] != io_page)) | 335 | (io_end->pages[io_end->num_io_pages-1] != io_page)) |
336 | goto submit_and_retry; | 336 | goto submit_and_retry; |
337 | if (buffer_uninit(bh)) | 337 | if (buffer_uninit(bh) && !(io_end->flag & EXT4_IO_END_UNWRITTEN)) { |
338 | io->io_end->flag |= EXT4_IO_END_UNWRITTEN; | 338 | io_end->flag |= EXT4_IO_END_UNWRITTEN; |
339 | atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten); | ||
340 | } | ||
339 | io->io_end->size += bh->b_size; | 341 | io->io_end->size += bh->b_size; |
340 | io->io_next_block++; | 342 | io->io_next_block++; |
341 | ret = bio_add_page(io->io_bio, bh->b_page, bh->b_size, bh_offset(bh)); | 343 | ret = bio_add_page(io->io_bio, bh->b_page, bh->b_size, bh_offset(bh)); |