xfs_fs_subr.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #include "xfs_vnodeops.h"
  20. /*
  21. * The following six includes are needed so that we can include
  22. * xfs_inode.h. What a mess..
  23. */
  24. #include "xfs_bmap_btree.h"
  25. #include "xfs_inum.h"
  26. #include "xfs_dir2.h"
  27. #include "xfs_dir2_sf.h"
  28. #include "xfs_attr_sf.h"
  29. #include "xfs_dinode.h"
  30. #include "xfs_inode.h"
  31. int fs_noerr(void) { return 0; }
  32. int fs_nosys(void) { return ENOSYS; }
  33. void fs_noval(void) { return; }
  34. void
  35. xfs_tosspages(
  36. xfs_inode_t *ip,
  37. xfs_off_t first,
  38. xfs_off_t last,
  39. int fiopt)
  40. {
  41. bhv_vnode_t *vp = XFS_ITOV(ip);
  42. struct inode *inode = vn_to_inode(vp);
  43. if (VN_CACHED(vp))
  44. truncate_inode_pages(inode->i_mapping, first);
  45. }
  46. int
  47. xfs_flushinval_pages(
  48. xfs_inode_t *ip,
  49. xfs_off_t first,
  50. xfs_off_t last,
  51. int fiopt)
  52. {
  53. bhv_vnode_t *vp = XFS_ITOV(ip);
  54. struct inode *inode = vn_to_inode(vp);
  55. int ret = 0;
  56. if (VN_CACHED(vp)) {
  57. if (VN_TRUNC(vp))
  58. VUNTRUNCATE(vp);
  59. ret = filemap_write_and_wait(inode->i_mapping);
  60. if (!ret)
  61. truncate_inode_pages(inode->i_mapping, first);
  62. }
  63. return ret;
  64. }
  65. int
  66. xfs_flush_pages(
  67. xfs_inode_t *ip,
  68. xfs_off_t first,
  69. xfs_off_t last,
  70. uint64_t flags,
  71. int fiopt)
  72. {
  73. bhv_vnode_t *vp = XFS_ITOV(ip);
  74. struct inode *inode = vn_to_inode(vp);
  75. int ret = 0;
  76. int ret2;
  77. if (VN_DIRTY(vp)) {
  78. if (VN_TRUNC(vp))
  79. VUNTRUNCATE(vp);
  80. ret = filemap_fdatawrite(inode->i_mapping);
  81. if (flags & XFS_B_ASYNC)
  82. return ret;
  83. ret2 = filemap_fdatawait(inode->i_mapping);
  84. if (!ret)
  85. ret = ret2;
  86. }
  87. return ret;
  88. }