Commit 7dd1f7f0 authored by Johannes Weiner's avatar Johannes Weiner Committed by Andrew Morton

mm: zswap: move zswap_invalidate_entry() to related functions

Move it up to the other tree and refcounting functions.

Link: https://lkml.kernel.org/r/20240130014208.565554-4-hannes@cmpxchg.orgSigned-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Reviewed-by: default avatarNhat Pham <nphamcs@gmail.com>
Acked-by: default avatarYosry Ahmed <yosryahmed@google.com>
Reviewed-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 5b297f70
...@@ -558,6 +558,18 @@ static void zswap_entry_put(struct zswap_entry *entry) ...@@ -558,6 +558,18 @@ static void zswap_entry_put(struct zswap_entry *entry)
} }
} }
/*
* If the entry is still valid in the tree, drop the initial ref and remove it
* from the tree. This function must be called with an additional ref held,
* otherwise it may race with another invalidation freeing the entry.
*/
static void zswap_invalidate_entry(struct zswap_tree *tree,
struct zswap_entry *entry)
{
if (zswap_rb_erase(&tree->rbroot, entry))
zswap_entry_put(entry);
}
/********************************* /*********************************
* shrinker functions * shrinker functions
**********************************/ **********************************/
...@@ -808,18 +820,6 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor) ...@@ -808,18 +820,6 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor)
return NULL; return NULL;
} }
/*
* If the entry is still valid in the tree, drop the initial ref and remove it
* from the tree. This function must be called with an additional ref held,
* otherwise it may race with another invalidation freeing the entry.
*/
static void zswap_invalidate_entry(struct zswap_tree *tree,
struct zswap_entry *entry)
{
if (zswap_rb_erase(&tree->rbroot, entry))
zswap_entry_put(entry);
}
static enum lru_status shrink_memcg_cb(struct list_head *item, struct list_lru_one *l, static enum lru_status shrink_memcg_cb(struct list_head *item, struct list_lru_one *l,
spinlock_t *lock, void *arg) spinlock_t *lock, void *arg)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment