4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2011, Lawrence Livermore National Security, LLC.
23 * Copyright (c) 2015 by Chunwei Chen. All rights reserved.
28 #include <linux/compat.h>
30 #include <sys/dmu_objset.h>
31 #include <sys/zfs_vfsops.h>
32 #include <sys/zfs_vnops.h>
33 #include <sys/zfs_znode.h>
38 zpl_open(struct inode
*ip
, struct file
*filp
)
42 fstrans_cookie_t cookie
;
44 error
= generic_file_open(ip
, filp
);
49 cookie
= spl_fstrans_mark();
50 error
= -zfs_open(ip
, filp
->f_mode
, filp
->f_flags
, cr
);
51 spl_fstrans_unmark(cookie
);
53 ASSERT3S(error
, <=, 0);
59 zpl_release(struct inode
*ip
, struct file
*filp
)
63 fstrans_cookie_t cookie
;
65 cookie
= spl_fstrans_mark();
66 if (ITOZ(ip
)->z_atime_dirty
)
67 zfs_mark_inode_dirty(ip
);
70 error
= -zfs_close(ip
, filp
->f_flags
, cr
);
71 spl_fstrans_unmark(cookie
);
73 ASSERT3S(error
, <=, 0);
79 zpl_iterate(struct file
*filp
, struct dir_context
*ctx
)
81 struct dentry
*dentry
= filp
->f_path
.dentry
;
84 fstrans_cookie_t cookie
;
87 cookie
= spl_fstrans_mark();
88 error
= -zfs_readdir(dentry
->d_inode
, ctx
, cr
);
89 spl_fstrans_unmark(cookie
);
91 ASSERT3S(error
, <=, 0);
96 #if !defined(HAVE_VFS_ITERATE) && !defined(HAVE_VFS_ITERATE_SHARED)
98 zpl_readdir(struct file
*filp
, void *dirent
, filldir_t filldir
)
100 struct dir_context ctx
= DIR_CONTEXT_INIT(dirent
, filldir
, filp
->f_pos
);
103 error
= zpl_iterate(filp
, &ctx
);
104 filp
->f_pos
= ctx
.pos
;
108 #endif /* HAVE_VFS_ITERATE */
110 #if defined(HAVE_FSYNC_WITH_DENTRY)
112 * Linux 2.6.x - 2.6.34 API,
113 * Through 2.6.34 the nfsd kernel server would pass a NULL 'file struct *'
114 * to the fops->fsync() hook. For this reason, we must be careful not to
115 * use filp unconditionally.
118 zpl_fsync(struct file
*filp
, struct dentry
*dentry
, int datasync
)
122 fstrans_cookie_t cookie
;
125 cookie
= spl_fstrans_mark();
126 error
= -zfs_fsync(dentry
->d_inode
, datasync
, cr
);
127 spl_fstrans_unmark(cookie
);
129 ASSERT3S(error
, <=, 0);
134 #ifdef HAVE_FILE_AIO_FSYNC
136 zpl_aio_fsync(struct kiocb
*kiocb
, int datasync
)
138 struct file
*filp
= kiocb
->ki_filp
;
139 return (zpl_fsync(filp
, filp
->f_path
.dentry
, datasync
));
143 #elif defined(HAVE_FSYNC_WITHOUT_DENTRY)
145 * Linux 2.6.35 - 3.0 API,
146 * As of 2.6.35 the dentry argument to the fops->fsync() hook was deemed
147 * redundant. The dentry is still accessible via filp->f_path.dentry,
148 * and we are guaranteed that filp will never be NULL.
151 zpl_fsync(struct file
*filp
, int datasync
)
153 struct inode
*inode
= filp
->f_mapping
->host
;
156 fstrans_cookie_t cookie
;
159 cookie
= spl_fstrans_mark();
160 error
= -zfs_fsync(inode
, datasync
, cr
);
161 spl_fstrans_unmark(cookie
);
163 ASSERT3S(error
, <=, 0);
168 #ifdef HAVE_FILE_AIO_FSYNC
170 zpl_aio_fsync(struct kiocb
*kiocb
, int datasync
)
172 return (zpl_fsync(kiocb
->ki_filp
, datasync
));
176 #elif defined(HAVE_FSYNC_RANGE)
178 * Linux 3.1 - 3.x API,
179 * As of 3.1 the responsibility to call filemap_write_and_wait_range() has
180 * been pushed down in to the .fsync() vfs hook. Additionally, the i_mutex
181 * lock is no longer held by the caller, for zfs we don't require the lock
182 * to be held so we don't acquire it.
185 zpl_fsync(struct file
*filp
, loff_t start
, loff_t end
, int datasync
)
187 struct inode
*inode
= filp
->f_mapping
->host
;
190 fstrans_cookie_t cookie
;
192 error
= filemap_write_and_wait_range(inode
->i_mapping
, start
, end
);
197 cookie
= spl_fstrans_mark();
198 error
= -zfs_fsync(inode
, datasync
, cr
);
199 spl_fstrans_unmark(cookie
);
201 ASSERT3S(error
, <=, 0);
206 #ifdef HAVE_FILE_AIO_FSYNC
208 zpl_aio_fsync(struct kiocb
*kiocb
, int datasync
)
210 return (zpl_fsync(kiocb
->ki_filp
, kiocb
->ki_pos
, -1, datasync
));
215 #error "Unsupported fops->fsync() implementation"
219 zpl_read_common_iovec(struct inode
*ip
, const struct iovec
*iovp
, size_t count
,
220 unsigned long nr_segs
, loff_t
*ppos
, uio_seg_t segment
, int flags
,
221 cred_t
*cr
, size_t skip
)
226 fstrans_cookie_t cookie
;
230 uio
.uio_resid
= count
;
231 uio
.uio_iovcnt
= nr_segs
;
232 uio
.uio_loffset
= *ppos
;
233 uio
.uio_limit
= MAXOFFSET_T
;
234 uio
.uio_segflg
= segment
;
236 cookie
= spl_fstrans_mark();
237 error
= -zfs_read(ip
, &uio
, flags
, cr
);
238 spl_fstrans_unmark(cookie
);
242 read
= count
- uio
.uio_resid
;
244 task_io_account_read(read
);
250 zpl_read_common(struct inode
*ip
, const char *buf
, size_t len
, loff_t
*ppos
,
251 uio_seg_t segment
, int flags
, cred_t
*cr
)
255 iov
.iov_base
= (void *)buf
;
258 return (zpl_read_common_iovec(ip
, &iov
, len
, 1, ppos
, segment
,
263 zpl_iter_read_common(struct kiocb
*kiocb
, const struct iovec
*iovp
,
264 unsigned long nr_segs
, size_t count
, uio_seg_t seg
, size_t skip
)
267 struct file
*filp
= kiocb
->ki_filp
;
271 read
= zpl_read_common_iovec(filp
->f_mapping
->host
, iovp
, count
,
272 nr_segs
, &kiocb
->ki_pos
, seg
, filp
->f_flags
, cr
, skip
);
279 #if defined(HAVE_VFS_RW_ITERATE)
281 zpl_iter_read(struct kiocb
*kiocb
, struct iov_iter
*to
)
284 uio_seg_t seg
= UIO_USERSPACE
;
285 if (to
->type
& ITER_KVEC
)
287 if (to
->type
& ITER_BVEC
)
289 ret
= zpl_iter_read_common(kiocb
, to
->iov
, to
->nr_segs
,
290 iov_iter_count(to
), seg
, to
->iov_offset
);
292 iov_iter_advance(to
, ret
);
297 zpl_aio_read(struct kiocb
*kiocb
, const struct iovec
*iovp
,
298 unsigned long nr_segs
, loff_t pos
)
303 ret
= generic_segment_checks(iovp
, &nr_segs
, &count
, VERIFY_WRITE
);
307 return (zpl_iter_read_common(kiocb
, iovp
, nr_segs
, count
,
310 #endif /* HAVE_VFS_RW_ITERATE */
313 zpl_write_common_iovec(struct inode
*ip
, const struct iovec
*iovp
, size_t count
,
314 unsigned long nr_segs
, loff_t
*ppos
, uio_seg_t segment
, int flags
,
315 cred_t
*cr
, size_t skip
)
320 fstrans_cookie_t cookie
;
322 if (flags
& O_APPEND
)
323 *ppos
= i_size_read(ip
);
327 uio
.uio_resid
= count
;
328 uio
.uio_iovcnt
= nr_segs
;
329 uio
.uio_loffset
= *ppos
;
330 uio
.uio_limit
= MAXOFFSET_T
;
331 uio
.uio_segflg
= segment
;
333 cookie
= spl_fstrans_mark();
334 error
= -zfs_write(ip
, &uio
, flags
, cr
);
335 spl_fstrans_unmark(cookie
);
339 wrote
= count
- uio
.uio_resid
;
341 task_io_account_write(wrote
);
347 zpl_write_common(struct inode
*ip
, const char *buf
, size_t len
, loff_t
*ppos
,
348 uio_seg_t segment
, int flags
, cred_t
*cr
)
352 iov
.iov_base
= (void *)buf
;
355 return (zpl_write_common_iovec(ip
, &iov
, len
, 1, ppos
, segment
,
360 zpl_iter_write_common(struct kiocb
*kiocb
, const struct iovec
*iovp
,
361 unsigned long nr_segs
, size_t count
, uio_seg_t seg
, size_t skip
)
364 struct file
*filp
= kiocb
->ki_filp
;
368 wrote
= zpl_write_common_iovec(filp
->f_mapping
->host
, iovp
, count
,
369 nr_segs
, &kiocb
->ki_pos
, seg
, filp
->f_flags
, cr
, skip
);
375 #if defined(HAVE_VFS_RW_ITERATE)
377 zpl_iter_write(struct kiocb
*kiocb
, struct iov_iter
*from
)
381 uio_seg_t seg
= UIO_USERSPACE
;
383 #ifndef HAVE_GENERIC_WRITE_CHECKS_KIOCB
384 struct file
*file
= kiocb
->ki_filp
;
385 struct address_space
*mapping
= file
->f_mapping
;
386 struct inode
*ip
= mapping
->host
;
387 int isblk
= S_ISBLK(ip
->i_mode
);
389 count
= iov_iter_count(from
);
390 ret
= generic_write_checks(file
, &kiocb
->ki_pos
, &count
, isblk
);
395 * XXX - ideally this check should be in the same lock region with
396 * write operations, so that there's no TOCTTOU race when doing
397 * append and someone else grow the file.
399 ret
= generic_write_checks(kiocb
, from
);
405 if (from
->type
& ITER_KVEC
)
407 if (from
->type
& ITER_BVEC
)
410 ret
= zpl_iter_write_common(kiocb
, from
->iov
, from
->nr_segs
,
411 count
, seg
, from
->iov_offset
);
413 iov_iter_advance(from
, ret
);
419 zpl_aio_write(struct kiocb
*kiocb
, const struct iovec
*iovp
,
420 unsigned long nr_segs
, loff_t pos
)
422 struct file
*file
= kiocb
->ki_filp
;
423 struct address_space
*mapping
= file
->f_mapping
;
424 struct inode
*ip
= mapping
->host
;
425 int isblk
= S_ISBLK(ip
->i_mode
);
429 ret
= generic_segment_checks(iovp
, &nr_segs
, &count
, VERIFY_READ
);
433 ret
= generic_write_checks(file
, &pos
, &count
, isblk
);
437 return (zpl_iter_write_common(kiocb
, iovp
, nr_segs
, count
,
440 #endif /* HAVE_VFS_RW_ITERATE */
443 zpl_llseek(struct file
*filp
, loff_t offset
, int whence
)
445 #if defined(SEEK_HOLE) && defined(SEEK_DATA)
446 fstrans_cookie_t cookie
;
448 if (whence
== SEEK_DATA
|| whence
== SEEK_HOLE
) {
449 struct inode
*ip
= filp
->f_mapping
->host
;
450 loff_t maxbytes
= ip
->i_sb
->s_maxbytes
;
453 spl_inode_lock_shared(ip
);
454 cookie
= spl_fstrans_mark();
455 error
= -zfs_holey(ip
, whence
, &offset
);
456 spl_fstrans_unmark(cookie
);
458 error
= lseek_execute(filp
, ip
, offset
, maxbytes
);
459 spl_inode_unlock_shared(ip
);
463 #endif /* SEEK_HOLE && SEEK_DATA */
465 return (generic_file_llseek(filp
, offset
, whence
));
469 * It's worth taking a moment to describe how mmap is implemented
470 * for zfs because it differs considerably from other Linux filesystems.
471 * However, this issue is handled the same way under OpenSolaris.
473 * The issue is that by design zfs bypasses the Linux page cache and
474 * leaves all caching up to the ARC. This has been shown to work
475 * well for the common read(2)/write(2) case. However, mmap(2)
476 * is problem because it relies on being tightly integrated with the
477 * page cache. To handle this we cache mmap'ed files twice, once in
478 * the ARC and a second time in the page cache. The code is careful
479 * to keep both copies synchronized.
481 * When a file with an mmap'ed region is written to using write(2)
482 * both the data in the ARC and existing pages in the page cache
483 * are updated. For a read(2) data will be read first from the page
484 * cache then the ARC if needed. Neither a write(2) or read(2) will
485 * will ever result in new pages being added to the page cache.
487 * New pages are added to the page cache only via .readpage() which
488 * is called when the vfs needs to read a page off disk to back the
489 * virtual memory region. These pages may be modified without
490 * notifying the ARC and will be written out periodically via
491 * .writepage(). This will occur due to either a sync or the usual
492 * page aging behavior. Note because a read(2) of a mmap'ed file
493 * will always check the page cache first even when the ARC is out
494 * of date correct data will still be returned.
496 * While this implementation ensures correct behavior it does have
497 * have some drawbacks. The most obvious of which is that it
498 * increases the required memory footprint when access mmap'ed
499 * files. It also adds additional complexity to the code keeping
500 * both caches synchronized.
502 * Longer term it may be possible to cleanly resolve this wart by
503 * mapping page cache pages directly on to the ARC buffers. The
504 * Linux address space operations are flexible enough to allow
505 * selection of which pages back a particular index. The trick
506 * would be working out the details of which subsystem is in
507 * charge, the ARC, the page cache, or both. It may also prove
508 * helpful to move the ARC buffers to a scatter-gather lists
509 * rather than a vmalloc'ed region.
512 zpl_mmap(struct file
*filp
, struct vm_area_struct
*vma
)
514 struct inode
*ip
= filp
->f_mapping
->host
;
515 znode_t
*zp
= ITOZ(ip
);
517 fstrans_cookie_t cookie
;
519 cookie
= spl_fstrans_mark();
520 error
= -zfs_map(ip
, vma
->vm_pgoff
, (caddr_t
*)vma
->vm_start
,
521 (size_t)(vma
->vm_end
- vma
->vm_start
), vma
->vm_flags
);
522 spl_fstrans_unmark(cookie
);
526 error
= generic_file_mmap(filp
, vma
);
530 mutex_enter(&zp
->z_lock
);
532 mutex_exit(&zp
->z_lock
);
538 * Populate a page with data for the Linux page cache. This function is
539 * only used to support mmap(2). There will be an identical copy of the
540 * data in the ARC which is kept up to date via .write() and .writepage().
542 * Current this function relies on zpl_read_common() and the O_DIRECT
543 * flag to read in a page. This works but the more correct way is to
544 * update zfs_fillpage() to be Linux friendly and use that interface.
547 zpl_readpage(struct file
*filp
, struct page
*pp
)
552 fstrans_cookie_t cookie
;
554 ASSERT(PageLocked(pp
));
555 ip
= pp
->mapping
->host
;
558 cookie
= spl_fstrans_mark();
559 error
= -zfs_getpage(ip
, pl
, 1);
560 spl_fstrans_unmark(cookie
);
564 ClearPageUptodate(pp
);
568 flush_dcache_page(pp
);
576 * Populate a set of pages with data for the Linux page cache. This
577 * function will only be called for read ahead and never for demand
578 * paging. For simplicity, the code relies on read_cache_pages() to
579 * correctly lock each page for IO and call zpl_readpage().
582 zpl_readpages(struct file
*filp
, struct address_space
*mapping
,
583 struct list_head
*pages
, unsigned nr_pages
)
585 return (read_cache_pages(mapping
, pages
,
586 (filler_t
*)zpl_readpage
, filp
));
590 zpl_putpage(struct page
*pp
, struct writeback_control
*wbc
, void *data
)
592 struct address_space
*mapping
= data
;
593 fstrans_cookie_t cookie
;
595 ASSERT(PageLocked(pp
));
596 ASSERT(!PageWriteback(pp
));
598 cookie
= spl_fstrans_mark();
599 (void) zfs_putpage(mapping
->host
, pp
, wbc
);
600 spl_fstrans_unmark(cookie
);
606 zpl_writepages(struct address_space
*mapping
, struct writeback_control
*wbc
)
608 znode_t
*zp
= ITOZ(mapping
->host
);
609 zfs_sb_t
*zsb
= ITOZSB(mapping
->host
);
610 enum writeback_sync_modes sync_mode
;
614 if (zsb
->z_os
->os_sync
== ZFS_SYNC_ALWAYS
)
615 wbc
->sync_mode
= WB_SYNC_ALL
;
617 sync_mode
= wbc
->sync_mode
;
620 * We don't want to run write_cache_pages() in SYNC mode here, because
621 * that would make putpage() wait for a single page to be committed to
622 * disk every single time, resulting in atrocious performance. Instead
623 * we run it once in non-SYNC mode so that the ZIL gets all the data,
624 * and then we commit it all in one go.
626 wbc
->sync_mode
= WB_SYNC_NONE
;
627 result
= write_cache_pages(mapping
, wbc
, zpl_putpage
, mapping
);
628 if (sync_mode
!= wbc
->sync_mode
) {
631 if (zsb
->z_log
!= NULL
)
632 zil_commit(zsb
->z_log
, zp
->z_id
);
636 * We need to call write_cache_pages() again (we can't just
637 * return after the commit) because the previous call in
638 * non-SYNC mode does not guarantee that we got all the dirty
639 * pages (see the implementation of write_cache_pages() for
640 * details). That being said, this is a no-op in most cases.
642 wbc
->sync_mode
= sync_mode
;
643 result
= write_cache_pages(mapping
, wbc
, zpl_putpage
, mapping
);
649 * Write out dirty pages to the ARC, this function is only required to
650 * support mmap(2). Mapped pages may be dirtied by memory operations
651 * which never call .write(). These dirty pages are kept in sync with
652 * the ARC buffers via this hook.
655 zpl_writepage(struct page
*pp
, struct writeback_control
*wbc
)
657 if (ITOZSB(pp
->mapping
->host
)->z_os
->os_sync
== ZFS_SYNC_ALWAYS
)
658 wbc
->sync_mode
= WB_SYNC_ALL
;
660 return (zpl_putpage(pp
, wbc
, pp
->mapping
));
664 * The only flag combination which matches the behavior of zfs_space()
665 * is FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE. The FALLOC_FL_PUNCH_HOLE
666 * flag was introduced in the 2.6.38 kernel.
668 #if defined(HAVE_FILE_FALLOCATE) || defined(HAVE_INODE_FALLOCATE)
670 zpl_fallocate_common(struct inode
*ip
, int mode
, loff_t offset
, loff_t len
)
672 int error
= -EOPNOTSUPP
;
674 #if defined(FALLOC_FL_PUNCH_HOLE) && defined(FALLOC_FL_KEEP_SIZE)
678 fstrans_cookie_t cookie
;
680 if (mode
!= (FALLOC_FL_KEEP_SIZE
| FALLOC_FL_PUNCH_HOLE
))
683 if (offset
< 0 || len
<= 0)
687 olen
= i_size_read(ip
);
690 spl_inode_unlock(ip
);
693 if (offset
+ len
> olen
)
702 cookie
= spl_fstrans_mark();
703 error
= -zfs_space(ip
, F_FREESP
, &bf
, FWRITE
, offset
, cr
);
704 spl_fstrans_unmark(cookie
);
705 spl_inode_unlock(ip
);
708 #endif /* defined(FALLOC_FL_PUNCH_HOLE) && defined(FALLOC_FL_KEEP_SIZE) */
710 ASSERT3S(error
, <=, 0);
713 #endif /* defined(HAVE_FILE_FALLOCATE) || defined(HAVE_INODE_FALLOCATE) */
715 #ifdef HAVE_FILE_FALLOCATE
717 zpl_fallocate(struct file
*filp
, int mode
, loff_t offset
, loff_t len
)
719 return zpl_fallocate_common(filp
->f_path
.dentry
->d_inode
,
722 #endif /* HAVE_FILE_FALLOCATE */
725 * Map zfs file z_pflags (xvattr_t) to linux file attributes. Only file
726 * attributes common to both Linux and Solaris are mapped.
729 zpl_ioctl_getflags(struct file
*filp
, void __user
*arg
)
731 struct inode
*ip
= file_inode(filp
);
732 unsigned int ioctl_flags
= 0;
733 uint64_t zfs_flags
= ITOZ(ip
)->z_pflags
;
736 if (zfs_flags
& ZFS_IMMUTABLE
)
737 ioctl_flags
|= FS_IMMUTABLE_FL
;
739 if (zfs_flags
& ZFS_APPENDONLY
)
740 ioctl_flags
|= FS_APPEND_FL
;
742 if (zfs_flags
& ZFS_NODUMP
)
743 ioctl_flags
|= FS_NODUMP_FL
;
745 ioctl_flags
&= FS_FL_USER_VISIBLE
;
747 error
= copy_to_user(arg
, &ioctl_flags
, sizeof (ioctl_flags
));
753 * fchange() is a helper macro to detect if we have been asked to change a
754 * flag. This is ugly, but the requirement that we do this is a consequence of
755 * how the Linux file attribute interface was designed. Another consequence is
756 * that concurrent modification of files suffers from a TOCTOU race. Neither
757 * are things we can fix without modifying the kernel-userland interface, which
758 * is outside of our jurisdiction.
761 #define fchange(f0, f1, b0, b1) (!((f0) & (b0)) != !((f1) & (b1)))
764 zpl_ioctl_setflags(struct file
*filp
, void __user
*arg
)
766 struct inode
*ip
= file_inode(filp
);
767 uint64_t zfs_flags
= ITOZ(ip
)->z_pflags
;
768 unsigned int ioctl_flags
;
773 fstrans_cookie_t cookie
;
775 if (copy_from_user(&ioctl_flags
, arg
, sizeof (ioctl_flags
)))
778 if ((ioctl_flags
& ~(FS_IMMUTABLE_FL
| FS_APPEND_FL
| FS_NODUMP_FL
)))
779 return (-EOPNOTSUPP
);
781 if ((ioctl_flags
& ~(FS_FL_USER_MODIFIABLE
)))
784 if ((fchange(ioctl_flags
, zfs_flags
, FS_IMMUTABLE_FL
, ZFS_IMMUTABLE
) ||
785 fchange(ioctl_flags
, zfs_flags
, FS_APPEND_FL
, ZFS_APPENDONLY
)) &&
786 !capable(CAP_LINUX_IMMUTABLE
))
789 if (!zpl_inode_owner_or_capable(ip
))
793 xoap
= xva_getxoptattr(&xva
);
795 XVA_SET_REQ(&xva
, XAT_IMMUTABLE
);
796 if (ioctl_flags
& FS_IMMUTABLE_FL
)
797 xoap
->xoa_immutable
= B_TRUE
;
799 XVA_SET_REQ(&xva
, XAT_APPENDONLY
);
800 if (ioctl_flags
& FS_APPEND_FL
)
801 xoap
->xoa_appendonly
= B_TRUE
;
803 XVA_SET_REQ(&xva
, XAT_NODUMP
);
804 if (ioctl_flags
& FS_NODUMP_FL
)
805 xoap
->xoa_nodump
= B_TRUE
;
808 cookie
= spl_fstrans_mark();
809 error
= -zfs_setattr(ip
, (vattr_t
*)&xva
, 0, cr
);
810 spl_fstrans_unmark(cookie
);
817 zpl_ioctl(struct file
*filp
, unsigned int cmd
, unsigned long arg
)
820 case FS_IOC_GETFLAGS
:
821 return (zpl_ioctl_getflags(filp
, (void *)arg
));
822 case FS_IOC_SETFLAGS
:
823 return (zpl_ioctl_setflags(filp
, (void *)arg
));
831 zpl_compat_ioctl(struct file
*filp
, unsigned int cmd
, unsigned long arg
)
834 case FS_IOC32_GETFLAGS
:
835 cmd
= FS_IOC_GETFLAGS
;
837 case FS_IOC32_SETFLAGS
:
838 cmd
= FS_IOC_SETFLAGS
;
843 return (zpl_ioctl(filp
, cmd
, (unsigned long)compat_ptr(arg
)));
845 #endif /* CONFIG_COMPAT */
848 const struct address_space_operations zpl_address_space_operations
= {
849 .readpages
= zpl_readpages
,
850 .readpage
= zpl_readpage
,
851 .writepage
= zpl_writepage
,
852 .writepages
= zpl_writepages
,
855 const struct file_operations zpl_file_operations
= {
857 .release
= zpl_release
,
858 .llseek
= zpl_llseek
,
859 #ifdef HAVE_VFS_RW_ITERATE
860 #ifdef HAVE_NEW_SYNC_READ
861 .read
= new_sync_read
,
862 .write
= new_sync_write
,
864 .read_iter
= zpl_iter_read
,
865 .write_iter
= zpl_iter_write
,
867 .read
= do_sync_read
,
868 .write
= do_sync_write
,
869 .aio_read
= zpl_aio_read
,
870 .aio_write
= zpl_aio_write
,
874 #ifdef HAVE_FILE_AIO_FSYNC
875 .aio_fsync
= zpl_aio_fsync
,
877 #ifdef HAVE_FILE_FALLOCATE
878 .fallocate
= zpl_fallocate
,
879 #endif /* HAVE_FILE_FALLOCATE */
880 .unlocked_ioctl
= zpl_ioctl
,
882 .compat_ioctl
= zpl_compat_ioctl
,
886 const struct file_operations zpl_dir_file_operations
= {
887 .llseek
= generic_file_llseek
,
888 .read
= generic_read_dir
,
889 #ifdef HAVE_VFS_ITERATE_SHARED
890 .iterate_shared
= zpl_iterate
,
891 #elif defined(HAVE_VFS_ITERATE)
892 .iterate
= zpl_iterate
,
894 .readdir
= zpl_readdir
,
897 .unlocked_ioctl
= zpl_ioctl
,
899 .compat_ioctl
= zpl_compat_ioctl
,