David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
Steven Whitehouse | 3a8a9a1 | 2006-05-18 15:09:15 -0400 | [diff] [blame] | 3 | * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 4 | * |
| 5 | * This copyrighted material is made available to anyone wishing to use, |
| 6 | * modify, copy, or redistribute it subject to the terms and conditions |
Steven Whitehouse | e9fc2aa | 2006-09-01 11:05:15 -0400 | [diff] [blame] | 7 | * of the GNU General Public License version 2. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <linux/sched.h> |
| 11 | #include <linux/slab.h> |
| 12 | #include <linux/spinlock.h> |
| 13 | #include <linux/completion.h> |
| 14 | #include <linux/buffer_head.h> |
| 15 | #include <linux/pagemap.h> |
| 16 | #include <linux/uio.h> |
| 17 | #include <linux/blkdev.h> |
| 18 | #include <linux/mm.h> |
| 19 | #include <linux/smp_lock.h> |
Steven Whitehouse | 18ec7d5 | 2006-02-08 11:50:51 +0000 | [diff] [blame] | 20 | #include <linux/fs.h> |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 21 | #include <linux/gfs2_ondisk.h> |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 22 | #include <linux/ext2_fs.h> |
| 23 | #include <linux/crc32.h> |
Fabio Massimo Di Nitto | 7d30859 | 2006-09-19 07:56:29 +0200 | [diff] [blame] | 24 | #include <linux/lm_interface.h> |
Steven Whitehouse | 33c3de3 | 2006-11-30 10:14:32 -0500 | [diff] [blame] | 25 | #include <linux/writeback.h> |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 26 | #include <asm/uaccess.h> |
| 27 | |
| 28 | #include "gfs2.h" |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 29 | #include "incore.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 30 | #include "bmap.h" |
| 31 | #include "dir.h" |
| 32 | #include "glock.h" |
| 33 | #include "glops.h" |
| 34 | #include "inode.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 35 | #include "lm.h" |
| 36 | #include "log.h" |
| 37 | #include "meta_io.h" |
| 38 | #include "ops_file.h" |
| 39 | #include "ops_vm.h" |
| 40 | #include "quota.h" |
| 41 | #include "rgrp.h" |
| 42 | #include "trans.h" |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 43 | #include "util.h" |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 44 | #include "eaops.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 45 | |
Steven Whitehouse | 61a30dc | 2006-02-15 10:15:18 +0000 | [diff] [blame] | 46 | /* |
| 47 | * Most fields left uninitialised to catch anybody who tries to |
| 48 | * use them. f_flags set to prevent file_accessed() from touching |
| 49 | * any other part of this. Its use is purely as a flag so that we |
| 50 | * know (in readpage()) whether or not do to locking. |
| 51 | */ |
Steven Whitehouse | dd538c8 | 2006-09-04 14:53:30 -0400 | [diff] [blame] | 52 | struct file gfs2_internal_file_sentinel = { |
Steven Whitehouse | 61a30dc | 2006-02-15 10:15:18 +0000 | [diff] [blame] | 53 | .f_flags = O_NOATIME|O_RDONLY, |
| 54 | }; |
| 55 | |
Steven Whitehouse | 18ec7d5 | 2006-02-08 11:50:51 +0000 | [diff] [blame] | 56 | static int gfs2_read_actor(read_descriptor_t *desc, struct page *page, |
| 57 | unsigned long offset, unsigned long size) |
| 58 | { |
| 59 | char *kaddr; |
| 60 | unsigned long count = desc->count; |
| 61 | |
| 62 | if (size > count) |
| 63 | size = count; |
| 64 | |
| 65 | kaddr = kmap(page); |
Al Viro | 9c9ab3d | 2006-10-13 23:49:23 -0400 | [diff] [blame] | 66 | memcpy(desc->arg.data, kaddr + offset, size); |
Steven Whitehouse | 26c1a57 | 2006-09-04 15:32:10 -0400 | [diff] [blame] | 67 | kunmap(page); |
Steven Whitehouse | 18ec7d5 | 2006-02-08 11:50:51 +0000 | [diff] [blame] | 68 | |
Steven Whitehouse | 26c1a57 | 2006-09-04 15:32:10 -0400 | [diff] [blame] | 69 | desc->count = count - size; |
| 70 | desc->written += size; |
| 71 | desc->arg.buf += size; |
| 72 | return size; |
Steven Whitehouse | 18ec7d5 | 2006-02-08 11:50:51 +0000 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state, |
| 76 | char *buf, loff_t *pos, unsigned size) |
| 77 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 78 | struct inode *inode = &ip->i_inode; |
Steven Whitehouse | 18ec7d5 | 2006-02-08 11:50:51 +0000 | [diff] [blame] | 79 | read_descriptor_t desc; |
| 80 | desc.written = 0; |
Al Viro | 9c9ab3d | 2006-10-13 23:49:23 -0400 | [diff] [blame] | 81 | desc.arg.data = buf; |
Steven Whitehouse | 18ec7d5 | 2006-02-08 11:50:51 +0000 | [diff] [blame] | 82 | desc.count = size; |
| 83 | desc.error = 0; |
Steven Whitehouse | 61a30dc | 2006-02-15 10:15:18 +0000 | [diff] [blame] | 84 | do_generic_mapping_read(inode->i_mapping, ra_state, |
Steven Whitehouse | dd538c8 | 2006-09-04 14:53:30 -0400 | [diff] [blame] | 85 | &gfs2_internal_file_sentinel, pos, &desc, |
Steven Whitehouse | 61a30dc | 2006-02-15 10:15:18 +0000 | [diff] [blame] | 86 | gfs2_read_actor); |
Steven Whitehouse | 18ec7d5 | 2006-02-08 11:50:51 +0000 | [diff] [blame] | 87 | return desc.written ? desc.written : desc.error; |
| 88 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * gfs2_llseek - seek to a location in a file |
| 92 | * @file: the file |
| 93 | * @offset: the offset |
| 94 | * @origin: Where to seek from (SEEK_SET, SEEK_CUR, or SEEK_END) |
| 95 | * |
| 96 | * SEEK_END requires the glock for the file because it references the |
| 97 | * file's size. |
| 98 | * |
| 99 | * Returns: The new offset, or errno |
| 100 | */ |
| 101 | |
| 102 | static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin) |
| 103 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 104 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 105 | struct gfs2_holder i_gh; |
| 106 | loff_t error; |
| 107 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 108 | if (origin == 2) { |
| 109 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, |
| 110 | &i_gh); |
| 111 | if (!error) { |
| 112 | error = remote_llseek(file, offset, origin); |
| 113 | gfs2_glock_dq_uninit(&i_gh); |
| 114 | } |
| 115 | } else |
| 116 | error = remote_llseek(file, offset, origin); |
| 117 | |
| 118 | return error; |
| 119 | } |
| 120 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 121 | /** |
Steven Whitehouse | f0e522a | 2006-09-19 16:41:11 -0400 | [diff] [blame] | 122 | * gfs2_readdir - Read directory entries from a directory |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 123 | * @file: The directory to read from |
| 124 | * @dirent: Buffer for dirents |
| 125 | * @filldir: Function used to do the copying |
| 126 | * |
| 127 | * Returns: errno |
| 128 | */ |
| 129 | |
Steven Whitehouse | f0e522a | 2006-09-19 16:41:11 -0400 | [diff] [blame] | 130 | static int gfs2_readdir(struct file *file, void *dirent, filldir_t filldir) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 131 | { |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 132 | struct inode *dir = file->f_mapping->host; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 133 | struct gfs2_inode *dip = GFS2_I(dir); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 134 | struct gfs2_holder d_gh; |
Steven Whitehouse | cd91549 | 2006-09-04 12:49:07 -0400 | [diff] [blame] | 135 | u64 offset = file->f_pos; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 136 | int error; |
| 137 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 138 | gfs2_holder_init(dip->i_gl, LM_ST_SHARED, GL_ATIME, &d_gh); |
| 139 | error = gfs2_glock_nq_atime(&d_gh); |
| 140 | if (error) { |
| 141 | gfs2_holder_uninit(&d_gh); |
| 142 | return error; |
| 143 | } |
| 144 | |
Steven Whitehouse | 3699e3a | 2007-01-17 15:09:20 +0000 | [diff] [blame^] | 145 | error = gfs2_dir_read(dir, &offset, dirent, filldir); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 146 | |
| 147 | gfs2_glock_dq_uninit(&d_gh); |
| 148 | |
| 149 | file->f_pos = offset; |
| 150 | |
| 151 | return error; |
| 152 | } |
| 153 | |
Steven Whitehouse | 128e5eb | 2006-10-02 11:24:43 -0400 | [diff] [blame] | 154 | /** |
| 155 | * fsflags_cvt |
| 156 | * @table: A table of 32 u32 flags |
| 157 | * @val: a 32 bit value to convert |
| 158 | * |
| 159 | * This function can be used to convert between fsflags values and |
| 160 | * GFS2's own flags values. |
| 161 | * |
| 162 | * Returns: the converted flags |
| 163 | */ |
| 164 | static u32 fsflags_cvt(const u32 *table, u32 val) |
| 165 | { |
| 166 | u32 res = 0; |
| 167 | while(val) { |
| 168 | if (val & 1) |
| 169 | res |= *table; |
| 170 | table++; |
| 171 | val >>= 1; |
| 172 | } |
| 173 | return res; |
| 174 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 175 | |
Steven Whitehouse | 128e5eb | 2006-10-02 11:24:43 -0400 | [diff] [blame] | 176 | static const u32 fsflags_to_gfs2[32] = { |
| 177 | [3] = GFS2_DIF_SYNC, |
| 178 | [4] = GFS2_DIF_IMMUTABLE, |
| 179 | [5] = GFS2_DIF_APPENDONLY, |
| 180 | [7] = GFS2_DIF_NOATIME, |
| 181 | [12] = GFS2_DIF_EXHASH, |
| 182 | [14] = GFS2_DIF_JDATA, |
| 183 | [20] = GFS2_DIF_DIRECTIO, |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 184 | }; |
| 185 | |
Steven Whitehouse | 128e5eb | 2006-10-02 11:24:43 -0400 | [diff] [blame] | 186 | static const u32 gfs2_to_fsflags[32] = { |
| 187 | [gfs2fl_Sync] = FS_SYNC_FL, |
| 188 | [gfs2fl_Immutable] = FS_IMMUTABLE_FL, |
| 189 | [gfs2fl_AppendOnly] = FS_APPEND_FL, |
| 190 | [gfs2fl_NoAtime] = FS_NOATIME_FL, |
| 191 | [gfs2fl_ExHash] = FS_INDEX_FL, |
| 192 | [gfs2fl_Jdata] = FS_JOURNAL_DATA_FL, |
| 193 | [gfs2fl_Directio] = FS_DIRECTIO_FL, |
| 194 | [gfs2fl_InheritDirectio] = FS_DIRECTIO_FL, |
| 195 | [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL, |
Steven Whitehouse | 7ea9ea8 | 2006-03-31 15:01:28 -0500 | [diff] [blame] | 196 | }; |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 197 | |
Steven Whitehouse | b09e593 | 2006-04-07 11:17:32 -0400 | [diff] [blame] | 198 | static int gfs2_get_flags(struct file *filp, u32 __user *ptr) |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 199 | { |
Josef Sipek | 8145409 | 2006-12-08 02:37:03 -0800 | [diff] [blame] | 200 | struct inode *inode = filp->f_path.dentry->d_inode; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 201 | struct gfs2_inode *ip = GFS2_I(inode); |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 202 | struct gfs2_holder gh; |
| 203 | int error; |
Steven Whitehouse | 128e5eb | 2006-10-02 11:24:43 -0400 | [diff] [blame] | 204 | u32 fsflags; |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 205 | |
| 206 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); |
Steven Whitehouse | dcd2479 | 2006-11-16 11:08:16 -0500 | [diff] [blame] | 207 | error = gfs2_glock_nq_atime(&gh); |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 208 | if (error) |
| 209 | return error; |
Steven Whitehouse | 907b9bc | 2006-09-25 09:26:04 -0400 | [diff] [blame] | 210 | |
Steven Whitehouse | 128e5eb | 2006-10-02 11:24:43 -0400 | [diff] [blame] | 211 | fsflags = fsflags_cvt(gfs2_to_fsflags, ip->i_di.di_flags); |
| 212 | if (put_user(fsflags, ptr)) |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 213 | error = -EFAULT; |
| 214 | |
| 215 | gfs2_glock_dq_m(1, &gh); |
| 216 | gfs2_holder_uninit(&gh); |
| 217 | return error; |
| 218 | } |
| 219 | |
Steven Whitehouse | 6b124d8 | 2006-11-08 12:51:06 -0500 | [diff] [blame] | 220 | void gfs2_set_inode_flags(struct inode *inode) |
| 221 | { |
| 222 | struct gfs2_inode *ip = GFS2_I(inode); |
| 223 | struct gfs2_dinode_host *di = &ip->i_di; |
| 224 | unsigned int flags = inode->i_flags; |
| 225 | |
| 226 | flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC); |
| 227 | if (di->di_flags & GFS2_DIF_IMMUTABLE) |
| 228 | flags |= S_IMMUTABLE; |
| 229 | if (di->di_flags & GFS2_DIF_APPENDONLY) |
| 230 | flags |= S_APPEND; |
| 231 | if (di->di_flags & GFS2_DIF_NOATIME) |
| 232 | flags |= S_NOATIME; |
| 233 | if (di->di_flags & GFS2_DIF_SYNC) |
| 234 | flags |= S_SYNC; |
| 235 | inode->i_flags = flags; |
| 236 | } |
| 237 | |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 238 | /* Flags that can be set by user space */ |
| 239 | #define GFS2_FLAGS_USER_SET (GFS2_DIF_JDATA| \ |
| 240 | GFS2_DIF_DIRECTIO| \ |
| 241 | GFS2_DIF_IMMUTABLE| \ |
| 242 | GFS2_DIF_APPENDONLY| \ |
| 243 | GFS2_DIF_NOATIME| \ |
| 244 | GFS2_DIF_SYNC| \ |
| 245 | GFS2_DIF_SYSTEM| \ |
| 246 | GFS2_DIF_INHERIT_DIRECTIO| \ |
| 247 | GFS2_DIF_INHERIT_JDATA) |
| 248 | |
| 249 | /** |
| 250 | * gfs2_set_flags - set flags on an inode |
| 251 | * @inode: The inode |
| 252 | * @flags: The flags to set |
| 253 | * @mask: Indicates which flags are valid |
| 254 | * |
| 255 | */ |
Steven Whitehouse | b09e593 | 2006-04-07 11:17:32 -0400 | [diff] [blame] | 256 | static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask) |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 257 | { |
Josef Sipek | 8145409 | 2006-12-08 02:37:03 -0800 | [diff] [blame] | 258 | struct inode *inode = filp->f_path.dentry->d_inode; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 259 | struct gfs2_inode *ip = GFS2_I(inode); |
| 260 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 261 | struct buffer_head *bh; |
| 262 | struct gfs2_holder gh; |
| 263 | int error; |
Steven Whitehouse | 55eccc6 | 2006-04-04 14:29:30 -0400 | [diff] [blame] | 264 | u32 new_flags, flags; |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 265 | |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 266 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); |
Abhijith Das | 52f341c | 2006-07-21 02:03:21 -0400 | [diff] [blame] | 267 | if (error) |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 268 | return error; |
| 269 | |
Steven Whitehouse | 55eccc6 | 2006-04-04 14:29:30 -0400 | [diff] [blame] | 270 | flags = ip->i_di.di_flags; |
| 271 | new_flags = (flags & ~mask) | (reqflags & mask); |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 272 | if ((new_flags ^ flags) == 0) |
| 273 | goto out; |
| 274 | |
Steven Whitehouse | 4bcf709 | 2006-04-25 13:20:27 -0400 | [diff] [blame] | 275 | if (S_ISDIR(inode->i_mode)) { |
| 276 | if ((new_flags ^ flags) & GFS2_DIF_JDATA) |
| 277 | new_flags ^= (GFS2_DIF_JDATA|GFS2_DIF_INHERIT_JDATA); |
| 278 | if ((new_flags ^ flags) & GFS2_DIF_DIRECTIO) |
| 279 | new_flags ^= (GFS2_DIF_DIRECTIO|GFS2_DIF_INHERIT_DIRECTIO); |
| 280 | } |
| 281 | |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 282 | error = -EINVAL; |
| 283 | if ((new_flags ^ flags) & ~GFS2_FLAGS_USER_SET) |
| 284 | goto out; |
| 285 | |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 286 | error = -EPERM; |
| 287 | if (IS_IMMUTABLE(inode) && (new_flags & GFS2_DIF_IMMUTABLE)) |
| 288 | goto out; |
| 289 | if (IS_APPEND(inode) && (new_flags & GFS2_DIF_APPENDONLY)) |
| 290 | goto out; |
Steven Whitehouse | 907b9bc | 2006-09-25 09:26:04 -0400 | [diff] [blame] | 291 | if (((new_flags ^ flags) & GFS2_DIF_IMMUTABLE) && |
Steven Whitehouse | b9cb981 | 2006-05-12 17:07:56 -0400 | [diff] [blame] | 292 | !capable(CAP_LINUX_IMMUTABLE)) |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 293 | goto out; |
Steven Whitehouse | b9cb981 | 2006-05-12 17:07:56 -0400 | [diff] [blame] | 294 | if (!IS_IMMUTABLE(inode)) { |
Steven Whitehouse | faf450e | 2006-06-22 10:59:10 -0400 | [diff] [blame] | 295 | error = permission(inode, MAY_WRITE, NULL); |
Steven Whitehouse | b9cb981 | 2006-05-12 17:07:56 -0400 | [diff] [blame] | 296 | if (error) |
| 297 | goto out; |
| 298 | } |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 299 | |
Steven Whitehouse | 55eccc6 | 2006-04-04 14:29:30 -0400 | [diff] [blame] | 300 | error = gfs2_trans_begin(sdp, RES_DINODE, 0); |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 301 | if (error) |
| 302 | goto out; |
Steven Whitehouse | 55eccc6 | 2006-04-04 14:29:30 -0400 | [diff] [blame] | 303 | error = gfs2_meta_inode_buffer(ip, &bh); |
| 304 | if (error) |
| 305 | goto out_trans_end; |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 306 | gfs2_trans_add_bh(ip->i_gl, bh, 1); |
| 307 | ip->i_di.di_flags = new_flags; |
Steven Whitehouse | 539e5d6 | 2006-10-31 15:07:05 -0500 | [diff] [blame] | 308 | gfs2_dinode_out(ip, bh->b_data); |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 309 | brelse(bh); |
Steven Whitehouse | 6b124d8 | 2006-11-08 12:51:06 -0500 | [diff] [blame] | 310 | gfs2_set_inode_flags(inode); |
Steven Whitehouse | 55eccc6 | 2006-04-04 14:29:30 -0400 | [diff] [blame] | 311 | out_trans_end: |
| 312 | gfs2_trans_end(sdp); |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 313 | out: |
| 314 | gfs2_glock_dq_uninit(&gh); |
| 315 | return error; |
| 316 | } |
| 317 | |
Steven Whitehouse | b09e593 | 2006-04-07 11:17:32 -0400 | [diff] [blame] | 318 | static int gfs2_set_flags(struct file *filp, u32 __user *ptr) |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 319 | { |
Steven Whitehouse | 128e5eb | 2006-10-02 11:24:43 -0400 | [diff] [blame] | 320 | u32 fsflags, gfsflags; |
| 321 | if (get_user(fsflags, ptr)) |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 322 | return -EFAULT; |
Steven Whitehouse | 128e5eb | 2006-10-02 11:24:43 -0400 | [diff] [blame] | 323 | gfsflags = fsflags_cvt(fsflags_to_gfs2, fsflags); |
Steven Whitehouse | b09e593 | 2006-04-07 11:17:32 -0400 | [diff] [blame] | 324 | return do_gfs2_set_flags(filp, gfsflags, ~0); |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 325 | } |
| 326 | |
Steven Whitehouse | b09e593 | 2006-04-07 11:17:32 -0400 | [diff] [blame] | 327 | static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 328 | { |
| 329 | switch(cmd) { |
Steven Whitehouse | 128e5eb | 2006-10-02 11:24:43 -0400 | [diff] [blame] | 330 | case FS_IOC_GETFLAGS: |
Steven Whitehouse | b09e593 | 2006-04-07 11:17:32 -0400 | [diff] [blame] | 331 | return gfs2_get_flags(filp, (u32 __user *)arg); |
Steven Whitehouse | 128e5eb | 2006-10-02 11:24:43 -0400 | [diff] [blame] | 332 | case FS_IOC_SETFLAGS: |
Steven Whitehouse | b09e593 | 2006-04-07 11:17:32 -0400 | [diff] [blame] | 333 | return gfs2_set_flags(filp, (u32 __user *)arg); |
Steven Whitehouse | 71b86f5 | 2006-03-28 14:14:04 -0500 | [diff] [blame] | 334 | } |
| 335 | return -ENOTTY; |
| 336 | } |
| 337 | |
| 338 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 339 | /** |
| 340 | * gfs2_mmap - |
| 341 | * @file: The file to map |
| 342 | * @vma: The VMA which described the mapping |
| 343 | * |
| 344 | * Returns: 0 or error code |
| 345 | */ |
| 346 | |
| 347 | static int gfs2_mmap(struct file *file, struct vm_area_struct *vma) |
| 348 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 349 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 350 | struct gfs2_holder i_gh; |
| 351 | int error; |
| 352 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 353 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &i_gh); |
| 354 | error = gfs2_glock_nq_atime(&i_gh); |
| 355 | if (error) { |
| 356 | gfs2_holder_uninit(&i_gh); |
| 357 | return error; |
| 358 | } |
| 359 | |
Steven Whitehouse | 18ec7d5 | 2006-02-08 11:50:51 +0000 | [diff] [blame] | 360 | /* This is VM_MAYWRITE instead of VM_WRITE because a call |
| 361 | to mprotect() can turn on VM_WRITE later. */ |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 362 | |
Steven Whitehouse | 18ec7d5 | 2006-02-08 11:50:51 +0000 | [diff] [blame] | 363 | if ((vma->vm_flags & (VM_MAYSHARE | VM_MAYWRITE)) == |
| 364 | (VM_MAYSHARE | VM_MAYWRITE)) |
| 365 | vma->vm_ops = &gfs2_vm_ops_sharewrite; |
| 366 | else |
| 367 | vma->vm_ops = &gfs2_vm_ops_private; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 368 | |
| 369 | gfs2_glock_dq_uninit(&i_gh); |
| 370 | |
| 371 | return error; |
| 372 | } |
| 373 | |
| 374 | /** |
| 375 | * gfs2_open - open a file |
| 376 | * @inode: the inode to open |
| 377 | * @file: the struct file for this opening |
| 378 | * |
| 379 | * Returns: errno |
| 380 | */ |
| 381 | |
| 382 | static int gfs2_open(struct inode *inode, struct file *file) |
| 383 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 384 | struct gfs2_inode *ip = GFS2_I(inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 385 | struct gfs2_holder i_gh; |
| 386 | struct gfs2_file *fp; |
| 387 | int error; |
| 388 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 389 | fp = kzalloc(sizeof(struct gfs2_file), GFP_KERNEL); |
| 390 | if (!fp) |
| 391 | return -ENOMEM; |
| 392 | |
Steven Whitehouse | f55ab26 | 2006-02-21 12:51:39 +0000 | [diff] [blame] | 393 | mutex_init(&fp->f_fl_mutex); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 394 | |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 395 | gfs2_assert_warn(GFS2_SB(inode), !file->private_data); |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 396 | file->private_data = fp; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 397 | |
Steven Whitehouse | b60623c | 2006-11-01 12:22:46 -0500 | [diff] [blame] | 398 | if (S_ISREG(ip->i_inode.i_mode)) { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 399 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, |
| 400 | &i_gh); |
| 401 | if (error) |
| 402 | goto fail; |
| 403 | |
| 404 | if (!(file->f_flags & O_LARGEFILE) && |
| 405 | ip->i_di.di_size > MAX_NON_LFS) { |
| 406 | error = -EFBIG; |
| 407 | goto fail_gunlock; |
| 408 | } |
| 409 | |
| 410 | /* Listen to the Direct I/O flag */ |
| 411 | |
| 412 | if (ip->i_di.di_flags & GFS2_DIF_DIRECTIO) |
| 413 | file->f_flags |= O_DIRECT; |
| 414 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 415 | gfs2_glock_dq_uninit(&i_gh); |
| 416 | } |
| 417 | |
| 418 | return 0; |
| 419 | |
Steven Whitehouse | 420b9e5 | 2006-07-31 15:42:17 -0400 | [diff] [blame] | 420 | fail_gunlock: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 421 | gfs2_glock_dq_uninit(&i_gh); |
Steven Whitehouse | 420b9e5 | 2006-07-31 15:42:17 -0400 | [diff] [blame] | 422 | fail: |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 423 | file->private_data = NULL; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 424 | kfree(fp); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 425 | return error; |
| 426 | } |
| 427 | |
| 428 | /** |
| 429 | * gfs2_close - called to close a struct file |
| 430 | * @inode: the inode the struct file belongs to |
| 431 | * @file: the struct file being closed |
| 432 | * |
| 433 | * Returns: errno |
| 434 | */ |
| 435 | |
| 436 | static int gfs2_close(struct inode *inode, struct file *file) |
| 437 | { |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 438 | struct gfs2_sbd *sdp = inode->i_sb->s_fs_info; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 439 | struct gfs2_file *fp; |
| 440 | |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 441 | fp = file->private_data; |
| 442 | file->private_data = NULL; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 443 | |
| 444 | if (gfs2_assert_warn(sdp, fp)) |
| 445 | return -EIO; |
| 446 | |
| 447 | kfree(fp); |
| 448 | |
| 449 | return 0; |
| 450 | } |
| 451 | |
| 452 | /** |
| 453 | * gfs2_fsync - sync the dirty data for a file (across the cluster) |
| 454 | * @file: the file that points to the dentry (we ignore this) |
| 455 | * @dentry: the dentry that points to the inode to sync |
| 456 | * |
Steven Whitehouse | 33c3de3 | 2006-11-30 10:14:32 -0500 | [diff] [blame] | 457 | * The VFS will flush "normal" data for us. We only need to worry |
| 458 | * about metadata here. For journaled data, we just do a log flush |
| 459 | * as we can't avoid it. Otherwise we can just bale out if datasync |
| 460 | * is set. For stuffed inodes we must flush the log in order to |
| 461 | * ensure that all data is on disk. |
| 462 | * |
Steven Whitehouse | 34126f9 | 2006-12-07 09:13:14 -0500 | [diff] [blame] | 463 | * The call to write_inode_now() is there to write back metadata and |
| 464 | * the inode itself. It does also try and write the data, but thats |
| 465 | * (hopefully) a no-op due to the VFS having already called filemap_fdatawrite() |
| 466 | * for us. |
| 467 | * |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 468 | * Returns: errno |
| 469 | */ |
| 470 | |
| 471 | static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync) |
| 472 | { |
Steven Whitehouse | 33c3de3 | 2006-11-30 10:14:32 -0500 | [diff] [blame] | 473 | struct inode *inode = dentry->d_inode; |
| 474 | int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC); |
| 475 | int ret = 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 476 | |
Steven Whitehouse | 33c3de3 | 2006-11-30 10:14:32 -0500 | [diff] [blame] | 477 | if (gfs2_is_jdata(GFS2_I(inode))) { |
| 478 | gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl); |
| 479 | return 0; |
| 480 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 481 | |
Steven Whitehouse | 33c3de3 | 2006-11-30 10:14:32 -0500 | [diff] [blame] | 482 | if (sync_state != 0) { |
| 483 | if (!datasync) |
Steven Whitehouse | 34126f9 | 2006-12-07 09:13:14 -0500 | [diff] [blame] | 484 | ret = write_inode_now(inode, 0); |
Steven Whitehouse | 33c3de3 | 2006-11-30 10:14:32 -0500 | [diff] [blame] | 485 | |
| 486 | if (gfs2_is_stuffed(GFS2_I(inode))) |
| 487 | gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl); |
| 488 | } |
| 489 | |
| 490 | return ret; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | /** |
| 494 | * gfs2_lock - acquire/release a posix lock on a file |
| 495 | * @file: the file pointer |
| 496 | * @cmd: either modify or retrieve lock state, possibly wait |
| 497 | * @fl: type and range of lock |
| 498 | * |
| 499 | * Returns: errno |
| 500 | */ |
| 501 | |
| 502 | static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) |
| 503 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 504 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); |
| 505 | struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 506 | struct lm_lockname name = |
| 507 | { .ln_number = ip->i_num.no_addr, |
| 508 | .ln_type = LM_TYPE_PLOCK }; |
| 509 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 510 | if (!(fl->fl_flags & FL_POSIX)) |
| 511 | return -ENOLCK; |
Steven Whitehouse | b60623c | 2006-11-01 12:22:46 -0500 | [diff] [blame] | 512 | if ((ip->i_inode.i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 513 | return -ENOLCK; |
| 514 | |
| 515 | if (sdp->sd_args.ar_localflocks) { |
| 516 | if (IS_GETLK(cmd)) { |
Steven Whitehouse | 8628de0 | 2006-03-31 16:48:41 -0500 | [diff] [blame] | 517 | struct file_lock tmp; |
| 518 | int ret; |
| 519 | ret = posix_test_lock(file, fl, &tmp); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 520 | fl->fl_type = F_UNLCK; |
Steven Whitehouse | 8628de0 | 2006-03-31 16:48:41 -0500 | [diff] [blame] | 521 | if (ret) |
| 522 | memcpy(fl, &tmp, sizeof(struct file_lock)); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 523 | return 0; |
| 524 | } else { |
Steven Whitehouse | 8628de0 | 2006-03-31 16:48:41 -0500 | [diff] [blame] | 525 | return posix_lock_file_wait(file, fl); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 526 | } |
| 527 | } |
| 528 | |
| 529 | if (IS_GETLK(cmd)) |
| 530 | return gfs2_lm_plock_get(sdp, &name, file, fl); |
| 531 | else if (fl->fl_type == F_UNLCK) |
| 532 | return gfs2_lm_punlock(sdp, &name, file, fl); |
| 533 | else |
| 534 | return gfs2_lm_plock(sdp, &name, file, cmd, fl); |
| 535 | } |
| 536 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 537 | static int do_flock(struct file *file, int cmd, struct file_lock *fl) |
| 538 | { |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 539 | struct gfs2_file *fp = file->private_data; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 540 | struct gfs2_holder *fl_gh = &fp->f_fl_gh; |
Josef Sipek | 8145409 | 2006-12-08 02:37:03 -0800 | [diff] [blame] | 541 | struct gfs2_inode *ip = GFS2_I(file->f_path.dentry->d_inode); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 542 | struct gfs2_glock *gl; |
| 543 | unsigned int state; |
| 544 | int flags; |
| 545 | int error = 0; |
| 546 | |
| 547 | state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; |
Steven Whitehouse | 26c1a57 | 2006-09-04 15:32:10 -0400 | [diff] [blame] | 548 | flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 549 | |
Steven Whitehouse | f55ab26 | 2006-02-21 12:51:39 +0000 | [diff] [blame] | 550 | mutex_lock(&fp->f_fl_mutex); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 551 | |
| 552 | gl = fl_gh->gh_gl; |
| 553 | if (gl) { |
| 554 | if (fl_gh->gh_state == state) |
| 555 | goto out; |
| 556 | gfs2_glock_hold(gl); |
| 557 | flock_lock_file_wait(file, |
Steven Whitehouse | 907b9bc | 2006-09-25 09:26:04 -0400 | [diff] [blame] | 558 | &(struct file_lock){.fl_type = F_UNLCK}); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 559 | gfs2_glock_dq_uninit(fl_gh); |
| 560 | } else { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 561 | error = gfs2_glock_get(GFS2_SB(&ip->i_inode), |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 562 | ip->i_num.no_addr, &gfs2_flock_glops, |
| 563 | CREATE, &gl); |
| 564 | if (error) |
| 565 | goto out; |
| 566 | } |
| 567 | |
| 568 | gfs2_holder_init(gl, state, flags, fl_gh); |
| 569 | gfs2_glock_put(gl); |
| 570 | |
| 571 | error = gfs2_glock_nq(fl_gh); |
| 572 | if (error) { |
| 573 | gfs2_holder_uninit(fl_gh); |
| 574 | if (error == GLR_TRYFAILED) |
| 575 | error = -EAGAIN; |
| 576 | } else { |
| 577 | error = flock_lock_file_wait(file, fl); |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 578 | gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 579 | } |
| 580 | |
Steven Whitehouse | 420b9e5 | 2006-07-31 15:42:17 -0400 | [diff] [blame] | 581 | out: |
Steven Whitehouse | f55ab26 | 2006-02-21 12:51:39 +0000 | [diff] [blame] | 582 | mutex_unlock(&fp->f_fl_mutex); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 583 | return error; |
| 584 | } |
| 585 | |
| 586 | static void do_unflock(struct file *file, struct file_lock *fl) |
| 587 | { |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 588 | struct gfs2_file *fp = file->private_data; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 589 | struct gfs2_holder *fl_gh = &fp->f_fl_gh; |
| 590 | |
Steven Whitehouse | f55ab26 | 2006-02-21 12:51:39 +0000 | [diff] [blame] | 591 | mutex_lock(&fp->f_fl_mutex); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 592 | flock_lock_file_wait(file, fl); |
| 593 | if (fl_gh->gh_gl) |
| 594 | gfs2_glock_dq_uninit(fl_gh); |
Steven Whitehouse | f55ab26 | 2006-02-21 12:51:39 +0000 | [diff] [blame] | 595 | mutex_unlock(&fp->f_fl_mutex); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | /** |
| 599 | * gfs2_flock - acquire/release a flock lock on a file |
| 600 | * @file: the file pointer |
| 601 | * @cmd: either modify or retrieve lock state, possibly wait |
| 602 | * @fl: type and range of lock |
| 603 | * |
| 604 | * Returns: errno |
| 605 | */ |
| 606 | |
| 607 | static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl) |
| 608 | { |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 609 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); |
| 610 | struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 611 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 612 | if (!(fl->fl_flags & FL_FLOCK)) |
| 613 | return -ENOLCK; |
Steven Whitehouse | b60623c | 2006-11-01 12:22:46 -0500 | [diff] [blame] | 614 | if ((ip->i_inode.i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 615 | return -ENOLCK; |
| 616 | |
| 617 | if (sdp->sd_args.ar_localflocks) |
| 618 | return flock_lock_file_wait(file, fl); |
| 619 | |
| 620 | if (fl->fl_type == F_UNLCK) { |
| 621 | do_unflock(file, fl); |
| 622 | return 0; |
Steven Whitehouse | d00223f | 2006-10-02 10:28:05 -0400 | [diff] [blame] | 623 | } else { |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 624 | return do_flock(file, cmd, fl); |
Steven Whitehouse | d00223f | 2006-10-02 10:28:05 -0400 | [diff] [blame] | 625 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 626 | } |
| 627 | |
Steven Whitehouse | b0dd930 | 2006-07-03 13:47:02 -0400 | [diff] [blame] | 628 | const struct file_operations gfs2_file_fops = { |
Steven Whitehouse | 26c1a57 | 2006-09-04 15:32:10 -0400 | [diff] [blame] | 629 | .llseek = gfs2_llseek, |
Steven Whitehouse | d00223f | 2006-10-02 10:28:05 -0400 | [diff] [blame] | 630 | .read = do_sync_read, |
Steven Whitehouse | 26c1a57 | 2006-09-04 15:32:10 -0400 | [diff] [blame] | 631 | .aio_read = generic_file_aio_read, |
Steven Whitehouse | d00223f | 2006-10-02 10:28:05 -0400 | [diff] [blame] | 632 | .write = do_sync_write, |
Steven Whitehouse | 26c1a57 | 2006-09-04 15:32:10 -0400 | [diff] [blame] | 633 | .aio_write = generic_file_aio_write, |
| 634 | .unlocked_ioctl = gfs2_ioctl, |
| 635 | .mmap = gfs2_mmap, |
| 636 | .open = gfs2_open, |
| 637 | .release = gfs2_close, |
| 638 | .fsync = gfs2_fsync, |
| 639 | .lock = gfs2_lock, |
| 640 | .sendfile = generic_file_sendfile, |
| 641 | .flock = gfs2_flock, |
| 642 | .splice_read = generic_file_splice_read, |
| 643 | .splice_write = generic_file_splice_write, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 644 | }; |
| 645 | |
Steven Whitehouse | b0dd930 | 2006-07-03 13:47:02 -0400 | [diff] [blame] | 646 | const struct file_operations gfs2_dir_fops = { |
Steven Whitehouse | 26c1a57 | 2006-09-04 15:32:10 -0400 | [diff] [blame] | 647 | .readdir = gfs2_readdir, |
| 648 | .unlocked_ioctl = gfs2_ioctl, |
| 649 | .open = gfs2_open, |
| 650 | .release = gfs2_close, |
| 651 | .fsync = gfs2_fsync, |
| 652 | .lock = gfs2_lock, |
| 653 | .flock = gfs2_flock, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 654 | }; |
| 655 | |