aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMingming <cmm@us.ibm.com>2009-11-10 10:48:04 -0500
committerTheodore Ts'o <tytso@mit.edu>2009-11-10 10:48:04 -0500
commit5f5249507e4b5c4fc0f9c93f33d133d8c95f47e1 (patch)
tree0b0a790f568c07298c3a4122572e84392c787648 /fs
parent109f55651954def97fa41ee71c464d268c512ab0 (diff)
ext4: skip conversion of uninit extents after direct IO if there isn't any
At the end of direct I/O operation, ext4_ext_direct_IO() always called ext4_convert_unwritten_extents(), regardless of whether there were any unwritten extents involved in the I/O or not. This commit adds a state flag so that ext4_ext_direct_IO() only calls ext4_convert_unwritten_extents() when necessary. Signed-off-by: Mingming Cao <cmm@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/ext4.h1
-rw-r--r--fs/ext4/extents.c22
-rw-r--r--fs/ext4/inode.c4
3 files changed, 21 insertions, 6 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 00d153f2f261..8825515eeddd 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -322,6 +322,7 @@ static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
322#define EXT4_STATE_NO_EXPAND 0x00000008 /* No space for expansion */ 322#define EXT4_STATE_NO_EXPAND 0x00000008 /* No space for expansion */
323#define EXT4_STATE_DA_ALLOC_CLOSE 0x00000010 /* Alloc DA blks on close */ 323#define EXT4_STATE_DA_ALLOC_CLOSE 0x00000010 /* Alloc DA blks on close */
324#define EXT4_STATE_EXT_MIGRATE 0x00000020 /* Inode is migrating */ 324#define EXT4_STATE_EXT_MIGRATE 0x00000020 /* Inode is migrating */
325#define EXT4_STATE_DIO_UNWRITTEN 0x00000040 /* need convert on dio done*/
325 326
326/* Used to pass group descriptor data when online resize is done */ 327/* Used to pass group descriptor data when online resize is done */
327struct ext4_new_group_input { 328struct ext4_new_group_input {
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 441716f33b4a..e991ae2b461c 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3048,12 +3048,18 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
3048 ret = ext4_split_unwritten_extents(handle, 3048 ret = ext4_split_unwritten_extents(handle,
3049 inode, path, iblock, 3049 inode, path, iblock,
3050 max_blocks, flags); 3050 max_blocks, flags);
3051 /* flag the io_end struct that we need convert when IO done */ 3051 /*
3052 * Flag the inode(non aio case) or end_io struct (aio case)
3053 * that this IO needs to convertion to written when IO is
3054 * completed
3055 */
3052 if (io) 3056 if (io)
3053 io->flag = DIO_AIO_UNWRITTEN; 3057 io->flag = DIO_AIO_UNWRITTEN;
3058 else
3059 EXT4_I(inode)->i_state |= EXT4_STATE_DIO_UNWRITTEN;
3054 goto out; 3060 goto out;
3055 } 3061 }
3056 /* DIO end_io complete, convert the filled extent to written */ 3062 /* async DIO end_io complete, convert the filled extent to written */
3057 if (flags == EXT4_GET_BLOCKS_DIO_CONVERT_EXT) { 3063 if (flags == EXT4_GET_BLOCKS_DIO_CONVERT_EXT) {
3058 ret = ext4_convert_unwritten_extents_dio(handle, inode, 3064 ret = ext4_convert_unwritten_extents_dio(handle, inode,
3059 path); 3065 path);
@@ -3295,10 +3301,16 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
3295 * To avoid unecessary convertion for every aio dio rewrite 3301 * To avoid unecessary convertion for every aio dio rewrite
3296 * to the mid of file, here we flag the IO that is really 3302 * to the mid of file, here we flag the IO that is really
3297 * need the convertion. 3303 * need the convertion.
3298 * 3304 * For non asycn direct IO case, flag the inode state
3305 * that we need to perform convertion when IO is done.
3299 */ 3306 */
3300 if (io && flags == EXT4_GET_BLOCKS_DIO_CREATE_EXT) 3307 if (flags == EXT4_GET_BLOCKS_DIO_CREATE_EXT) {
3301 io->flag = DIO_AIO_UNWRITTEN; 3308 if (io)
3309 io->flag = DIO_AIO_UNWRITTEN;
3310 else
3311 EXT4_I(inode)->i_state |=
3312 EXT4_STATE_DIO_UNWRITTEN;;
3313 }
3302 } 3314 }
3303 err = ext4_ext_insert_extent(handle, inode, path, &newex, flags); 3315 err = ext4_ext_insert_extent(handle, inode, path, &newex, flags);
3304 if (err) { 3316 if (err) {
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 12d727f8fedf..a9ed2bce74d1 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3772,7 +3772,8 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
3772 if (ret != -EIOCBQUEUED && ret <= 0 && iocb->private) { 3772 if (ret != -EIOCBQUEUED && ret <= 0 && iocb->private) {
3773 ext4_free_io_end(iocb->private); 3773 ext4_free_io_end(iocb->private);
3774 iocb->private = NULL; 3774 iocb->private = NULL;
3775 } else if (ret > 0) { 3775 } else if (ret > 0 && (EXT4_I(inode)->i_state &
3776 EXT4_STATE_DIO_UNWRITTEN)) {
3776 int err; 3777 int err;
3777 /* 3778 /*
3778 * for non AIO case, since the IO is already 3779 * for non AIO case, since the IO is already
@@ -3782,6 +3783,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
3782 offset, ret); 3783 offset, ret);
3783 if (err < 0) 3784 if (err < 0)
3784 ret = err; 3785 ret = err;
3786 EXT4_I(inode)->i_state &= ~EXT4_STATE_DIO_UNWRITTEN;
3785 } 3787 }
3786 return ret; 3788 return ret;
3787 } 3789 }