18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * fs/cifs/fscache.h - CIFS filesystem cache interface definitions 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) 2010 Novell, Inc. 58c2ecf20Sopenharmony_ci * Authors(s): Suresh Jayaraman (sjayaraman@suse.de> 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * This library is free software; you can redistribute it and/or modify 88c2ecf20Sopenharmony_ci * it under the terms of the GNU Lesser General Public License as published 98c2ecf20Sopenharmony_ci * by the Free Software Foundation; either version 2.1 of the License, or 108c2ecf20Sopenharmony_ci * (at your option) any later version. 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * This library is distributed in the hope that it will be useful, 138c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 148c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 158c2ecf20Sopenharmony_ci * the GNU Lesser General Public License for more details. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * You should have received a copy of the GNU Lesser General Public License 188c2ecf20Sopenharmony_ci * along with this library; if not, write to the Free Software 198c2ecf20Sopenharmony_ci * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 208c2ecf20Sopenharmony_ci */ 218c2ecf20Sopenharmony_ci#ifndef _CIFS_FSCACHE_H 228c2ecf20Sopenharmony_ci#define _CIFS_FSCACHE_H 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#include <linux/fscache.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#include "cifsglob.h" 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#ifdef CONFIG_CIFS_FSCACHE 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* 318c2ecf20Sopenharmony_ci * Auxiliary data attached to CIFS superblock within the cache 328c2ecf20Sopenharmony_ci */ 338c2ecf20Sopenharmony_cistruct cifs_fscache_super_auxdata { 348c2ecf20Sopenharmony_ci u64 resource_id; /* unique server resource id */ 358c2ecf20Sopenharmony_ci __le64 vol_create_time; 368c2ecf20Sopenharmony_ci u32 vol_serial_number; 378c2ecf20Sopenharmony_ci} __packed; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* 408c2ecf20Sopenharmony_ci * Auxiliary data attached to CIFS inode within the cache 418c2ecf20Sopenharmony_ci */ 428c2ecf20Sopenharmony_cistruct cifs_fscache_inode_auxdata { 438c2ecf20Sopenharmony_ci u64 last_write_time_sec; 448c2ecf20Sopenharmony_ci u64 last_change_time_sec; 458c2ecf20Sopenharmony_ci u32 last_write_time_nsec; 468c2ecf20Sopenharmony_ci u32 last_change_time_nsec; 478c2ecf20Sopenharmony_ci u64 eof; 488c2ecf20Sopenharmony_ci}; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* 518c2ecf20Sopenharmony_ci * cache.c 528c2ecf20Sopenharmony_ci */ 538c2ecf20Sopenharmony_ciextern struct fscache_netfs cifs_fscache_netfs; 548c2ecf20Sopenharmony_ciextern const struct fscache_cookie_def cifs_fscache_server_index_def; 558c2ecf20Sopenharmony_ciextern const struct fscache_cookie_def cifs_fscache_super_index_def; 568c2ecf20Sopenharmony_ciextern const struct fscache_cookie_def cifs_fscache_inode_object_def; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ciextern int cifs_fscache_register(void); 598c2ecf20Sopenharmony_ciextern void cifs_fscache_unregister(void); 608c2ecf20Sopenharmony_ciextern char *extract_sharename(const char *); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* 638c2ecf20Sopenharmony_ci * fscache.c 648c2ecf20Sopenharmony_ci */ 658c2ecf20Sopenharmony_ciextern void cifs_fscache_get_client_cookie(struct TCP_Server_Info *); 668c2ecf20Sopenharmony_ciextern void cifs_fscache_release_client_cookie(struct TCP_Server_Info *); 678c2ecf20Sopenharmony_ciextern void cifs_fscache_get_super_cookie(struct cifs_tcon *); 688c2ecf20Sopenharmony_ciextern void cifs_fscache_release_super_cookie(struct cifs_tcon *); 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ciextern void cifs_fscache_release_inode_cookie(struct inode *); 718c2ecf20Sopenharmony_ciextern void cifs_fscache_set_inode_cookie(struct inode *, struct file *); 728c2ecf20Sopenharmony_ciextern void cifs_fscache_reset_inode_cookie(struct inode *); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ciextern void __cifs_fscache_invalidate_page(struct page *, struct inode *); 758c2ecf20Sopenharmony_ciextern int cifs_fscache_release_page(struct page *page, gfp_t gfp); 768c2ecf20Sopenharmony_ciextern int __cifs_readpage_from_fscache(struct inode *, struct page *); 778c2ecf20Sopenharmony_ciextern int __cifs_readpages_from_fscache(struct inode *, 788c2ecf20Sopenharmony_ci struct address_space *, 798c2ecf20Sopenharmony_ci struct list_head *, 808c2ecf20Sopenharmony_ci unsigned *); 818c2ecf20Sopenharmony_ciextern void __cifs_fscache_readpages_cancel(struct inode *, struct list_head *); 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciextern void __cifs_readpage_to_fscache(struct inode *, struct page *); 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cistatic inline void cifs_fscache_invalidate_page(struct page *page, 868c2ecf20Sopenharmony_ci struct inode *inode) 878c2ecf20Sopenharmony_ci{ 888c2ecf20Sopenharmony_ci if (PageFsCache(page)) 898c2ecf20Sopenharmony_ci __cifs_fscache_invalidate_page(page, inode); 908c2ecf20Sopenharmony_ci} 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistatic inline int cifs_readpage_from_fscache(struct inode *inode, 938c2ecf20Sopenharmony_ci struct page *page) 948c2ecf20Sopenharmony_ci{ 958c2ecf20Sopenharmony_ci if (CIFS_I(inode)->fscache) 968c2ecf20Sopenharmony_ci return __cifs_readpage_from_fscache(inode, page); 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci return -ENOBUFS; 998c2ecf20Sopenharmony_ci} 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_cistatic inline int cifs_readpages_from_fscache(struct inode *inode, 1028c2ecf20Sopenharmony_ci struct address_space *mapping, 1038c2ecf20Sopenharmony_ci struct list_head *pages, 1048c2ecf20Sopenharmony_ci unsigned *nr_pages) 1058c2ecf20Sopenharmony_ci{ 1068c2ecf20Sopenharmony_ci if (CIFS_I(inode)->fscache) 1078c2ecf20Sopenharmony_ci return __cifs_readpages_from_fscache(inode, mapping, pages, 1088c2ecf20Sopenharmony_ci nr_pages); 1098c2ecf20Sopenharmony_ci return -ENOBUFS; 1108c2ecf20Sopenharmony_ci} 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_cistatic inline void cifs_readpage_to_fscache(struct inode *inode, 1138c2ecf20Sopenharmony_ci struct page *page) 1148c2ecf20Sopenharmony_ci{ 1158c2ecf20Sopenharmony_ci if (PageFsCache(page)) 1168c2ecf20Sopenharmony_ci __cifs_readpage_to_fscache(inode, page); 1178c2ecf20Sopenharmony_ci} 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_cistatic inline void cifs_fscache_readpages_cancel(struct inode *inode, 1208c2ecf20Sopenharmony_ci struct list_head *pages) 1218c2ecf20Sopenharmony_ci{ 1228c2ecf20Sopenharmony_ci if (CIFS_I(inode)->fscache) 1238c2ecf20Sopenharmony_ci return __cifs_fscache_readpages_cancel(inode, pages); 1248c2ecf20Sopenharmony_ci} 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci#else /* CONFIG_CIFS_FSCACHE */ 1278c2ecf20Sopenharmony_cistatic inline int cifs_fscache_register(void) { return 0; } 1288c2ecf20Sopenharmony_cistatic inline void cifs_fscache_unregister(void) {} 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_cistatic inline void 1318c2ecf20Sopenharmony_cicifs_fscache_get_client_cookie(struct TCP_Server_Info *server) {} 1328c2ecf20Sopenharmony_cistatic inline void 1338c2ecf20Sopenharmony_cicifs_fscache_release_client_cookie(struct TCP_Server_Info *server) {} 1348c2ecf20Sopenharmony_cistatic inline void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon) {} 1358c2ecf20Sopenharmony_cistatic inline void 1368c2ecf20Sopenharmony_cicifs_fscache_release_super_cookie(struct cifs_tcon *tcon) {} 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_cistatic inline void cifs_fscache_release_inode_cookie(struct inode *inode) {} 1398c2ecf20Sopenharmony_cistatic inline void cifs_fscache_set_inode_cookie(struct inode *inode, 1408c2ecf20Sopenharmony_ci struct file *filp) {} 1418c2ecf20Sopenharmony_cistatic inline void cifs_fscache_reset_inode_cookie(struct inode *inode) {} 1428c2ecf20Sopenharmony_cistatic inline int cifs_fscache_release_page(struct page *page, gfp_t gfp) 1438c2ecf20Sopenharmony_ci{ 1448c2ecf20Sopenharmony_ci return 1; /* May release page */ 1458c2ecf20Sopenharmony_ci} 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cistatic inline void cifs_fscache_invalidate_page(struct page *page, 1488c2ecf20Sopenharmony_ci struct inode *inode) {} 1498c2ecf20Sopenharmony_cistatic inline int 1508c2ecf20Sopenharmony_cicifs_readpage_from_fscache(struct inode *inode, struct page *page) 1518c2ecf20Sopenharmony_ci{ 1528c2ecf20Sopenharmony_ci return -ENOBUFS; 1538c2ecf20Sopenharmony_ci} 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_cistatic inline int cifs_readpages_from_fscache(struct inode *inode, 1568c2ecf20Sopenharmony_ci struct address_space *mapping, 1578c2ecf20Sopenharmony_ci struct list_head *pages, 1588c2ecf20Sopenharmony_ci unsigned *nr_pages) 1598c2ecf20Sopenharmony_ci{ 1608c2ecf20Sopenharmony_ci return -ENOBUFS; 1618c2ecf20Sopenharmony_ci} 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_cistatic inline void cifs_readpage_to_fscache(struct inode *inode, 1648c2ecf20Sopenharmony_ci struct page *page) {} 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_cistatic inline void cifs_fscache_readpages_cancel(struct inode *inode, 1678c2ecf20Sopenharmony_ci struct list_head *pages) 1688c2ecf20Sopenharmony_ci{ 1698c2ecf20Sopenharmony_ci} 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci#endif /* CONFIG_CIFS_FSCACHE */ 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci#endif /* _CIFS_FSCACHE_H */ 174