18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * V9FS cache definitions. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2009 by Abhishek Kulkarni <adkulkar@umail.iu.edu> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _9P_CACHE_H 98c2ecf20Sopenharmony_ci#define _9P_CACHE_H 108c2ecf20Sopenharmony_ci#ifdef CONFIG_9P_FSCACHE 118c2ecf20Sopenharmony_ci#include <linux/fscache.h> 128c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ciextern struct fscache_netfs v9fs_cache_netfs; 158c2ecf20Sopenharmony_ciextern const struct fscache_cookie_def v9fs_cache_session_index_def; 168c2ecf20Sopenharmony_ciextern const struct fscache_cookie_def v9fs_cache_inode_index_def; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ciextern void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses); 198c2ecf20Sopenharmony_ciextern void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses); 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciextern void v9fs_cache_inode_get_cookie(struct inode *inode); 228c2ecf20Sopenharmony_ciextern void v9fs_cache_inode_put_cookie(struct inode *inode); 238c2ecf20Sopenharmony_ciextern void v9fs_cache_inode_flush_cookie(struct inode *inode); 248c2ecf20Sopenharmony_ciextern void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *filp); 258c2ecf20Sopenharmony_ciextern void v9fs_cache_inode_reset_cookie(struct inode *inode); 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ciextern int __v9fs_cache_register(void); 288c2ecf20Sopenharmony_ciextern void __v9fs_cache_unregister(void); 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ciextern int __v9fs_fscache_release_page(struct page *page, gfp_t gfp); 318c2ecf20Sopenharmony_ciextern void __v9fs_fscache_invalidate_page(struct page *page); 328c2ecf20Sopenharmony_ciextern int __v9fs_readpage_from_fscache(struct inode *inode, 338c2ecf20Sopenharmony_ci struct page *page); 348c2ecf20Sopenharmony_ciextern int __v9fs_readpages_from_fscache(struct inode *inode, 358c2ecf20Sopenharmony_ci struct address_space *mapping, 368c2ecf20Sopenharmony_ci struct list_head *pages, 378c2ecf20Sopenharmony_ci unsigned *nr_pages); 388c2ecf20Sopenharmony_ciextern void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page); 398c2ecf20Sopenharmony_ciextern void __v9fs_fscache_wait_on_page_write(struct inode *inode, 408c2ecf20Sopenharmony_ci struct page *page); 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistatic inline int v9fs_fscache_release_page(struct page *page, 438c2ecf20Sopenharmony_ci gfp_t gfp) 448c2ecf20Sopenharmony_ci{ 458c2ecf20Sopenharmony_ci return __v9fs_fscache_release_page(page, gfp); 468c2ecf20Sopenharmony_ci} 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic inline void v9fs_fscache_invalidate_page(struct page *page) 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci __v9fs_fscache_invalidate_page(page); 518c2ecf20Sopenharmony_ci} 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic inline int v9fs_readpage_from_fscache(struct inode *inode, 548c2ecf20Sopenharmony_ci struct page *page) 558c2ecf20Sopenharmony_ci{ 568c2ecf20Sopenharmony_ci return __v9fs_readpage_from_fscache(inode, page); 578c2ecf20Sopenharmony_ci} 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistatic inline int v9fs_readpages_from_fscache(struct inode *inode, 608c2ecf20Sopenharmony_ci struct address_space *mapping, 618c2ecf20Sopenharmony_ci struct list_head *pages, 628c2ecf20Sopenharmony_ci unsigned *nr_pages) 638c2ecf20Sopenharmony_ci{ 648c2ecf20Sopenharmony_ci return __v9fs_readpages_from_fscache(inode, mapping, pages, 658c2ecf20Sopenharmony_ci nr_pages); 668c2ecf20Sopenharmony_ci} 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistatic inline void v9fs_readpage_to_fscache(struct inode *inode, 698c2ecf20Sopenharmony_ci struct page *page) 708c2ecf20Sopenharmony_ci{ 718c2ecf20Sopenharmony_ci if (PageFsCache(page)) 728c2ecf20Sopenharmony_ci __v9fs_readpage_to_fscache(inode, page); 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cistatic inline void v9fs_uncache_page(struct inode *inode, struct page *page) 768c2ecf20Sopenharmony_ci{ 778c2ecf20Sopenharmony_ci struct v9fs_inode *v9inode = V9FS_I(inode); 788c2ecf20Sopenharmony_ci fscache_uncache_page(v9inode->fscache, page); 798c2ecf20Sopenharmony_ci BUG_ON(PageFsCache(page)); 808c2ecf20Sopenharmony_ci} 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cistatic inline void v9fs_fscache_wait_on_page_write(struct inode *inode, 838c2ecf20Sopenharmony_ci struct page *page) 848c2ecf20Sopenharmony_ci{ 858c2ecf20Sopenharmony_ci return __v9fs_fscache_wait_on_page_write(inode, page); 868c2ecf20Sopenharmony_ci} 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#else /* CONFIG_9P_FSCACHE */ 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_cistatic inline void v9fs_cache_inode_get_cookie(struct inode *inode) 918c2ecf20Sopenharmony_ci{ 928c2ecf20Sopenharmony_ci} 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistatic inline void v9fs_cache_inode_put_cookie(struct inode *inode) 958c2ecf20Sopenharmony_ci{ 968c2ecf20Sopenharmony_ci} 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistatic inline void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *file) 998c2ecf20Sopenharmony_ci{ 1008c2ecf20Sopenharmony_ci} 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistatic inline int v9fs_fscache_release_page(struct page *page, 1038c2ecf20Sopenharmony_ci gfp_t gfp) { 1048c2ecf20Sopenharmony_ci return 1; 1058c2ecf20Sopenharmony_ci} 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_cistatic inline void v9fs_fscache_invalidate_page(struct page *page) {} 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cistatic inline int v9fs_readpage_from_fscache(struct inode *inode, 1108c2ecf20Sopenharmony_ci struct page *page) 1118c2ecf20Sopenharmony_ci{ 1128c2ecf20Sopenharmony_ci return -ENOBUFS; 1138c2ecf20Sopenharmony_ci} 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistatic inline int v9fs_readpages_from_fscache(struct inode *inode, 1168c2ecf20Sopenharmony_ci struct address_space *mapping, 1178c2ecf20Sopenharmony_ci struct list_head *pages, 1188c2ecf20Sopenharmony_ci unsigned *nr_pages) 1198c2ecf20Sopenharmony_ci{ 1208c2ecf20Sopenharmony_ci return -ENOBUFS; 1218c2ecf20Sopenharmony_ci} 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cistatic inline void v9fs_readpage_to_fscache(struct inode *inode, 1248c2ecf20Sopenharmony_ci struct page *page) 1258c2ecf20Sopenharmony_ci{} 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_cistatic inline void v9fs_uncache_page(struct inode *inode, struct page *page) 1288c2ecf20Sopenharmony_ci{} 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_cistatic inline void v9fs_fscache_wait_on_page_write(struct inode *inode, 1318c2ecf20Sopenharmony_ci struct page *page) 1328c2ecf20Sopenharmony_ci{ 1338c2ecf20Sopenharmony_ci return; 1348c2ecf20Sopenharmony_ci} 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci#endif /* CONFIG_9P_FSCACHE */ 1378c2ecf20Sopenharmony_ci#endif /* _9P_CACHE_H */ 138