1/* SPDX-License-Identifier: GPL-2.0-only */ 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) 7 */ 8 9#ifndef _CEPH_CACHE_H 10#define _CEPH_CACHE_H 11 12#include <linux/netfs.h> 13 14#ifdef CONFIG_CEPH_FSCACHE 15 16extern struct fscache_netfs ceph_cache_netfs; 17 18int ceph_fscache_register(void); 19void ceph_fscache_unregister(void); 20 21int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc); 22void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc); 23 24void ceph_fscache_register_inode_cookie(struct inode *inode); 25void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci); 26void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp); 27void ceph_fscache_revalidate_cookie(struct ceph_inode_info *ci); 28 29static inline void ceph_fscache_inode_init(struct ceph_inode_info *ci) 30{ 31 ci->fscache = NULL; 32} 33 34static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci) 35{ 36 return ci->fscache; 37} 38 39static inline void ceph_fscache_invalidate(struct inode *inode) 40{ 41 fscache_invalidate(ceph_inode(inode)->fscache); 42} 43 44static inline bool ceph_is_cache_enabled(struct inode *inode) 45{ 46 struct fscache_cookie *cookie = ceph_fscache_cookie(ceph_inode(inode)); 47 48 if (!cookie) 49 return false; 50 return fscache_cookie_enabled(cookie); 51} 52 53static inline int ceph_begin_cache_operation(struct netfs_read_request *rreq) 54{ 55 struct fscache_cookie *cookie = ceph_fscache_cookie(ceph_inode(rreq->inode)); 56 57 return fscache_begin_read_operation(rreq, cookie); 58} 59#else 60 61static inline int ceph_fscache_register(void) 62{ 63 return 0; 64} 65 66static inline void ceph_fscache_unregister(void) 67{ 68} 69 70static inline int ceph_fscache_register_fs(struct ceph_fs_client* fsc, 71 struct fs_context *fc) 72{ 73 return 0; 74} 75 76static inline void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc) 77{ 78} 79 80static inline void ceph_fscache_inode_init(struct ceph_inode_info *ci) 81{ 82} 83 84static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci) 85{ 86 return NULL; 87} 88 89static inline void ceph_fscache_register_inode_cookie(struct inode *inode) 90{ 91} 92 93static inline void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci) 94{ 95} 96 97static inline void ceph_fscache_file_set_cookie(struct inode *inode, 98 struct file *filp) 99{ 100} 101 102static inline void ceph_fscache_invalidate(struct inode *inode) 103{ 104} 105 106static inline bool ceph_is_cache_enabled(struct inode *inode) 107{ 108 return false; 109} 110 111static inline int ceph_begin_cache_operation(struct netfs_read_request *rreq) 112{ 113 return -ENOBUFS; 114} 115#endif 116 117#endif /* _CEPH_CACHE_H */ 118