Comments
Patch
@@ -2059,6 +2059,8 @@ errout:
return ret;
}
+#define CACHE_EXTENT_HOLE 1
+#define CACHE_EXTENT_INITIALIZED 2
/*
* ext4_ext_in_cache()
* Checks to see if the given block is in the cache.
@@ -2083,7 +2085,10 @@ ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block,
ex->ee_block = cpu_to_le32(cex.ec_block);
ext4_ext_store_pblock(ex, cex.ec_start);
ex->ee_len = cpu_to_le16(cex.ec_len);
- ret = 1;
+ if (cex.ec_start == 0)
+ ret = CACHE_EXTENT_HOLE;
+ else
+ ret = CACHE_EXTENT_INITIALIZED;
}
return ret;
@@ -3721,9 +3726,10 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
trace_ext4_ext_map_blocks_enter(inode, map->m_lblk, map->m_len, flags);
/* check in cache */
- if (!(flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) &&
- ext4_ext_in_cache(inode, map->m_lblk, &newex)) {
- if (!newex.ee_start_lo && !newex.ee_start_hi) {
+ if (!(flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT)) {
+ ret = ext4_ext_in_cache(inode, map->m_lblk, &newex);
+ switch (ret) {
+ case CACHE_EXTENT_HOLE:
if ((sbi->s_cluster_ratio > 1) &&
ext4_find_delalloc_cluster(inode, map->m_lblk, 0))
map->m_flags |= EXT4_MAP_FROM_CLUSTER;
@@ -3736,7 +3742,9 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
goto out2;
}
/* we should allocate requested block */
- } else {
+ break;
+
+ case CACHE_EXTENT_INITIALIZED:
/* block is already allocated */
if (sbi->s_cluster_ratio > 1)
map->m_flags |= EXT4_MAP_FROM_CLUSTER;
This patch let ext4_ext_in_cache return the type of cached extent. Now two kinds of cached extents are supported, they are delayed extent and initialized extent respectively. Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com> --- fs/ext4/extents.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-)