Skip to content

Commit 63b9996

Browse files
committed
ext4: call ext4_es_lru_add() after handling cache miss
If there are no items in the extent status tree, ext4_es_lru_add() is a no-op. So it is not sufficient to call ext4_es_lru_add() before we try to lookup an entry in the extent status tree. We also need to call it at the end of ext4_ext_map_blocks(), after items have been added to the extent status tree. This could lead to inodes with that have extent status trees but which are not in the LRU list, which means they won't get considered for eviction by the es_shrinker. Signed-off-by: "Theodore Ts'o" <[email protected]> Cc: Zheng Liu <[email protected]> Cc: [email protected]
1 parent 76828c8 commit 63b9996

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

fs/ext4/extents.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4385,8 +4385,9 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
43854385
}
43864386

43874387
out3:
4388-
trace_ext4_ext_map_blocks_exit(inode, flags, map, err ? err : allocated);
4389-
4388+
trace_ext4_ext_map_blocks_exit(inode, flags, map,
4389+
err ? err : allocated);
4390+
ext4_es_lru_add(inode);
43904391
return err ? err : allocated;
43914392
}
43924393

fs/ext4/inode.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,9 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
514514
"logical block %lu\n", inode->i_ino, flags, map->m_len,
515515
(unsigned long) map->m_lblk);
516516

517-
ext4_es_lru_add(inode);
518-
519517
/* Lookup extent status tree firstly */
520518
if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) {
519+
ext4_es_lru_add(inode);
521520
if (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) {
522521
map->m_pblk = ext4_es_pblock(&es) +
523522
map->m_lblk - es.es_lblk;
@@ -1529,11 +1528,9 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
15291528
"logical block %lu\n", inode->i_ino, map->m_len,
15301529
(unsigned long) map->m_lblk);
15311530

1532-
ext4_es_lru_add(inode);
1533-
15341531
/* Lookup extent status tree firstly */
15351532
if (ext4_es_lookup_extent(inode, iblock, &es)) {
1536-
1533+
ext4_es_lru_add(inode);
15371534
if (ext4_es_is_hole(&es)) {
15381535
retval = 0;
15391536
down_read((&EXT4_I(inode)->i_data_sem));

0 commit comments

Comments
 (0)