file.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2005, 2006
  3. * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com)
  4. * Copyright (C) 2005, 2006
  5. * International Business Machines
  6. * Copyright (C) 2008, 2009
  7. * Boaz Harrosh <bharrosh@panasas.com>
  8. *
  9. * Copyrights for code taken from ext2:
  10. * Copyright (C) 1992, 1993, 1994, 1995
  11. * Remy Card (card@masi.ibp.fr)
  12. * Laboratoire MASI - Institut Blaise Pascal
  13. * Universite Pierre et Marie Curie (Paris VI)
  14. * from
  15. * linux/fs/minix/inode.c
  16. * Copyright (C) 1991, 1992 Linus Torvalds
  17. *
  18. * This file is part of exofs.
  19. *
  20. * exofs is free software; you can redistribute it and/or modify
  21. * it under the terms of the GNU General Public License as published by
  22. * the Free Software Foundation. Since it is based on ext2, and the only
  23. * valid version of GPL for the Linux kernel is version 2, the only valid
  24. * version of GPL for exofs is version 2.
  25. *
  26. * exofs is distributed in the hope that it will be useful,
  27. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. * GNU General Public License for more details.
  30. *
  31. * You should have received a copy of the GNU General Public License
  32. * along with exofs; if not, write to the Free Software
  33. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  34. */
  35. #include <linux/buffer_head.h>
  36. #include "exofs.h"
  37. static int exofs_release_file(struct inode *inode, struct file *filp)
  38. {
  39. return 0;
  40. }
  41. static int exofs_file_fsync(struct file *filp, struct dentry *dentry,
  42. int datasync)
  43. {
  44. int ret;
  45. struct address_space *mapping = filp->f_mapping;
  46. ret = filemap_write_and_wait(mapping);
  47. if (ret)
  48. return ret;
  49. /*Note: file_fsync below also calles sync_blockdev, which is a no-op
  50. * for exofs, but other then that it does sync_inode and
  51. * sync_superblock which is what we need here.
  52. */
  53. return file_fsync(filp, dentry, datasync);
  54. }
  55. static int exofs_flush(struct file *file, fl_owner_t id)
  56. {
  57. exofs_file_fsync(file, file->f_path.dentry, 1);
  58. /* TODO: Flush the OSD target */
  59. return 0;
  60. }
  61. const struct file_operations exofs_file_operations = {
  62. .llseek = generic_file_llseek,
  63. .read = do_sync_read,
  64. .write = do_sync_write,
  65. .aio_read = generic_file_aio_read,
  66. .aio_write = generic_file_aio_write,
  67. .mmap = generic_file_mmap,
  68. .open = generic_file_open,
  69. .release = exofs_release_file,
  70. .fsync = exofs_file_fsync,
  71. .flush = exofs_flush,
  72. .splice_read = generic_file_splice_read,
  73. .splice_write = generic_file_splice_write,
  74. };
  75. const struct inode_operations exofs_file_inode_operations = {
  76. .truncate = exofs_truncate,
  77. .setattr = exofs_setattr,
  78. };