diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-05-06 17:38:41 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-05-06 17:38:41 -0400 |
commit | a8324754889c0a491b216bc0502ef9ba557eeac7 (patch) | |
tree | b8772481375d524a079519d00a74c347682a24dd /fs/ext4 | |
parent | 1456c0a87c4241d3a801651019e66983c69ad17d (diff) | |
parent | f5ccfe1ddbaf9d923a3ebdadcb1e5e32d83e9c28 (diff) |
Merge ext4 changes in ext4_file_write() into for-next
From ext4.git#dev, needed for switch of ext4 to ->write_iter() ;-/
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/ext4.h | 24 | ||||
-rw-r--r-- | fs/ext4/ext4_extents.h | 22 | ||||
-rw-r--r-- | fs/ext4/extents.c | 222 | ||||
-rw-r--r-- | fs/ext4/extents_status.c | 2 | ||||
-rw-r--r-- | fs/ext4/file.c | 150 | ||||
-rw-r--r-- | fs/ext4/inode.c | 25 | ||||
-rw-r--r-- | fs/ext4/move_extent.c | 38 | ||||
-rw-r--r-- | fs/ext4/super.c | 2 |
8 files changed, 240 insertions, 245 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 9334f55dab6f..eb37d76bf911 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -158,7 +158,6 @@ struct ext4_allocation_request { | |||
158 | #define EXT4_MAP_MAPPED (1 << BH_Mapped) | 158 | #define EXT4_MAP_MAPPED (1 << BH_Mapped) |
159 | #define EXT4_MAP_UNWRITTEN (1 << BH_Unwritten) | 159 | #define EXT4_MAP_UNWRITTEN (1 << BH_Unwritten) |
160 | #define EXT4_MAP_BOUNDARY (1 << BH_Boundary) | 160 | #define EXT4_MAP_BOUNDARY (1 << BH_Boundary) |
161 | #define EXT4_MAP_UNINIT (1 << BH_Uninit) | ||
162 | /* Sometimes (in the bigalloc case, from ext4_da_get_block_prep) the caller of | 161 | /* Sometimes (in the bigalloc case, from ext4_da_get_block_prep) the caller of |
163 | * ext4_map_blocks wants to know whether or not the underlying cluster has | 162 | * ext4_map_blocks wants to know whether or not the underlying cluster has |
164 | * already been accounted for. EXT4_MAP_FROM_CLUSTER conveys to the caller that | 163 | * already been accounted for. EXT4_MAP_FROM_CLUSTER conveys to the caller that |
@@ -169,7 +168,7 @@ struct ext4_allocation_request { | |||
169 | #define EXT4_MAP_FROM_CLUSTER (1 << BH_AllocFromCluster) | 168 | #define EXT4_MAP_FROM_CLUSTER (1 << BH_AllocFromCluster) |
170 | #define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\ | 169 | #define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\ |
171 | EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY |\ | 170 | EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY |\ |
172 | EXT4_MAP_UNINIT | EXT4_MAP_FROM_CLUSTER) | 171 | EXT4_MAP_FROM_CLUSTER) |
173 | 172 | ||
174 | struct ext4_map_blocks { | 173 | struct ext4_map_blocks { |
175 | ext4_fsblk_t m_pblk; | 174 | ext4_fsblk_t m_pblk; |
@@ -184,7 +183,7 @@ struct ext4_map_blocks { | |||
184 | #define EXT4_IO_END_UNWRITTEN 0x0001 | 183 | #define EXT4_IO_END_UNWRITTEN 0x0001 |
185 | 184 | ||
186 | /* | 185 | /* |
187 | * For converting uninitialized extents on a work queue. 'handle' is used for | 186 | * For converting unwritten extents on a work queue. 'handle' is used for |
188 | * buffered writeback. | 187 | * buffered writeback. |
189 | */ | 188 | */ |
190 | typedef struct ext4_io_end { | 189 | typedef struct ext4_io_end { |
@@ -537,26 +536,26 @@ enum { | |||
537 | /* | 536 | /* |
538 | * Flags used by ext4_map_blocks() | 537 | * Flags used by ext4_map_blocks() |
539 | */ | 538 | */ |
540 | /* Allocate any needed blocks and/or convert an unitialized | 539 | /* Allocate any needed blocks and/or convert an unwritten |
541 | extent to be an initialized ext4 */ | 540 | extent to be an initialized ext4 */ |
542 | #define EXT4_GET_BLOCKS_CREATE 0x0001 | 541 | #define EXT4_GET_BLOCKS_CREATE 0x0001 |
543 | /* Request the creation of an unitialized extent */ | 542 | /* Request the creation of an unwritten extent */ |
544 | #define EXT4_GET_BLOCKS_UNINIT_EXT 0x0002 | 543 | #define EXT4_GET_BLOCKS_UNWRIT_EXT 0x0002 |
545 | #define EXT4_GET_BLOCKS_CREATE_UNINIT_EXT (EXT4_GET_BLOCKS_UNINIT_EXT|\ | 544 | #define EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT (EXT4_GET_BLOCKS_UNWRIT_EXT|\ |
546 | EXT4_GET_BLOCKS_CREATE) | 545 | EXT4_GET_BLOCKS_CREATE) |
547 | /* Caller is from the delayed allocation writeout path | 546 | /* Caller is from the delayed allocation writeout path |
548 | * finally doing the actual allocation of delayed blocks */ | 547 | * finally doing the actual allocation of delayed blocks */ |
549 | #define EXT4_GET_BLOCKS_DELALLOC_RESERVE 0x0004 | 548 | #define EXT4_GET_BLOCKS_DELALLOC_RESERVE 0x0004 |
550 | /* caller is from the direct IO path, request to creation of an | 549 | /* caller is from the direct IO path, request to creation of an |
551 | unitialized extents if not allocated, split the uninitialized | 550 | unwritten extents if not allocated, split the unwritten |
552 | extent if blocks has been preallocated already*/ | 551 | extent if blocks has been preallocated already*/ |
553 | #define EXT4_GET_BLOCKS_PRE_IO 0x0008 | 552 | #define EXT4_GET_BLOCKS_PRE_IO 0x0008 |
554 | #define EXT4_GET_BLOCKS_CONVERT 0x0010 | 553 | #define EXT4_GET_BLOCKS_CONVERT 0x0010 |
555 | #define EXT4_GET_BLOCKS_IO_CREATE_EXT (EXT4_GET_BLOCKS_PRE_IO|\ | 554 | #define EXT4_GET_BLOCKS_IO_CREATE_EXT (EXT4_GET_BLOCKS_PRE_IO|\ |
556 | EXT4_GET_BLOCKS_CREATE_UNINIT_EXT) | 555 | EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT) |
557 | /* Convert extent to initialized after IO complete */ | 556 | /* Convert extent to initialized after IO complete */ |
558 | #define EXT4_GET_BLOCKS_IO_CONVERT_EXT (EXT4_GET_BLOCKS_CONVERT|\ | 557 | #define EXT4_GET_BLOCKS_IO_CONVERT_EXT (EXT4_GET_BLOCKS_CONVERT|\ |
559 | EXT4_GET_BLOCKS_CREATE_UNINIT_EXT) | 558 | EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT) |
560 | /* Eventual metadata allocation (due to growing extent tree) | 559 | /* Eventual metadata allocation (due to growing extent tree) |
561 | * should not fail, so try to use reserved blocks for that.*/ | 560 | * should not fail, so try to use reserved blocks for that.*/ |
562 | #define EXT4_GET_BLOCKS_METADATA_NOFAIL 0x0020 | 561 | #define EXT4_GET_BLOCKS_METADATA_NOFAIL 0x0020 |
@@ -2783,10 +2782,9 @@ extern int ext4_mmp_csum_verify(struct super_block *sb, | |||
2783 | * See EXT4_MAP_... to see where this is used. | 2782 | * See EXT4_MAP_... to see where this is used. |
2784 | */ | 2783 | */ |
2785 | enum ext4_state_bits { | 2784 | enum ext4_state_bits { |
2786 | BH_Uninit /* blocks are allocated but uninitialized on disk */ | 2785 | BH_AllocFromCluster /* allocated blocks were part of already |
2787 | = BH_JBDPrivateStart, | ||
2788 | BH_AllocFromCluster, /* allocated blocks were part of already | ||
2789 | * allocated cluster. */ | 2786 | * allocated cluster. */ |
2787 | = BH_JBDPrivateStart | ||
2790 | }; | 2788 | }; |
2791 | 2789 | ||
2792 | /* | 2790 | /* |
diff --git a/fs/ext4/ext4_extents.h b/fs/ext4/ext4_extents.h index 5074fe23f19e..a867f5ca9991 100644 --- a/fs/ext4/ext4_extents.h +++ b/fs/ext4/ext4_extents.h | |||
@@ -137,21 +137,21 @@ struct ext4_ext_path { | |||
137 | * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an | 137 | * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an |
138 | * initialized extent. This is 2^15 and not (2^16 - 1), since we use the | 138 | * initialized extent. This is 2^15 and not (2^16 - 1), since we use the |
139 | * MSB of ee_len field in the extent datastructure to signify if this | 139 | * MSB of ee_len field in the extent datastructure to signify if this |
140 | * particular extent is an initialized extent or an uninitialized (i.e. | 140 | * particular extent is an initialized extent or an unwritten (i.e. |
141 | * preallocated). | 141 | * preallocated). |
142 | * EXT_UNINIT_MAX_LEN is the maximum number of blocks we can have in an | 142 | * EXT_UNWRITTEN_MAX_LEN is the maximum number of blocks we can have in an |
143 | * uninitialized extent. | 143 | * unwritten extent. |
144 | * If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an | 144 | * If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an |
145 | * uninitialized one. In other words, if MSB of ee_len is set, it is an | 145 | * unwritten one. In other words, if MSB of ee_len is set, it is an |
146 | * uninitialized extent with only one special scenario when ee_len = 0x8000. | 146 | * unwritten extent with only one special scenario when ee_len = 0x8000. |
147 | * In this case we can not have an uninitialized extent of zero length and | 147 | * In this case we can not have an unwritten extent of zero length and |
148 | * thus we make it as a special case of initialized extent with 0x8000 length. | 148 | * thus we make it as a special case of initialized extent with 0x8000 length. |
149 | * This way we get better extent-to-group alignment for initialized extents. | 149 | * This way we get better extent-to-group alignment for initialized extents. |
150 | * Hence, the maximum number of blocks we can have in an *initialized* | 150 | * Hence, the maximum number of blocks we can have in an *initialized* |
151 | * extent is 2^15 (32768) and in an *uninitialized* extent is 2^15-1 (32767). | 151 | * extent is 2^15 (32768) and in an *unwritten* extent is 2^15-1 (32767). |
152 | */ | 152 | */ |
153 | #define EXT_INIT_MAX_LEN (1UL << 15) | 153 | #define EXT_INIT_MAX_LEN (1UL << 15) |
154 | #define EXT_UNINIT_MAX_LEN (EXT_INIT_MAX_LEN - 1) | 154 | #define EXT_UNWRITTEN_MAX_LEN (EXT_INIT_MAX_LEN - 1) |
155 | 155 | ||
156 | 156 | ||
157 | #define EXT_FIRST_EXTENT(__hdr__) \ | 157 | #define EXT_FIRST_EXTENT(__hdr__) \ |
@@ -187,14 +187,14 @@ static inline unsigned short ext_depth(struct inode *inode) | |||
187 | return le16_to_cpu(ext_inode_hdr(inode)->eh_depth); | 187 | return le16_to_cpu(ext_inode_hdr(inode)->eh_depth); |
188 | } | 188 | } |
189 | 189 | ||
190 | static inline void ext4_ext_mark_uninitialized(struct ext4_extent *ext) | 190 | static inline void ext4_ext_mark_unwritten(struct ext4_extent *ext) |
191 | { | 191 | { |
192 | /* We can not have an uninitialized extent of zero length! */ | 192 | /* We can not have an unwritten extent of zero length! */ |
193 | BUG_ON((le16_to_cpu(ext->ee_len) & ~EXT_INIT_MAX_LEN) == 0); | 193 | BUG_ON((le16_to_cpu(ext->ee_len) & ~EXT_INIT_MAX_LEN) == 0); |
194 | ext->ee_len |= cpu_to_le16(EXT_INIT_MAX_LEN); | 194 | ext->ee_len |= cpu_to_le16(EXT_INIT_MAX_LEN); |
195 | } | 195 | } |
196 | 196 | ||
197 | static inline int ext4_ext_is_uninitialized(struct ext4_extent *ext) | 197 | static inline int ext4_ext_is_unwritten(struct ext4_extent *ext) |
198 | { | 198 | { |
199 | /* Extent with ee_len of 0x8000 is treated as an initialized extent */ | 199 | /* Extent with ee_len of 0x8000 is treated as an initialized extent */ |
200 | return (le16_to_cpu(ext->ee_len) > EXT_INIT_MAX_LEN); | 200 | return (le16_to_cpu(ext->ee_len) > EXT_INIT_MAX_LEN); |
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 01b0c208f625..e305a31641f2 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -50,8 +50,8 @@ | |||
50 | */ | 50 | */ |
51 | #define EXT4_EXT_MAY_ZEROOUT 0x1 /* safe to zeroout if split fails \ | 51 | #define EXT4_EXT_MAY_ZEROOUT 0x1 /* safe to zeroout if split fails \ |
52 | due to ENOSPC */ | 52 | due to ENOSPC */ |
53 | #define EXT4_EXT_MARK_UNINIT1 0x2 /* mark first half uninitialized */ | 53 | #define EXT4_EXT_MARK_UNWRIT1 0x2 /* mark first half unwritten */ |
54 | #define EXT4_EXT_MARK_UNINIT2 0x4 /* mark second half uninitialized */ | 54 | #define EXT4_EXT_MARK_UNWRIT2 0x4 /* mark second half unwritten */ |
55 | 55 | ||
56 | #define EXT4_EXT_DATA_VALID1 0x8 /* first half contains valid data */ | 56 | #define EXT4_EXT_DATA_VALID1 0x8 /* first half contains valid data */ |
57 | #define EXT4_EXT_DATA_VALID2 0x10 /* second half contains valid data */ | 57 | #define EXT4_EXT_DATA_VALID2 0x10 /* second half contains valid data */ |
@@ -524,7 +524,7 @@ __read_extent_tree_block(const char *function, unsigned int line, | |||
524 | lblk - prev, ~0, | 524 | lblk - prev, ~0, |
525 | EXTENT_STATUS_HOLE); | 525 | EXTENT_STATUS_HOLE); |
526 | 526 | ||
527 | if (ext4_ext_is_uninitialized(ex)) | 527 | if (ext4_ext_is_unwritten(ex)) |
528 | status = EXTENT_STATUS_UNWRITTEN; | 528 | status = EXTENT_STATUS_UNWRITTEN; |
529 | ext4_es_cache_extent(inode, lblk, len, | 529 | ext4_es_cache_extent(inode, lblk, len, |
530 | ext4_ext_pblock(ex), status); | 530 | ext4_ext_pblock(ex), status); |
@@ -620,7 +620,7 @@ static void ext4_ext_show_path(struct inode *inode, struct ext4_ext_path *path) | |||
620 | } else if (path->p_ext) { | 620 | } else if (path->p_ext) { |
621 | ext_debug(" %d:[%d]%d:%llu ", | 621 | ext_debug(" %d:[%d]%d:%llu ", |
622 | le32_to_cpu(path->p_ext->ee_block), | 622 | le32_to_cpu(path->p_ext->ee_block), |
623 | ext4_ext_is_uninitialized(path->p_ext), | 623 | ext4_ext_is_unwritten(path->p_ext), |
624 | ext4_ext_get_actual_len(path->p_ext), | 624 | ext4_ext_get_actual_len(path->p_ext), |
625 | ext4_ext_pblock(path->p_ext)); | 625 | ext4_ext_pblock(path->p_ext)); |
626 | } else | 626 | } else |
@@ -646,7 +646,7 @@ static void ext4_ext_show_leaf(struct inode *inode, struct ext4_ext_path *path) | |||
646 | 646 | ||
647 | for (i = 0; i < le16_to_cpu(eh->eh_entries); i++, ex++) { | 647 | for (i = 0; i < le16_to_cpu(eh->eh_entries); i++, ex++) { |
648 | ext_debug("%d:[%d]%d:%llu ", le32_to_cpu(ex->ee_block), | 648 | ext_debug("%d:[%d]%d:%llu ", le32_to_cpu(ex->ee_block), |
649 | ext4_ext_is_uninitialized(ex), | 649 | ext4_ext_is_unwritten(ex), |
650 | ext4_ext_get_actual_len(ex), ext4_ext_pblock(ex)); | 650 | ext4_ext_get_actual_len(ex), ext4_ext_pblock(ex)); |
651 | } | 651 | } |
652 | ext_debug("\n"); | 652 | ext_debug("\n"); |
@@ -677,7 +677,7 @@ static void ext4_ext_show_move(struct inode *inode, struct ext4_ext_path *path, | |||
677 | ext_debug("move %d:%llu:[%d]%d in new leaf %llu\n", | 677 | ext_debug("move %d:%llu:[%d]%d in new leaf %llu\n", |
678 | le32_to_cpu(ex->ee_block), | 678 | le32_to_cpu(ex->ee_block), |
679 | ext4_ext_pblock(ex), | 679 | ext4_ext_pblock(ex), |
680 | ext4_ext_is_uninitialized(ex), | 680 | ext4_ext_is_unwritten(ex), |
681 | ext4_ext_get_actual_len(ex), | 681 | ext4_ext_get_actual_len(ex), |
682 | newblock); | 682 | newblock); |
683 | ex++; | 683 | ex++; |
@@ -802,7 +802,7 @@ ext4_ext_binsearch(struct inode *inode, | |||
802 | ext_debug(" -> %d:%llu:[%d]%d ", | 802 | ext_debug(" -> %d:%llu:[%d]%d ", |
803 | le32_to_cpu(path->p_ext->ee_block), | 803 | le32_to_cpu(path->p_ext->ee_block), |
804 | ext4_ext_pblock(path->p_ext), | 804 | ext4_ext_pblock(path->p_ext), |
805 | ext4_ext_is_uninitialized(path->p_ext), | 805 | ext4_ext_is_unwritten(path->p_ext), |
806 | ext4_ext_get_actual_len(path->p_ext)); | 806 | ext4_ext_get_actual_len(path->p_ext)); |
807 | 807 | ||
808 | #ifdef CHECK_BINSEARCH | 808 | #ifdef CHECK_BINSEARCH |
@@ -1686,11 +1686,11 @@ ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1, | |||
1686 | 1686 | ||
1687 | /* | 1687 | /* |
1688 | * Make sure that both extents are initialized. We don't merge | 1688 | * Make sure that both extents are initialized. We don't merge |
1689 | * uninitialized extents so that we can be sure that end_io code has | 1689 | * unwritten extents so that we can be sure that end_io code has |
1690 | * the extent that was written properly split out and conversion to | 1690 | * the extent that was written properly split out and conversion to |
1691 | * initialized is trivial. | 1691 | * initialized is trivial. |
1692 | */ | 1692 | */ |
1693 | if (ext4_ext_is_uninitialized(ex1) != ext4_ext_is_uninitialized(ex2)) | 1693 | if (ext4_ext_is_unwritten(ex1) != ext4_ext_is_unwritten(ex2)) |
1694 | return 0; | 1694 | return 0; |
1695 | 1695 | ||
1696 | ext1_ee_len = ext4_ext_get_actual_len(ex1); | 1696 | ext1_ee_len = ext4_ext_get_actual_len(ex1); |
@@ -1707,10 +1707,10 @@ ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1, | |||
1707 | */ | 1707 | */ |
1708 | if (ext1_ee_len + ext2_ee_len > EXT_INIT_MAX_LEN) | 1708 | if (ext1_ee_len + ext2_ee_len > EXT_INIT_MAX_LEN) |
1709 | return 0; | 1709 | return 0; |
1710 | if (ext4_ext_is_uninitialized(ex1) && | 1710 | if (ext4_ext_is_unwritten(ex1) && |
1711 | (ext4_test_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN) || | 1711 | (ext4_test_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN) || |
1712 | atomic_read(&EXT4_I(inode)->i_unwritten) || | 1712 | atomic_read(&EXT4_I(inode)->i_unwritten) || |
1713 | (ext1_ee_len + ext2_ee_len > EXT_UNINIT_MAX_LEN))) | 1713 | (ext1_ee_len + ext2_ee_len > EXT_UNWRITTEN_MAX_LEN))) |
1714 | return 0; | 1714 | return 0; |
1715 | #ifdef AGGRESSIVE_TEST | 1715 | #ifdef AGGRESSIVE_TEST |
1716 | if (ext1_ee_len >= 4) | 1716 | if (ext1_ee_len >= 4) |
@@ -1735,7 +1735,7 @@ static int ext4_ext_try_to_merge_right(struct inode *inode, | |||
1735 | { | 1735 | { |
1736 | struct ext4_extent_header *eh; | 1736 | struct ext4_extent_header *eh; |
1737 | unsigned int depth, len; | 1737 | unsigned int depth, len; |
1738 | int merge_done = 0, uninit; | 1738 | int merge_done = 0, unwritten; |
1739 | 1739 | ||
1740 | depth = ext_depth(inode); | 1740 | depth = ext_depth(inode); |
1741 | BUG_ON(path[depth].p_hdr == NULL); | 1741 | BUG_ON(path[depth].p_hdr == NULL); |
@@ -1745,11 +1745,11 @@ static int ext4_ext_try_to_merge_right(struct inode *inode, | |||
1745 | if (!ext4_can_extents_be_merged(inode, ex, ex + 1)) | 1745 | if (!ext4_can_extents_be_merged(inode, ex, ex + 1)) |
1746 | break; | 1746 | break; |
1747 | /* merge with next extent! */ | 1747 | /* merge with next extent! */ |
1748 | uninit = ext4_ext_is_uninitialized(ex); | 1748 | unwritten = ext4_ext_is_unwritten(ex); |
1749 | ex->ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex) | 1749 | ex->ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex) |
1750 | + ext4_ext_get_actual_len(ex + 1)); | 1750 | + ext4_ext_get_actual_len(ex + 1)); |
1751 | if (uninit) | 1751 | if (unwritten) |
1752 | ext4_ext_mark_uninitialized(ex); | 1752 | ext4_ext_mark_unwritten(ex); |
1753 | 1753 | ||
1754 | if (ex + 1 < EXT_LAST_EXTENT(eh)) { | 1754 | if (ex + 1 < EXT_LAST_EXTENT(eh)) { |
1755 | len = (EXT_LAST_EXTENT(eh) - ex - 1) | 1755 | len = (EXT_LAST_EXTENT(eh) - ex - 1) |
@@ -1903,7 +1903,7 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, | |||
1903 | struct ext4_ext_path *npath = NULL; | 1903 | struct ext4_ext_path *npath = NULL; |
1904 | int depth, len, err; | 1904 | int depth, len, err; |
1905 | ext4_lblk_t next; | 1905 | ext4_lblk_t next; |
1906 | int mb_flags = 0, uninit; | 1906 | int mb_flags = 0, unwritten; |
1907 | 1907 | ||
1908 | if (unlikely(ext4_ext_get_actual_len(newext) == 0)) { | 1908 | if (unlikely(ext4_ext_get_actual_len(newext) == 0)) { |
1909 | EXT4_ERROR_INODE(inode, "ext4_ext_get_actual_len(newext) == 0"); | 1909 | EXT4_ERROR_INODE(inode, "ext4_ext_get_actual_len(newext) == 0"); |
@@ -1943,21 +1943,21 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, | |||
1943 | if (ext4_can_extents_be_merged(inode, ex, newext)) { | 1943 | if (ext4_can_extents_be_merged(inode, ex, newext)) { |
1944 | ext_debug("append [%d]%d block to %u:[%d]%d" | 1944 | ext_debug("append [%d]%d block to %u:[%d]%d" |
1945 | "(from %llu)\n", | 1945 | "(from %llu)\n", |
1946 | ext4_ext_is_uninitialized(newext), | 1946 | ext4_ext_is_unwritten(newext), |
1947 | ext4_ext_get_actual_len(newext), | 1947 | ext4_ext_get_actual_len(newext), |
1948 | le32_to_cpu(ex->ee_block), | 1948 | le32_to_cpu(ex->ee_block), |
1949 | ext4_ext_is_uninitialized(ex), | 1949 | ext4_ext_is_unwritten(ex), |
1950 | ext4_ext_get_actual_len(ex), | 1950 | ext4_ext_get_actual_len(ex), |
1951 | ext4_ext_pblock(ex)); | 1951 | ext4_ext_pblock(ex)); |
1952 | err = ext4_ext_get_access(handle, inode, | 1952 | err = ext4_ext_get_access(handle, inode, |
1953 | path + depth); | 1953 | path + depth); |
1954 | if (err) | 1954 | if (err) |
1955 | return err; | 1955 | return err; |
1956 | uninit = ext4_ext_is_uninitialized(ex); | 1956 | unwritten = ext4_ext_is_unwritten(ex); |
1957 | ex->ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex) | 1957 | ex->ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex) |
1958 | + ext4_ext_get_actual_len(newext)); | 1958 | + ext4_ext_get_actual_len(newext)); |
1959 | if (uninit) | 1959 | if (unwritten) |
1960 | ext4_ext_mark_uninitialized(ex); | 1960 | ext4_ext_mark_unwritten(ex); |
1961 | eh = path[depth].p_hdr; | 1961 | eh = path[depth].p_hdr; |
1962 | nearex = ex; | 1962 | nearex = ex; |
1963 | goto merge; | 1963 | goto merge; |
@@ -1969,10 +1969,10 @@ prepend: | |||
1969 | ext_debug("prepend %u[%d]%d block to %u:[%d]%d" | 1969 | ext_debug("prepend %u[%d]%d block to %u:[%d]%d" |
1970 | "(from %llu)\n", | 1970 | "(from %llu)\n", |
1971 | le32_to_cpu(newext->ee_block), | 1971 | le32_to_cpu(newext->ee_block), |
1972 | ext4_ext_is_uninitialized(newext), | 1972 | ext4_ext_is_unwritten(newext), |
1973 | ext4_ext_get_actual_len(newext), | 1973 | ext4_ext_get_actual_len(newext), |
1974 | le32_to_cpu(ex->ee_block), | 1974 | le32_to_cpu(ex->ee_block), |
1975 | ext4_ext_is_uninitialized(ex), | 1975 | ext4_ext_is_unwritten(ex), |
1976 | ext4_ext_get_actual_len(ex), | 1976 | ext4_ext_get_actual_len(ex), |
1977 | ext4_ext_pblock(ex)); | 1977 | ext4_ext_pblock(ex)); |
1978 | err = ext4_ext_get_access(handle, inode, | 1978 | err = ext4_ext_get_access(handle, inode, |
@@ -1980,13 +1980,13 @@ prepend: | |||
1980 | if (err) | 1980 | if (err) |
1981 | return err; | 1981 | return err; |
1982 | 1982 | ||
1983 | uninit = ext4_ext_is_uninitialized(ex); | 1983 | unwritten = ext4_ext_is_unwritten(ex); |
1984 | ex->ee_block = newext->ee_block; | 1984 | ex->ee_block = newext->ee_block; |
1985 | ext4_ext_store_pblock(ex, ext4_ext_pblock(newext)); | 1985 | ext4_ext_store_pblock(ex, ext4_ext_pblock(newext)); |
1986 | ex->ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex) | 1986 | ex->ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex) |
1987 | + ext4_ext_get_actual_len(newext)); | 1987 | + ext4_ext_get_actual_len(newext)); |
1988 | if (uninit) | 1988 | if (unwritten) |
1989 | ext4_ext_mark_uninitialized(ex); | 1989 | ext4_ext_mark_unwritten(ex); |
1990 | eh = path[depth].p_hdr; | 1990 | eh = path[depth].p_hdr; |
1991 | nearex = ex; | 1991 | nearex = ex; |
1992 | goto merge; | 1992 | goto merge; |
@@ -2046,7 +2046,7 @@ has_space: | |||
2046 | ext_debug("first extent in the leaf: %u:%llu:[%d]%d\n", | 2046 | ext_debug("first extent in the leaf: %u:%llu:[%d]%d\n", |
2047 | le32_to_cpu(newext->ee_block), | 2047 | le32_to_cpu(newext->ee_block), |
2048 | ext4_ext_pblock(newext), | 2048 | ext4_ext_pblock(newext), |
2049 | ext4_ext_is_uninitialized(newext), | 2049 | ext4_ext_is_unwritten(newext), |
2050 | ext4_ext_get_actual_len(newext)); | 2050 | ext4_ext_get_actual_len(newext)); |
2051 | nearex = EXT_FIRST_EXTENT(eh); | 2051 | nearex = EXT_FIRST_EXTENT(eh); |
2052 | } else { | 2052 | } else { |
@@ -2057,7 +2057,7 @@ has_space: | |||
2057 | "nearest %p\n", | 2057 | "nearest %p\n", |
2058 | le32_to_cpu(newext->ee_block), | 2058 | le32_to_cpu(newext->ee_block), |
2059 | ext4_ext_pblock(newext), | 2059 | ext4_ext_pblock(newext), |
2060 | ext4_ext_is_uninitialized(newext), | 2060 | ext4_ext_is_unwritten(newext), |
2061 | ext4_ext_get_actual_len(newext), | 2061 | ext4_ext_get_actual_len(newext), |
2062 | nearex); | 2062 | nearex); |
2063 | nearex++; | 2063 | nearex++; |
@@ -2068,7 +2068,7 @@ has_space: | |||
2068 | "nearest %p\n", | 2068 | "nearest %p\n", |
2069 | le32_to_cpu(newext->ee_block), | 2069 | le32_to_cpu(newext->ee_block), |
2070 | ext4_ext_pblock(newext), | 2070 | ext4_ext_pblock(newext), |
2071 | ext4_ext_is_uninitialized(newext), | 2071 | ext4_ext_is_unwritten(newext), |
2072 | ext4_ext_get_actual_len(newext), | 2072 | ext4_ext_get_actual_len(newext), |
2073 | nearex); | 2073 | nearex); |
2074 | } | 2074 | } |
@@ -2078,7 +2078,7 @@ has_space: | |||
2078 | "move %d extents from 0x%p to 0x%p\n", | 2078 | "move %d extents from 0x%p to 0x%p\n", |
2079 | le32_to_cpu(newext->ee_block), | 2079 | le32_to_cpu(newext->ee_block), |
2080 | ext4_ext_pblock(newext), | 2080 | ext4_ext_pblock(newext), |
2081 | ext4_ext_is_uninitialized(newext), | 2081 | ext4_ext_is_unwritten(newext), |
2082 | ext4_ext_get_actual_len(newext), | 2082 | ext4_ext_get_actual_len(newext), |
2083 | len, nearex, nearex + 1); | 2083 | len, nearex, nearex + 1); |
2084 | memmove(nearex + 1, nearex, | 2084 | memmove(nearex + 1, nearex, |
@@ -2200,7 +2200,7 @@ static int ext4_fill_fiemap_extents(struct inode *inode, | |||
2200 | es.es_lblk = le32_to_cpu(ex->ee_block); | 2200 | es.es_lblk = le32_to_cpu(ex->ee_block); |
2201 | es.es_len = ext4_ext_get_actual_len(ex); | 2201 | es.es_len = ext4_ext_get_actual_len(ex); |
2202 | es.es_pblk = ext4_ext_pblock(ex); | 2202 | es.es_pblk = ext4_ext_pblock(ex); |
2203 | if (ext4_ext_is_uninitialized(ex)) | 2203 | if (ext4_ext_is_unwritten(ex)) |
2204 | flags |= FIEMAP_EXTENT_UNWRITTEN; | 2204 | flags |= FIEMAP_EXTENT_UNWRITTEN; |
2205 | } | 2205 | } |
2206 | 2206 | ||
@@ -2576,7 +2576,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, | |||
2576 | unsigned num; | 2576 | unsigned num; |
2577 | ext4_lblk_t ex_ee_block; | 2577 | ext4_lblk_t ex_ee_block; |
2578 | unsigned short ex_ee_len; | 2578 | unsigned short ex_ee_len; |
2579 | unsigned uninitialized = 0; | 2579 | unsigned unwritten = 0; |
2580 | struct ext4_extent *ex; | 2580 | struct ext4_extent *ex; |
2581 | ext4_fsblk_t pblk; | 2581 | ext4_fsblk_t pblk; |
2582 | 2582 | ||
@@ -2623,13 +2623,13 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, | |||
2623 | while (ex >= EXT_FIRST_EXTENT(eh) && | 2623 | while (ex >= EXT_FIRST_EXTENT(eh) && |
2624 | ex_ee_block + ex_ee_len > start) { | 2624 | ex_ee_block + ex_ee_len > start) { |
2625 | 2625 | ||
2626 | if (ext4_ext_is_uninitialized(ex)) | 2626 | if (ext4_ext_is_unwritten(ex)) |
2627 | uninitialized = 1; | 2627 | unwritten = 1; |
2628 | else | 2628 | else |
2629 | uninitialized = 0; | 2629 | unwritten = 0; |
2630 | 2630 | ||
2631 | ext_debug("remove ext %u:[%d]%d\n", ex_ee_block, | 2631 | ext_debug("remove ext %u:[%d]%d\n", ex_ee_block, |
2632 | uninitialized, ex_ee_len); | 2632 | unwritten, ex_ee_len); |
2633 | path[depth].p_ext = ex; | 2633 | path[depth].p_ext = ex; |
2634 | 2634 | ||
2635 | a = ex_ee_block > start ? ex_ee_block : start; | 2635 | a = ex_ee_block > start ? ex_ee_block : start; |
@@ -2701,11 +2701,11 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, | |||
2701 | 2701 | ||
2702 | ex->ee_len = cpu_to_le16(num); | 2702 | ex->ee_len = cpu_to_le16(num); |
2703 | /* | 2703 | /* |
2704 | * Do not mark uninitialized if all the blocks in the | 2704 | * Do not mark unwritten if all the blocks in the |
2705 | * extent have been removed. | 2705 | * extent have been removed. |
2706 | */ | 2706 | */ |
2707 | if (uninitialized && num) | 2707 | if (unwritten && num) |
2708 | ext4_ext_mark_uninitialized(ex); | 2708 | ext4_ext_mark_unwritten(ex); |
2709 | /* | 2709 | /* |
2710 | * If the extent was completely released, | 2710 | * If the extent was completely released, |
2711 | * we need to remove it from the leaf | 2711 | * we need to remove it from the leaf |
@@ -2854,9 +2854,9 @@ again: | |||
2854 | end < ee_block + ext4_ext_get_actual_len(ex) - 1) { | 2854 | end < ee_block + ext4_ext_get_actual_len(ex) - 1) { |
2855 | int split_flag = 0; | 2855 | int split_flag = 0; |
2856 | 2856 | ||
2857 | if (ext4_ext_is_uninitialized(ex)) | 2857 | if (ext4_ext_is_unwritten(ex)) |
2858 | split_flag = EXT4_EXT_MARK_UNINIT1 | | 2858 | split_flag = EXT4_EXT_MARK_UNWRIT1 | |
2859 | EXT4_EXT_MARK_UNINIT2; | 2859 | EXT4_EXT_MARK_UNWRIT2; |
2860 | 2860 | ||
2861 | /* | 2861 | /* |
2862 | * Split the extent in two so that 'end' is the last | 2862 | * Split the extent in two so that 'end' is the last |
@@ -3113,7 +3113,7 @@ static int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex) | |||
3113 | * @path: the path to the extent | 3113 | * @path: the path to the extent |
3114 | * @split: the logical block where the extent is splitted. | 3114 | * @split: the logical block where the extent is splitted. |
3115 | * @split_flags: indicates if the extent could be zeroout if split fails, and | 3115 | * @split_flags: indicates if the extent could be zeroout if split fails, and |
3116 | * the states(init or uninit) of new extents. | 3116 | * the states(init or unwritten) of new extents. |
3117 | * @flags: flags used to insert new extent to extent tree. | 3117 | * @flags: flags used to insert new extent to extent tree. |
3118 | * | 3118 | * |
3119 | * | 3119 | * |
@@ -3155,10 +3155,10 @@ static int ext4_split_extent_at(handle_t *handle, | |||
3155 | newblock = split - ee_block + ext4_ext_pblock(ex); | 3155 | newblock = split - ee_block + ext4_ext_pblock(ex); |
3156 | 3156 | ||
3157 | BUG_ON(split < ee_block || split >= (ee_block + ee_len)); | 3157 | BUG_ON(split < ee_block || split >= (ee_block + ee_len)); |
3158 | BUG_ON(!ext4_ext_is_uninitialized(ex) && | 3158 | BUG_ON(!ext4_ext_is_unwritten(ex) && |
3159 | split_flag & (EXT4_EXT_MAY_ZEROOUT | | 3159 | split_flag & (EXT4_EXT_MAY_ZEROOUT | |
3160 | EXT4_EXT_MARK_UNINIT1 | | 3160 | EXT4_EXT_MARK_UNWRIT1 | |
3161 | EXT4_EXT_MARK_UNINIT2)); | 3161 | EXT4_EXT_MARK_UNWRIT2)); |
3162 | 3162 | ||
3163 | err = ext4_ext_get_access(handle, inode, path + depth); | 3163 | err = ext4_ext_get_access(handle, inode, path + depth); |
3164 | if (err) | 3164 | if (err) |
@@ -3170,8 +3170,8 @@ static int ext4_split_extent_at(handle_t *handle, | |||
3170 | * then we just change the state of the extent, and splitting | 3170 | * then we just change the state of the extent, and splitting |
3171 | * is not needed. | 3171 | * is not needed. |
3172 | */ | 3172 | */ |
3173 | if (split_flag & EXT4_EXT_MARK_UNINIT2) | 3173 | if (split_flag & EXT4_EXT_MARK_UNWRIT2) |
3174 | ext4_ext_mark_uninitialized(ex); | 3174 | ext4_ext_mark_unwritten(ex); |
3175 | else | 3175 | else |
3176 | ext4_ext_mark_initialized(ex); | 3176 | ext4_ext_mark_initialized(ex); |
3177 | 3177 | ||
@@ -3185,8 +3185,8 @@ static int ext4_split_extent_at(handle_t *handle, | |||
3185 | /* case a */ | 3185 | /* case a */ |
3186 | memcpy(&orig_ex, ex, sizeof(orig_ex)); | 3186 | memcpy(&orig_ex, ex, sizeof(orig_ex)); |
3187 | ex->ee_len = cpu_to_le16(split - ee_block); | 3187 | ex->ee_len = cpu_to_le16(split - ee_block); |
3188 | if (split_flag & EXT4_EXT_MARK_UNINIT1) | 3188 | if (split_flag & EXT4_EXT_MARK_UNWRIT1) |
3189 | ext4_ext_mark_uninitialized(ex); | 3189 | ext4_ext_mark_unwritten(ex); |
3190 | 3190 | ||
3191 | /* | 3191 | /* |
3192 | * path may lead to new leaf, not to original leaf any more | 3192 | * path may lead to new leaf, not to original leaf any more |
@@ -3200,8 +3200,8 @@ static int ext4_split_extent_at(handle_t *handle, | |||
3200 | ex2->ee_block = cpu_to_le32(split); | 3200 | ex2->ee_block = cpu_to_le32(split); |
3201 | ex2->ee_len = cpu_to_le16(ee_len - (split - ee_block)); | 3201 | ex2->ee_len = cpu_to_le16(ee_len - (split - ee_block)); |
3202 | ext4_ext_store_pblock(ex2, newblock); | 3202 | ext4_ext_store_pblock(ex2, newblock); |
3203 | if (split_flag & EXT4_EXT_MARK_UNINIT2) | 3203 | if (split_flag & EXT4_EXT_MARK_UNWRIT2) |
3204 | ext4_ext_mark_uninitialized(ex2); | 3204 | ext4_ext_mark_unwritten(ex2); |
3205 | 3205 | ||
3206 | err = ext4_ext_insert_extent(handle, inode, path, &newex, flags); | 3206 | err = ext4_ext_insert_extent(handle, inode, path, &newex, flags); |
3207 | if (err == -ENOSPC && (EXT4_EXT_MAY_ZEROOUT & split_flag)) { | 3207 | if (err == -ENOSPC && (EXT4_EXT_MAY_ZEROOUT & split_flag)) { |
@@ -3278,7 +3278,7 @@ static int ext4_split_extent(handle_t *handle, | |||
3278 | struct ext4_extent *ex; | 3278 | struct ext4_extent *ex; |
3279 | unsigned int ee_len, depth; | 3279 | unsigned int ee_len, depth; |
3280 | int err = 0; | 3280 | int err = 0; |
3281 | int uninitialized; | 3281 | int unwritten; |
3282 | int split_flag1, flags1; | 3282 | int split_flag1, flags1; |
3283 | int allocated = map->m_len; | 3283 | int allocated = map->m_len; |
3284 | 3284 | ||
@@ -3286,14 +3286,14 @@ static int ext4_split_extent(handle_t *handle, | |||
3286 | ex = path[depth].p_ext; | 3286 | ex = path[depth].p_ext; |
3287 | ee_block = le32_to_cpu(ex->ee_block); | 3287 | ee_block = le32_to_cpu(ex->ee_block); |
3288 | ee_len = ext4_ext_get_actual_len(ex); | 3288 | ee_len = ext4_ext_get_actual_len(ex); |
3289 | uninitialized = ext4_ext_is_uninitialized(ex); | 3289 | unwritten = ext4_ext_is_unwritten(ex); |
3290 | 3290 | ||
3291 | if (map->m_lblk + map->m_len < ee_block + ee_len) { | 3291 | if (map->m_lblk + map->m_len < ee_block + ee_len) { |
3292 | split_flag1 = split_flag & EXT4_EXT_MAY_ZEROOUT; | 3292 | split_flag1 = split_flag & EXT4_EXT_MAY_ZEROOUT; |
3293 | flags1 = flags | EXT4_GET_BLOCKS_PRE_IO; | 3293 | flags1 = flags | EXT4_GET_BLOCKS_PRE_IO; |
3294 | if (uninitialized) | 3294 | if (unwritten) |
3295 | split_flag1 |= EXT4_EXT_MARK_UNINIT1 | | 3295 | split_flag1 |= EXT4_EXT_MARK_UNWRIT1 | |
3296 | EXT4_EXT_MARK_UNINIT2; | 3296 | EXT4_EXT_MARK_UNWRIT2; |
3297 | if (split_flag & EXT4_EXT_DATA_VALID2) | 3297 | if (split_flag & EXT4_EXT_DATA_VALID2) |
3298 | split_flag1 |= EXT4_EXT_DATA_VALID1; | 3298 | split_flag1 |= EXT4_EXT_DATA_VALID1; |
3299 | err = ext4_split_extent_at(handle, inode, path, | 3299 | err = ext4_split_extent_at(handle, inode, path, |
@@ -3318,15 +3318,15 @@ static int ext4_split_extent(handle_t *handle, | |||
3318 | (unsigned long) map->m_lblk); | 3318 | (unsigned long) map->m_lblk); |
3319 | return -EIO; | 3319 | return -EIO; |
3320 | } | 3320 | } |
3321 | uninitialized = ext4_ext_is_uninitialized(ex); | 3321 | unwritten = ext4_ext_is_unwritten(ex); |
3322 | split_flag1 = 0; | 3322 | split_flag1 = 0; |
3323 | 3323 | ||
3324 | if (map->m_lblk >= ee_block) { | 3324 | if (map->m_lblk >= ee_block) { |
3325 | split_flag1 = split_flag & EXT4_EXT_DATA_VALID2; | 3325 | split_flag1 = split_flag & EXT4_EXT_DATA_VALID2; |
3326 | if (uninitialized) { | 3326 | if (unwritten) { |
3327 | split_flag1 |= EXT4_EXT_MARK_UNINIT1; | 3327 | split_flag1 |= EXT4_EXT_MARK_UNWRIT1; |
3328 | split_flag1 |= split_flag & (EXT4_EXT_MAY_ZEROOUT | | 3328 | split_flag1 |= split_flag & (EXT4_EXT_MAY_ZEROOUT | |
3329 | EXT4_EXT_MARK_UNINIT2); | 3329 | EXT4_EXT_MARK_UNWRIT2); |
3330 | } | 3330 | } |
3331 | err = ext4_split_extent_at(handle, inode, path, | 3331 | err = ext4_split_extent_at(handle, inode, path, |
3332 | map->m_lblk, split_flag1, flags); | 3332 | map->m_lblk, split_flag1, flags); |
@@ -3341,16 +3341,16 @@ out: | |||
3341 | 3341 | ||
3342 | /* | 3342 | /* |
3343 | * This function is called by ext4_ext_map_blocks() if someone tries to write | 3343 | * This function is called by ext4_ext_map_blocks() if someone tries to write |
3344 | * to an uninitialized extent. It may result in splitting the uninitialized | 3344 | * to an unwritten extent. It may result in splitting the unwritten |
3345 | * extent into multiple extents (up to three - one initialized and two | 3345 | * extent into multiple extents (up to three - one initialized and two |
3346 | * uninitialized). | 3346 | * unwritten). |
3347 | * There are three possibilities: | 3347 | * There are three possibilities: |
3348 | * a> There is no split required: Entire extent should be initialized | 3348 | * a> There is no split required: Entire extent should be initialized |
3349 | * b> Splits in two extents: Write is happening at either end of the extent | 3349 | * b> Splits in two extents: Write is happening at either end of the extent |
3350 | * c> Splits in three extents: Somone is writing in middle of the extent | 3350 | * c> Splits in three extents: Somone is writing in middle of the extent |
3351 | * | 3351 | * |
3352 | * Pre-conditions: | 3352 | * Pre-conditions: |
3353 | * - The extent pointed to by 'path' is uninitialized. | 3353 | * - The extent pointed to by 'path' is unwritten. |
3354 | * - The extent pointed to by 'path' contains a superset | 3354 | * - The extent pointed to by 'path' contains a superset |
3355 | * of the logical span [map->m_lblk, map->m_lblk + map->m_len). | 3355 | * of the logical span [map->m_lblk, map->m_lblk + map->m_len). |
3356 | * | 3356 | * |
@@ -3396,12 +3396,12 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, | |||
3396 | trace_ext4_ext_convert_to_initialized_enter(inode, map, ex); | 3396 | trace_ext4_ext_convert_to_initialized_enter(inode, map, ex); |
3397 | 3397 | ||
3398 | /* Pre-conditions */ | 3398 | /* Pre-conditions */ |
3399 | BUG_ON(!ext4_ext_is_uninitialized(ex)); | 3399 | BUG_ON(!ext4_ext_is_unwritten(ex)); |
3400 | BUG_ON(!in_range(map->m_lblk, ee_block, ee_len)); | 3400 | BUG_ON(!in_range(map->m_lblk, ee_block, ee_len)); |
3401 | 3401 | ||
3402 | /* | 3402 | /* |
3403 | * Attempt to transfer newly initialized blocks from the currently | 3403 | * Attempt to transfer newly initialized blocks from the currently |
3404 | * uninitialized extent to its neighbor. This is much cheaper | 3404 | * unwritten extent to its neighbor. This is much cheaper |
3405 | * than an insertion followed by a merge as those involve costly | 3405 | * than an insertion followed by a merge as those involve costly |
3406 | * memmove() calls. Transferring to the left is the common case in | 3406 | * memmove() calls. Transferring to the left is the common case in |
3407 | * steady state for workloads doing fallocate(FALLOC_FL_KEEP_SIZE) | 3407 | * steady state for workloads doing fallocate(FALLOC_FL_KEEP_SIZE) |
@@ -3437,7 +3437,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, | |||
3437 | * - C4: abut_ex can receive the additional blocks without | 3437 | * - C4: abut_ex can receive the additional blocks without |
3438 | * overflowing the (initialized) length limit. | 3438 | * overflowing the (initialized) length limit. |
3439 | */ | 3439 | */ |
3440 | if ((!ext4_ext_is_uninitialized(abut_ex)) && /*C1*/ | 3440 | if ((!ext4_ext_is_unwritten(abut_ex)) && /*C1*/ |
3441 | ((prev_lblk + prev_len) == ee_block) && /*C2*/ | 3441 | ((prev_lblk + prev_len) == ee_block) && /*C2*/ |
3442 | ((prev_pblk + prev_len) == ee_pblk) && /*C3*/ | 3442 | ((prev_pblk + prev_len) == ee_pblk) && /*C3*/ |
3443 | (prev_len < (EXT_INIT_MAX_LEN - map_len))) { /*C4*/ | 3443 | (prev_len < (EXT_INIT_MAX_LEN - map_len))) { /*C4*/ |
@@ -3452,7 +3452,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, | |||
3452 | ex->ee_block = cpu_to_le32(ee_block + map_len); | 3452 | ex->ee_block = cpu_to_le32(ee_block + map_len); |
3453 | ext4_ext_store_pblock(ex, ee_pblk + map_len); | 3453 | ext4_ext_store_pblock(ex, ee_pblk + map_len); |
3454 | ex->ee_len = cpu_to_le16(ee_len - map_len); | 3454 | ex->ee_len = cpu_to_le16(ee_len - map_len); |
3455 | ext4_ext_mark_uninitialized(ex); /* Restore the flag */ | 3455 | ext4_ext_mark_unwritten(ex); /* Restore the flag */ |
3456 | 3456 | ||
3457 | /* Extend abut_ex by 'map_len' blocks */ | 3457 | /* Extend abut_ex by 'map_len' blocks */ |
3458 | abut_ex->ee_len = cpu_to_le16(prev_len + map_len); | 3458 | abut_ex->ee_len = cpu_to_le16(prev_len + map_len); |
@@ -3483,7 +3483,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, | |||
3483 | * - C4: abut_ex can receive the additional blocks without | 3483 | * - C4: abut_ex can receive the additional blocks without |
3484 | * overflowing the (initialized) length limit. | 3484 | * overflowing the (initialized) length limit. |
3485 | */ | 3485 | */ |
3486 | if ((!ext4_ext_is_uninitialized(abut_ex)) && /*C1*/ | 3486 | if ((!ext4_ext_is_unwritten(abut_ex)) && /*C1*/ |
3487 | ((map->m_lblk + map_len) == next_lblk) && /*C2*/ | 3487 | ((map->m_lblk + map_len) == next_lblk) && /*C2*/ |
3488 | ((ee_pblk + ee_len) == next_pblk) && /*C3*/ | 3488 | ((ee_pblk + ee_len) == next_pblk) && /*C3*/ |
3489 | (next_len < (EXT_INIT_MAX_LEN - map_len))) { /*C4*/ | 3489 | (next_len < (EXT_INIT_MAX_LEN - map_len))) { /*C4*/ |
@@ -3498,7 +3498,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, | |||
3498 | abut_ex->ee_block = cpu_to_le32(next_lblk - map_len); | 3498 | abut_ex->ee_block = cpu_to_le32(next_lblk - map_len); |
3499 | ext4_ext_store_pblock(abut_ex, next_pblk - map_len); | 3499 | ext4_ext_store_pblock(abut_ex, next_pblk - map_len); |
3500 | ex->ee_len = cpu_to_le16(ee_len - map_len); | 3500 | ex->ee_len = cpu_to_le16(ee_len - map_len); |
3501 | ext4_ext_mark_uninitialized(ex); /* Restore the flag */ | 3501 | ext4_ext_mark_unwritten(ex); /* Restore the flag */ |
3502 | 3502 | ||
3503 | /* Extend abut_ex by 'map_len' blocks */ | 3503 | /* Extend abut_ex by 'map_len' blocks */ |
3504 | abut_ex->ee_len = cpu_to_le16(next_len + map_len); | 3504 | abut_ex->ee_len = cpu_to_le16(next_len + map_len); |
@@ -3603,26 +3603,26 @@ out: | |||
3603 | /* | 3603 | /* |
3604 | * This function is called by ext4_ext_map_blocks() from | 3604 | * This function is called by ext4_ext_map_blocks() from |
3605 | * ext4_get_blocks_dio_write() when DIO to write | 3605 | * ext4_get_blocks_dio_write() when DIO to write |
3606 | * to an uninitialized extent. | 3606 | * to an unwritten extent. |
3607 | * | 3607 | * |
3608 | * Writing to an uninitialized extent may result in splitting the uninitialized | 3608 | * Writing to an unwritten extent may result in splitting the unwritten |
3609 | * extent into multiple initialized/uninitialized extents (up to three) | 3609 | * extent into multiple initialized/unwritten extents (up to three) |
3610 | * There are three possibilities: | 3610 | * There are three possibilities: |
3611 | * a> There is no split required: Entire extent should be uninitialized | 3611 | * a> There is no split required: Entire extent should be unwritten |
3612 | * b> Splits in two extents: Write is happening at either end of the extent | 3612 | * b> Splits in two extents: Write is happening at either end of the extent |
3613 | * c> Splits in three extents: Somone is writing in middle of the extent | 3613 | * c> Splits in three extents: Somone is writing in middle of the extent |
3614 | * | 3614 | * |
3615 | * This works the same way in the case of initialized -> unwritten conversion. | 3615 | * This works the same way in the case of initialized -> unwritten conversion. |
3616 | * | 3616 | * |
3617 | * One of more index blocks maybe needed if the extent tree grow after | 3617 | * One of more index blocks maybe needed if the extent tree grow after |
3618 | * the uninitialized extent split. To prevent ENOSPC occur at the IO | 3618 | * the unwritten extent split. To prevent ENOSPC occur at the IO |
3619 | * complete, we need to split the uninitialized extent before DIO submit | 3619 | * complete, we need to split the unwritten extent before DIO submit |
3620 | * the IO. The uninitialized extent called at this time will be split | 3620 | * the IO. The unwritten extent called at this time will be split |
3621 | * into three uninitialized extent(at most). After IO complete, the part | 3621 | * into three unwritten extent(at most). After IO complete, the part |
3622 | * being filled will be convert to initialized by the end_io callback function | 3622 | * being filled will be convert to initialized by the end_io callback function |
3623 | * via ext4_convert_unwritten_extents(). | 3623 | * via ext4_convert_unwritten_extents(). |
3624 | * | 3624 | * |
3625 | * Returns the size of uninitialized extent to be written on success. | 3625 | * Returns the size of unwritten extent to be written on success. |
3626 | */ | 3626 | */ |
3627 | static int ext4_split_convert_extents(handle_t *handle, | 3627 | static int ext4_split_convert_extents(handle_t *handle, |
3628 | struct inode *inode, | 3628 | struct inode *inode, |
@@ -3660,7 +3660,7 @@ static int ext4_split_convert_extents(handle_t *handle, | |||
3660 | } else if (flags & EXT4_GET_BLOCKS_CONVERT) { | 3660 | } else if (flags & EXT4_GET_BLOCKS_CONVERT) { |
3661 | split_flag |= ee_block + ee_len <= eof_block ? | 3661 | split_flag |= ee_block + ee_len <= eof_block ? |
3662 | EXT4_EXT_MAY_ZEROOUT : 0; | 3662 | EXT4_EXT_MAY_ZEROOUT : 0; |
3663 | split_flag |= (EXT4_EXT_MARK_UNINIT2 | EXT4_EXT_DATA_VALID2); | 3663 | split_flag |= (EXT4_EXT_MARK_UNWRIT2 | EXT4_EXT_DATA_VALID2); |
3664 | } | 3664 | } |
3665 | flags |= EXT4_GET_BLOCKS_PRE_IO; | 3665 | flags |= EXT4_GET_BLOCKS_PRE_IO; |
3666 | return ext4_split_extent(handle, inode, path, map, split_flag, flags); | 3666 | return ext4_split_extent(handle, inode, path, map, split_flag, flags); |
@@ -3710,8 +3710,8 @@ static int ext4_convert_initialized_extents(handle_t *handle, | |||
3710 | err = ext4_ext_get_access(handle, inode, path + depth); | 3710 | err = ext4_ext_get_access(handle, inode, path + depth); |
3711 | if (err) | 3711 | if (err) |
3712 | goto out; | 3712 | goto out; |
3713 | /* first mark the extent as uninitialized */ | 3713 | /* first mark the extent as unwritten */ |
3714 | ext4_ext_mark_uninitialized(ex); | 3714 | ext4_ext_mark_unwritten(ex); |
3715 | 3715 | ||
3716 | /* note: ext4_ext_correct_indexes() isn't needed here because | 3716 | /* note: ext4_ext_correct_indexes() isn't needed here because |
3717 | * borders are not changed | 3717 | * borders are not changed |
@@ -3971,10 +3971,10 @@ ext4_ext_convert_initialized_extent(handle_t *handle, struct inode *inode, | |||
3971 | 3971 | ||
3972 | /* | 3972 | /* |
3973 | * Make sure that the extent is no bigger than we support with | 3973 | * Make sure that the extent is no bigger than we support with |
3974 | * uninitialized extent | 3974 | * unwritten extent |
3975 | */ | 3975 | */ |
3976 | if (map->m_len > EXT_UNINIT_MAX_LEN) | 3976 | if (map->m_len > EXT_UNWRITTEN_MAX_LEN) |
3977 | map->m_len = EXT_UNINIT_MAX_LEN / 2; | 3977 | map->m_len = EXT_UNWRITTEN_MAX_LEN / 2; |
3978 | 3978 | ||
3979 | ret = ext4_convert_initialized_extents(handle, inode, map, | 3979 | ret = ext4_convert_initialized_extents(handle, inode, map, |
3980 | path); | 3980 | path); |
@@ -3993,7 +3993,7 @@ ext4_ext_convert_initialized_extent(handle_t *handle, struct inode *inode, | |||
3993 | } | 3993 | } |
3994 | 3994 | ||
3995 | static int | 3995 | static int |
3996 | ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, | 3996 | ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode, |
3997 | struct ext4_map_blocks *map, | 3997 | struct ext4_map_blocks *map, |
3998 | struct ext4_ext_path *path, int flags, | 3998 | struct ext4_ext_path *path, int flags, |
3999 | unsigned int allocated, ext4_fsblk_t newblock) | 3999 | unsigned int allocated, ext4_fsblk_t newblock) |
@@ -4002,19 +4002,19 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, | |||
4002 | int err = 0; | 4002 | int err = 0; |
4003 | ext4_io_end_t *io = ext4_inode_aio(inode); | 4003 | ext4_io_end_t *io = ext4_inode_aio(inode); |
4004 | 4004 | ||
4005 | ext_debug("ext4_ext_handle_uninitialized_extents: inode %lu, logical " | 4005 | ext_debug("ext4_ext_handle_unwritten_extents: inode %lu, logical " |
4006 | "block %llu, max_blocks %u, flags %x, allocated %u\n", | 4006 | "block %llu, max_blocks %u, flags %x, allocated %u\n", |
4007 | inode->i_ino, (unsigned long long)map->m_lblk, map->m_len, | 4007 | inode->i_ino, (unsigned long long)map->m_lblk, map->m_len, |
4008 | flags, allocated); | 4008 | flags, allocated); |
4009 | ext4_ext_show_leaf(inode, path); | 4009 | ext4_ext_show_leaf(inode, path); |
4010 | 4010 | ||
4011 | /* | 4011 | /* |
4012 | * When writing into uninitialized space, we should not fail to | 4012 | * When writing into unwritten space, we should not fail to |
4013 | * allocate metadata blocks for the new extent block if needed. | 4013 | * allocate metadata blocks for the new extent block if needed. |
4014 | */ | 4014 | */ |
4015 | flags |= EXT4_GET_BLOCKS_METADATA_NOFAIL; | 4015 | flags |= EXT4_GET_BLOCKS_METADATA_NOFAIL; |
4016 | 4016 | ||
4017 | trace_ext4_ext_handle_uninitialized_extents(inode, map, flags, | 4017 | trace_ext4_ext_handle_unwritten_extents(inode, map, flags, |
4018 | allocated, newblock); | 4018 | allocated, newblock); |
4019 | 4019 | ||
4020 | /* get_block() before submit the IO, split the extent */ | 4020 | /* get_block() before submit the IO, split the extent */ |
@@ -4033,8 +4033,6 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, | |||
4033 | else | 4033 | else |
4034 | ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN); | 4034 | ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN); |
4035 | map->m_flags |= EXT4_MAP_UNWRITTEN; | 4035 | map->m_flags |= EXT4_MAP_UNWRITTEN; |
4036 | if (ext4_should_dioread_nolock(inode)) | ||
4037 | map->m_flags |= EXT4_MAP_UNINIT; | ||
4038 | goto out; | 4036 | goto out; |
4039 | } | 4037 | } |
4040 | /* IO end_io complete, convert the filled extent to written */ | 4038 | /* IO end_io complete, convert the filled extent to written */ |
@@ -4059,7 +4057,7 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, | |||
4059 | * repeat fallocate creation request | 4057 | * repeat fallocate creation request |
4060 | * we already have an unwritten extent | 4058 | * we already have an unwritten extent |
4061 | */ | 4059 | */ |
4062 | if (flags & EXT4_GET_BLOCKS_UNINIT_EXT) { | 4060 | if (flags & EXT4_GET_BLOCKS_UNWRIT_EXT) { |
4063 | map->m_flags |= EXT4_MAP_UNWRITTEN; | 4061 | map->m_flags |= EXT4_MAP_UNWRITTEN; |
4064 | goto map_out; | 4062 | goto map_out; |
4065 | } | 4063 | } |
@@ -4310,7 +4308,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
4310 | 4308 | ||
4311 | 4309 | ||
4312 | /* | 4310 | /* |
4313 | * Uninitialized extents are treated as holes, except that | 4311 | * unwritten extents are treated as holes, except that |
4314 | * we split out initialized portions during a write. | 4312 | * we split out initialized portions during a write. |
4315 | */ | 4313 | */ |
4316 | ee_len = ext4_ext_get_actual_len(ex); | 4314 | ee_len = ext4_ext_get_actual_len(ex); |
@@ -4329,16 +4327,16 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
4329 | * If the extent is initialized check whether the | 4327 | * If the extent is initialized check whether the |
4330 | * caller wants to convert it to unwritten. | 4328 | * caller wants to convert it to unwritten. |
4331 | */ | 4329 | */ |
4332 | if ((!ext4_ext_is_uninitialized(ex)) && | 4330 | if ((!ext4_ext_is_unwritten(ex)) && |
4333 | (flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)) { | 4331 | (flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)) { |
4334 | allocated = ext4_ext_convert_initialized_extent( | 4332 | allocated = ext4_ext_convert_initialized_extent( |
4335 | handle, inode, map, path, flags, | 4333 | handle, inode, map, path, flags, |
4336 | allocated, newblock); | 4334 | allocated, newblock); |
4337 | goto out2; | 4335 | goto out2; |
4338 | } else if (!ext4_ext_is_uninitialized(ex)) | 4336 | } else if (!ext4_ext_is_unwritten(ex)) |
4339 | goto out; | 4337 | goto out; |
4340 | 4338 | ||
4341 | ret = ext4_ext_handle_uninitialized_extents( | 4339 | ret = ext4_ext_handle_unwritten_extents( |
4342 | handle, inode, map, path, flags, | 4340 | handle, inode, map, path, flags, |
4343 | allocated, newblock); | 4341 | allocated, newblock); |
4344 | if (ret < 0) | 4342 | if (ret < 0) |
@@ -4410,15 +4408,15 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
4410 | /* | 4408 | /* |
4411 | * See if request is beyond maximum number of blocks we can have in | 4409 | * See if request is beyond maximum number of blocks we can have in |
4412 | * a single extent. For an initialized extent this limit is | 4410 | * a single extent. For an initialized extent this limit is |
4413 | * EXT_INIT_MAX_LEN and for an uninitialized extent this limit is | 4411 | * EXT_INIT_MAX_LEN and for an unwritten extent this limit is |
4414 | * EXT_UNINIT_MAX_LEN. | 4412 | * EXT_UNWRITTEN_MAX_LEN. |
4415 | */ | 4413 | */ |
4416 | if (map->m_len > EXT_INIT_MAX_LEN && | 4414 | if (map->m_len > EXT_INIT_MAX_LEN && |
4417 | !(flags & EXT4_GET_BLOCKS_UNINIT_EXT)) | 4415 | !(flags & EXT4_GET_BLOCKS_UNWRIT_EXT)) |
4418 | map->m_len = EXT_INIT_MAX_LEN; | 4416 | map->m_len = EXT_INIT_MAX_LEN; |
4419 | else if (map->m_len > EXT_UNINIT_MAX_LEN && | 4417 | else if (map->m_len > EXT_UNWRITTEN_MAX_LEN && |
4420 | (flags & EXT4_GET_BLOCKS_UNINIT_EXT)) | 4418 | (flags & EXT4_GET_BLOCKS_UNWRIT_EXT)) |
4421 | map->m_len = EXT_UNINIT_MAX_LEN; | 4419 | map->m_len = EXT_UNWRITTEN_MAX_LEN; |
4422 | 4420 | ||
4423 | /* Check if we can really insert (m_lblk)::(m_lblk + m_len) extent */ | 4421 | /* Check if we can really insert (m_lblk)::(m_lblk + m_len) extent */ |
4424 | newex.ee_len = cpu_to_le16(map->m_len); | 4422 | newex.ee_len = cpu_to_le16(map->m_len); |
@@ -4466,21 +4464,19 @@ got_allocated_blocks: | |||
4466 | /* try to insert new extent into found leaf and return */ | 4464 | /* try to insert new extent into found leaf and return */ |
4467 | ext4_ext_store_pblock(&newex, newblock + offset); | 4465 | ext4_ext_store_pblock(&newex, newblock + offset); |
4468 | newex.ee_len = cpu_to_le16(ar.len); | 4466 | newex.ee_len = cpu_to_le16(ar.len); |
4469 | /* Mark uninitialized */ | 4467 | /* Mark unwritten */ |
4470 | if (flags & EXT4_GET_BLOCKS_UNINIT_EXT){ | 4468 | if (flags & EXT4_GET_BLOCKS_UNWRIT_EXT){ |
4471 | ext4_ext_mark_uninitialized(&newex); | 4469 | ext4_ext_mark_unwritten(&newex); |
4472 | map->m_flags |= EXT4_MAP_UNWRITTEN; | 4470 | map->m_flags |= EXT4_MAP_UNWRITTEN; |
4473 | /* | 4471 | /* |
4474 | * io_end structure was created for every IO write to an | 4472 | * io_end structure was created for every IO write to an |
4475 | * uninitialized extent. To avoid unnecessary conversion, | 4473 | * unwritten extent. To avoid unnecessary conversion, |
4476 | * here we flag the IO that really needs the conversion. | 4474 | * here we flag the IO that really needs the conversion. |
4477 | * For non asycn direct IO case, flag the inode state | 4475 | * For non asycn direct IO case, flag the inode state |
4478 | * that we need to perform conversion when IO is done. | 4476 | * that we need to perform conversion when IO is done. |
4479 | */ | 4477 | */ |
4480 | if ((flags & EXT4_GET_BLOCKS_PRE_IO)) | 4478 | if ((flags & EXT4_GET_BLOCKS_PRE_IO)) |
4481 | set_unwritten = 1; | 4479 | set_unwritten = 1; |
4482 | if (ext4_should_dioread_nolock(inode)) | ||
4483 | map->m_flags |= EXT4_MAP_UNINIT; | ||
4484 | } | 4480 | } |
4485 | 4481 | ||
4486 | err = 0; | 4482 | err = 0; |
@@ -4607,9 +4603,9 @@ got_allocated_blocks: | |||
4607 | 4603 | ||
4608 | /* | 4604 | /* |
4609 | * Cache the extent and update transaction to commit on fdatasync only | 4605 | * Cache the extent and update transaction to commit on fdatasync only |
4610 | * when it is _not_ an uninitialized extent. | 4606 | * when it is _not_ an unwritten extent. |
4611 | */ | 4607 | */ |
4612 | if ((flags & EXT4_GET_BLOCKS_UNINIT_EXT) == 0) | 4608 | if ((flags & EXT4_GET_BLOCKS_UNWRIT_EXT) == 0) |
4613 | ext4_update_inode_fsync_trans(handle, inode, 1); | 4609 | ext4_update_inode_fsync_trans(handle, inode, 1); |
4614 | else | 4610 | else |
4615 | ext4_update_inode_fsync_trans(handle, inode, 0); | 4611 | ext4_update_inode_fsync_trans(handle, inode, 0); |
@@ -4683,7 +4679,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset, | |||
4683 | * that it doesn't get unnecessarily split into multiple | 4679 | * that it doesn't get unnecessarily split into multiple |
4684 | * extents. | 4680 | * extents. |
4685 | */ | 4681 | */ |
4686 | if (len <= EXT_UNINIT_MAX_LEN) | 4682 | if (len <= EXT_UNWRITTEN_MAX_LEN) |
4687 | flags |= EXT4_GET_BLOCKS_NO_NORMALIZE; | 4683 | flags |= EXT4_GET_BLOCKS_NO_NORMALIZE; |
4688 | 4684 | ||
4689 | /* | 4685 | /* |
@@ -4775,7 +4771,7 @@ static long ext4_zero_range(struct file *file, loff_t offset, | |||
4775 | else | 4771 | else |
4776 | max_blocks -= lblk; | 4772 | max_blocks -= lblk; |
4777 | 4773 | ||
4778 | flags = EXT4_GET_BLOCKS_CREATE_UNINIT_EXT | | 4774 | flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT | |
4779 | EXT4_GET_BLOCKS_CONVERT_UNWRITTEN; | 4775 | EXT4_GET_BLOCKS_CONVERT_UNWRITTEN; |
4780 | if (mode & FALLOC_FL_KEEP_SIZE) | 4776 | if (mode & FALLOC_FL_KEEP_SIZE) |
4781 | flags |= EXT4_GET_BLOCKS_KEEP_SIZE; | 4777 | flags |= EXT4_GET_BLOCKS_KEEP_SIZE; |
@@ -4918,7 +4914,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
4918 | max_blocks = (EXT4_BLOCK_ALIGN(len + offset, blkbits) >> blkbits) | 4914 | max_blocks = (EXT4_BLOCK_ALIGN(len + offset, blkbits) >> blkbits) |
4919 | - lblk; | 4915 | - lblk; |
4920 | 4916 | ||
4921 | flags = EXT4_GET_BLOCKS_CREATE_UNINIT_EXT; | 4917 | flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT; |
4922 | if (mode & FALLOC_FL_KEEP_SIZE) | 4918 | if (mode & FALLOC_FL_KEEP_SIZE) |
4923 | flags |= EXT4_GET_BLOCKS_KEEP_SIZE; | 4919 | flags |= EXT4_GET_BLOCKS_KEEP_SIZE; |
4924 | 4920 | ||
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index 0ebc21204b51..98c90f5834ee 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c | |||
@@ -433,7 +433,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode, | |||
433 | ee_start = ext4_ext_pblock(ex); | 433 | ee_start = ext4_ext_pblock(ex); |
434 | ee_len = ext4_ext_get_actual_len(ex); | 434 | ee_len = ext4_ext_get_actual_len(ex); |
435 | 435 | ||
436 | ee_status = ext4_ext_is_uninitialized(ex) ? 1 : 0; | 436 | ee_status = ext4_ext_is_unwritten(ex) ? 1 : 0; |
437 | es_status = ext4_es_is_unwritten(es) ? 1 : 0; | 437 | es_status = ext4_es_is_unwritten(es) ? 1 : 0; |
438 | 438 | ||
439 | /* | 439 | /* |
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 881394280d5f..86a13a514e4a 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -92,58 +92,91 @@ ext4_unaligned_aio(struct inode *inode, const struct iovec *iov, | |||
92 | } | 92 | } |
93 | 93 | ||
94 | static ssize_t | 94 | static ssize_t |
95 | ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov, | 95 | ext4_file_write(struct kiocb *iocb, const struct iovec *iov, |
96 | unsigned long nr_segs, loff_t pos) | 96 | unsigned long nr_segs, loff_t pos) |
97 | { | 97 | { |
98 | struct file *file = iocb->ki_filp; | 98 | struct file *file = iocb->ki_filp; |
99 | struct inode *inode = file->f_mapping->host; | 99 | struct inode *inode = file_inode(iocb->ki_filp); |
100 | struct mutex *aio_mutex = NULL; | ||
100 | struct blk_plug plug; | 101 | struct blk_plug plug; |
101 | int unaligned_aio = 0; | 102 | int o_direct = file->f_flags & O_DIRECT; |
102 | ssize_t ret; | ||
103 | int overwrite = 0; | 103 | int overwrite = 0; |
104 | size_t length = iov_length(iov, nr_segs); | 104 | size_t length = iov_length(iov, nr_segs); |
105 | ssize_t ret; | ||
105 | 106 | ||
106 | if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS) && | 107 | BUG_ON(iocb->ki_pos != pos); |
107 | !is_sync_kiocb(iocb)) | ||
108 | unaligned_aio = ext4_unaligned_aio(inode, iov, nr_segs, pos); | ||
109 | 108 | ||
110 | /* Unaligned direct AIO must be serialized; see comment above */ | 109 | /* |
111 | if (unaligned_aio) { | 110 | * Unaligned direct AIO must be serialized; see comment above |
112 | mutex_lock(ext4_aio_mutex(inode)); | 111 | * In the case of O_APPEND, assume that we must always serialize |
112 | */ | ||
113 | if (o_direct && | ||
114 | ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS) && | ||
115 | !is_sync_kiocb(iocb) && | ||
116 | (file->f_flags & O_APPEND || | ||
117 | ext4_unaligned_aio(inode, iov, nr_segs, pos))) { | ||
118 | aio_mutex = ext4_aio_mutex(inode); | ||
119 | mutex_lock(aio_mutex); | ||
113 | ext4_unwritten_wait(inode); | 120 | ext4_unwritten_wait(inode); |
114 | } | 121 | } |
115 | 122 | ||
116 | BUG_ON(iocb->ki_pos != pos); | ||
117 | |||
118 | mutex_lock(&inode->i_mutex); | 123 | mutex_lock(&inode->i_mutex); |
119 | blk_start_plug(&plug); | 124 | if (file->f_flags & O_APPEND) |
125 | iocb->ki_pos = pos = i_size_read(inode); | ||
126 | |||
127 | /* | ||
128 | * If we have encountered a bitmap-format file, the size limit | ||
129 | * is smaller than s_maxbytes, which is for extent-mapped files. | ||
130 | */ | ||
131 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { | ||
132 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | ||
120 | 133 | ||
121 | iocb->private = &overwrite; | 134 | if ((pos > sbi->s_bitmap_maxbytes) || |
135 | (pos == sbi->s_bitmap_maxbytes && length > 0)) { | ||
136 | mutex_unlock(&inode->i_mutex); | ||
137 | ret = -EFBIG; | ||
138 | goto errout; | ||
139 | } | ||
122 | 140 | ||
123 | /* check whether we do a DIO overwrite or not */ | 141 | if (pos + length > sbi->s_bitmap_maxbytes) { |
124 | if (ext4_should_dioread_nolock(inode) && !unaligned_aio && | 142 | nr_segs = iov_shorten((struct iovec *)iov, nr_segs, |
125 | !file->f_mapping->nrpages && pos + length <= i_size_read(inode)) { | 143 | sbi->s_bitmap_maxbytes - pos); |
126 | struct ext4_map_blocks map; | 144 | } |
127 | unsigned int blkbits = inode->i_blkbits; | 145 | } |
128 | int err, len; | ||
129 | 146 | ||
130 | map.m_lblk = pos >> blkbits; | 147 | if (o_direct) { |
131 | map.m_len = (EXT4_BLOCK_ALIGN(pos + length, blkbits) >> blkbits) | 148 | blk_start_plug(&plug); |
132 | - map.m_lblk; | ||
133 | len = map.m_len; | ||
134 | 149 | ||
135 | err = ext4_map_blocks(NULL, inode, &map, 0); | 150 | iocb->private = &overwrite; |
136 | /* | 151 | |
137 | * 'err==len' means that all of blocks has been preallocated no | 152 | /* check whether we do a DIO overwrite or not */ |
138 | * matter they are initialized or not. For excluding | 153 | if (ext4_should_dioread_nolock(inode) && !aio_mutex && |
139 | * uninitialized extents, we need to check m_flags. There are | 154 | !file->f_mapping->nrpages && pos + length <= i_size_read(inode)) { |
140 | * two conditions that indicate for initialized extents. | 155 | struct ext4_map_blocks map; |
141 | * 1) If we hit extent cache, EXT4_MAP_MAPPED flag is returned; | 156 | unsigned int blkbits = inode->i_blkbits; |
142 | * 2) If we do a real lookup, non-flags are returned. | 157 | int err, len; |
143 | * So we should check these two conditions. | 158 | |
144 | */ | 159 | map.m_lblk = pos >> blkbits; |
145 | if (err == len && (map.m_flags & EXT4_MAP_MAPPED)) | 160 | map.m_len = (EXT4_BLOCK_ALIGN(pos + length, blkbits) >> blkbits) |
146 | overwrite = 1; | 161 | - map.m_lblk; |
162 | len = map.m_len; | ||
163 | |||
164 | err = ext4_map_blocks(NULL, inode, &map, 0); | ||
165 | /* | ||
166 | * 'err==len' means that all of blocks has | ||
167 | * been preallocated no matter they are | ||
168 | * initialized or not. For excluding | ||
169 | * unwritten extents, we need to check | ||
170 | * m_flags. There are two conditions that | ||
171 | * indicate for initialized extents. 1) If we | ||
172 | * hit extent cache, EXT4_MAP_MAPPED flag is | ||
173 | * returned; 2) If we do a real lookup, | ||
174 | * non-flags are returned. So we should check | ||
175 | * these two conditions. | ||
176 | */ | ||
177 | if (err == len && (map.m_flags & EXT4_MAP_MAPPED)) | ||
178 | overwrite = 1; | ||
179 | } | ||
147 | } | 180 | } |
148 | 181 | ||
149 | ret = __generic_file_aio_write(iocb, iov, nr_segs); | 182 | ret = __generic_file_aio_write(iocb, iov, nr_segs); |
@@ -156,45 +189,12 @@ ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov, | |||
156 | if (err < 0) | 189 | if (err < 0) |
157 | ret = err; | 190 | ret = err; |
158 | } | 191 | } |
159 | blk_finish_plug(&plug); | 192 | if (o_direct) |
160 | 193 | blk_finish_plug(&plug); | |
161 | if (unaligned_aio) | ||
162 | mutex_unlock(ext4_aio_mutex(inode)); | ||
163 | |||
164 | return ret; | ||
165 | } | ||
166 | |||
167 | static ssize_t | ||
168 | ext4_file_write(struct kiocb *iocb, const struct iovec *iov, | ||
169 | unsigned long nr_segs, loff_t pos) | ||
170 | { | ||
171 | struct inode *inode = file_inode(iocb->ki_filp); | ||
172 | ssize_t ret; | ||
173 | |||
174 | /* | ||
175 | * If we have encountered a bitmap-format file, the size limit | ||
176 | * is smaller than s_maxbytes, which is for extent-mapped files. | ||
177 | */ | ||
178 | |||
179 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { | ||
180 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | ||
181 | size_t length = iov_length(iov, nr_segs); | ||
182 | |||
183 | if ((pos > sbi->s_bitmap_maxbytes || | ||
184 | (pos == sbi->s_bitmap_maxbytes && length > 0))) | ||
185 | return -EFBIG; | ||
186 | |||
187 | if (pos + length > sbi->s_bitmap_maxbytes) { | ||
188 | nr_segs = iov_shorten((struct iovec *)iov, nr_segs, | ||
189 | sbi->s_bitmap_maxbytes - pos); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | if (unlikely(iocb->ki_filp->f_flags & O_DIRECT)) | ||
194 | ret = ext4_file_dio_write(iocb, iov, nr_segs, pos); | ||
195 | else | ||
196 | ret = generic_file_aio_write(iocb, iov, nr_segs, pos); | ||
197 | 194 | ||
195 | errout: | ||
196 | if (aio_mutex) | ||
197 | mutex_unlock(aio_mutex); | ||
198 | return ret; | 198 | return ret; |
199 | } | 199 | } |
200 | 200 | ||
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index e5718385a037..b2cee73c1437 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -489,8 +489,8 @@ static void ext4_map_blocks_es_recheck(handle_t *handle, | |||
489 | * Otherwise, call with ext4_ind_map_blocks() to handle indirect mapping | 489 | * Otherwise, call with ext4_ind_map_blocks() to handle indirect mapping |
490 | * based files | 490 | * based files |
491 | * | 491 | * |
492 | * On success, it returns the number of blocks being mapped or allocate. | 492 | * On success, it returns the number of blocks being mapped or allocated. |
493 | * if create==0 and the blocks are pre-allocated and uninitialized block, | 493 | * if create==0 and the blocks are pre-allocated and unwritten block, |
494 | * the result buffer head is unmapped. If the create ==1, it will make sure | 494 | * the result buffer head is unmapped. If the create ==1, it will make sure |
495 | * the buffer head is mapped. | 495 | * the buffer head is mapped. |
496 | * | 496 | * |
@@ -622,7 +622,7 @@ found: | |||
622 | map->m_flags &= ~EXT4_MAP_FLAGS; | 622 | map->m_flags &= ~EXT4_MAP_FLAGS; |
623 | 623 | ||
624 | /* | 624 | /* |
625 | * New blocks allocate and/or writing to uninitialized extent | 625 | * New blocks allocate and/or writing to unwritten extent |
626 | * will possibly result in updating i_data, so we take | 626 | * will possibly result in updating i_data, so we take |
627 | * the write lock of i_data_sem, and call get_blocks() | 627 | * the write lock of i_data_sem, and call get_blocks() |
628 | * with create == 1 flag. | 628 | * with create == 1 flag. |
@@ -2032,7 +2032,7 @@ static int mpage_process_page_bufs(struct mpage_da_data *mpd, | |||
2032 | * Scan buffers corresponding to changed extent (we expect corresponding pages | 2032 | * Scan buffers corresponding to changed extent (we expect corresponding pages |
2033 | * to be already locked) and update buffer state according to new extent state. | 2033 | * to be already locked) and update buffer state according to new extent state. |
2034 | * We map delalloc buffers to their physical location, clear unwritten bits, | 2034 | * We map delalloc buffers to their physical location, clear unwritten bits, |
2035 | * and mark buffers as uninit when we perform writes to uninitialized extents | 2035 | * and mark buffers as uninit when we perform writes to unwritten extents |
2036 | * and do extent conversion after IO is finished. If the last page is not fully | 2036 | * and do extent conversion after IO is finished. If the last page is not fully |
2037 | * mapped, we update @map to the next extent in the last page that needs | 2037 | * mapped, we update @map to the next extent in the last page that needs |
2038 | * mapping. Otherwise we submit the page for IO. | 2038 | * mapping. Otherwise we submit the page for IO. |
@@ -2126,12 +2126,12 @@ static int mpage_map_one_extent(handle_t *handle, struct mpage_da_data *mpd) | |||
2126 | struct inode *inode = mpd->inode; | 2126 | struct inode *inode = mpd->inode; |
2127 | struct ext4_map_blocks *map = &mpd->map; | 2127 | struct ext4_map_blocks *map = &mpd->map; |
2128 | int get_blocks_flags; | 2128 | int get_blocks_flags; |
2129 | int err; | 2129 | int err, dioread_nolock; |
2130 | 2130 | ||
2131 | trace_ext4_da_write_pages_extent(inode, map); | 2131 | trace_ext4_da_write_pages_extent(inode, map); |
2132 | /* | 2132 | /* |
2133 | * Call ext4_map_blocks() to allocate any delayed allocation blocks, or | 2133 | * Call ext4_map_blocks() to allocate any delayed allocation blocks, or |
2134 | * to convert an uninitialized extent to be initialized (in the case | 2134 | * to convert an unwritten extent to be initialized (in the case |
2135 | * where we have written into one or more preallocated blocks). It is | 2135 | * where we have written into one or more preallocated blocks). It is |
2136 | * possible that we're going to need more metadata blocks than | 2136 | * possible that we're going to need more metadata blocks than |
2137 | * previously reserved. However we must not fail because we're in | 2137 | * previously reserved. However we must not fail because we're in |
@@ -2148,7 +2148,8 @@ static int mpage_map_one_extent(handle_t *handle, struct mpage_da_data *mpd) | |||
2148 | */ | 2148 | */ |
2149 | get_blocks_flags = EXT4_GET_BLOCKS_CREATE | | 2149 | get_blocks_flags = EXT4_GET_BLOCKS_CREATE | |
2150 | EXT4_GET_BLOCKS_METADATA_NOFAIL; | 2150 | EXT4_GET_BLOCKS_METADATA_NOFAIL; |
2151 | if (ext4_should_dioread_nolock(inode)) | 2151 | dioread_nolock = ext4_should_dioread_nolock(inode); |
2152 | if (dioread_nolock) | ||
2152 | get_blocks_flags |= EXT4_GET_BLOCKS_IO_CREATE_EXT; | 2153 | get_blocks_flags |= EXT4_GET_BLOCKS_IO_CREATE_EXT; |
2153 | if (map->m_flags & (1 << BH_Delay)) | 2154 | if (map->m_flags & (1 << BH_Delay)) |
2154 | get_blocks_flags |= EXT4_GET_BLOCKS_DELALLOC_RESERVE; | 2155 | get_blocks_flags |= EXT4_GET_BLOCKS_DELALLOC_RESERVE; |
@@ -2156,7 +2157,7 @@ static int mpage_map_one_extent(handle_t *handle, struct mpage_da_data *mpd) | |||
2156 | err = ext4_map_blocks(handle, inode, map, get_blocks_flags); | 2157 | err = ext4_map_blocks(handle, inode, map, get_blocks_flags); |
2157 | if (err < 0) | 2158 | if (err < 0) |
2158 | return err; | 2159 | return err; |
2159 | if (map->m_flags & EXT4_MAP_UNINIT) { | 2160 | if (dioread_nolock && (map->m_flags & EXT4_MAP_UNWRITTEN)) { |
2160 | if (!mpd->io_submit.io_end->handle && | 2161 | if (!mpd->io_submit.io_end->handle && |
2161 | ext4_handle_valid(handle)) { | 2162 | ext4_handle_valid(handle)) { |
2162 | mpd->io_submit.io_end->handle = handle->h_rsv_handle; | 2163 | mpd->io_submit.io_end->handle = handle->h_rsv_handle; |
@@ -3070,9 +3071,9 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset, | |||
3070 | * preallocated extents, and those write extend the file, no need to | 3071 | * preallocated extents, and those write extend the file, no need to |
3071 | * fall back to buffered IO. | 3072 | * fall back to buffered IO. |
3072 | * | 3073 | * |
3073 | * For holes, we fallocate those blocks, mark them as uninitialized | 3074 | * For holes, we fallocate those blocks, mark them as unwritten |
3074 | * If those blocks were preallocated, we mark sure they are split, but | 3075 | * If those blocks were preallocated, we mark sure they are split, but |
3075 | * still keep the range to write as uninitialized. | 3076 | * still keep the range to write as unwritten. |
3076 | * | 3077 | * |
3077 | * The unwritten extents will be converted to written when DIO is completed. | 3078 | * The unwritten extents will be converted to written when DIO is completed. |
3078 | * For async direct IO, since the IO may still pending when return, we | 3079 | * For async direct IO, since the IO may still pending when return, we |
@@ -3123,12 +3124,12 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb, | |||
3123 | * We could direct write to holes and fallocate. | 3124 | * We could direct write to holes and fallocate. |
3124 | * | 3125 | * |
3125 | * Allocated blocks to fill the hole are marked as | 3126 | * Allocated blocks to fill the hole are marked as |
3126 | * uninitialized to prevent parallel buffered read to expose | 3127 | * unwritten to prevent parallel buffered read to expose |
3127 | * the stale data before DIO complete the data IO. | 3128 | * the stale data before DIO complete the data IO. |
3128 | * | 3129 | * |
3129 | * As to previously fallocated extents, ext4 get_block will | 3130 | * As to previously fallocated extents, ext4 get_block will |
3130 | * just simply mark the buffer mapped but still keep the | 3131 | * just simply mark the buffer mapped but still keep the |
3131 | * extents uninitialized. | 3132 | * extents unwritten. |
3132 | * | 3133 | * |
3133 | * For non AIO case, we will convert those unwritten extents | 3134 | * For non AIO case, we will convert those unwritten extents |
3134 | * to written after return back from blockdev_direct_IO. | 3135 | * to written after return back from blockdev_direct_IO. |
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 58ee7dc87669..1b809fe51da1 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c | |||
@@ -57,8 +57,8 @@ get_ext_path(struct inode *inode, ext4_lblk_t lblock, | |||
57 | static void | 57 | static void |
58 | copy_extent_status(struct ext4_extent *src, struct ext4_extent *dest) | 58 | copy_extent_status(struct ext4_extent *src, struct ext4_extent *dest) |
59 | { | 59 | { |
60 | if (ext4_ext_is_uninitialized(src)) | 60 | if (ext4_ext_is_unwritten(src)) |
61 | ext4_ext_mark_uninitialized(dest); | 61 | ext4_ext_mark_unwritten(dest); |
62 | else | 62 | else |
63 | dest->ee_len = cpu_to_le16(ext4_ext_get_actual_len(dest)); | 63 | dest->ee_len = cpu_to_le16(ext4_ext_get_actual_len(dest)); |
64 | } | 64 | } |
@@ -593,14 +593,14 @@ mext_calc_swap_extents(struct ext4_extent *tmp_dext, | |||
593 | * @inode: inode in question | 593 | * @inode: inode in question |
594 | * @from: block offset of inode | 594 | * @from: block offset of inode |
595 | * @count: block count to be checked | 595 | * @count: block count to be checked |
596 | * @uninit: extents expected to be uninitialized | 596 | * @unwritten: extents expected to be unwritten |
597 | * @err: pointer to save error value | 597 | * @err: pointer to save error value |
598 | * | 598 | * |
599 | * Return 1 if all extents in range has expected type, and zero otherwise. | 599 | * Return 1 if all extents in range has expected type, and zero otherwise. |
600 | */ | 600 | */ |
601 | static int | 601 | static int |
602 | mext_check_coverage(struct inode *inode, ext4_lblk_t from, ext4_lblk_t count, | 602 | mext_check_coverage(struct inode *inode, ext4_lblk_t from, ext4_lblk_t count, |
603 | int uninit, int *err) | 603 | int unwritten, int *err) |
604 | { | 604 | { |
605 | struct ext4_ext_path *path = NULL; | 605 | struct ext4_ext_path *path = NULL; |
606 | struct ext4_extent *ext; | 606 | struct ext4_extent *ext; |
@@ -611,7 +611,7 @@ mext_check_coverage(struct inode *inode, ext4_lblk_t from, ext4_lblk_t count, | |||
611 | if (*err) | 611 | if (*err) |
612 | goto out; | 612 | goto out; |
613 | ext = path[ext_depth(inode)].p_ext; | 613 | ext = path[ext_depth(inode)].p_ext; |
614 | if (uninit != ext4_ext_is_uninitialized(ext)) | 614 | if (unwritten != ext4_ext_is_unwritten(ext)) |
615 | goto out; | 615 | goto out; |
616 | from += ext4_ext_get_actual_len(ext); | 616 | from += ext4_ext_get_actual_len(ext); |
617 | ext4_ext_drop_refs(path); | 617 | ext4_ext_drop_refs(path); |
@@ -894,7 +894,7 @@ out: | |||
894 | * @orig_page_offset: page index on original file | 894 | * @orig_page_offset: page index on original file |
895 | * @data_offset_in_page: block index where data swapping starts | 895 | * @data_offset_in_page: block index where data swapping starts |
896 | * @block_len_in_page: the number of blocks to be swapped | 896 | * @block_len_in_page: the number of blocks to be swapped |
897 | * @uninit: orig extent is uninitialized or not | 897 | * @unwritten: orig extent is unwritten or not |
898 | * @err: pointer to save return value | 898 | * @err: pointer to save return value |
899 | * | 899 | * |
900 | * Save the data in original inode blocks and replace original inode extents | 900 | * Save the data in original inode blocks and replace original inode extents |
@@ -905,7 +905,7 @@ out: | |||
905 | static int | 905 | static int |
906 | move_extent_per_page(struct file *o_filp, struct inode *donor_inode, | 906 | move_extent_per_page(struct file *o_filp, struct inode *donor_inode, |
907 | pgoff_t orig_page_offset, int data_offset_in_page, | 907 | pgoff_t orig_page_offset, int data_offset_in_page, |
908 | int block_len_in_page, int uninit, int *err) | 908 | int block_len_in_page, int unwritten, int *err) |
909 | { | 909 | { |
910 | struct inode *orig_inode = file_inode(o_filp); | 910 | struct inode *orig_inode = file_inode(o_filp); |
911 | struct page *pagep[2] = {NULL, NULL}; | 911 | struct page *pagep[2] = {NULL, NULL}; |
@@ -962,27 +962,27 @@ again: | |||
962 | if (unlikely(*err < 0)) | 962 | if (unlikely(*err < 0)) |
963 | goto stop_journal; | 963 | goto stop_journal; |
964 | /* | 964 | /* |
965 | * If orig extent was uninitialized it can become initialized | 965 | * If orig extent was unwritten it can become initialized |
966 | * at any time after i_data_sem was dropped, in order to | 966 | * at any time after i_data_sem was dropped, in order to |
967 | * serialize with delalloc we have recheck extent while we | 967 | * serialize with delalloc we have recheck extent while we |
968 | * hold page's lock, if it is still the case data copy is not | 968 | * hold page's lock, if it is still the case data copy is not |
969 | * necessary, just swap data blocks between orig and donor. | 969 | * necessary, just swap data blocks between orig and donor. |
970 | */ | 970 | */ |
971 | if (uninit) { | 971 | if (unwritten) { |
972 | ext4_double_down_write_data_sem(orig_inode, donor_inode); | 972 | ext4_double_down_write_data_sem(orig_inode, donor_inode); |
973 | /* If any of extents in range became initialized we have to | 973 | /* If any of extents in range became initialized we have to |
974 | * fallback to data copying */ | 974 | * fallback to data copying */ |
975 | uninit = mext_check_coverage(orig_inode, orig_blk_offset, | 975 | unwritten = mext_check_coverage(orig_inode, orig_blk_offset, |
976 | block_len_in_page, 1, err); | 976 | block_len_in_page, 1, err); |
977 | if (*err) | 977 | if (*err) |
978 | goto drop_data_sem; | 978 | goto drop_data_sem; |
979 | 979 | ||
980 | uninit &= mext_check_coverage(donor_inode, orig_blk_offset, | 980 | unwritten &= mext_check_coverage(donor_inode, orig_blk_offset, |
981 | block_len_in_page, 1, err); | 981 | block_len_in_page, 1, err); |
982 | if (*err) | 982 | if (*err) |
983 | goto drop_data_sem; | 983 | goto drop_data_sem; |
984 | 984 | ||
985 | if (!uninit) { | 985 | if (!unwritten) { |
986 | ext4_double_up_write_data_sem(orig_inode, donor_inode); | 986 | ext4_double_up_write_data_sem(orig_inode, donor_inode); |
987 | goto data_copy; | 987 | goto data_copy; |
988 | } | 988 | } |
@@ -1259,7 +1259,7 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, | |||
1259 | int blocks_per_page = PAGE_CACHE_SIZE >> orig_inode->i_blkbits; | 1259 | int blocks_per_page = PAGE_CACHE_SIZE >> orig_inode->i_blkbits; |
1260 | int data_offset_in_page; | 1260 | int data_offset_in_page; |
1261 | int block_len_in_page; | 1261 | int block_len_in_page; |
1262 | int uninit; | 1262 | int unwritten; |
1263 | 1263 | ||
1264 | if (orig_inode->i_sb != donor_inode->i_sb) { | 1264 | if (orig_inode->i_sb != donor_inode->i_sb) { |
1265 | ext4_debug("ext4 move extent: The argument files " | 1265 | ext4_debug("ext4 move extent: The argument files " |
@@ -1391,8 +1391,8 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, | |||
1391 | !last_extent) | 1391 | !last_extent) |
1392 | continue; | 1392 | continue; |
1393 | 1393 | ||
1394 | /* Is original extent is uninitialized */ | 1394 | /* Is original extent is unwritten */ |
1395 | uninit = ext4_ext_is_uninitialized(ext_prev); | 1395 | unwritten = ext4_ext_is_unwritten(ext_prev); |
1396 | 1396 | ||
1397 | data_offset_in_page = seq_start % blocks_per_page; | 1397 | data_offset_in_page = seq_start % blocks_per_page; |
1398 | 1398 | ||
@@ -1432,8 +1432,8 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, | |||
1432 | o_filp, donor_inode, | 1432 | o_filp, donor_inode, |
1433 | orig_page_offset, | 1433 | orig_page_offset, |
1434 | data_offset_in_page, | 1434 | data_offset_in_page, |
1435 | block_len_in_page, uninit, | 1435 | block_len_in_page, |
1436 | &ret); | 1436 | unwritten, &ret); |
1437 | 1437 | ||
1438 | /* Count how many blocks we have exchanged */ | 1438 | /* Count how many blocks we have exchanged */ |
1439 | *moved_len += block_len_in_page; | 1439 | *moved_len += block_len_in_page; |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 6f9e6fadac04..c4895c195e00 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -3337,7 +3337,7 @@ static ext4_fsblk_t ext4_calculate_resv_clusters(struct super_block *sb) | |||
3337 | * By default we reserve 2% or 4096 clusters, whichever is smaller. | 3337 | * By default we reserve 2% or 4096 clusters, whichever is smaller. |
3338 | * This should cover the situations where we can not afford to run | 3338 | * This should cover the situations where we can not afford to run |
3339 | * out of space like for example punch hole, or converting | 3339 | * out of space like for example punch hole, or converting |
3340 | * uninitialized extents in delalloc path. In most cases such | 3340 | * unwritten extents in delalloc path. In most cases such |
3341 | * allocation would require 1, or 2 blocks, higher numbers are | 3341 | * allocation would require 1, or 2 blocks, higher numbers are |
3342 | * very rare. | 3342 | * very rare. |
3343 | */ | 3343 | */ |