Blame view
include/linux/cleancache.h
3.89 KB
b24413180 License cleanup: ... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
077b1f83a mm: cleancache co... |
2 3 4 5 6 7 |
#ifndef _LINUX_CLEANCACHE_H #define _LINUX_CLEANCACHE_H #include <linux/fs.h> #include <linux/exportfs.h> #include <linux/mm.h> |
3cb29d111 cleancache: remov... |
8 9 10 |
#define CLEANCACHE_NO_POOL -1 #define CLEANCACHE_NO_BACKEND -2 #define CLEANCACHE_NO_BACKEND_SHARED -3 |
077b1f83a mm: cleancache co... |
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#define CLEANCACHE_KEY_MAX 6 /* * cleancache requires every file with a page in cleancache to have a * unique key unless/until the file is removed/truncated. For some * filesystems, the inode number is unique, but for "modern" filesystems * an exportable filehandle is required (see exportfs.h) */ struct cleancache_filekey { union { ino_t ino; __u32 fh[CLEANCACHE_KEY_MAX]; u32 key[CLEANCACHE_KEY_MAX]; } u; }; struct cleancache_ops { int (*init_fs)(size_t); |
85787090a fs: switch ->s_uu... |
29 |
int (*init_shared_fs)(uuid_t *uuid, size_t); |
077b1f83a mm: cleancache co... |
30 31 32 33 |
int (*get_page)(int, struct cleancache_filekey, pgoff_t, struct page *); void (*put_page)(int, struct cleancache_filekey, pgoff_t, struct page *); |
91c6cc9b5 mm: zcache/tmem/c... |
34 35 36 |
void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t); void (*invalidate_inode)(int, struct cleancache_filekey); void (*invalidate_fs)(int); |
077b1f83a mm: cleancache co... |
37 |
}; |
b3c6de492 cleancache: const... |
38 |
extern int cleancache_register_ops(const struct cleancache_ops *ops); |
077b1f83a mm: cleancache co... |
39 |
extern void __cleancache_init_fs(struct super_block *); |
9de162629 cleancache: zap u... |
40 |
extern void __cleancache_init_shared_fs(struct super_block *); |
077b1f83a mm: cleancache co... |
41 42 |
extern int __cleancache_get_page(struct page *); extern void __cleancache_put_page(struct page *); |
3167760f8 mm: cleancache: s... |
43 44 45 |
extern void __cleancache_invalidate_page(struct address_space *, struct page *); extern void __cleancache_invalidate_inode(struct address_space *); extern void __cleancache_invalidate_fs(struct super_block *); |
077b1f83a mm: cleancache co... |
46 47 |
#ifdef CONFIG_CLEANCACHE |
ff610a1d5 mm: cleancache: c... |
48 |
#define cleancache_enabled (1) |
077b1f83a mm: cleancache co... |
49 50 51 52 |
static inline bool cleancache_fs_enabled_mapping(struct address_space *mapping) { return mapping->host->i_sb->cleancache_poolid >= 0; } |
a39bb9a05 include/linux/cle... |
53 54 55 56 |
static inline bool cleancache_fs_enabled(struct page *page) { return cleancache_fs_enabled_mapping(page->mapping); } |
077b1f83a mm: cleancache co... |
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
#else #define cleancache_enabled (0) #define cleancache_fs_enabled(_page) (0) #define cleancache_fs_enabled_mapping(_page) (0) #endif /* * The shim layer provided by these inline functions allows the compiler * to reduce all cleancache hooks to nothingness if CONFIG_CLEANCACHE * is disabled, to a single global variable check if CONFIG_CLEANCACHE * is enabled but no cleancache "backend" has dynamically enabled it, * and, for the most frequent cleancache ops, to a single global variable * check plus a superblock element comparison if CONFIG_CLEANCACHE is enabled * and a cleancache backend has dynamically enabled cleancache, but the * filesystem referenced by that cleancache op has not enabled cleancache. * As a result, CONFIG_CLEANCACHE can be enabled by default with essentially * no measurable performance impact. */ static inline void cleancache_init_fs(struct super_block *sb) { if (cleancache_enabled) __cleancache_init_fs(sb); } |
9de162629 cleancache: zap u... |
81 |
static inline void cleancache_init_shared_fs(struct super_block *sb) |
077b1f83a mm: cleancache co... |
82 83 |
{ if (cleancache_enabled) |
9de162629 cleancache: zap u... |
84 |
__cleancache_init_shared_fs(sb); |
077b1f83a mm: cleancache co... |
85 86 87 88 |
} static inline int cleancache_get_page(struct page *page) { |
077b1f83a mm: cleancache co... |
89 |
if (cleancache_enabled && cleancache_fs_enabled(page)) |
a39bb9a05 include/linux/cle... |
90 91 |
return __cleancache_get_page(page); return -1; |
077b1f83a mm: cleancache co... |
92 93 94 95 96 97 98 |
} static inline void cleancache_put_page(struct page *page) { if (cleancache_enabled && cleancache_fs_enabled(page)) __cleancache_put_page(page); } |
3167760f8 mm: cleancache: s... |
99 |
static inline void cleancache_invalidate_page(struct address_space *mapping, |
077b1f83a mm: cleancache co... |
100 101 102 103 |
struct page *page) { /* careful... page->mapping is NULL sometimes when this is called */ if (cleancache_enabled && cleancache_fs_enabled_mapping(mapping)) |
3167760f8 mm: cleancache: s... |
104 |
__cleancache_invalidate_page(mapping, page); |
077b1f83a mm: cleancache co... |
105 |
} |
3167760f8 mm: cleancache: s... |
106 |
static inline void cleancache_invalidate_inode(struct address_space *mapping) |
077b1f83a mm: cleancache co... |
107 108 |
{ if (cleancache_enabled && cleancache_fs_enabled_mapping(mapping)) |
3167760f8 mm: cleancache: s... |
109 |
__cleancache_invalidate_inode(mapping); |
077b1f83a mm: cleancache co... |
110 |
} |
3167760f8 mm: cleancache: s... |
111 |
static inline void cleancache_invalidate_fs(struct super_block *sb) |
077b1f83a mm: cleancache co... |
112 113 |
{ if (cleancache_enabled) |
3167760f8 mm: cleancache: s... |
114 |
__cleancache_invalidate_fs(sb); |
077b1f83a mm: cleancache co... |
115 116 117 |
} #endif /* _LINUX_CLEANCACHE_H */ |