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