Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 9 | * This program is distributed in the hope that it would be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write the Free Software Foundation, |
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include "xfs.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 19 | #include "xfs_bit.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include "xfs_log.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 21 | #include "xfs_inum.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include "xfs_sb.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 23 | #include "xfs_ag.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include "xfs_dir.h" |
| 25 | #include "xfs_dir2.h" |
| 26 | #include "xfs_trans.h" |
| 27 | #include "xfs_dmapi.h" |
| 28 | #include "xfs_mount.h" |
| 29 | #include "xfs_bmap_btree.h" |
| 30 | #include "xfs_alloc_btree.h" |
| 31 | #include "xfs_ialloc_btree.h" |
| 32 | #include "xfs_alloc.h" |
| 33 | #include "xfs_btree.h" |
| 34 | #include "xfs_attr_sf.h" |
| 35 | #include "xfs_dir_sf.h" |
| 36 | #include "xfs_dir2_sf.h" |
| 37 | #include "xfs_dinode.h" |
| 38 | #include "xfs_inode.h" |
| 39 | #include "xfs_error.h" |
| 40 | #include "xfs_rw.h" |
| 41 | #include "xfs_ioctl32.h" |
| 42 | |
| 43 | #include <linux/dcache.h> |
| 44 | #include <linux/smp_lock.h> |
| 45 | |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 46 | static struct vm_operations_struct xfs_file_vm_ops; |
Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 47 | #ifdef CONFIG_XFS_DMAPI |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 48 | static struct vm_operations_struct xfs_dmapi_file_vm_ops; |
Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 49 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
| 51 | STATIC inline ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 52 | __xfs_file_read( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | struct kiocb *iocb, |
| 54 | char __user *buf, |
| 55 | int ioflags, |
| 56 | size_t count, |
| 57 | loff_t pos) |
| 58 | { |
| 59 | struct iovec iov = {buf, count}; |
| 60 | struct file *file = iocb->ki_filp; |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 61 | vnode_t *vp = vn_from_inode(file->f_dentry->d_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | ssize_t rval; |
| 63 | |
| 64 | BUG_ON(iocb->ki_pos != pos); |
| 65 | |
| 66 | if (unlikely(file->f_flags & O_DIRECT)) |
| 67 | ioflags |= IO_ISDIRECT; |
| 68 | VOP_READ(vp, iocb, &iov, 1, &iocb->ki_pos, ioflags, NULL, rval); |
| 69 | return rval; |
| 70 | } |
| 71 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | STATIC ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 73 | xfs_file_aio_read( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | struct kiocb *iocb, |
| 75 | char __user *buf, |
| 76 | size_t count, |
| 77 | loff_t pos) |
| 78 | { |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 79 | return __xfs_file_read(iocb, buf, IO_ISAIO, count, pos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | STATIC ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 83 | xfs_file_aio_read_invis( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | struct kiocb *iocb, |
| 85 | char __user *buf, |
| 86 | size_t count, |
| 87 | loff_t pos) |
| 88 | { |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 89 | return __xfs_file_read(iocb, buf, IO_ISAIO|IO_INVIS, count, pos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | STATIC inline ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 93 | __xfs_file_write( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | struct kiocb *iocb, |
| 95 | const char __user *buf, |
| 96 | int ioflags, |
| 97 | size_t count, |
| 98 | loff_t pos) |
| 99 | { |
| 100 | struct iovec iov = {(void __user *)buf, count}; |
| 101 | struct file *file = iocb->ki_filp; |
| 102 | struct inode *inode = file->f_mapping->host; |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 103 | vnode_t *vp = vn_from_inode(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | ssize_t rval; |
| 105 | |
| 106 | BUG_ON(iocb->ki_pos != pos); |
| 107 | if (unlikely(file->f_flags & O_DIRECT)) |
| 108 | ioflags |= IO_ISDIRECT; |
| 109 | |
| 110 | VOP_WRITE(vp, iocb, &iov, 1, &iocb->ki_pos, ioflags, NULL, rval); |
| 111 | return rval; |
| 112 | } |
| 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | STATIC ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 115 | xfs_file_aio_write( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | struct kiocb *iocb, |
| 117 | const char __user *buf, |
| 118 | size_t count, |
| 119 | loff_t pos) |
| 120 | { |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 121 | return __xfs_file_write(iocb, buf, IO_ISAIO, count, pos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | STATIC ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 125 | xfs_file_aio_write_invis( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | struct kiocb *iocb, |
| 127 | const char __user *buf, |
| 128 | size_t count, |
| 129 | loff_t pos) |
| 130 | { |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 131 | return __xfs_file_write(iocb, buf, IO_ISAIO|IO_INVIS, count, pos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | STATIC inline ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 135 | __xfs_file_readv( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | struct file *file, |
| 137 | const struct iovec *iov, |
| 138 | int ioflags, |
| 139 | unsigned long nr_segs, |
| 140 | loff_t *ppos) |
| 141 | { |
| 142 | struct inode *inode = file->f_mapping->host; |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 143 | vnode_t *vp = vn_from_inode(inode); |
Nathan Scott | 524fbf5 | 2006-03-14 14:07:53 +1100 | [diff] [blame] | 144 | struct kiocb kiocb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | ssize_t rval; |
| 146 | |
Nathan Scott | 524fbf5 | 2006-03-14 14:07:53 +1100 | [diff] [blame] | 147 | init_sync_kiocb(&kiocb, file); |
| 148 | kiocb.ki_pos = *ppos; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
| 150 | if (unlikely(file->f_flags & O_DIRECT)) |
| 151 | ioflags |= IO_ISDIRECT; |
Nathan Scott | 524fbf5 | 2006-03-14 14:07:53 +1100 | [diff] [blame] | 152 | VOP_READ(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos, ioflags, NULL, rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
Nathan Scott | 524fbf5 | 2006-03-14 14:07:53 +1100 | [diff] [blame] | 154 | *ppos = kiocb.ki_pos; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | return rval; |
| 156 | } |
| 157 | |
| 158 | STATIC ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 159 | xfs_file_readv( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | struct file *file, |
| 161 | const struct iovec *iov, |
| 162 | unsigned long nr_segs, |
| 163 | loff_t *ppos) |
| 164 | { |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 165 | return __xfs_file_readv(file, iov, 0, nr_segs, ppos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | STATIC ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 169 | xfs_file_readv_invis( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | struct file *file, |
| 171 | const struct iovec *iov, |
| 172 | unsigned long nr_segs, |
| 173 | loff_t *ppos) |
| 174 | { |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 175 | return __xfs_file_readv(file, iov, IO_INVIS, nr_segs, ppos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | } |
| 177 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | STATIC inline ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 179 | __xfs_file_writev( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | struct file *file, |
| 181 | const struct iovec *iov, |
| 182 | int ioflags, |
| 183 | unsigned long nr_segs, |
| 184 | loff_t *ppos) |
| 185 | { |
| 186 | struct inode *inode = file->f_mapping->host; |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 187 | vnode_t *vp = vn_from_inode(inode); |
Nathan Scott | 524fbf5 | 2006-03-14 14:07:53 +1100 | [diff] [blame] | 188 | struct kiocb kiocb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | ssize_t rval; |
| 190 | |
Nathan Scott | 524fbf5 | 2006-03-14 14:07:53 +1100 | [diff] [blame] | 191 | init_sync_kiocb(&kiocb, file); |
| 192 | kiocb.ki_pos = *ppos; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | if (unlikely(file->f_flags & O_DIRECT)) |
| 194 | ioflags |= IO_ISDIRECT; |
| 195 | |
Nathan Scott | 524fbf5 | 2006-03-14 14:07:53 +1100 | [diff] [blame] | 196 | VOP_WRITE(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos, ioflags, NULL, rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | |
Nathan Scott | 524fbf5 | 2006-03-14 14:07:53 +1100 | [diff] [blame] | 198 | *ppos = kiocb.ki_pos; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | return rval; |
| 200 | } |
| 201 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | STATIC ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 203 | xfs_file_writev( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | struct file *file, |
| 205 | const struct iovec *iov, |
| 206 | unsigned long nr_segs, |
| 207 | loff_t *ppos) |
| 208 | { |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 209 | return __xfs_file_writev(file, iov, 0, nr_segs, ppos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | STATIC ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 213 | xfs_file_writev_invis( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | struct file *file, |
| 215 | const struct iovec *iov, |
| 216 | unsigned long nr_segs, |
| 217 | loff_t *ppos) |
| 218 | { |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 219 | return __xfs_file_writev(file, iov, IO_INVIS, nr_segs, ppos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | STATIC ssize_t |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 223 | xfs_file_sendfile( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | struct file *filp, |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 225 | loff_t *pos, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | size_t count, |
| 227 | read_actor_t actor, |
| 228 | void *target) |
| 229 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 230 | vnode_t *vp = vn_from_inode(filp->f_dentry->d_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | ssize_t rval; |
| 232 | |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 233 | VOP_SENDFILE(vp, filp, pos, 0, count, actor, target, NULL, rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | return rval; |
| 235 | } |
| 236 | |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 237 | STATIC ssize_t |
| 238 | xfs_file_sendfile_invis( |
| 239 | struct file *filp, |
| 240 | loff_t *pos, |
| 241 | size_t count, |
| 242 | read_actor_t actor, |
| 243 | void *target) |
| 244 | { |
| 245 | vnode_t *vp = vn_from_inode(filp->f_dentry->d_inode); |
| 246 | ssize_t rval; |
| 247 | |
| 248 | VOP_SENDFILE(vp, filp, pos, IO_INVIS, count, actor, target, NULL, rval); |
| 249 | return rval; |
| 250 | } |
| 251 | |
| 252 | STATIC ssize_t |
| 253 | xfs_file_splice_read( |
| 254 | struct file *infilp, |
Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 255 | loff_t *ppos, |
Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 256 | struct pipe_inode_info *pipe, |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 257 | size_t len, |
| 258 | unsigned int flags) |
| 259 | { |
| 260 | vnode_t *vp = vn_from_inode(infilp->f_dentry->d_inode); |
| 261 | ssize_t rval; |
| 262 | |
Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 263 | VOP_SPLICE_READ(vp, infilp, ppos, pipe, len, flags, 0, NULL, rval); |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 264 | return rval; |
| 265 | } |
| 266 | |
| 267 | STATIC ssize_t |
| 268 | xfs_file_splice_read_invis( |
| 269 | struct file *infilp, |
Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 270 | loff_t *ppos, |
Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 271 | struct pipe_inode_info *pipe, |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 272 | size_t len, |
| 273 | unsigned int flags) |
| 274 | { |
| 275 | vnode_t *vp = vn_from_inode(infilp->f_dentry->d_inode); |
| 276 | ssize_t rval; |
| 277 | |
Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 278 | VOP_SPLICE_READ(vp, infilp, ppos, pipe, len, flags, IO_INVIS, NULL, rval); |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 279 | return rval; |
| 280 | } |
| 281 | |
| 282 | STATIC ssize_t |
| 283 | xfs_file_splice_write( |
Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 284 | struct pipe_inode_info *pipe, |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 285 | struct file *outfilp, |
Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 286 | loff_t *ppos, |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 287 | size_t len, |
| 288 | unsigned int flags) |
| 289 | { |
| 290 | vnode_t *vp = vn_from_inode(outfilp->f_dentry->d_inode); |
| 291 | ssize_t rval; |
| 292 | |
Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 293 | VOP_SPLICE_WRITE(vp, pipe, outfilp, ppos, len, flags, 0, NULL, rval); |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 294 | return rval; |
| 295 | } |
| 296 | |
| 297 | STATIC ssize_t |
| 298 | xfs_file_splice_write_invis( |
Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 299 | struct pipe_inode_info *pipe, |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 300 | struct file *outfilp, |
Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 301 | loff_t *ppos, |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 302 | size_t len, |
| 303 | unsigned int flags) |
| 304 | { |
| 305 | vnode_t *vp = vn_from_inode(outfilp->f_dentry->d_inode); |
| 306 | ssize_t rval; |
| 307 | |
Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 308 | VOP_SPLICE_WRITE(vp, pipe, outfilp, ppos, len, flags, IO_INVIS, NULL, rval); |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 309 | return rval; |
| 310 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
| 312 | STATIC int |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 313 | xfs_file_open( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | struct inode *inode, |
| 315 | struct file *filp) |
| 316 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 317 | vnode_t *vp = vn_from_inode(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | int error; |
| 319 | |
| 320 | if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS) |
| 321 | return -EFBIG; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | VOP_OPEN(vp, NULL, error); |
| 323 | return -error; |
| 324 | } |
| 325 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | STATIC int |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame^] | 327 | xfs_file_close( |
| 328 | struct file *filp) |
| 329 | { |
| 330 | vnode_t *vp = vn_from_inode(filp->f_dentry->d_inode); |
| 331 | int error; |
| 332 | |
| 333 | VOP_CLOSE(vp, 0, file_count(filp) > 1 ? L_FALSE : L_TRUE, NULL, error); |
| 334 | return -error; |
| 335 | } |
| 336 | |
| 337 | STATIC int |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 338 | xfs_file_release( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | struct inode *inode, |
| 340 | struct file *filp) |
| 341 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 342 | vnode_t *vp = vn_from_inode(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | int error = 0; |
| 344 | |
| 345 | if (vp) |
| 346 | VOP_RELEASE(vp, error); |
| 347 | return -error; |
| 348 | } |
| 349 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | STATIC int |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 351 | xfs_file_fsync( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | struct file *filp, |
| 353 | struct dentry *dentry, |
| 354 | int datasync) |
| 355 | { |
| 356 | struct inode *inode = dentry->d_inode; |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 357 | vnode_t *vp = vn_from_inode(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | int error; |
| 359 | int flags = FSYNC_WAIT; |
| 360 | |
| 361 | if (datasync) |
| 362 | flags |= FSYNC_DATA; |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame^] | 363 | if (VN_TRUNC(vp)) |
| 364 | VUNTRUNCATE(vp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | VOP_FSYNC(vp, flags, NULL, (xfs_off_t)0, (xfs_off_t)-1, error); |
| 366 | return -error; |
| 367 | } |
| 368 | |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 369 | #ifdef CONFIG_XFS_DMAPI |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 370 | STATIC struct page * |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 371 | xfs_vm_nopage( |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 372 | struct vm_area_struct *area, |
| 373 | unsigned long address, |
| 374 | int *type) |
| 375 | { |
| 376 | struct inode *inode = area->vm_file->f_dentry->d_inode; |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 377 | vnode_t *vp = vn_from_inode(inode); |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 378 | |
| 379 | ASSERT_ALWAYS(vp->v_vfsp->vfs_flag & VFS_DMI); |
Nathan Scott | fbc1462 | 2006-06-09 14:52:13 +1000 | [diff] [blame] | 380 | if (XFS_SEND_MMAP(XFS_VFSTOM(vp->v_vfsp), area, 0)) |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 381 | return NULL; |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 382 | return filemap_nopage(area, address, type); |
| 383 | } |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 384 | #endif /* CONFIG_XFS_DMAPI */ |
| 385 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | STATIC int |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 387 | xfs_file_readdir( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | struct file *filp, |
| 389 | void *dirent, |
| 390 | filldir_t filldir) |
| 391 | { |
| 392 | int error = 0; |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 393 | vnode_t *vp = vn_from_inode(filp->f_dentry->d_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | uio_t uio; |
| 395 | iovec_t iov; |
| 396 | int eof = 0; |
| 397 | caddr_t read_buf; |
| 398 | int namelen, size = 0; |
| 399 | size_t rlen = PAGE_CACHE_SIZE; |
| 400 | xfs_off_t start_offset, curr_offset; |
| 401 | xfs_dirent_t *dbp = NULL; |
| 402 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | /* Try fairly hard to get memory */ |
| 404 | do { |
| 405 | if ((read_buf = (caddr_t)kmalloc(rlen, GFP_KERNEL))) |
| 406 | break; |
| 407 | rlen >>= 1; |
| 408 | } while (rlen >= 1024); |
| 409 | |
| 410 | if (read_buf == NULL) |
| 411 | return -ENOMEM; |
| 412 | |
| 413 | uio.uio_iov = &iov; |
| 414 | uio.uio_segflg = UIO_SYSSPACE; |
| 415 | curr_offset = filp->f_pos; |
| 416 | if (filp->f_pos != 0x7fffffff) |
| 417 | uio.uio_offset = filp->f_pos; |
| 418 | else |
| 419 | uio.uio_offset = 0xffffffff; |
| 420 | |
| 421 | while (!eof) { |
| 422 | uio.uio_resid = iov.iov_len = rlen; |
| 423 | iov.iov_base = read_buf; |
| 424 | uio.uio_iovcnt = 1; |
| 425 | |
| 426 | start_offset = uio.uio_offset; |
| 427 | |
| 428 | VOP_READDIR(vp, &uio, NULL, &eof, error); |
| 429 | if ((uio.uio_offset == start_offset) || error) { |
| 430 | size = 0; |
| 431 | break; |
| 432 | } |
| 433 | |
| 434 | size = rlen - uio.uio_resid; |
| 435 | dbp = (xfs_dirent_t *)read_buf; |
| 436 | while (size > 0) { |
| 437 | namelen = strlen(dbp->d_name); |
| 438 | |
| 439 | if (filldir(dirent, dbp->d_name, namelen, |
| 440 | (loff_t) curr_offset & 0x7fffffff, |
| 441 | (ino_t) dbp->d_ino, |
| 442 | DT_UNKNOWN)) { |
| 443 | goto done; |
| 444 | } |
| 445 | size -= dbp->d_reclen; |
| 446 | curr_offset = (loff_t)dbp->d_off /* & 0x7fffffff */; |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 447 | dbp = (xfs_dirent_t *)((char *)dbp + dbp->d_reclen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | } |
| 449 | } |
| 450 | done: |
| 451 | if (!error) { |
| 452 | if (size == 0) |
| 453 | filp->f_pos = uio.uio_offset & 0x7fffffff; |
| 454 | else if (dbp) |
| 455 | filp->f_pos = curr_offset; |
| 456 | } |
| 457 | |
| 458 | kfree(read_buf); |
| 459 | return -error; |
| 460 | } |
| 461 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | STATIC int |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 463 | xfs_file_mmap( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | struct file *filp, |
| 465 | struct vm_area_struct *vma) |
| 466 | { |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 467 | vma->vm_ops = &xfs_file_vm_ops; |
Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 468 | |
Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 469 | #ifdef CONFIG_XFS_DMAPI |
Nathan Scott | fbc1462 | 2006-06-09 14:52:13 +1000 | [diff] [blame] | 470 | if (vn_from_inode(filp->f_dentry->d_inode)->v_vfsp->vfs_flag & VFS_DMI) |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 471 | vma->vm_ops = &xfs_dmapi_file_vm_ops; |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 472 | #endif /* CONFIG_XFS_DMAPI */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | |
Nathan Scott | fbc1462 | 2006-06-09 14:52:13 +1000 | [diff] [blame] | 474 | file_accessed(filp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | return 0; |
| 476 | } |
| 477 | |
| 478 | |
| 479 | STATIC long |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 480 | xfs_file_ioctl( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | struct file *filp, |
| 482 | unsigned int cmd, |
| 483 | unsigned long arg) |
| 484 | { |
| 485 | int error; |
Nathan Scott | 1f6553f | 2006-03-14 13:30:48 +1100 | [diff] [blame] | 486 | struct inode *inode = filp->f_dentry->d_inode; |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 487 | vnode_t *vp = vn_from_inode(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
| 489 | VOP_IOCTL(vp, inode, filp, 0, cmd, (void __user *)arg, error); |
| 490 | VMODIFY(vp); |
| 491 | |
| 492 | /* NOTE: some of the ioctl's return positive #'s as a |
| 493 | * byte count indicating success, such as |
| 494 | * readlink_by_handle. So we don't "sign flip" |
| 495 | * like most other routines. This means true |
| 496 | * errors need to be returned as a negative value. |
| 497 | */ |
| 498 | return error; |
| 499 | } |
| 500 | |
| 501 | STATIC long |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 502 | xfs_file_ioctl_invis( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | struct file *filp, |
| 504 | unsigned int cmd, |
| 505 | unsigned long arg) |
| 506 | { |
Nathan Scott | 1f6553f | 2006-03-14 13:30:48 +1100 | [diff] [blame] | 507 | struct inode *inode = filp->f_dentry->d_inode; |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 508 | vnode_t *vp = vn_from_inode(inode); |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 509 | int error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, (void __user *)arg, error); |
| 512 | VMODIFY(vp); |
| 513 | |
| 514 | /* NOTE: some of the ioctl's return positive #'s as a |
| 515 | * byte count indicating success, such as |
| 516 | * readlink_by_handle. So we don't "sign flip" |
| 517 | * like most other routines. This means true |
| 518 | * errors need to be returned as a negative value. |
| 519 | */ |
| 520 | return error; |
| 521 | } |
| 522 | |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 523 | #ifdef CONFIG_XFS_DMAPI |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | #ifdef HAVE_VMOP_MPROTECT |
| 525 | STATIC int |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 526 | xfs_vm_mprotect( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | struct vm_area_struct *vma, |
| 528 | unsigned int newflags) |
| 529 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 530 | vnode_t *vp = vn_from_inode(vma->vm_file->f_dentry->d_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | int error = 0; |
| 532 | |
| 533 | if (vp->v_vfsp->vfs_flag & VFS_DMI) { |
| 534 | if ((vma->vm_flags & VM_MAYSHARE) && |
| 535 | (newflags & VM_WRITE) && !(vma->vm_flags & VM_WRITE)) { |
| 536 | xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp); |
| 537 | |
| 538 | error = XFS_SEND_MMAP(mp, vma, VM_WRITE); |
| 539 | } |
| 540 | } |
| 541 | return error; |
| 542 | } |
| 543 | #endif /* HAVE_VMOP_MPROTECT */ |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 544 | #endif /* CONFIG_XFS_DMAPI */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | |
| 546 | #ifdef HAVE_FOP_OPEN_EXEC |
| 547 | /* If the user is attempting to execute a file that is offline then |
| 548 | * we have to trigger a DMAPI READ event before the file is marked as busy |
| 549 | * otherwise the invisible I/O will not be able to write to the file to bring |
| 550 | * it back online. |
| 551 | */ |
| 552 | STATIC int |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 553 | xfs_file_open_exec( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | struct inode *inode) |
| 555 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 556 | vnode_t *vp = vn_from_inode(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp); |
| 558 | int error = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | xfs_inode_t *ip; |
| 560 | |
| 561 | if (vp->v_vfsp->vfs_flag & VFS_DMI) { |
Christoph Hellwig | 75e17b3 | 2006-01-11 20:58:44 +1100 | [diff] [blame] | 562 | ip = xfs_vtoi(vp); |
| 563 | if (!ip) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | error = -EINVAL; |
| 565 | goto open_exec_out; |
| 566 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ)) { |
| 568 | error = -XFS_SEND_DATA(mp, DM_EVENT_READ, vp, |
| 569 | 0, 0, 0, NULL); |
| 570 | } |
| 571 | } |
| 572 | open_exec_out: |
| 573 | return error; |
| 574 | } |
| 575 | #endif /* HAVE_FOP_OPEN_EXEC */ |
| 576 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 577 | const struct file_operations xfs_file_operations = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | .llseek = generic_file_llseek, |
| 579 | .read = do_sync_read, |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 580 | .write = do_sync_write, |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 581 | .readv = xfs_file_readv, |
| 582 | .writev = xfs_file_writev, |
| 583 | .aio_read = xfs_file_aio_read, |
| 584 | .aio_write = xfs_file_aio_write, |
| 585 | .sendfile = xfs_file_sendfile, |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 586 | .splice_read = xfs_file_splice_read, |
| 587 | .splice_write = xfs_file_splice_write, |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 588 | .unlocked_ioctl = xfs_file_ioctl, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | #ifdef CONFIG_COMPAT |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 590 | .compat_ioctl = xfs_file_compat_ioctl, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | #endif |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 592 | .mmap = xfs_file_mmap, |
| 593 | .open = xfs_file_open, |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame^] | 594 | .flush = xfs_file_close, |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 595 | .release = xfs_file_release, |
| 596 | .fsync = xfs_file_fsync, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | #ifdef HAVE_FOP_OPEN_EXEC |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 598 | .open_exec = xfs_file_open_exec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | #endif |
| 600 | }; |
| 601 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 602 | const struct file_operations xfs_invis_file_operations = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | .llseek = generic_file_llseek, |
| 604 | .read = do_sync_read, |
Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 605 | .write = do_sync_write, |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 606 | .readv = xfs_file_readv_invis, |
| 607 | .writev = xfs_file_writev_invis, |
| 608 | .aio_read = xfs_file_aio_read_invis, |
| 609 | .aio_write = xfs_file_aio_write_invis, |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 610 | .sendfile = xfs_file_sendfile_invis, |
| 611 | .splice_read = xfs_file_splice_read_invis, |
| 612 | .splice_write = xfs_file_splice_write_invis, |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 613 | .unlocked_ioctl = xfs_file_ioctl_invis, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | #ifdef CONFIG_COMPAT |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 615 | .compat_ioctl = xfs_file_compat_invis_ioctl, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | #endif |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 617 | .mmap = xfs_file_mmap, |
| 618 | .open = xfs_file_open, |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame^] | 619 | .flush = xfs_file_close, |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 620 | .release = xfs_file_release, |
| 621 | .fsync = xfs_file_fsync, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | }; |
| 623 | |
| 624 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 625 | const struct file_operations xfs_dir_file_operations = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | .read = generic_read_dir, |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 627 | .readdir = xfs_file_readdir, |
| 628 | .unlocked_ioctl = xfs_file_ioctl, |
Nathan Scott | d387039 | 2005-05-06 06:44:46 -0700 | [diff] [blame] | 629 | #ifdef CONFIG_COMPAT |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 630 | .compat_ioctl = xfs_file_compat_ioctl, |
Nathan Scott | d387039 | 2005-05-06 06:44:46 -0700 | [diff] [blame] | 631 | #endif |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 632 | .fsync = xfs_file_fsync, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | }; |
| 634 | |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 635 | static struct vm_operations_struct xfs_file_vm_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | .nopage = filemap_nopage, |
| 637 | .populate = filemap_populate, |
Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 638 | }; |
| 639 | |
| 640 | #ifdef CONFIG_XFS_DMAPI |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 641 | static struct vm_operations_struct xfs_dmapi_file_vm_ops = { |
| 642 | .nopage = xfs_vm_nopage, |
Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 643 | .populate = filemap_populate, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | #ifdef HAVE_VMOP_MPROTECT |
Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 645 | .mprotect = xfs_vm_mprotect, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | #endif |
| 647 | }; |
Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 648 | #endif /* CONFIG_XFS_DMAPI */ |