diff --git a/fs/btrfs/lru_cache.c b/fs/btrfs/lru_cache.c index 01821d66a8a2df759a51cf82d80a25a7f664f4f2..38722dc07676d589cb7e441375b9c617a4800579 100644 --- a/fs/btrfs/lru_cache.c +++ b/fs/btrfs/lru_cache.c @@ -57,8 +57,16 @@ struct btrfs_lru_cache_entry *btrfs_lru_cache_lookup(struct btrfs_lru_cache *cac return entry; } -static void delete_entry(struct btrfs_lru_cache *cache, - struct btrfs_lru_cache_entry *entry) +/* + * Remove an entry from the cache. + * + * @cache: The cache to remove from. + * @entry: The entry to remove from the cache. + * + * Note: this also frees the memory used by the entry. + */ +void btrfs_lru_cache_remove(struct btrfs_lru_cache *cache, + struct btrfs_lru_cache_entry *entry) { struct list_head *prev = entry->list.prev; @@ -127,7 +135,7 @@ int btrfs_lru_cache_store(struct btrfs_lru_cache *cache, lru_entry = list_first_entry(&cache->lru_list, struct btrfs_lru_cache_entry, lru_list); - delete_entry(cache, lru_entry); + btrfs_lru_cache_remove(cache, lru_entry); } list_add_tail(&new_entry->lru_list, &cache->lru_list); @@ -149,7 +157,7 @@ void btrfs_lru_cache_clear(struct btrfs_lru_cache *cache) struct btrfs_lru_cache_entry *tmp; list_for_each_entry_safe(entry, tmp, &cache->lru_list, lru_list) - delete_entry(cache, entry); + btrfs_lru_cache_remove(cache, entry); ASSERT(cache->size == 0); ASSERT(mtree_empty(&cache->entries)); diff --git a/fs/btrfs/lru_cache.h b/fs/btrfs/lru_cache.h index c1f20f4b70380516855ffac63be6b8e4d95dbdb9..a97206f04990b3f2fe5a3e28e060f7d97e96cbc8 100644 --- a/fs/btrfs/lru_cache.h +++ b/fs/btrfs/lru_cache.h @@ -58,6 +58,8 @@ struct btrfs_lru_cache_entry *btrfs_lru_cache_lookup(struct btrfs_lru_cache *cac int btrfs_lru_cache_store(struct btrfs_lru_cache *cache, struct btrfs_lru_cache_entry *new_entry, gfp_t gfp); +void btrfs_lru_cache_remove(struct btrfs_lru_cache *cache, + struct btrfs_lru_cache_entry *entry); void btrfs_lru_cache_clear(struct btrfs_lru_cache *cache); #endif