blob: fb326fd33251aaee1d7410f7e8d0aa75220fc40c [file] [log] [blame]
Milosz Tanski99ccbd22013-08-21 17:29:54 -04001/*
2 * Ceph cache definitions.
3 *
4 * Copyright (C) 2013 by Adfin Solutions, Inc. All Rights Reserved.
5 * Written by Milosz Tanski (milosz@adfin.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to:
18 * Free Software Foundation
19 * 51 Franklin Street, Fifth Floor
20 * Boston, MA 02111-1301 USA
21 *
22 */
23
24#ifndef _CEPH_CACHE_H
25#define _CEPH_CACHE_H
26
27#ifdef CONFIG_CEPH_FSCACHE
28
29int ceph_fscache_register(void);
30void ceph_fscache_unregister(void);
31
32int ceph_fscache_register_fs(struct ceph_fs_client* fsc);
33void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc);
34
35void ceph_fscache_inode_init(struct ceph_inode_info *ci);
36void ceph_fscache_register_inode_cookie(struct ceph_fs_client* fsc,
37 struct ceph_inode_info* ci);
38void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci);
39
40int ceph_readpage_from_fscache(struct inode *inode, struct page *page);
41int ceph_readpages_from_fscache(struct inode *inode,
42 struct address_space *mapping,
43 struct list_head *pages,
44 unsigned *nr_pages);
45void ceph_readpage_to_fscache(struct inode *inode, struct page *page);
46void ceph_invalidate_fscache_page(struct inode* inode, struct page *page);
47void ceph_queue_revalidate(struct inode *inode);
48
49static inline void ceph_fscache_invalidate(struct inode *inode)
50{
51 fscache_invalidate(ceph_inode(inode)->fscache);
52}
53
54static inline int ceph_release_fscache_page(struct page *page, gfp_t gfp)
55{
56 struct inode* inode = page->mapping->host;
57 struct ceph_inode_info *ci = ceph_inode(inode);
58 return fscache_maybe_release_page(ci->fscache, page, gfp);
59}
60
Milosz Tanski76be7782013-08-21 17:30:27 -040061static inline void ceph_fscache_readpages_cancel(struct inode *inode,
62 struct list_head *pages)
63{
64 struct ceph_inode_info *ci = ceph_inode(inode);
65 return fscache_readpages_cancel(ci->fscache, pages);
66}
67
Milosz Tanski99ccbd22013-08-21 17:29:54 -040068#else
69
70static inline int ceph_fscache_register(void)
71{
72 return 0;
73}
74
75static inline void ceph_fscache_unregister(void)
76{
77}
78
79static inline int ceph_fscache_register_fs(struct ceph_fs_client* fsc)
80{
81 return 0;
82}
83
84static inline void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc)
85{
86}
87
88static inline void ceph_fscache_inode_init(struct ceph_inode_info *ci)
89{
90}
91
92static inline void ceph_fscache_register_inode_cookie(struct ceph_fs_client* parent_fsc,
93 struct ceph_inode_info* ci)
94{
95}
96
97static inline void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci)
98{
99}
100
101static inline int ceph_readpage_from_fscache(struct inode* inode,
102 struct page *page)
103{
104 return -ENOBUFS;
105}
106
107static inline int ceph_readpages_from_fscache(struct inode *inode,
108 struct address_space *mapping,
109 struct list_head *pages,
110 unsigned *nr_pages)
111{
112 return -ENOBUFS;
113}
114
115static inline void ceph_readpage_to_fscache(struct inode *inode,
116 struct page *page)
117{
118}
119
120static inline void ceph_fscache_invalidate(struct inode *inode)
121{
122}
123
124static inline void ceph_invalidate_fscache_page(struct inode *inode,
125 struct page *page)
126{
127}
128
129static inline int ceph_release_fscache_page(struct page *page, gfp_t gfp)
130{
131 return 1;
132}
133
134static inline void ceph_fscache_readpages_cancel(struct inode *inode,
135 struct list_head *pages)
136{
137}
138
139static inline void ceph_queue_revalidate(struct inode *inode)
140{
141}
142
143#endif
144
145#endif