]> bbs.cooldavid.org Git - net-next-2.6.git/blame - fs/exofs/file.c
exofs: exofs_file_fsync and exofs_file_flush correctness
[net-next-2.6.git] / fs / exofs / file.c
CommitLineData
e8062719
BH
1/*
2 * Copyright (C) 2005, 2006
27d2e149 3 * Avishay Traeger (avishay@gmail.com)
e8062719
BH
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 */
e8062719
BH
33#include "exofs.h"
34
35static int exofs_release_file(struct inode *inode, struct file *filp)
36{
37 return 0;
38}
39
b2848349
BH
40/* exofs_file_fsync - flush the inode to disk
41 *
42 * Note, in exofs all metadata is written as part of inode, regardless.
43 * The writeout is synchronous
44 */
7ea80859 45static int exofs_file_fsync(struct file *filp, int datasync)
e8062719
BH
46{
47 int ret;
b2848349
BH
48 struct inode *inode = filp->f_mapping->host;
49 struct writeback_control wbc = {
50 .sync_mode = WB_SYNC_ALL,
51 .nr_to_write = 0, /* metadata-only; caller takes care of data */
52 };
baaf94cd 53 struct super_block *sb;
e8062719 54
b2848349
BH
55 if (!(inode->i_state & I_DIRTY))
56 return 0;
57 if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
58 return 0;
e8062719 59
b2848349 60 ret = sync_inode(inode, &wbc);
baaf94cd
BH
61
62 /* This is a good place to write the sb */
63 /* TODO: Sechedule an sb-sync on create */
64 sb = inode->i_sb;
65 if (sb->s_dirt)
66 exofs_sync_fs(sb, 1);
67
68 return ret;
e8062719
BH
69}
70
71static int exofs_flush(struct file *file, fl_owner_t id)
72{
b2848349 73 int ret = vfs_fsync(file, 0);
e8062719 74 /* TODO: Flush the OSD target */
b2848349 75 return ret;
e8062719
BH
76}
77
78const struct file_operations exofs_file_operations = {
79 .llseek = generic_file_llseek,
80 .read = do_sync_read,
81 .write = do_sync_write,
82 .aio_read = generic_file_aio_read,
83 .aio_write = generic_file_aio_write,
84 .mmap = generic_file_mmap,
85 .open = generic_file_open,
86 .release = exofs_release_file,
87 .fsync = exofs_file_fsync,
88 .flush = exofs_flush,
89 .splice_read = generic_file_splice_read,
90 .splice_write = generic_file_splice_write,
91};
92
93const struct inode_operations exofs_file_inode_operations = {
94 .truncate = exofs_truncate,
95 .setattr = exofs_setattr,
96};