diff options
author | Tao Ma <boyu.mt@taobao.com> | 2011-10-31 17:30:44 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-10-31 17:30:44 -0400 |
commit | 0edeb71dc9133bfb505d3bf59642e07cd936613e (patch) | |
tree | bcb68e2676d9bba1e4e4e28fb1ba8d382caf26eb /fs/ext4/extents.c | |
parent | b82e384c7bb9a19036b4daf58fa216df7cd48aa0 (diff) |
ext4: Create helper function for EXT4_IO_END_UNWRITTEN and i_aiodio_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 have found some bugs that the flag is set while leaving
i_aiodio_unwritten unchanged(commit 32c80b32c053d). So this patch just tries
to create a helper function to wrap them to avoid any future bug.
The idea is inspired by Eric.
Cc: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 36a0f177ecad..a5c8caaaa099 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -3472,12 +3472,9 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, | |||
3472 | * that this IO needs to conversion to written when IO is | 3472 | * that this IO needs to conversion to written when IO is |
3473 | * completed | 3473 | * completed |
3474 | */ | 3474 | */ |
3475 | if (io) { | 3475 | if (io) |
3476 | if (!(io->flag & EXT4_IO_END_UNWRITTEN)) { | 3476 | ext4_set_io_unwritten_flag(inode, io); |
3477 | io->flag = EXT4_IO_END_UNWRITTEN; | 3477 | else |
3478 | atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten); | ||
3479 | } | ||
3480 | } else | ||
3481 | ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN); | 3478 | ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN); |
3482 | if (ext4_should_dioread_nolock(inode)) | 3479 | if (ext4_should_dioread_nolock(inode)) |
3483 | map->m_flags |= EXT4_MAP_UNINIT; | 3480 | map->m_flags |= EXT4_MAP_UNINIT; |
@@ -4030,12 +4027,9 @@ got_allocated_blocks: | |||
4030 | * that we need to perform conversion when IO is done. | 4027 | * that we need to perform conversion when IO is done. |
4031 | */ | 4028 | */ |
4032 | if ((flags & EXT4_GET_BLOCKS_PRE_IO)) { | 4029 | if ((flags & EXT4_GET_BLOCKS_PRE_IO)) { |
4033 | if (io) { | 4030 | if (io) |
4034 | if (!(io->flag & EXT4_IO_END_UNWRITTEN)) { | 4031 | ext4_set_io_unwritten_flag(inode, io); |
4035 | io->flag = EXT4_IO_END_UNWRITTEN; | 4032 | else |
4036 | atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten); | ||
4037 | } | ||
4038 | } else | ||
4039 | ext4_set_inode_state(inode, | 4033 | ext4_set_inode_state(inode, |
4040 | EXT4_STATE_DIO_UNWRITTEN); | 4034 | EXT4_STATE_DIO_UNWRITTEN); |
4041 | } | 4035 | } |