diff options
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 0554c48cb1fd..d53e20f53103 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -117,11 +117,33 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode, | |||
117 | struct ext4_extent *ex; | 117 | struct ext4_extent *ex; |
118 | depth = path->p_depth; | 118 | depth = path->p_depth; |
119 | 119 | ||
120 | /* try to predict block placement */ | 120 | /* |
121 | * Try to predict block placement assuming that we are | ||
122 | * filling in a file which will eventually be | ||
123 | * non-sparse --- i.e., in the case of libbfd writing | ||
124 | * an ELF object sections out-of-order but in a way | ||
125 | * the eventually results in a contiguous object or | ||
126 | * executable file, or some database extending a table | ||
127 | * space file. However, this is actually somewhat | ||
128 | * non-ideal if we are writing a sparse file such as | ||
129 | * qemu or KVM writing a raw image file that is going | ||
130 | * to stay fairly sparse, since it will end up | ||
131 | * fragmenting the file system's free space. Maybe we | ||
132 | * should have some hueristics or some way to allow | ||
133 | * userspace to pass a hint to file system, | ||
134 | * especiially if the latter case turns out to be | ||
135 | * common. | ||
136 | */ | ||
121 | ex = path[depth].p_ext; | 137 | ex = path[depth].p_ext; |
122 | if (ex) | 138 | if (ex) { |
123 | return (ext4_ext_pblock(ex) + | 139 | ext4_fsblk_t ext_pblk = ext4_ext_pblock(ex); |
124 | (block - le32_to_cpu(ex->ee_block))); | 140 | ext4_lblk_t ext_block = le32_to_cpu(ex->ee_block); |
141 | |||
142 | if (block > ext_block) | ||
143 | return ext_pblk + (block - ext_block); | ||
144 | else | ||
145 | return ext_pblk - (ext_block - block); | ||
146 | } | ||
125 | 147 | ||
126 | /* it looks like index is empty; | 148 | /* it looks like index is empty; |
127 | * try to find starting block from index itself */ | 149 | * try to find starting block from index itself */ |