blob: b905c79b4f0afc88b7a1997009960f09f50f595f [file] [log] [blame]
Boaz Harroshe8062712008-10-27 18:37:02 +02001/*
2 * Copyright (C) 2005, 2006
Boaz Harrosh27d2e142009-06-14 17:23:09 +03003 * Avishay Traeger (avishay@gmail.com)
Boaz Harroshe8062712008-10-27 18:37:02 +02004 * 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 */
Boaz Harroshe8062712008-10-27 18:37:02 +020033#include "exofs.h"
34
35static int exofs_release_file(struct inode *inode, struct file *filp)
36{
37 return 0;
38}
39
Boaz Harroshb2848342010-05-31 18:02:39 +030040/* 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 */
Christoph Hellwig7ea80852010-05-26 17:53:25 +020045static int exofs_file_fsync(struct file *filp, int datasync)
Boaz Harroshe8062712008-10-27 18:37:02 +020046{
47 int ret;
Boaz Harroshb2848342010-05-31 18:02:39 +030048 struct inode *inode = filp->f_mapping->host;
Boaz Harroshbaaf94c2009-06-14 16:52:10 +030049 struct super_block *sb;
Boaz Harroshe8062712008-10-27 18:37:02 +020050
Boaz Harroshb2848342010-05-31 18:02:39 +030051 if (!(inode->i_state & I_DIRTY))
52 return 0;
53 if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
54 return 0;
Boaz Harroshe8062712008-10-27 18:37:02 +020055
Christoph Hellwigc37650162010-10-06 10:48:20 +020056 ret = sync_inode_metadata(inode, 1);
Boaz Harroshbaaf94c2009-06-14 16:52:10 +030057
58 /* This is a good place to write the sb */
59 /* TODO: Sechedule an sb-sync on create */
60 sb = inode->i_sb;
61 if (sb->s_dirt)
62 exofs_sync_fs(sb, 1);
63
64 return ret;
Boaz Harroshe8062712008-10-27 18:37:02 +020065}
66
67static int exofs_flush(struct file *file, fl_owner_t id)
68{
Boaz Harroshb2848342010-05-31 18:02:39 +030069 int ret = vfs_fsync(file, 0);
Boaz Harroshe8062712008-10-27 18:37:02 +020070 /* TODO: Flush the OSD target */
Boaz Harroshb2848342010-05-31 18:02:39 +030071 return ret;
Boaz Harroshe8062712008-10-27 18:37:02 +020072}
73
74const struct file_operations exofs_file_operations = {
75 .llseek = generic_file_llseek,
76 .read = do_sync_read,
77 .write = do_sync_write,
78 .aio_read = generic_file_aio_read,
79 .aio_write = generic_file_aio_write,
80 .mmap = generic_file_mmap,
81 .open = generic_file_open,
82 .release = exofs_release_file,
83 .fsync = exofs_file_fsync,
84 .flush = exofs_flush,
85 .splice_read = generic_file_splice_read,
86 .splice_write = generic_file_splice_write,
87};
88
89const struct inode_operations exofs_file_inode_operations = {
Boaz Harroshe8062712008-10-27 18:37:02 +020090 .setattr = exofs_setattr,
91};