xfs_fs_subr.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) 2000-2002,2005-2006 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "xfs.h"
  19. int fs_noerr(void) { return 0; }
  20. int fs_nosys(void) { return ENOSYS; }
  21. void fs_noval(void) { return; }
  22. void
  23. fs_tosspages(
  24. bhv_desc_t *bdp,
  25. xfs_off_t first,
  26. xfs_off_t last,
  27. int fiopt)
  28. {
  29. bhv_vnode_t *vp = BHV_TO_VNODE(bdp);
  30. struct inode *ip = vn_to_inode(vp);
  31. if (VN_CACHED(vp))
  32. truncate_inode_pages(ip->i_mapping, first);
  33. }
  34. void
  35. fs_flushinval_pages(
  36. bhv_desc_t *bdp,
  37. xfs_off_t first,
  38. xfs_off_t last,
  39. int fiopt)
  40. {
  41. bhv_vnode_t *vp = BHV_TO_VNODE(bdp);
  42. struct inode *ip = vn_to_inode(vp);
  43. if (VN_CACHED(vp)) {
  44. if (VN_TRUNC(vp))
  45. VUNTRUNCATE(vp);
  46. filemap_write_and_wait(ip->i_mapping);
  47. truncate_inode_pages(ip->i_mapping, first);
  48. }
  49. }
  50. int
  51. fs_flush_pages(
  52. bhv_desc_t *bdp,
  53. xfs_off_t first,
  54. xfs_off_t last,
  55. uint64_t flags,
  56. int fiopt)
  57. {
  58. bhv_vnode_t *vp = BHV_TO_VNODE(bdp);
  59. struct inode *ip = vn_to_inode(vp);
  60. if (VN_DIRTY(vp)) {
  61. if (VN_TRUNC(vp))
  62. VUNTRUNCATE(vp);
  63. filemap_fdatawrite(ip->i_mapping);
  64. if (flags & XFS_B_ASYNC)
  65. return 0;
  66. filemap_fdatawait(ip->i_mapping);
  67. }
  68. return 0;
  69. }