file.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (C) 2005, 2006
  3. * Avishay Traeger (avishay@gmail.com)
  4. * Copyright (C) 2008, 2009
  5. * Boaz Harrosh <bharrosh@panasas.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 <linux/buffer_head.h>
  34. #include "exofs.h"
  35. static int exofs_release_file(struct inode *inode, struct file *filp)
  36. {
  37. return 0;
  38. }
  39. static int exofs_file_fsync(struct file *filp, struct dentry *dentry,
  40. int datasync)
  41. {
  42. int ret;
  43. struct address_space *mapping = filp->f_mapping;
  44. struct inode *inode = dentry->d_inode;
  45. struct super_block *sb;
  46. ret = filemap_write_and_wait(mapping);
  47. if (ret)
  48. return ret;
  49. /* sync the inode attributes */
  50. ret = write_inode_now(inode, 1);
  51. /* This is a good place to write the sb */
  52. /* TODO: Sechedule an sb-sync on create */
  53. sb = inode->i_sb;
  54. if (sb->s_dirt)
  55. exofs_sync_fs(sb, 1);
  56. return ret;
  57. }
  58. static int exofs_flush(struct file *file, fl_owner_t id)
  59. {
  60. exofs_file_fsync(file, file->f_path.dentry, 1);
  61. /* TODO: Flush the OSD target */
  62. return 0;
  63. }
  64. const struct file_operations exofs_file_operations = {
  65. .llseek = generic_file_llseek,
  66. .read = do_sync_read,
  67. .write = do_sync_write,
  68. .aio_read = generic_file_aio_read,
  69. .aio_write = generic_file_aio_write,
  70. .mmap = generic_file_mmap,
  71. .open = generic_file_open,
  72. .release = exofs_release_file,
  73. .fsync = exofs_file_fsync,
  74. .flush = exofs_flush,
  75. .splice_read = generic_file_splice_read,
  76. .splice_write = generic_file_splice_write,
  77. };
  78. const struct inode_operations exofs_file_inode_operations = {
  79. .truncate = exofs_truncate,
  80. .setattr = exofs_setattr,
  81. };