cache.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * V9FS cache definitions.
  3. *
  4. * Copyright (C) 2009 by Abhishek Kulkarni <adkulkar@umail.iu.edu>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2
  8. * as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to:
  17. * Free Software Foundation
  18. * 51 Franklin Street, Fifth Floor
  19. * Boston, MA 02111-1301 USA
  20. *
  21. */
  22. #ifndef _9P_CACHE_H
  23. #ifdef CONFIG_9P_FSCACHE
  24. #include <linux/fscache.h>
  25. #include <linux/spinlock.h>
  26. extern struct fscache_netfs v9fs_cache_netfs;
  27. extern const struct fscache_cookie_def v9fs_cache_session_index_def;
  28. extern const struct fscache_cookie_def v9fs_cache_inode_index_def;
  29. extern void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses);
  30. extern void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses);
  31. extern void v9fs_cache_inode_get_cookie(struct inode *inode);
  32. extern void v9fs_cache_inode_put_cookie(struct inode *inode);
  33. extern void v9fs_cache_inode_flush_cookie(struct inode *inode);
  34. extern void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *filp);
  35. extern void v9fs_cache_inode_reset_cookie(struct inode *inode);
  36. extern int __v9fs_cache_register(void);
  37. extern void __v9fs_cache_unregister(void);
  38. extern int __v9fs_fscache_release_page(struct page *page, gfp_t gfp);
  39. extern void __v9fs_fscache_invalidate_page(struct page *page);
  40. extern int __v9fs_readpage_from_fscache(struct inode *inode,
  41. struct page *page);
  42. extern int __v9fs_readpages_from_fscache(struct inode *inode,
  43. struct address_space *mapping,
  44. struct list_head *pages,
  45. unsigned *nr_pages);
  46. extern void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page);
  47. extern void __v9fs_fscache_wait_on_page_write(struct inode *inode,
  48. struct page *page);
  49. static inline int v9fs_fscache_release_page(struct page *page,
  50. gfp_t gfp)
  51. {
  52. return __v9fs_fscache_release_page(page, gfp);
  53. }
  54. static inline void v9fs_fscache_invalidate_page(struct page *page)
  55. {
  56. __v9fs_fscache_invalidate_page(page);
  57. }
  58. static inline int v9fs_readpage_from_fscache(struct inode *inode,
  59. struct page *page)
  60. {
  61. return __v9fs_readpage_from_fscache(inode, page);
  62. }
  63. static inline int v9fs_readpages_from_fscache(struct inode *inode,
  64. struct address_space *mapping,
  65. struct list_head *pages,
  66. unsigned *nr_pages)
  67. {
  68. return __v9fs_readpages_from_fscache(inode, mapping, pages,
  69. nr_pages);
  70. }
  71. static inline void v9fs_readpage_to_fscache(struct inode *inode,
  72. struct page *page)
  73. {
  74. if (PageFsCache(page))
  75. __v9fs_readpage_to_fscache(inode, page);
  76. }
  77. static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
  78. {
  79. struct v9fs_inode *v9inode = V9FS_I(inode);
  80. fscache_uncache_page(v9inode->fscache, page);
  81. BUG_ON(PageFsCache(page));
  82. }
  83. static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
  84. struct page *page)
  85. {
  86. return __v9fs_fscache_wait_on_page_write(inode, page);
  87. }
  88. #else /* CONFIG_9P_FSCACHE */
  89. static inline int v9fs_fscache_release_page(struct page *page,
  90. gfp_t gfp) {
  91. return 1;
  92. }
  93. static inline void v9fs_fscache_invalidate_page(struct page *page) {}
  94. static inline int v9fs_readpage_from_fscache(struct inode *inode,
  95. struct page *page)
  96. {
  97. return -ENOBUFS;
  98. }
  99. static inline int v9fs_readpages_from_fscache(struct inode *inode,
  100. struct address_space *mapping,
  101. struct list_head *pages,
  102. unsigned *nr_pages)
  103. {
  104. return -ENOBUFS;
  105. }
  106. static inline void v9fs_readpage_to_fscache(struct inode *inode,
  107. struct page *page)
  108. {}
  109. static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
  110. {}
  111. static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
  112. struct page *page)
  113. {
  114. return;
  115. }
  116. #endif /* CONFIG_9P_FSCACHE */
  117. #endif /* _9P_CACHE_H */