^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * fs/cifs/fscache.h - CIFS filesystem cache interface definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2010 Novell, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Authors(s): Suresh Jayaraman (sjayaraman@suse.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * This library is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * it under the terms of the GNU Lesser General Public License as published
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * by the Free Software Foundation; either version 2.1 of the License, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * This library is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * the GNU Lesser General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * You should have received a copy of the GNU Lesser General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * along with this library; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #ifndef _CIFS_FSCACHE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define _CIFS_FSCACHE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/fscache.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include "cifsglob.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #ifdef CONFIG_CIFS_FSCACHE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * Auxiliary data attached to CIFS superblock within the cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct cifs_fscache_super_auxdata {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) u64 resource_id; /* unique server resource id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) __le64 vol_create_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) u32 vol_serial_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * Auxiliary data attached to CIFS inode within the cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct cifs_fscache_inode_auxdata {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) u64 last_write_time_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) u64 last_change_time_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) u32 last_write_time_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) u32 last_change_time_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) u64 eof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * cache.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) extern struct fscache_netfs cifs_fscache_netfs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) extern const struct fscache_cookie_def cifs_fscache_server_index_def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) extern const struct fscache_cookie_def cifs_fscache_super_index_def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) extern const struct fscache_cookie_def cifs_fscache_inode_object_def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) extern int cifs_fscache_register(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) extern void cifs_fscache_unregister(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) extern char *extract_sharename(const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * fscache.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) extern void cifs_fscache_get_client_cookie(struct TCP_Server_Info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) extern void cifs_fscache_release_client_cookie(struct TCP_Server_Info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) extern void cifs_fscache_get_super_cookie(struct cifs_tcon *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) extern void cifs_fscache_release_super_cookie(struct cifs_tcon *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) extern void cifs_fscache_release_inode_cookie(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) extern void cifs_fscache_set_inode_cookie(struct inode *, struct file *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) extern void cifs_fscache_reset_inode_cookie(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) extern void __cifs_fscache_invalidate_page(struct page *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) extern int cifs_fscache_release_page(struct page *page, gfp_t gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) extern int __cifs_readpage_from_fscache(struct inode *, struct page *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) extern int __cifs_readpages_from_fscache(struct inode *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct address_space *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct list_head *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) unsigned *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) extern void __cifs_fscache_readpages_cancel(struct inode *, struct list_head *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) extern void __cifs_readpage_to_fscache(struct inode *, struct page *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static inline void cifs_fscache_invalidate_page(struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (PageFsCache(page))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) __cifs_fscache_invalidate_page(page, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static inline int cifs_readpage_from_fscache(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (CIFS_I(inode)->fscache)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return __cifs_readpage_from_fscache(inode, page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static inline int cifs_readpages_from_fscache(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct address_space *mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct list_head *pages,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) unsigned *nr_pages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (CIFS_I(inode)->fscache)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) return __cifs_readpages_from_fscache(inode, mapping, pages,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) nr_pages);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static inline void cifs_readpage_to_fscache(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (PageFsCache(page))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) __cifs_readpage_to_fscache(inode, page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static inline void cifs_fscache_readpages_cancel(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct list_head *pages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (CIFS_I(inode)->fscache)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) return __cifs_fscache_readpages_cancel(inode, pages);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #else /* CONFIG_CIFS_FSCACHE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static inline int cifs_fscache_register(void) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static inline void cifs_fscache_unregister(void) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) cifs_fscache_get_client_cookie(struct TCP_Server_Info *server) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) cifs_fscache_release_client_cookie(struct TCP_Server_Info *server) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static inline void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) cifs_fscache_release_super_cookie(struct cifs_tcon *tcon) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static inline void cifs_fscache_release_inode_cookie(struct inode *inode) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static inline void cifs_fscache_set_inode_cookie(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct file *filp) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static inline void cifs_fscache_reset_inode_cookie(struct inode *inode) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static inline int cifs_fscache_release_page(struct page *page, gfp_t gfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return 1; /* May release page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) static inline void cifs_fscache_invalidate_page(struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct inode *inode) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) cifs_readpage_from_fscache(struct inode *inode, struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) return -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) static inline int cifs_readpages_from_fscache(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct address_space *mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct list_head *pages,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) unsigned *nr_pages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) return -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static inline void cifs_readpage_to_fscache(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) struct page *page) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static inline void cifs_fscache_readpages_cancel(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct list_head *pages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #endif /* CONFIG_CIFS_FSCACHE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #endif /* _CIFS_FSCACHE_H */