xfs_fs_subr.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. xfs_iflags_clear(ip, XFS_ITRUNCATED);
  58. ret = filemap_write_and_wait(inode->i_mapping);
  59. if (!ret)
  60. truncate_inode_pages(inode->i_mapping, first);
  61. }
  62. return ret;
  63. }
  64. int
  65. xfs_flush_pages(
  66. xfs_inode_t *ip,
  67. xfs_off_t first,
  68. xfs_off_t last,
  69. uint64_t flags,
  70. int fiopt)
  71. {
  72. bhv_vnode_t *vp = XFS_ITOV(ip);
  73. struct inode *inode = vn_to_inode(vp);
  74. int ret = 0;
  75. int ret2;
  76. if (VN_DIRTY(vp)) {
  77. xfs_iflags_clear(ip, XFS_ITRUNCATED);
  78. ret = filemap_fdatawrite(inode->i_mapping);
  79. if (flags & XFS_B_ASYNC)
  80. return ret;
  81. ret2 = filemap_fdatawait(inode->i_mapping);
  82. if (!ret)
  83. ret = ret2;
  84. }
  85. return ret;
  86. }