xfs_fs_subr.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. int
  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. int ret = 0;
  44. if (VN_CACHED(vp)) {
  45. if (VN_TRUNC(vp))
  46. VUNTRUNCATE(vp);
  47. ret = filemap_write_and_wait(ip->i_mapping);
  48. if (!ret)
  49. truncate_inode_pages(ip->i_mapping, first);
  50. }
  51. return ret;
  52. }
  53. int
  54. fs_flush_pages(
  55. bhv_desc_t *bdp,
  56. xfs_off_t first,
  57. xfs_off_t last,
  58. uint64_t flags,
  59. int fiopt)
  60. {
  61. bhv_vnode_t *vp = BHV_TO_VNODE(bdp);
  62. struct inode *ip = vn_to_inode(vp);
  63. int ret = 0;
  64. int ret2;
  65. if (VN_DIRTY(vp)) {
  66. if (VN_TRUNC(vp))
  67. VUNTRUNCATE(vp);
  68. ret = filemap_fdatawrite(ip->i_mapping);
  69. if (flags & XFS_B_ASYNC)
  70. return ret;
  71. ret2 = filemap_fdatawait(ip->i_mapping);
  72. if (!ret)
  73. ret = ret2;
  74. }
  75. return ret;
  76. }