OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [fs/] [jfs/] [file.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *   Copyright (c) International Business Machines Corp., 2000-2002
3
 *   Portions Copyright (c) Christoph Hellwig, 2001-2002
4
 *
5
 *   This program is free software;  you can redistribute it and/or modify
6
 *   it under the terms of the GNU General Public License as published by
7
 *   the Free Software Foundation; either version 2 of the License, or
8
 *   (at your option) any later version.
9
 *
10
 *   This program is distributed in the hope that it will be useful,
11
 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13
 *   the GNU General Public License for more details.
14
 *
15
 *   You should have received a copy of the GNU General Public License
16
 *   along with this program;  if not, write to the Free Software
17
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
 */
19
 
20
#include <linux/fs.h>
21
#include "jfs_incore.h"
22
#include "jfs_dmap.h"
23
#include "jfs_txnmgr.h"
24
#include "jfs_xattr.h"
25
#include "jfs_debug.h"
26
 
27
 
28
extern int jfs_commit_inode(struct inode *, int);
29
extern void jfs_truncate(struct inode *);
30
 
31
int jfs_fsync(struct file *file, struct dentry *dentry, int datasync)
32
{
33
        struct inode *inode = dentry->d_inode;
34
        int rc = 0;
35
 
36
        /* No need to resync the data at commit time, unless this flag gets
37
         * set again */
38
        clear_cflag(COMMIT_Syncdata, inode);
39
 
40
        rc = fsync_inode_data_buffers(inode);
41
 
42
        if (!(inode->i_state & I_DIRTY) ||
43
            (datasync && !(inode->i_state & I_DIRTY_DATASYNC))) {
44
                /* Make sure committed changes hit the disk */
45
                jfs_flush_journal(JFS_SBI(inode->i_sb)->log, 1);
46
                return rc;
47
        }
48
 
49
        rc |= jfs_commit_inode(inode, 1);
50
 
51
        return rc ? -EIO : 0;
52
}
53
 
54
static int jfs_open(struct inode *inode, struct file *file)
55
{
56
        int rc;
57
 
58
        if ((rc = generic_file_open(inode, file)))
59
                return rc;
60
 
61
        /*
62
         * We attempt to allow only one "active" file open per aggregate
63
         * group.  Otherwise, appending to files in parallel can cause
64
         * fragmentation within the files.
65
         *
66
         * If the file is empty, it was probably just created and going
67
         * to be written to.  If it has a size, we'll hold off until the
68
         * file is actually grown.
69
         */
70
        if (S_ISREG(inode->i_mode) && file->f_mode & FMODE_WRITE &&
71
            (inode->i_size == 0)) {
72
                struct jfs_inode_info *ji = JFS_IP(inode);
73
                if (ji->active_ag == -1) {
74
                        ji->active_ag = ji->agno;
75
                        atomic_inc(
76
                            &JFS_SBI(inode->i_sb)->bmap->db_active[ji->agno]);
77
                }
78
        }
79
 
80
        return 0;
81
}
82
static int jfs_release(struct inode *inode, struct file *file)
83
{
84
        struct jfs_inode_info *ji = JFS_IP(inode);
85
 
86
        if (ji->active_ag != -1) {
87
                struct bmap *bmap = JFS_SBI(inode->i_sb)->bmap;
88
                atomic_dec(&bmap->db_active[ji->active_ag]);
89
                ji->active_ag = -1;
90
        }
91
 
92
        return 0;
93
}
94
 
95
struct inode_operations jfs_file_inode_operations = {
96
        .truncate       = jfs_truncate,
97
        .setxattr       = jfs_setxattr,
98
        .getxattr       = jfs_getxattr,
99
        .listxattr      = jfs_listxattr,
100
        .removexattr    = jfs_removexattr,
101
};
102
 
103
struct file_operations jfs_file_operations = {
104
        .open           = jfs_open,
105
        .llseek         = generic_file_llseek,
106
        .write          = generic_file_write,
107
        .read           = generic_file_read,
108
        .mmap           = generic_file_mmap,
109
        .fsync          = jfs_fsync,
110
        .release        = jfs_release,
111
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.