diff options
| author | David S. Miller <davem@davemloft.net> | 2009-12-03 15:51:21 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2009-12-03 15:51:21 -0500 |
| commit | a6c872afb2536f47285e6643f4629dec7520041d (patch) | |
| tree | 4b54e69fc6594f9afc1277520a350db04e578e77 /fs/ext4/extents.c | |
| parent | 9fe02668fe48a1d546196bc1392330ff28d9bd57 (diff) | |
| parent | 22763c5cf3690a681551162c15d34d935308c8d7 (diff) | |
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Diffstat (limited to 'fs/ext4/extents.c')
| -rw-r--r-- | fs/ext4/extents.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 10539e364283..715264b4bae4 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
| @@ -2807,6 +2807,8 @@ fix_extent_len: | |||
| 2807 | * into three uninitialized extent(at most). After IO complete, the part | 2807 | * into three uninitialized extent(at most). After IO complete, the part |
| 2808 | * being filled will be convert to initialized by the end_io callback function | 2808 | * being filled will be convert to initialized by the end_io callback function |
| 2809 | * via ext4_convert_unwritten_extents(). | 2809 | * via ext4_convert_unwritten_extents(). |
| 2810 | * | ||
| 2811 | * Returns the size of uninitialized extent to be written on success. | ||
| 2810 | */ | 2812 | */ |
| 2811 | static int ext4_split_unwritten_extents(handle_t *handle, | 2813 | static int ext4_split_unwritten_extents(handle_t *handle, |
| 2812 | struct inode *inode, | 2814 | struct inode *inode, |
| @@ -2824,7 +2826,6 @@ static int ext4_split_unwritten_extents(handle_t *handle, | |||
| 2824 | unsigned int allocated, ee_len, depth; | 2826 | unsigned int allocated, ee_len, depth; |
| 2825 | ext4_fsblk_t newblock; | 2827 | ext4_fsblk_t newblock; |
| 2826 | int err = 0; | 2828 | int err = 0; |
| 2827 | int ret = 0; | ||
| 2828 | 2829 | ||
| 2829 | ext_debug("ext4_split_unwritten_extents: inode %lu," | 2830 | ext_debug("ext4_split_unwritten_extents: inode %lu," |
| 2830 | "iblock %llu, max_blocks %u\n", inode->i_ino, | 2831 | "iblock %llu, max_blocks %u\n", inode->i_ino, |
| @@ -2842,12 +2843,12 @@ static int ext4_split_unwritten_extents(handle_t *handle, | |||
| 2842 | ext4_ext_store_pblock(&orig_ex, ext_pblock(ex)); | 2843 | ext4_ext_store_pblock(&orig_ex, ext_pblock(ex)); |
| 2843 | 2844 | ||
| 2844 | /* | 2845 | /* |
| 2845 | * if the entire unintialized extent length less than | 2846 | * If the uninitialized extent begins at the same logical |
| 2846 | * the size of extent to write, there is no need to split | 2847 | * block where the write begins, and the write completely |
| 2847 | * uninitialized extent | 2848 | * covers the extent, then we don't need to split it. |
| 2848 | */ | 2849 | */ |
| 2849 | if (allocated <= max_blocks) | 2850 | if ((iblock == ee_block) && (allocated <= max_blocks)) |
| 2850 | return ret; | 2851 | return allocated; |
| 2851 | 2852 | ||
| 2852 | err = ext4_ext_get_access(handle, inode, path + depth); | 2853 | err = ext4_ext_get_access(handle, inode, path + depth); |
| 2853 | if (err) | 2854 | if (err) |
| @@ -3048,12 +3049,18 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, | |||
| 3048 | ret = ext4_split_unwritten_extents(handle, | 3049 | ret = ext4_split_unwritten_extents(handle, |
| 3049 | inode, path, iblock, | 3050 | inode, path, iblock, |
| 3050 | max_blocks, flags); | 3051 | max_blocks, flags); |
| 3051 | /* flag the io_end struct that we need convert when IO done */ | 3052 | /* |
| 3053 | * Flag the inode(non aio case) or end_io struct (aio case) | ||
| 3054 | * that this IO needs to convertion to written when IO is | ||
| 3055 | * completed | ||
| 3056 | */ | ||
| 3052 | if (io) | 3057 | if (io) |
| 3053 | io->flag = DIO_AIO_UNWRITTEN; | 3058 | io->flag = DIO_AIO_UNWRITTEN; |
| 3059 | else | ||
| 3060 | EXT4_I(inode)->i_state |= EXT4_STATE_DIO_UNWRITTEN; | ||
| 3054 | goto out; | 3061 | goto out; |
| 3055 | } | 3062 | } |
| 3056 | /* DIO end_io complete, convert the filled extent to written */ | 3063 | /* async DIO end_io complete, convert the filled extent to written */ |
| 3057 | if (flags == EXT4_GET_BLOCKS_DIO_CONVERT_EXT) { | 3064 | if (flags == EXT4_GET_BLOCKS_DIO_CONVERT_EXT) { |
| 3058 | ret = ext4_convert_unwritten_extents_dio(handle, inode, | 3065 | ret = ext4_convert_unwritten_extents_dio(handle, inode, |
| 3059 | path); | 3066 | path); |
| @@ -3295,10 +3302,16 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | |||
| 3295 | * To avoid unecessary convertion for every aio dio rewrite | 3302 | * To avoid unecessary convertion for every aio dio rewrite |
| 3296 | * to the mid of file, here we flag the IO that is really | 3303 | * to the mid of file, here we flag the IO that is really |
| 3297 | * need the convertion. | 3304 | * need the convertion. |
| 3298 | * | 3305 | * For non asycn direct IO case, flag the inode state |
| 3306 | * that we need to perform convertion when IO is done. | ||
| 3299 | */ | 3307 | */ |
| 3300 | if (io && flags == EXT4_GET_BLOCKS_DIO_CREATE_EXT) | 3308 | if (flags == EXT4_GET_BLOCKS_DIO_CREATE_EXT) { |
| 3301 | io->flag = DIO_AIO_UNWRITTEN; | 3309 | if (io) |
| 3310 | io->flag = DIO_AIO_UNWRITTEN; | ||
| 3311 | else | ||
| 3312 | EXT4_I(inode)->i_state |= | ||
| 3313 | EXT4_STATE_DIO_UNWRITTEN;; | ||
| 3314 | } | ||
| 3302 | } | 3315 | } |
| 3303 | err = ext4_ext_insert_extent(handle, inode, path, &newex, flags); | 3316 | err = ext4_ext_insert_extent(handle, inode, path, &newex, flags); |
| 3304 | if (err) { | 3317 | if (err) { |
| @@ -3519,6 +3532,7 @@ retry: | |||
| 3519 | * | 3532 | * |
| 3520 | * This function is called from the direct IO end io call back | 3533 | * This function is called from the direct IO end io call back |
| 3521 | * function, to convert the fallocated extents after IO is completed. | 3534 | * function, to convert the fallocated extents after IO is completed. |
| 3535 | * Returns 0 on success. | ||
| 3522 | */ | 3536 | */ |
| 3523 | int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset, | 3537 | int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset, |
| 3524 | loff_t len) | 3538 | loff_t len) |
