xfs_fs_subr.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include "xfs_bmap_btree.h"
  21. #include "xfs_inode.h"
  22. int fs_noerr(void) { return 0; }
  23. int fs_nosys(void) { return ENOSYS; }
  24. void fs_noval(void) { return; }
  25. void
  26. xfs_tosspages(
  27. xfs_inode_t *ip,
  28. xfs_off_t first,
  29. xfs_off_t last,
  30. int fiopt)
  31. {
  32. struct address_space *mapping = VFS_I(ip)->i_mapping;
  33. if (mapping->nrpages)
  34. truncate_inode_pages(mapping, first);
  35. }
  36. int
  37. xfs_flushinval_pages(
  38. xfs_inode_t *ip,
  39. xfs_off_t first,
  40. xfs_off_t last,
  41. int fiopt)
  42. {
  43. struct address_space *mapping = VFS_I(ip)->i_mapping;
  44. int ret = 0;
  45. if (mapping->nrpages) {
  46. xfs_iflags_clear(ip, XFS_ITRUNCATED);
  47. ret = filemap_write_and_wait(mapping);
  48. if (!ret)
  49. truncate_inode_pages(mapping, first);
  50. }
  51. return ret;
  52. }
  53. int
  54. xfs_flush_pages(
  55. xfs_inode_t *ip,
  56. xfs_off_t first,
  57. xfs_off_t last,
  58. uint64_t flags,
  59. int fiopt)
  60. {
  61. struct address_space *mapping = VFS_I(ip)->i_mapping;
  62. int ret = 0;
  63. int ret2;
  64. if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
  65. xfs_iflags_clear(ip, XFS_ITRUNCATED);
  66. ret = filemap_fdatawrite(mapping);
  67. if (flags & XFS_B_ASYNC)
  68. return ret;
  69. ret2 = filemap_fdatawait(mapping);
  70. if (!ret)
  71. ret = ret2;
  72. }
  73. return ret;
  74. }