From 779e1322d47a5f28364343446853f24ac145e9ff Mon Sep 17 00:00:00 2001 From: Dmitry Monakhov Date: Fri, 8 Nov 2019 18:08:49 +0300 Subject: [PATCH] ext4: Don't cache clean inline extents Signed-off-by: Dmitry Monakhov --- fs/ext4/inode.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index abaaf7d..6839ac4 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -45,6 +45,7 @@ #include "xattr.h" #include "acl.h" #include "truncate.h" +#include "ext4_extents.h" #include @@ -584,11 +585,13 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, ext4_es_scan_range(inode, &ext4_es_is_delayed, map->m_lblk, map->m_lblk + map->m_len - 1)) status |= EXTENT_STATUS_DELAYED; - ret = ext4_es_insert_extent(inode, map->m_lblk, - map->m_len, map->m_pblk, status); - if (ret < 0) - retval = ret; + /* Don't cache if there are no external extent blocks */ + if ((status & EXTENT_STATUS_DELAYED) || ext_depth(inode)) { + ret = ext4_es_insert_extent(inode, map->m_lblk, + map->m_len, map->m_pblk, status); + if (ret < 0) + retval = ret; + } } up_read((&EXT4_I(inode)->i_data_sem)); -- 2.7.4