file.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2005, 2006
  3. * Avishay Traeger (avishay@gmail.com)
  4. * Copyright (C) 2008, 2009
  5. * Boaz Harrosh <ooo@electrozaur.com>
  6. *
  7. * Copyrights for code taken from ext2:
  8. * Copyright (C) 1992, 1993, 1994, 1995
  9. * Remy Card (card@masi.ibp.fr)
  10. * Laboratoire MASI - Institut Blaise Pascal
  11. * Universite Pierre et Marie Curie (Paris VI)
  12. * from
  13. * linux/fs/minix/inode.c
  14. * Copyright (C) 1991, 1992 Linus Torvalds
  15. *
  16. * This file is part of exofs.
  17. *
  18. * exofs is free software; you can redistribute it and/or modify
  19. * it under the terms of the GNU General Public License as published by
  20. * the Free Software Foundation. Since it is based on ext2, and the only
  21. * valid version of GPL for the Linux kernel is version 2, the only valid
  22. * version of GPL for exofs is version 2.
  23. *
  24. * exofs is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with exofs; if not, write to the Free Software
  31. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  32. */
  33. #include "exofs.h"
  34. static int exofs_release_file(struct inode *inode, struct file *filp)
  35. {
  36. return 0;
  37. }
  38. /* exofs_file_fsync - flush the inode to disk
  39. *
  40. * Note, in exofs all metadata is written as part of inode, regardless.
  41. * The writeout is synchronous
  42. */
  43. static int exofs_file_fsync(struct file *filp, loff_t start, loff_t end,
  44. int datasync)
  45. {
  46. struct inode *inode = filp->f_mapping->host;
  47. int ret;
  48. ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
  49. if (ret)
  50. return ret;
  51. inode_lock(inode);
  52. ret = sync_inode_metadata(filp->f_mapping->host, 1);
  53. inode_unlock(inode);
  54. return ret;
  55. }
  56. static int exofs_flush(struct file *file, fl_owner_t id)
  57. {
  58. int ret = vfs_fsync(file, 0);
  59. /* TODO: Flush the OSD target */
  60. return ret;
  61. }
  62. const struct file_operations exofs_file_operations = {
  63. .llseek = generic_file_llseek,
  64. .read_iter = generic_file_read_iter,
  65. .write_iter = generic_file_write_iter,
  66. .mmap = generic_file_mmap,
  67. .open = generic_file_open,
  68. .release = exofs_release_file,
  69. .fsync = exofs_file_fsync,
  70. .flush = exofs_flush,
  71. .splice_read = generic_file_splice_read,
  72. .splice_write = iter_file_splice_write,
  73. };
  74. const struct inode_operations exofs_file_inode_operations = {
  75. .setattr = exofs_setattr,
  76. };