mm: return the folio from __read_swap_cache_async()
[linux-block.git] / include / linux / zswap.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_ZSWAP_H
3 #define _LINUX_ZSWAP_H
4
5 #include <linux/types.h>
6 #include <linux/mm_types.h>
7
8 struct lruvec;
9
10 extern u64 zswap_pool_total_size;
11 extern atomic_t zswap_stored_pages;
12
13 #ifdef CONFIG_ZSWAP
14
15 struct zswap_lruvec_state {
16         /*
17          * Number of pages in zswap that should be protected from the shrinker.
18          * This number is an estimate of the following counts:
19          *
20          * a) Recent page faults.
21          * b) Recent insertion to the zswap LRU. This includes new zswap stores,
22          *    as well as recent zswap LRU rotations.
23          *
24          * These pages are likely to be warm, and might incur IO if the are written
25          * to swap.
26          */
27         atomic_long_t nr_zswap_protected;
28 };
29
30 bool zswap_store(struct folio *folio);
31 bool zswap_load(struct folio *folio);
32 void zswap_invalidate(int type, pgoff_t offset);
33 void zswap_swapon(int type);
34 void zswap_swapoff(int type);
35 void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg);
36 void zswap_lruvec_state_init(struct lruvec *lruvec);
37 void zswap_folio_swapin(struct folio *folio);
38 #else
39
40 struct zswap_lruvec_state {};
41
42 static inline bool zswap_store(struct folio *folio)
43 {
44         return false;
45 }
46
47 static inline bool zswap_load(struct folio *folio)
48 {
49         return false;
50 }
51
52 static inline void zswap_invalidate(int type, pgoff_t offset) {}
53 static inline void zswap_swapon(int type) {}
54 static inline void zswap_swapoff(int type) {}
55 static inline void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg) {}
56 static inline void zswap_lruvec_state_init(struct lruvec *lruvec) {}
57 static inline void zswap_folio_swapin(struct folio *folio) {}
58 #endif
59
60 #endif /* _LINUX_ZSWAP_H */