aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorTao Ma <boyu.mt@taobao.com>2011-08-13 12:30:59 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-29 13:29:11 -0700
commit4eddd2a50f2548c6c83081fde8fdbc3de07626f6 (patch)
tree2adb177da1b18471c528e5821850b6d5233f8501 /fs/ext4/inode.c
parent2526f368949bccda6e8ed1bf74a4e955e3af42af (diff)
downloadkernel_samsung_smdk4412-4eddd2a50f2548c6c83081fde8fdbc3de07626f6.zip
kernel_samsung_smdk4412-4eddd2a50f2548c6c83081fde8fdbc3de07626f6.tar.gz
kernel_samsung_smdk4412-4eddd2a50f2548c6c83081fde8fdbc3de07626f6.tar.bz2
ext4: Resolve the hang of direct i/o read in handling EXT4_IO_END_UNWRITTEN.
commit 32c80b32c053dc52712dedac5e4d0aa7c93fc353 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 773de46..5390b4d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3645,8 +3645,15 @@ static void ext4_end_io_buffer_write(struct buffer_head *bh, int uptodate)
goto out;
}
- io_end->flag = EXT4_IO_END_UNWRITTEN;
+ /*
+ * It may be over-defensive here to check EXT4_IO_END_UNWRITTEN now,
+ * but being more careful is always safe for the future change.
+ */
inode = io_end->inode;
+ if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
+ io_end->flag |= EXT4_IO_END_UNWRITTEN;
+ atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten);
+ }
/* Add the io_end to per-inode completed io list*/
spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags);