| 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_dir2.h" | 
|  | 25 | #include "xfs_trans.h" | 
|  | 26 | #include "xfs_dmapi.h" | 
|  | 27 | #include "xfs_mount.h" | 
|  | 28 | #include "xfs_bmap_btree.h" | 
|  | 29 | #include "xfs_alloc_btree.h" | 
|  | 30 | #include "xfs_ialloc_btree.h" | 
|  | 31 | #include "xfs_alloc.h" | 
|  | 32 | #include "xfs_btree.h" | 
|  | 33 | #include "xfs_attr_sf.h" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include "xfs_dir2_sf.h" | 
|  | 35 | #include "xfs_dinode.h" | 
|  | 36 | #include "xfs_inode.h" | 
|  | 37 | #include "xfs_error.h" | 
|  | 38 | #include "xfs_rw.h" | 
|  | 39 | #include "xfs_ioctl32.h" | 
|  | 40 |  | 
|  | 41 | #include <linux/dcache.h> | 
|  | 42 | #include <linux/smp_lock.h> | 
|  | 43 |  | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 44 | static struct vm_operations_struct xfs_file_vm_ops; | 
| Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 45 | #ifdef CONFIG_XFS_DMAPI | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 46 | static struct vm_operations_struct xfs_dmapi_file_vm_ops; | 
| Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 47 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 |  | 
| David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 49 | STATIC_INLINE ssize_t | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 50 | __xfs_file_read( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | struct kiocb		*iocb, | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 52 | const struct iovec	*iov, | 
|  | 53 | unsigned long		nr_segs, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | int			ioflags, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | loff_t			pos) | 
|  | 56 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | struct file		*file = iocb->ki_filp; | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 58 | bhv_vnode_t		*vp = vn_from_inode(file->f_path.dentry->d_inode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 |  | 
|  | 60 | BUG_ON(iocb->ki_pos != pos); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | if (unlikely(file->f_flags & O_DIRECT)) | 
|  | 62 | ioflags |= IO_ISDIRECT; | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 63 | return bhv_vop_read(vp, iocb, iov, nr_segs, &iocb->ki_pos, | 
|  | 64 | ioflags, NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } | 
|  | 66 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | STATIC ssize_t | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 68 | xfs_file_aio_read( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | struct kiocb		*iocb, | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 70 | const struct iovec	*iov, | 
|  | 71 | unsigned long		nr_segs, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | loff_t			pos) | 
|  | 73 | { | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 74 | return __xfs_file_read(iocb, iov, nr_segs, IO_ISAIO, pos); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | } | 
|  | 76 |  | 
|  | 77 | STATIC ssize_t | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 78 | xfs_file_aio_read_invis( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | struct kiocb		*iocb, | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 80 | const struct iovec	*iov, | 
|  | 81 | unsigned long		nr_segs, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | loff_t			pos) | 
|  | 83 | { | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 84 | return __xfs_file_read(iocb, iov, nr_segs, IO_ISAIO|IO_INVIS, pos); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | } | 
|  | 86 |  | 
| David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 87 | STATIC_INLINE ssize_t | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 88 | __xfs_file_write( | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 89 | struct kiocb		*iocb, | 
|  | 90 | const struct iovec	*iov, | 
|  | 91 | unsigned long		nr_segs, | 
|  | 92 | int			ioflags, | 
|  | 93 | loff_t			pos) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | struct file	*file = iocb->ki_filp; | 
|  | 96 | struct inode	*inode = file->f_mapping->host; | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 97 | bhv_vnode_t	*vp = vn_from_inode(inode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 |  | 
|  | 99 | BUG_ON(iocb->ki_pos != pos); | 
|  | 100 | if (unlikely(file->f_flags & O_DIRECT)) | 
|  | 101 | ioflags |= IO_ISDIRECT; | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 102 | return bhv_vop_write(vp, iocb, iov, nr_segs, &iocb->ki_pos, | 
|  | 103 | ioflags, NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | } | 
|  | 105 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | STATIC ssize_t | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 107 | xfs_file_aio_write( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | struct kiocb		*iocb, | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 109 | const struct iovec	*iov, | 
|  | 110 | unsigned long		nr_segs, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | loff_t			pos) | 
|  | 112 | { | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 113 | return __xfs_file_write(iocb, iov, nr_segs, IO_ISAIO, pos); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | } | 
|  | 115 |  | 
|  | 116 | STATIC ssize_t | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 117 | xfs_file_aio_write_invis( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | struct kiocb		*iocb, | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 119 | const struct iovec	*iov, | 
|  | 120 | unsigned long		nr_segs, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | loff_t			pos) | 
|  | 122 | { | 
| Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 123 | return __xfs_file_write(iocb, iov, nr_segs, IO_ISAIO|IO_INVIS, pos); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | } | 
|  | 125 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | STATIC ssize_t | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 127 | xfs_file_sendfile( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | struct file		*filp, | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 129 | loff_t			*pos, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | size_t			count, | 
|  | 131 | read_actor_t		actor, | 
|  | 132 | void			*target) | 
|  | 133 | { | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 134 | return bhv_vop_sendfile(vn_from_inode(filp->f_path.dentry->d_inode), | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 135 | filp, pos, 0, count, actor, target, NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } | 
|  | 137 |  | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 138 | STATIC ssize_t | 
|  | 139 | xfs_file_sendfile_invis( | 
|  | 140 | struct file		*filp, | 
|  | 141 | loff_t			*pos, | 
|  | 142 | size_t			count, | 
|  | 143 | read_actor_t		actor, | 
|  | 144 | void			*target) | 
|  | 145 | { | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 146 | return bhv_vop_sendfile(vn_from_inode(filp->f_path.dentry->d_inode), | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 147 | filp, pos, IO_INVIS, count, actor, target, NULL); | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 148 | } | 
|  | 149 |  | 
|  | 150 | STATIC ssize_t | 
|  | 151 | xfs_file_splice_read( | 
|  | 152 | struct file		*infilp, | 
| Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 153 | loff_t			*ppos, | 
| Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 154 | struct pipe_inode_info	*pipe, | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 155 | size_t			len, | 
|  | 156 | unsigned int		flags) | 
|  | 157 | { | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 158 | return bhv_vop_splice_read(vn_from_inode(infilp->f_path.dentry->d_inode), | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 159 | infilp, ppos, pipe, len, flags, 0, NULL); | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 160 | } | 
|  | 161 |  | 
|  | 162 | STATIC ssize_t | 
|  | 163 | xfs_file_splice_read_invis( | 
|  | 164 | struct file		*infilp, | 
| Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 165 | loff_t			*ppos, | 
| Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 166 | struct pipe_inode_info	*pipe, | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 167 | size_t			len, | 
|  | 168 | unsigned int		flags) | 
|  | 169 | { | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 170 | return bhv_vop_splice_read(vn_from_inode(infilp->f_path.dentry->d_inode), | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 171 | infilp, ppos, pipe, len, flags, IO_INVIS, | 
|  | 172 | NULL); | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 173 | } | 
|  | 174 |  | 
|  | 175 | STATIC ssize_t | 
|  | 176 | xfs_file_splice_write( | 
| Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 177 | struct pipe_inode_info	*pipe, | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 178 | struct file		*outfilp, | 
| Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 179 | loff_t			*ppos, | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 180 | size_t			len, | 
|  | 181 | unsigned int		flags) | 
|  | 182 | { | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 183 | return bhv_vop_splice_write(vn_from_inode(outfilp->f_path.dentry->d_inode), | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 184 | pipe, outfilp, ppos, len, flags, 0, NULL); | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 185 | } | 
|  | 186 |  | 
|  | 187 | STATIC ssize_t | 
|  | 188 | xfs_file_splice_write_invis( | 
| Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 189 | struct pipe_inode_info	*pipe, | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 190 | struct file		*outfilp, | 
| Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 191 | loff_t			*ppos, | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 192 | size_t			len, | 
|  | 193 | unsigned int		flags) | 
|  | 194 | { | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 195 | return bhv_vop_splice_write(vn_from_inode(outfilp->f_path.dentry->d_inode), | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 196 | pipe, outfilp, ppos, len, flags, IO_INVIS, | 
|  | 197 | NULL); | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 198 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 |  | 
|  | 200 | STATIC int | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 201 | xfs_file_open( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | struct inode	*inode, | 
|  | 203 | struct file	*filp) | 
|  | 204 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS) | 
|  | 206 | return -EFBIG; | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 207 | return -bhv_vop_open(vn_from_inode(inode), NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | } | 
|  | 209 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | STATIC int | 
| Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 211 | xfs_file_close( | 
| Alexey Dobriyan | 1e788f8 | 2006-06-25 16:42:33 -0700 | [diff] [blame] | 212 | struct file	*filp, | 
|  | 213 | fl_owner_t	id) | 
| Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 214 | { | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 215 | return -bhv_vop_close(vn_from_inode(filp->f_path.dentry->d_inode), 0, | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 216 | file_count(filp) > 1 ? L_FALSE : L_TRUE, NULL); | 
| Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 217 | } | 
|  | 218 |  | 
|  | 219 | STATIC int | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 220 | xfs_file_release( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | struct inode	*inode, | 
|  | 222 | struct file	*filp) | 
|  | 223 | { | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 224 | bhv_vnode_t	*vp = vn_from_inode(inode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 |  | 
|  | 226 | if (vp) | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 227 | return -bhv_vop_release(vp); | 
|  | 228 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | } | 
|  | 230 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | STATIC int | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 232 | xfs_file_fsync( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | struct file	*filp, | 
|  | 234 | struct dentry	*dentry, | 
|  | 235 | int		datasync) | 
|  | 236 | { | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 237 | bhv_vnode_t	*vp = vn_from_inode(dentry->d_inode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | int		flags = FSYNC_WAIT; | 
|  | 239 |  | 
|  | 240 | if (datasync) | 
|  | 241 | flags |= FSYNC_DATA; | 
| Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 242 | if (VN_TRUNC(vp)) | 
|  | 243 | VUNTRUNCATE(vp); | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 244 | return -bhv_vop_fsync(vp, flags, NULL, (xfs_off_t)0, (xfs_off_t)-1); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | } | 
|  | 246 |  | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 247 | #ifdef CONFIG_XFS_DMAPI | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 248 | STATIC struct page * | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 249 | xfs_vm_nopage( | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 250 | struct vm_area_struct	*area, | 
|  | 251 | unsigned long		address, | 
|  | 252 | int			*type) | 
|  | 253 | { | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 254 | struct inode	*inode = area->vm_file->f_path.dentry->d_inode; | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 255 | bhv_vnode_t	*vp = vn_from_inode(inode); | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 256 |  | 
|  | 257 | ASSERT_ALWAYS(vp->v_vfsp->vfs_flag & VFS_DMI); | 
| Nathan Scott | fbc1462 | 2006-06-09 14:52:13 +1000 | [diff] [blame] | 258 | if (XFS_SEND_MMAP(XFS_VFSTOM(vp->v_vfsp), area, 0)) | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 259 | return NULL; | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 260 | return filemap_nopage(area, address, type); | 
|  | 261 | } | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 262 | #endif /* CONFIG_XFS_DMAPI */ | 
|  | 263 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | STATIC int | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 265 | xfs_file_readdir( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | struct file	*filp, | 
|  | 267 | void		*dirent, | 
|  | 268 | filldir_t	filldir) | 
|  | 269 | { | 
|  | 270 | int		error = 0; | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 271 | bhv_vnode_t	*vp = vn_from_inode(filp->f_path.dentry->d_inode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | uio_t		uio; | 
|  | 273 | iovec_t		iov; | 
|  | 274 | int		eof = 0; | 
|  | 275 | caddr_t		read_buf; | 
|  | 276 | int		namelen, size = 0; | 
|  | 277 | size_t		rlen = PAGE_CACHE_SIZE; | 
|  | 278 | xfs_off_t	start_offset, curr_offset; | 
|  | 279 | xfs_dirent_t	*dbp = NULL; | 
|  | 280 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | /* Try fairly hard to get memory */ | 
|  | 282 | do { | 
| Panagiotis Issaris | f52720c | 2006-09-27 01:49:39 -0700 | [diff] [blame] | 283 | if ((read_buf = kmalloc(rlen, GFP_KERNEL))) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | break; | 
|  | 285 | rlen >>= 1; | 
|  | 286 | } while (rlen >= 1024); | 
|  | 287 |  | 
|  | 288 | if (read_buf == NULL) | 
|  | 289 | return -ENOMEM; | 
|  | 290 |  | 
|  | 291 | uio.uio_iov = &iov; | 
|  | 292 | uio.uio_segflg = UIO_SYSSPACE; | 
|  | 293 | curr_offset = filp->f_pos; | 
|  | 294 | if (filp->f_pos != 0x7fffffff) | 
|  | 295 | uio.uio_offset = filp->f_pos; | 
|  | 296 | else | 
|  | 297 | uio.uio_offset = 0xffffffff; | 
|  | 298 |  | 
|  | 299 | while (!eof) { | 
|  | 300 | uio.uio_resid = iov.iov_len = rlen; | 
|  | 301 | iov.iov_base = read_buf; | 
|  | 302 | uio.uio_iovcnt = 1; | 
|  | 303 |  | 
|  | 304 | start_offset = uio.uio_offset; | 
|  | 305 |  | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 306 | error = bhv_vop_readdir(vp, &uio, NULL, &eof); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | if ((uio.uio_offset == start_offset) || error) { | 
|  | 308 | size = 0; | 
|  | 309 | break; | 
|  | 310 | } | 
|  | 311 |  | 
|  | 312 | size = rlen - uio.uio_resid; | 
|  | 313 | dbp = (xfs_dirent_t *)read_buf; | 
|  | 314 | while (size > 0) { | 
|  | 315 | namelen = strlen(dbp->d_name); | 
|  | 316 |  | 
|  | 317 | if (filldir(dirent, dbp->d_name, namelen, | 
|  | 318 | (loff_t) curr_offset & 0x7fffffff, | 
|  | 319 | (ino_t) dbp->d_ino, | 
|  | 320 | DT_UNKNOWN)) { | 
|  | 321 | goto done; | 
|  | 322 | } | 
|  | 323 | size -= dbp->d_reclen; | 
|  | 324 | curr_offset = (loff_t)dbp->d_off /* & 0x7fffffff */; | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 325 | dbp = (xfs_dirent_t *)((char *)dbp + dbp->d_reclen); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | } | 
|  | 327 | } | 
|  | 328 | done: | 
|  | 329 | if (!error) { | 
|  | 330 | if (size == 0) | 
|  | 331 | filp->f_pos = uio.uio_offset & 0x7fffffff; | 
|  | 332 | else if (dbp) | 
|  | 333 | filp->f_pos = curr_offset; | 
|  | 334 | } | 
|  | 335 |  | 
|  | 336 | kfree(read_buf); | 
|  | 337 | return -error; | 
|  | 338 | } | 
|  | 339 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | STATIC int | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 341 | xfs_file_mmap( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | struct file	*filp, | 
|  | 343 | struct vm_area_struct *vma) | 
|  | 344 | { | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 345 | vma->vm_ops = &xfs_file_vm_ops; | 
| Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 346 |  | 
| Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 347 | #ifdef CONFIG_XFS_DMAPI | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 348 | if (vn_from_inode(filp->f_path.dentry->d_inode)->v_vfsp->vfs_flag & VFS_DMI) | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 349 | vma->vm_ops = &xfs_dmapi_file_vm_ops; | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 350 | #endif /* CONFIG_XFS_DMAPI */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 |  | 
| Nathan Scott | fbc1462 | 2006-06-09 14:52:13 +1000 | [diff] [blame] | 352 | file_accessed(filp); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | return 0; | 
|  | 354 | } | 
|  | 355 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | STATIC long | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 357 | xfs_file_ioctl( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | struct file	*filp, | 
|  | 359 | unsigned int	cmd, | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 360 | unsigned long	p) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | { | 
|  | 362 | int		error; | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 363 | struct inode	*inode = filp->f_path.dentry->d_inode; | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 364 | bhv_vnode_t	*vp = vn_from_inode(inode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 |  | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 366 | error = bhv_vop_ioctl(vp, inode, filp, 0, cmd, (void __user *)p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | VMODIFY(vp); | 
|  | 368 |  | 
|  | 369 | /* NOTE:  some of the ioctl's return positive #'s as a | 
|  | 370 | *	  byte count indicating success, such as | 
|  | 371 | *	  readlink_by_handle.  So we don't "sign flip" | 
|  | 372 | *	  like most other routines.  This means true | 
|  | 373 | *	  errors need to be returned as a negative value. | 
|  | 374 | */ | 
|  | 375 | return error; | 
|  | 376 | } | 
|  | 377 |  | 
|  | 378 | STATIC long | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 379 | xfs_file_ioctl_invis( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | struct file	*filp, | 
|  | 381 | unsigned int	cmd, | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 382 | unsigned long	p) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | { | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 384 | int		error; | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 385 | struct inode	*inode = filp->f_path.dentry->d_inode; | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 386 | bhv_vnode_t	*vp = vn_from_inode(inode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 |  | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 388 | error = bhv_vop_ioctl(vp, inode, filp, IO_INVIS, cmd, (void __user *)p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | VMODIFY(vp); | 
|  | 390 |  | 
|  | 391 | /* NOTE:  some of the ioctl's return positive #'s as a | 
|  | 392 | *	  byte count indicating success, such as | 
|  | 393 | *	  readlink_by_handle.  So we don't "sign flip" | 
|  | 394 | *	  like most other routines.  This means true | 
|  | 395 | *	  errors need to be returned as a negative value. | 
|  | 396 | */ | 
|  | 397 | return error; | 
|  | 398 | } | 
|  | 399 |  | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 400 | #ifdef CONFIG_XFS_DMAPI | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | #ifdef HAVE_VMOP_MPROTECT | 
|  | 402 | STATIC int | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 403 | xfs_vm_mprotect( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | struct vm_area_struct *vma, | 
|  | 405 | unsigned int	newflags) | 
|  | 406 | { | 
| Josef "Jeff" Sipek | e678fb0 | 2006-12-08 02:36:49 -0800 | [diff] [blame] | 407 | bhv_vnode_t	*vp = vn_from_inode(vma->vm_file->f_path.dentry->d_inode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | int		error = 0; | 
|  | 409 |  | 
|  | 410 | if (vp->v_vfsp->vfs_flag & VFS_DMI) { | 
|  | 411 | if ((vma->vm_flags & VM_MAYSHARE) && | 
|  | 412 | (newflags & VM_WRITE) && !(vma->vm_flags & VM_WRITE)) { | 
|  | 413 | xfs_mount_t	*mp = XFS_VFSTOM(vp->v_vfsp); | 
|  | 414 |  | 
|  | 415 | error = XFS_SEND_MMAP(mp, vma, VM_WRITE); | 
|  | 416 | } | 
|  | 417 | } | 
|  | 418 | return error; | 
|  | 419 | } | 
|  | 420 | #endif /* HAVE_VMOP_MPROTECT */ | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 421 | #endif /* CONFIG_XFS_DMAPI */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 |  | 
|  | 423 | #ifdef HAVE_FOP_OPEN_EXEC | 
|  | 424 | /* If the user is attempting to execute a file that is offline then | 
|  | 425 | * we have to trigger a DMAPI READ event before the file is marked as busy | 
|  | 426 | * otherwise the invisible I/O will not be able to write to the file to bring | 
|  | 427 | * it back online. | 
|  | 428 | */ | 
|  | 429 | STATIC int | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 430 | xfs_file_open_exec( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | struct inode	*inode) | 
|  | 432 | { | 
| Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 433 | bhv_vnode_t	*vp = vn_from_inode(inode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 |  | 
| Nathan Scott | 1d47bec | 2006-06-19 08:39:16 +1000 | [diff] [blame] | 435 | if (unlikely(vp->v_vfsp->vfs_flag & VFS_DMI)) { | 
|  | 436 | xfs_mount_t	*mp = XFS_VFSTOM(vp->v_vfsp); | 
|  | 437 | xfs_inode_t	*ip = xfs_vtoi(vp); | 
|  | 438 |  | 
|  | 439 | if (!ip) | 
|  | 440 | return -EINVAL; | 
|  | 441 | if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ)) | 
|  | 442 | return -XFS_SEND_DATA(mp, DM_EVENT_READ, vp, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | 0, 0, 0, NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | } | 
| Nathan Scott | 1d47bec | 2006-06-19 08:39:16 +1000 | [diff] [blame] | 445 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | } | 
|  | 447 | #endif /* HAVE_FOP_OPEN_EXEC */ | 
|  | 448 |  | 
| Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 449 | const struct file_operations xfs_file_operations = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | .llseek		= generic_file_llseek, | 
|  | 451 | .read		= do_sync_read, | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 452 | .write		= do_sync_write, | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 453 | .aio_read	= xfs_file_aio_read, | 
|  | 454 | .aio_write	= xfs_file_aio_write, | 
|  | 455 | .sendfile	= xfs_file_sendfile, | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 456 | .splice_read	= xfs_file_splice_read, | 
|  | 457 | .splice_write	= xfs_file_splice_write, | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 458 | .unlocked_ioctl	= xfs_file_ioctl, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | #ifdef CONFIG_COMPAT | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 460 | .compat_ioctl	= xfs_file_compat_ioctl, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | #endif | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 462 | .mmap		= xfs_file_mmap, | 
|  | 463 | .open		= xfs_file_open, | 
| Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 464 | .flush		= xfs_file_close, | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 465 | .release	= xfs_file_release, | 
|  | 466 | .fsync		= xfs_file_fsync, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | #ifdef HAVE_FOP_OPEN_EXEC | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 468 | .open_exec	= xfs_file_open_exec, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | #endif | 
|  | 470 | }; | 
|  | 471 |  | 
| Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 472 | const struct file_operations xfs_invis_file_operations = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | .llseek		= generic_file_llseek, | 
|  | 474 | .read		= do_sync_read, | 
| Dean Roehrich | bb3f724 | 2005-09-02 15:43:05 +1000 | [diff] [blame] | 475 | .write		= do_sync_write, | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 476 | .aio_read	= xfs_file_aio_read_invis, | 
|  | 477 | .aio_write	= xfs_file_aio_write_invis, | 
| Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 478 | .sendfile	= xfs_file_sendfile_invis, | 
|  | 479 | .splice_read	= xfs_file_splice_read_invis, | 
|  | 480 | .splice_write	= xfs_file_splice_write_invis, | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 481 | .unlocked_ioctl	= xfs_file_ioctl_invis, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | #ifdef CONFIG_COMPAT | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 483 | .compat_ioctl	= xfs_file_compat_invis_ioctl, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | #endif | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 485 | .mmap		= xfs_file_mmap, | 
|  | 486 | .open		= xfs_file_open, | 
| Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 487 | .flush		= xfs_file_close, | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 488 | .release	= xfs_file_release, | 
|  | 489 | .fsync		= xfs_file_fsync, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | }; | 
|  | 491 |  | 
|  | 492 |  | 
| Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 493 | const struct file_operations xfs_dir_file_operations = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | .read		= generic_read_dir, | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 495 | .readdir	= xfs_file_readdir, | 
|  | 496 | .unlocked_ioctl	= xfs_file_ioctl, | 
| Nathan Scott | d387039 | 2005-05-06 06:44:46 -0700 | [diff] [blame] | 497 | #ifdef CONFIG_COMPAT | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 498 | .compat_ioctl	= xfs_file_compat_ioctl, | 
| Nathan Scott | d387039 | 2005-05-06 06:44:46 -0700 | [diff] [blame] | 499 | #endif | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 500 | .fsync		= xfs_file_fsync, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | }; | 
|  | 502 |  | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 503 | static struct vm_operations_struct xfs_file_vm_ops = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | .nopage		= filemap_nopage, | 
|  | 505 | .populate	= filemap_populate, | 
| Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 506 | }; | 
|  | 507 |  | 
|  | 508 | #ifdef CONFIG_XFS_DMAPI | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 509 | static struct vm_operations_struct xfs_dmapi_file_vm_ops = { | 
|  | 510 | .nopage		= xfs_vm_nopage, | 
| Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 511 | .populate	= filemap_populate, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | #ifdef HAVE_VMOP_MPROTECT | 
| Nathan Scott | 3562fd4 | 2006-03-14 14:00:35 +1100 | [diff] [blame] | 513 | .mprotect	= xfs_vm_mprotect, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | #endif | 
|  | 515 | }; | 
| Dean Roehrich | 6fac0cb | 2005-06-21 14:07:45 +1000 | [diff] [blame] | 516 | #endif /* CONFIG_XFS_DMAPI */ |