0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _CEPH_CACHE_H
0010 #define _CEPH_CACHE_H
0011
0012 #include <linux/netfs.h>
0013
0014 #ifdef CONFIG_CEPH_FSCACHE
0015 #include <linux/fscache.h>
0016
0017 int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc);
0018 void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc);
0019
0020 void ceph_fscache_register_inode_cookie(struct inode *inode);
0021 void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci);
0022
0023 void ceph_fscache_use_cookie(struct inode *inode, bool will_modify);
0024 void ceph_fscache_unuse_cookie(struct inode *inode, bool update);
0025
0026 void ceph_fscache_update(struct inode *inode);
0027 void ceph_fscache_invalidate(struct inode *inode, bool dio_write);
0028
0029 static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci)
0030 {
0031 return netfs_i_cookie(&ci->netfs);
0032 }
0033
0034 static inline void ceph_fscache_resize(struct inode *inode, loff_t to)
0035 {
0036 struct ceph_inode_info *ci = ceph_inode(inode);
0037 struct fscache_cookie *cookie = ceph_fscache_cookie(ci);
0038
0039 if (cookie) {
0040 ceph_fscache_use_cookie(inode, true);
0041 fscache_resize_cookie(cookie, to);
0042 ceph_fscache_unuse_cookie(inode, true);
0043 }
0044 }
0045
0046 static inline void ceph_fscache_unpin_writeback(struct inode *inode,
0047 struct writeback_control *wbc)
0048 {
0049 fscache_unpin_writeback(wbc, ceph_fscache_cookie(ceph_inode(inode)));
0050 }
0051
0052 static inline int ceph_fscache_dirty_folio(struct address_space *mapping,
0053 struct folio *folio)
0054 {
0055 struct ceph_inode_info *ci = ceph_inode(mapping->host);
0056
0057 return fscache_dirty_folio(mapping, folio, ceph_fscache_cookie(ci));
0058 }
0059
0060 static inline int ceph_begin_cache_operation(struct netfs_io_request *rreq)
0061 {
0062 struct fscache_cookie *cookie = ceph_fscache_cookie(ceph_inode(rreq->inode));
0063
0064 return fscache_begin_read_operation(&rreq->cache_resources, cookie);
0065 }
0066
0067 static inline bool ceph_is_cache_enabled(struct inode *inode)
0068 {
0069 return fscache_cookie_enabled(ceph_fscache_cookie(ceph_inode(inode)));
0070 }
0071
0072 static inline void ceph_fscache_note_page_release(struct inode *inode)
0073 {
0074 struct ceph_inode_info *ci = ceph_inode(inode);
0075
0076 fscache_note_page_release(ceph_fscache_cookie(ci));
0077 }
0078 #else
0079 static inline int ceph_fscache_register_fs(struct ceph_fs_client* fsc,
0080 struct fs_context *fc)
0081 {
0082 return 0;
0083 }
0084
0085 static inline void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc)
0086 {
0087 }
0088
0089 static inline void ceph_fscache_register_inode_cookie(struct inode *inode)
0090 {
0091 }
0092
0093 static inline void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci)
0094 {
0095 }
0096
0097 static inline void ceph_fscache_use_cookie(struct inode *inode, bool will_modify)
0098 {
0099 }
0100
0101 static inline void ceph_fscache_unuse_cookie(struct inode *inode, bool update)
0102 {
0103 }
0104
0105 static inline void ceph_fscache_update(struct inode *inode)
0106 {
0107 }
0108
0109 static inline void ceph_fscache_invalidate(struct inode *inode, bool dio_write)
0110 {
0111 }
0112
0113 static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci)
0114 {
0115 return NULL;
0116 }
0117
0118 static inline void ceph_fscache_resize(struct inode *inode, loff_t to)
0119 {
0120 }
0121
0122 static inline void ceph_fscache_unpin_writeback(struct inode *inode,
0123 struct writeback_control *wbc)
0124 {
0125 }
0126
0127 static inline int ceph_fscache_dirty_folio(struct address_space *mapping,
0128 struct folio *folio)
0129 {
0130 return filemap_dirty_folio(mapping, folio);
0131 }
0132
0133 static inline bool ceph_is_cache_enabled(struct inode *inode)
0134 {
0135 return false;
0136 }
0137
0138 static inline int ceph_begin_cache_operation(struct netfs_io_request *rreq)
0139 {
0140 return -ENOBUFS;
0141 }
0142
0143 static inline void ceph_fscache_note_page_release(struct inode *inode)
0144 {
0145 }
0146 #endif
0147
0148 #endif