]>
Commit | Line | Data |
---|---|---|
1f327613 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
99ccbd22 MT |
2 | /* |
3 | * Ceph cache definitions. | |
4 | * | |
5 | * Copyright (C) 2013 by Adfin Solutions, Inc. All Rights Reserved. | |
6 | * Written by Milosz Tanski (milosz@adfin.com) | |
99ccbd22 MT |
7 | */ |
8 | ||
9 | #ifndef _CEPH_CACHE_H | |
10 | #define _CEPH_CACHE_H | |
11 | ||
f0702876 JL |
12 | #include <linux/netfs.h> |
13 | ||
99ccbd22 MT |
14 | #ifdef CONFIG_CEPH_FSCACHE |
15 | ||
971f0bde MT |
16 | extern struct fscache_netfs ceph_cache_netfs; |
17 | ||
99ccbd22 MT |
18 | int ceph_fscache_register(void); |
19 | void ceph_fscache_unregister(void); | |
20 | ||
82995cc6 | 21 | int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc); |
99ccbd22 MT |
22 | void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc); |
23 | ||
46b59b2b | 24 | void ceph_fscache_register_inode_cookie(struct inode *inode); |
99ccbd22 | 25 | void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci); |
46b59b2b | 26 | void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp); |
f7f7e7a0 | 27 | void ceph_fscache_revalidate_cookie(struct ceph_inode_info *ci); |
99ccbd22 MT |
28 | |
29 | int ceph_readpage_from_fscache(struct inode *inode, struct page *page); | |
30 | int ceph_readpages_from_fscache(struct inode *inode, | |
31 | struct address_space *mapping, | |
32 | struct list_head *pages, | |
33 | unsigned *nr_pages); | |
f7f7e7a0 YZ |
34 | |
35 | static inline void ceph_fscache_inode_init(struct ceph_inode_info *ci) | |
36 | { | |
37 | ci->fscache = NULL; | |
f7f7e7a0 | 38 | } |
99ccbd22 | 39 | |
f0702876 JL |
40 | static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci) |
41 | { | |
42 | return ci->fscache; | |
43 | } | |
44 | ||
99ccbd22 MT |
45 | static inline void ceph_fscache_invalidate(struct inode *inode) |
46 | { | |
47 | fscache_invalidate(ceph_inode(inode)->fscache); | |
48 | } | |
49 | ||
f0702876 JL |
50 | static inline bool ceph_is_cache_enabled(struct inode *inode) |
51 | { | |
52 | struct fscache_cookie *cookie = ceph_fscache_cookie(ceph_inode(inode)); | |
53 | ||
54 | if (!cookie) | |
55 | return false; | |
56 | return fscache_cookie_enabled(cookie); | |
57 | } | |
58 | ||
59 | static inline int ceph_begin_cache_operation(struct netfs_read_request *rreq) | |
60 | { | |
61 | struct fscache_cookie *cookie = ceph_fscache_cookie(ceph_inode(rreq->inode)); | |
62 | ||
63 | return fscache_begin_read_operation(rreq, cookie); | |
64 | } | |
99ccbd22 MT |
65 | #else |
66 | ||
67 | static inline int ceph_fscache_register(void) | |
68 | { | |
69 | return 0; | |
70 | } | |
71 | ||
72 | static inline void ceph_fscache_unregister(void) | |
73 | { | |
74 | } | |
75 | ||
82995cc6 DH |
76 | static inline int ceph_fscache_register_fs(struct ceph_fs_client* fsc, |
77 | struct fs_context *fc) | |
99ccbd22 MT |
78 | { |
79 | return 0; | |
80 | } | |
81 | ||
82 | static inline void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc) | |
83 | { | |
84 | } | |
85 | ||
86 | static inline void ceph_fscache_inode_init(struct ceph_inode_info *ci) | |
87 | { | |
88 | } | |
89 | ||
f0702876 JL |
90 | static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci) |
91 | { | |
92 | return NULL; | |
93 | } | |
94 | ||
46b59b2b YZ |
95 | static inline void ceph_fscache_register_inode_cookie(struct inode *inode) |
96 | { | |
97 | } | |
98 | ||
99 | static inline void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci) | |
100 | { | |
101 | } | |
102 | ||
103 | static inline void ceph_fscache_file_set_cookie(struct inode *inode, | |
104 | struct file *filp) | |
99ccbd22 MT |
105 | { |
106 | } | |
107 | ||
99ccbd22 MT |
108 | static inline void ceph_fscache_invalidate(struct inode *inode) |
109 | { | |
110 | } | |
111 | ||
f0702876 JL |
112 | static inline bool ceph_is_cache_enabled(struct inode *inode) |
113 | { | |
114 | return false; | |
115 | } | |
116 | ||
117 | static inline int ceph_begin_cache_operation(struct netfs_read_request *rreq) | |
118 | { | |
119 | return -ENOBUFS; | |
120 | } | |
99ccbd22 MT |
121 | #endif |
122 | ||
e7df4524 | 123 | #endif /* _CEPH_CACHE_H */ |