ceph: use fscache as a local presisent cache
[deliverable/linux.git] / fs / ceph / cache.h
CommitLineData
99ccbd22
MT
1/*
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
61#else
62
63static inline int ceph_fscache_register(void)
64{
65 return 0;
66}
67
68static inline void ceph_fscache_unregister(void)
69{
70}
71
72static inline int ceph_fscache_register_fs(struct ceph_fs_client* fsc)
73{
74 return 0;
75}
76
77static inline void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc)
78{
79}
80
81static inline void ceph_fscache_inode_init(struct ceph_inode_info *ci)
82{
83}
84
85static inline void ceph_fscache_register_inode_cookie(struct ceph_fs_client* parent_fsc,
86 struct ceph_inode_info* ci)
87{
88}
89
90static inline void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci)
91{
92}
93
94static inline int ceph_readpage_from_fscache(struct inode* inode,
95 struct page *page)
96{
97 return -ENOBUFS;
98}
99
100static inline int ceph_readpages_from_fscache(struct inode *inode,
101 struct address_space *mapping,
102 struct list_head *pages,
103 unsigned *nr_pages)
104{
105 return -ENOBUFS;
106}
107
108static inline void ceph_readpage_to_fscache(struct inode *inode,
109 struct page *page)
110{
111}
112
113static inline void ceph_fscache_invalidate(struct inode *inode)
114{
115}
116
117static inline void ceph_invalidate_fscache_page(struct inode *inode,
118 struct page *page)
119{
120}
121
122static inline int ceph_release_fscache_page(struct page *page, gfp_t gfp)
123{
124 return 1;
125}
126
127static inline void ceph_fscache_readpages_cancel(struct inode *inode,
128 struct list_head *pages)
129{
130}
131
132static inline void ceph_queue_revalidate(struct inode *inode)
133{
134}
135
136#endif
137
138#endif
This page took 0.029333 seconds and 5 git commands to generate.