cache.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Ceph cache definitions.
  3. *
  4. * Copyright (C) 2013 by Adfin Solutions, Inc. All Rights Reserved.
  5. * Written by Milosz Tanski (milosz@adfin.com)
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2
  9. * as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to:
  18. * Free Software Foundation
  19. * 51 Franklin Street, Fifth Floor
  20. * Boston, MA 02111-1301 USA
  21. *
  22. */
  23. #ifndef _CEPH_CACHE_H
  24. #define _CEPH_CACHE_H
  25. #ifdef CONFIG_CEPH_FSCACHE
  26. int ceph_fscache_register(void);
  27. void ceph_fscache_unregister(void);
  28. int ceph_fscache_register_fs(struct ceph_fs_client* fsc);
  29. void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc);
  30. void ceph_fscache_inode_init(struct ceph_inode_info *ci);
  31. void ceph_fscache_register_inode_cookie(struct ceph_fs_client* fsc,
  32. struct ceph_inode_info* ci);
  33. void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci);
  34. int ceph_readpage_from_fscache(struct inode *inode, struct page *page);
  35. int ceph_readpages_from_fscache(struct inode *inode,
  36. struct address_space *mapping,
  37. struct list_head *pages,
  38. unsigned *nr_pages);
  39. void ceph_readpage_to_fscache(struct inode *inode, struct page *page);
  40. void ceph_invalidate_fscache_page(struct inode* inode, struct page *page);
  41. void ceph_queue_revalidate(struct inode *inode);
  42. static inline void ceph_fscache_invalidate(struct inode *inode)
  43. {
  44. fscache_invalidate(ceph_inode(inode)->fscache);
  45. }
  46. static inline int ceph_release_fscache_page(struct page *page, gfp_t gfp)
  47. {
  48. struct inode* inode = page->mapping->host;
  49. struct ceph_inode_info *ci = ceph_inode(inode);
  50. return fscache_maybe_release_page(ci->fscache, page, gfp);
  51. }
  52. static inline void ceph_fscache_readpages_cancel(struct inode *inode,
  53. struct list_head *pages)
  54. {
  55. struct ceph_inode_info *ci = ceph_inode(inode);
  56. return fscache_readpages_cancel(ci->fscache, pages);
  57. }
  58. #else
  59. static inline int ceph_fscache_register(void)
  60. {
  61. return 0;
  62. }
  63. static inline void ceph_fscache_unregister(void)
  64. {
  65. }
  66. static inline int ceph_fscache_register_fs(struct ceph_fs_client* fsc)
  67. {
  68. return 0;
  69. }
  70. static inline void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc)
  71. {
  72. }
  73. static inline void ceph_fscache_inode_init(struct ceph_inode_info *ci)
  74. {
  75. }
  76. static inline void ceph_fscache_register_inode_cookie(struct ceph_fs_client* parent_fsc,
  77. struct ceph_inode_info* ci)
  78. {
  79. }
  80. static inline void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci)
  81. {
  82. }
  83. static inline int ceph_readpage_from_fscache(struct inode* inode,
  84. struct page *page)
  85. {
  86. return -ENOBUFS;
  87. }
  88. static inline int ceph_readpages_from_fscache(struct inode *inode,
  89. struct address_space *mapping,
  90. struct list_head *pages,
  91. unsigned *nr_pages)
  92. {
  93. return -ENOBUFS;
  94. }
  95. static inline void ceph_readpage_to_fscache(struct inode *inode,
  96. struct page *page)
  97. {
  98. }
  99. static inline void ceph_fscache_invalidate(struct inode *inode)
  100. {
  101. }
  102. static inline void ceph_invalidate_fscache_page(struct inode *inode,
  103. struct page *page)
  104. {
  105. }
  106. static inline int ceph_release_fscache_page(struct page *page, gfp_t gfp)
  107. {
  108. return 1;
  109. }
  110. static inline void ceph_fscache_readpages_cancel(struct inode *inode,
  111. struct list_head *pages)
  112. {
  113. }
  114. static inline void ceph_queue_revalidate(struct inode *inode)
  115. {
  116. }
  117. #endif
  118. #endif