Milosz Tanski | 99ccbd2 | 2013-08-21 17:29:54 -0400 | [diff] [blame] | 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 | |
| 29 | int ceph_fscache_register(void); |
| 30 | void ceph_fscache_unregister(void); |
| 31 | |
| 32 | int ceph_fscache_register_fs(struct ceph_fs_client* fsc); |
| 33 | void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc); |
| 34 | |
| 35 | void ceph_fscache_inode_init(struct ceph_inode_info *ci); |
| 36 | void ceph_fscache_register_inode_cookie(struct ceph_fs_client* fsc, |
| 37 | struct ceph_inode_info* ci); |
| 38 | void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci); |
| 39 | |
| 40 | int ceph_readpage_from_fscache(struct inode *inode, struct page *page); |
| 41 | int ceph_readpages_from_fscache(struct inode *inode, |
| 42 | struct address_space *mapping, |
| 43 | struct list_head *pages, |
| 44 | unsigned *nr_pages); |
| 45 | void ceph_readpage_to_fscache(struct inode *inode, struct page *page); |
| 46 | void ceph_invalidate_fscache_page(struct inode* inode, struct page *page); |
| 47 | void ceph_queue_revalidate(struct inode *inode); |
| 48 | |
| 49 | static inline void ceph_fscache_invalidate(struct inode *inode) |
| 50 | { |
| 51 | fscache_invalidate(ceph_inode(inode)->fscache); |
| 52 | } |
| 53 | |
Milosz Tanski | d4d3aa3 | 2013-09-03 19:11:17 -0400 | [diff] [blame^] | 54 | static inline void ceph_fscache_uncache_page(struct inode *inode, |
| 55 | struct page *page) |
| 56 | { |
| 57 | struct ceph_inode_info *ci = ceph_inode(inode); |
| 58 | return fscache_uncache_page(ci->fscache, page); |
| 59 | } |
| 60 | |
Milosz Tanski | 99ccbd2 | 2013-08-21 17:29:54 -0400 | [diff] [blame] | 61 | static inline int ceph_release_fscache_page(struct page *page, gfp_t gfp) |
| 62 | { |
| 63 | struct inode* inode = page->mapping->host; |
| 64 | struct ceph_inode_info *ci = ceph_inode(inode); |
| 65 | return fscache_maybe_release_page(ci->fscache, page, gfp); |
| 66 | } |
| 67 | |
Milosz Tanski | 76be778 | 2013-08-21 17:30:27 -0400 | [diff] [blame] | 68 | static inline void ceph_fscache_readpages_cancel(struct inode *inode, |
| 69 | struct list_head *pages) |
| 70 | { |
| 71 | struct ceph_inode_info *ci = ceph_inode(inode); |
| 72 | return fscache_readpages_cancel(ci->fscache, pages); |
| 73 | } |
| 74 | |
Milosz Tanski | 99ccbd2 | 2013-08-21 17:29:54 -0400 | [diff] [blame] | 75 | #else |
| 76 | |
| 77 | static inline int ceph_fscache_register(void) |
| 78 | { |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | static inline void ceph_fscache_unregister(void) |
| 83 | { |
| 84 | } |
| 85 | |
| 86 | static inline int ceph_fscache_register_fs(struct ceph_fs_client* fsc) |
| 87 | { |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | static inline void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc) |
| 92 | { |
| 93 | } |
| 94 | |
| 95 | static inline void ceph_fscache_inode_init(struct ceph_inode_info *ci) |
| 96 | { |
| 97 | } |
| 98 | |
| 99 | static inline void ceph_fscache_register_inode_cookie(struct ceph_fs_client* parent_fsc, |
| 100 | struct ceph_inode_info* ci) |
| 101 | { |
| 102 | } |
| 103 | |
Milosz Tanski | d4d3aa3 | 2013-09-03 19:11:17 -0400 | [diff] [blame^] | 104 | static inline void ceph_fscache_uncache_page(struct inode *inode, |
| 105 | struct page *pages) |
Milosz Tanski | 99ccbd2 | 2013-08-21 17:29:54 -0400 | [diff] [blame] | 106 | { |
| 107 | } |
| 108 | |
| 109 | static inline int ceph_readpage_from_fscache(struct inode* inode, |
| 110 | struct page *page) |
| 111 | { |
| 112 | return -ENOBUFS; |
| 113 | } |
| 114 | |
| 115 | static inline int ceph_readpages_from_fscache(struct inode *inode, |
| 116 | struct address_space *mapping, |
| 117 | struct list_head *pages, |
| 118 | unsigned *nr_pages) |
| 119 | { |
| 120 | return -ENOBUFS; |
| 121 | } |
| 122 | |
| 123 | static inline void ceph_readpage_to_fscache(struct inode *inode, |
| 124 | struct page *page) |
| 125 | { |
| 126 | } |
| 127 | |
| 128 | static inline void ceph_fscache_invalidate(struct inode *inode) |
| 129 | { |
| 130 | } |
| 131 | |
| 132 | static inline void ceph_invalidate_fscache_page(struct inode *inode, |
| 133 | struct page *page) |
| 134 | { |
| 135 | } |
| 136 | |
Milosz Tanski | d4d3aa3 | 2013-09-03 19:11:17 -0400 | [diff] [blame^] | 137 | static inline void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci) |
| 138 | { |
| 139 | } |
| 140 | |
Milosz Tanski | 99ccbd2 | 2013-08-21 17:29:54 -0400 | [diff] [blame] | 141 | static inline int ceph_release_fscache_page(struct page *page, gfp_t gfp) |
| 142 | { |
| 143 | return 1; |
| 144 | } |
| 145 | |
| 146 | static inline void ceph_fscache_readpages_cancel(struct inode *inode, |
| 147 | struct list_head *pages) |
| 148 | { |
| 149 | } |
| 150 | |
| 151 | static inline void ceph_queue_revalidate(struct inode *inode) |
| 152 | { |
| 153 | } |
| 154 | |
| 155 | #endif |
| 156 | |
| 157 | #endif |