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