Blame view

fs/exofs/file.c 2.53 KB
e80627191   Boaz Harrosh   exofs: file and f...
1
2
  /*
   * Copyright (C) 2005, 2006
27d2e1491   Boaz Harrosh   exofs: Remove IBM...
3
   * Avishay Traeger (avishay@gmail.com)
e80627191   Boaz Harrosh   exofs: file and f...
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
   * Copyright (C) 2008, 2009
   * Boaz Harrosh <bharrosh@panasas.com>
   *
   * Copyrights for code taken from ext2:
   *     Copyright (C) 1992, 1993, 1994, 1995
   *     Remy Card (card@masi.ibp.fr)
   *     Laboratoire MASI - Institut Blaise Pascal
   *     Universite Pierre et Marie Curie (Paris VI)
   *     from
   *     linux/fs/minix/inode.c
   *     Copyright (C) 1991, 1992  Linus Torvalds
   *
   * This file is part of exofs.
   *
   * exofs is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation.  Since it is based on ext2, and the only
   * valid version of GPL for the Linux kernel is version 2, the only valid
   * version of GPL for exofs is version 2.
   *
   * exofs is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with exofs; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   */
e80627191   Boaz Harrosh   exofs: file and f...
33
34
35
36
37
38
  #include "exofs.h"
  
  static int exofs_release_file(struct inode *inode, struct file *filp)
  {
  	return 0;
  }
b28483492   Boaz Harrosh   exofs: exofs_file...
39
40
41
42
43
  /* exofs_file_fsync - flush the inode to disk
   *
   *   Note, in exofs all metadata is written as part of inode, regardless.
   *   The writeout is synchronous
   */
02c24a821   Josef Bacik   fs: push i_mutex ...
44
45
  static int exofs_file_fsync(struct file *filp, loff_t start, loff_t end,
  			    int datasync)
e80627191   Boaz Harrosh   exofs: file and f...
46
  {
02c24a821   Josef Bacik   fs: push i_mutex ...
47
  	struct inode *inode = filp->f_mapping->host;
e80627191   Boaz Harrosh   exofs: file and f...
48
  	int ret;
baaf94cdc   Boaz Harrosh   exofs: Avoid usin...
49

02c24a821   Josef Bacik   fs: push i_mutex ...
50
51
52
53
54
  	ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
  	if (ret)
  		return ret;
  
  	mutex_lock(&inode->i_mutex);
1cea312ad   Boaz Harrosh   exofs: Write sbi-...
55
  	ret = sync_inode_metadata(filp->f_mapping->host, 1);
02c24a821   Josef Bacik   fs: push i_mutex ...
56
  	mutex_unlock(&inode->i_mutex);
baaf94cdc   Boaz Harrosh   exofs: Avoid usin...
57
  	return ret;
e80627191   Boaz Harrosh   exofs: file and f...
58
59
60
61
  }
  
  static int exofs_flush(struct file *file, fl_owner_t id)
  {
b28483492   Boaz Harrosh   exofs: exofs_file...
62
  	int ret = vfs_fsync(file, 0);
e80627191   Boaz Harrosh   exofs: file and f...
63
  	/* TODO: Flush the OSD target */
b28483492   Boaz Harrosh   exofs: exofs_file...
64
  	return ret;
e80627191   Boaz Harrosh   exofs: file and f...
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
  }
  
  const struct file_operations exofs_file_operations = {
  	.llseek		= generic_file_llseek,
  	.read		= do_sync_read,
  	.write		= do_sync_write,
  	.aio_read	= generic_file_aio_read,
  	.aio_write	= generic_file_aio_write,
  	.mmap		= generic_file_mmap,
  	.open		= generic_file_open,
  	.release	= exofs_release_file,
  	.fsync		= exofs_file_fsync,
  	.flush		= exofs_flush,
  	.splice_read	= generic_file_splice_read,
  	.splice_write	= generic_file_splice_write,
  };
  
  const struct inode_operations exofs_file_inode_operations = {
e80627191   Boaz Harrosh   exofs: file and f...
83
84
  	.setattr	= exofs_setattr,
  };