]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - fs/ext4/file.c
Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-focal-kernel.git] / fs / ext4 / file.c
1 /*
2 * linux/fs/ext4/file.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/fs/minix/file.c
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 *
15 * ext4 fs regular file handling primitives
16 *
17 * 64-bit file support on 64-bit platforms by Jakub Jelinek
18 * (jj@sunsite.ms.mff.cuni.cz)
19 */
20
21 #include <linux/time.h>
22 #include <linux/fs.h>
23 #include <linux/mount.h>
24 #include <linux/path.h>
25 #include <linux/dax.h>
26 #include <linux/quotaops.h>
27 #include <linux/pagevec.h>
28 #include <linux/uio.h>
29 #include "ext4.h"
30 #include "ext4_jbd2.h"
31 #include "xattr.h"
32 #include "acl.h"
33
34 #ifdef CONFIG_FS_DAX
35 static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)
36 {
37 struct inode *inode = file_inode(iocb->ki_filp);
38 ssize_t ret;
39
40 if (!inode_trylock_shared(inode)) {
41 if (iocb->ki_flags & IOCB_NOWAIT)
42 return -EAGAIN;
43 inode_lock_shared(inode);
44 }
45 /*
46 * Recheck under inode lock - at this point we are sure it cannot
47 * change anymore
48 */
49 if (!IS_DAX(inode)) {
50 inode_unlock_shared(inode);
51 /* Fallback to buffered IO in case we cannot support DAX */
52 return generic_file_read_iter(iocb, to);
53 }
54 ret = dax_iomap_rw(iocb, to, &ext4_iomap_ops);
55 inode_unlock_shared(inode);
56
57 file_accessed(iocb->ki_filp);
58 return ret;
59 }
60 #endif
61
62 static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
63 {
64 if (unlikely(ext4_forced_shutdown(EXT4_SB(file_inode(iocb->ki_filp)->i_sb))))
65 return -EIO;
66
67 if (!iov_iter_count(to))
68 return 0; /* skip atime */
69
70 #ifdef CONFIG_FS_DAX
71 if (IS_DAX(file_inode(iocb->ki_filp)))
72 return ext4_dax_read_iter(iocb, to);
73 #endif
74 return generic_file_read_iter(iocb, to);
75 }
76
77 /*
78 * Called when an inode is released. Note that this is different
79 * from ext4_file_open: open gets called at every open, but release
80 * gets called only when /all/ the files are closed.
81 */
82 static int ext4_release_file(struct inode *inode, struct file *filp)
83 {
84 if (ext4_test_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE)) {
85 ext4_alloc_da_blocks(inode);
86 ext4_clear_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
87 }
88 /* if we are the last writer on the inode, drop the block reservation */
89 if ((filp->f_mode & FMODE_WRITE) &&
90 (atomic_read(&inode->i_writecount) == 1) &&
91 !EXT4_I(inode)->i_reserved_data_blocks)
92 {
93 down_write(&EXT4_I(inode)->i_data_sem);
94 ext4_discard_preallocations(inode);
95 up_write(&EXT4_I(inode)->i_data_sem);
96 }
97 if (is_dx(inode) && filp->private_data)
98 ext4_htree_free_dir_info(filp->private_data);
99
100 return 0;
101 }
102
103 static void ext4_unwritten_wait(struct inode *inode)
104 {
105 wait_queue_head_t *wq = ext4_ioend_wq(inode);
106
107 wait_event(*wq, (atomic_read(&EXT4_I(inode)->i_unwritten) == 0));
108 }
109
110 /*
111 * This tests whether the IO in question is block-aligned or not.
112 * Ext4 utilizes unwritten extents when hole-filling during direct IO, and they
113 * are converted to written only after the IO is complete. Until they are
114 * mapped, these blocks appear as holes, so dio_zero_block() will assume that
115 * it needs to zero out portions of the start and/or end block. If 2 AIO
116 * threads are at work on the same unwritten block, they must be synchronized
117 * or one thread will zero the other's data, causing corruption.
118 */
119 static int
120 ext4_unaligned_aio(struct inode *inode, struct iov_iter *from, loff_t pos)
121 {
122 struct super_block *sb = inode->i_sb;
123 int blockmask = sb->s_blocksize - 1;
124
125 if (pos >= i_size_read(inode))
126 return 0;
127
128 if ((pos | iov_iter_alignment(from)) & blockmask)
129 return 1;
130
131 return 0;
132 }
133
134 /* Is IO overwriting allocated and initialized blocks? */
135 static bool ext4_overwrite_io(struct inode *inode, loff_t pos, loff_t len)
136 {
137 struct ext4_map_blocks map;
138 unsigned int blkbits = inode->i_blkbits;
139 int err, blklen;
140
141 if (pos + len > i_size_read(inode))
142 return false;
143
144 map.m_lblk = pos >> blkbits;
145 map.m_len = EXT4_MAX_BLOCKS(len, pos, blkbits);
146 blklen = map.m_len;
147
148 err = ext4_map_blocks(NULL, inode, &map, 0);
149 /*
150 * 'err==len' means that all of the blocks have been preallocated,
151 * regardless of whether they have been initialized or not. To exclude
152 * unwritten extents, we need to check m_flags.
153 */
154 return err == blklen && (map.m_flags & EXT4_MAP_MAPPED);
155 }
156
157 static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *from)
158 {
159 struct inode *inode = file_inode(iocb->ki_filp);
160 ssize_t ret;
161
162 ret = generic_write_checks(iocb, from);
163 if (ret <= 0)
164 return ret;
165 /*
166 * If we have encountered a bitmap-format file, the size limit
167 * is smaller than s_maxbytes, which is for extent-mapped files.
168 */
169 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
170 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
171
172 if (iocb->ki_pos >= sbi->s_bitmap_maxbytes)
173 return -EFBIG;
174 iov_iter_truncate(from, sbi->s_bitmap_maxbytes - iocb->ki_pos);
175 }
176 return iov_iter_count(from);
177 }
178
179 #ifdef CONFIG_FS_DAX
180 static ssize_t
181 ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)
182 {
183 struct inode *inode = file_inode(iocb->ki_filp);
184 ssize_t ret;
185
186 if (!inode_trylock(inode)) {
187 if (iocb->ki_flags & IOCB_NOWAIT)
188 return -EAGAIN;
189 inode_lock(inode);
190 }
191 ret = ext4_write_checks(iocb, from);
192 if (ret <= 0)
193 goto out;
194 ret = file_remove_privs(iocb->ki_filp);
195 if (ret)
196 goto out;
197 ret = file_update_time(iocb->ki_filp);
198 if (ret)
199 goto out;
200
201 ret = dax_iomap_rw(iocb, from, &ext4_iomap_ops);
202 out:
203 inode_unlock(inode);
204 if (ret > 0)
205 ret = generic_write_sync(iocb, ret);
206 return ret;
207 }
208 #endif
209
210 static ssize_t
211 ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
212 {
213 struct inode *inode = file_inode(iocb->ki_filp);
214 int o_direct = iocb->ki_flags & IOCB_DIRECT;
215 int unaligned_aio = 0;
216 int overwrite = 0;
217 ssize_t ret;
218
219 if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
220 return -EIO;
221
222 #ifdef CONFIG_FS_DAX
223 if (IS_DAX(inode))
224 return ext4_dax_write_iter(iocb, from);
225 #endif
226
227 if (!inode_trylock(inode)) {
228 if (iocb->ki_flags & IOCB_NOWAIT)
229 return -EAGAIN;
230 inode_lock(inode);
231 }
232
233 ret = ext4_write_checks(iocb, from);
234 if (ret <= 0)
235 goto out;
236
237 /*
238 * Unaligned direct AIO must be serialized among each other as zeroing
239 * of partial blocks of two competing unaligned AIOs can result in data
240 * corruption.
241 */
242 if (o_direct && ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS) &&
243 !is_sync_kiocb(iocb) &&
244 ext4_unaligned_aio(inode, from, iocb->ki_pos)) {
245 unaligned_aio = 1;
246 ext4_unwritten_wait(inode);
247 }
248
249 iocb->private = &overwrite;
250 /* Check whether we do a DIO overwrite or not */
251 if (o_direct && !unaligned_aio) {
252 if (ext4_overwrite_io(inode, iocb->ki_pos, iov_iter_count(from))) {
253 if (ext4_should_dioread_nolock(inode))
254 overwrite = 1;
255 } else if (iocb->ki_flags & IOCB_NOWAIT) {
256 ret = -EAGAIN;
257 goto out;
258 }
259 }
260
261 ret = __generic_file_write_iter(iocb, from);
262 inode_unlock(inode);
263
264 if (ret > 0)
265 ret = generic_write_sync(iocb, ret);
266
267 return ret;
268
269 out:
270 inode_unlock(inode);
271 return ret;
272 }
273
274 #ifdef CONFIG_FS_DAX
275 static int ext4_dax_huge_fault(struct vm_fault *vmf,
276 enum page_entry_size pe_size)
277 {
278 int result;
279 handle_t *handle = NULL;
280 struct inode *inode = file_inode(vmf->vma->vm_file);
281 struct super_block *sb = inode->i_sb;
282
283 /*
284 * We have to distinguish real writes from writes which will result in a
285 * COW page; COW writes should *not* poke the journal (the file will not
286 * be changed). Doing so would cause unintended failures when mounted
287 * read-only.
288 *
289 * We check for VM_SHARED rather than vmf->cow_page since the latter is
290 * unset for pe_size != PE_SIZE_PTE (i.e. only in do_cow_fault); for
291 * other sizes, dax_iomap_fault will handle splitting / fallback so that
292 * we eventually come back with a COW page.
293 */
294 bool write = (vmf->flags & FAULT_FLAG_WRITE) &&
295 (vmf->vma->vm_flags & VM_SHARED);
296
297 if (write) {
298 sb_start_pagefault(sb);
299 file_update_time(vmf->vma->vm_file);
300 down_read(&EXT4_I(inode)->i_mmap_sem);
301 handle = ext4_journal_start_sb(sb, EXT4_HT_WRITE_PAGE,
302 EXT4_DATA_TRANS_BLOCKS(sb));
303 } else {
304 down_read(&EXT4_I(inode)->i_mmap_sem);
305 }
306 if (!IS_ERR(handle))
307 result = dax_iomap_fault(vmf, pe_size, &ext4_iomap_ops);
308 else
309 result = VM_FAULT_SIGBUS;
310 if (write) {
311 if (!IS_ERR(handle))
312 ext4_journal_stop(handle);
313 up_read(&EXT4_I(inode)->i_mmap_sem);
314 sb_end_pagefault(sb);
315 } else {
316 up_read(&EXT4_I(inode)->i_mmap_sem);
317 }
318
319 return result;
320 }
321
322 static int ext4_dax_fault(struct vm_fault *vmf)
323 {
324 return ext4_dax_huge_fault(vmf, PE_SIZE_PTE);
325 }
326
327 static const struct vm_operations_struct ext4_dax_vm_ops = {
328 .fault = ext4_dax_fault,
329 .huge_fault = ext4_dax_huge_fault,
330 .page_mkwrite = ext4_dax_fault,
331 .pfn_mkwrite = ext4_dax_fault,
332 };
333 #else
334 #define ext4_dax_vm_ops ext4_file_vm_ops
335 #endif
336
337 static const struct vm_operations_struct ext4_file_vm_ops = {
338 .fault = ext4_filemap_fault,
339 .map_pages = filemap_map_pages,
340 .page_mkwrite = ext4_page_mkwrite,
341 };
342
343 static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
344 {
345 struct inode *inode = file->f_mapping->host;
346
347 if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
348 return -EIO;
349
350 file_accessed(file);
351 if (IS_DAX(file_inode(file))) {
352 vma->vm_ops = &ext4_dax_vm_ops;
353 vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE;
354 } else {
355 vma->vm_ops = &ext4_file_vm_ops;
356 }
357 return 0;
358 }
359
360 static int ext4_file_open(struct inode * inode, struct file * filp)
361 {
362 struct super_block *sb = inode->i_sb;
363 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
364 struct vfsmount *mnt = filp->f_path.mnt;
365 struct dentry *dir;
366 struct path path;
367 char buf[64], *cp;
368 int ret;
369
370 if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
371 return -EIO;
372
373 if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED) &&
374 !(sb->s_flags & MS_RDONLY))) {
375 sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED;
376 /*
377 * Sample where the filesystem has been mounted and
378 * store it in the superblock for sysadmin convenience
379 * when trying to sort through large numbers of block
380 * devices or filesystem images.
381 */
382 memset(buf, 0, sizeof(buf));
383 path.mnt = mnt;
384 path.dentry = mnt->mnt_root;
385 cp = d_path(&path, buf, sizeof(buf));
386 if (!IS_ERR(cp)) {
387 handle_t *handle;
388 int err;
389
390 handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1);
391 if (IS_ERR(handle))
392 return PTR_ERR(handle);
393 BUFFER_TRACE(sbi->s_sbh, "get_write_access");
394 err = ext4_journal_get_write_access(handle, sbi->s_sbh);
395 if (err) {
396 ext4_journal_stop(handle);
397 return err;
398 }
399 strlcpy(sbi->s_es->s_last_mounted, cp,
400 sizeof(sbi->s_es->s_last_mounted));
401 ext4_handle_dirty_super(handle, sb);
402 ext4_journal_stop(handle);
403 }
404 }
405 if (ext4_encrypted_inode(inode)) {
406 ret = fscrypt_get_encryption_info(inode);
407 if (ret)
408 return -EACCES;
409 if (!fscrypt_has_encryption_key(inode))
410 return -ENOKEY;
411 }
412
413 dir = dget_parent(file_dentry(filp));
414 if (ext4_encrypted_inode(d_inode(dir)) &&
415 !fscrypt_has_permitted_context(d_inode(dir), inode)) {
416 ext4_warning(inode->i_sb,
417 "Inconsistent encryption contexts: %lu/%lu",
418 (unsigned long) d_inode(dir)->i_ino,
419 (unsigned long) inode->i_ino);
420 dput(dir);
421 return -EPERM;
422 }
423 dput(dir);
424 /*
425 * Set up the jbd2_inode if we are opening the inode for
426 * writing and the journal is present
427 */
428 if (filp->f_mode & FMODE_WRITE) {
429 ret = ext4_inode_attach_jinode(inode);
430 if (ret < 0)
431 return ret;
432 }
433
434 /* Set the flags to support nowait AIO */
435 filp->f_mode |= FMODE_AIO_NOWAIT;
436
437 return dquot_file_open(inode, filp);
438 }
439
440 /*
441 * Here we use ext4_map_blocks() to get a block mapping for a extent-based
442 * file rather than ext4_ext_walk_space() because we can introduce
443 * SEEK_DATA/SEEK_HOLE for block-mapped and extent-mapped file at the same
444 * function. When extent status tree has been fully implemented, it will
445 * track all extent status for a file and we can directly use it to
446 * retrieve the offset for SEEK_DATA/SEEK_HOLE.
447 */
448
449 /*
450 * When we retrieve the offset for SEEK_DATA/SEEK_HOLE, we would need to
451 * lookup page cache to check whether or not there has some data between
452 * [startoff, endoff] because, if this range contains an unwritten extent,
453 * we determine this extent as a data or a hole according to whether the
454 * page cache has data or not.
455 */
456 static int ext4_find_unwritten_pgoff(struct inode *inode,
457 int whence,
458 ext4_lblk_t end_blk,
459 loff_t *offset)
460 {
461 struct pagevec pvec;
462 unsigned int blkbits;
463 pgoff_t index;
464 pgoff_t end;
465 loff_t endoff;
466 loff_t startoff;
467 loff_t lastoff;
468 int found = 0;
469
470 blkbits = inode->i_sb->s_blocksize_bits;
471 startoff = *offset;
472 lastoff = startoff;
473 endoff = (loff_t)end_blk << blkbits;
474
475 index = startoff >> PAGE_SHIFT;
476 end = (endoff - 1) >> PAGE_SHIFT;
477
478 pagevec_init(&pvec, 0);
479 do {
480 int i;
481 unsigned long nr_pages;
482
483 nr_pages = pagevec_lookup_range(&pvec, inode->i_mapping,
484 &index, end);
485 if (nr_pages == 0)
486 break;
487
488 for (i = 0; i < nr_pages; i++) {
489 struct page *page = pvec.pages[i];
490 struct buffer_head *bh, *head;
491
492 /*
493 * If current offset is smaller than the page offset,
494 * there is a hole at this offset.
495 */
496 if (whence == SEEK_HOLE && lastoff < endoff &&
497 lastoff < page_offset(pvec.pages[i])) {
498 found = 1;
499 *offset = lastoff;
500 goto out;
501 }
502
503 lock_page(page);
504
505 if (unlikely(page->mapping != inode->i_mapping)) {
506 unlock_page(page);
507 continue;
508 }
509
510 if (!page_has_buffers(page)) {
511 unlock_page(page);
512 continue;
513 }
514
515 if (page_has_buffers(page)) {
516 lastoff = page_offset(page);
517 bh = head = page_buffers(page);
518 do {
519 if (lastoff + bh->b_size <= startoff)
520 goto next;
521 if (buffer_uptodate(bh) ||
522 buffer_unwritten(bh)) {
523 if (whence == SEEK_DATA)
524 found = 1;
525 } else {
526 if (whence == SEEK_HOLE)
527 found = 1;
528 }
529 if (found) {
530 *offset = max_t(loff_t,
531 startoff, lastoff);
532 unlock_page(page);
533 goto out;
534 }
535 next:
536 lastoff += bh->b_size;
537 bh = bh->b_this_page;
538 } while (bh != head);
539 }
540
541 lastoff = page_offset(page) + PAGE_SIZE;
542 unlock_page(page);
543 }
544
545 pagevec_release(&pvec);
546 } while (index <= end);
547
548 /* There are no pages upto endoff - that would be a hole in there. */
549 if (whence == SEEK_HOLE && lastoff < endoff) {
550 found = 1;
551 *offset = lastoff;
552 }
553 out:
554 pagevec_release(&pvec);
555 return found;
556 }
557
558 /*
559 * ext4_seek_data() retrieves the offset for SEEK_DATA.
560 */
561 static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
562 {
563 struct inode *inode = file->f_mapping->host;
564 struct extent_status es;
565 ext4_lblk_t start, last, end;
566 loff_t dataoff, isize;
567 int blkbits;
568 int ret;
569
570 inode_lock(inode);
571
572 isize = i_size_read(inode);
573 if (offset < 0 || offset >= isize) {
574 inode_unlock(inode);
575 return -ENXIO;
576 }
577
578 blkbits = inode->i_sb->s_blocksize_bits;
579 start = offset >> blkbits;
580 last = start;
581 end = isize >> blkbits;
582 dataoff = offset;
583
584 do {
585 ret = ext4_get_next_extent(inode, last, end - last + 1, &es);
586 if (ret <= 0) {
587 /* No extent found -> no data */
588 if (ret == 0)
589 ret = -ENXIO;
590 inode_unlock(inode);
591 return ret;
592 }
593
594 last = es.es_lblk;
595 if (last != start)
596 dataoff = (loff_t)last << blkbits;
597 if (!ext4_es_is_unwritten(&es))
598 break;
599
600 /*
601 * If there is a unwritten extent at this offset,
602 * it will be as a data or a hole according to page
603 * cache that has data or not.
604 */
605 if (ext4_find_unwritten_pgoff(inode, SEEK_DATA,
606 es.es_lblk + es.es_len, &dataoff))
607 break;
608 last += es.es_len;
609 dataoff = (loff_t)last << blkbits;
610 cond_resched();
611 } while (last <= end);
612
613 inode_unlock(inode);
614
615 if (dataoff > isize)
616 return -ENXIO;
617
618 return vfs_setpos(file, dataoff, maxsize);
619 }
620
621 /*
622 * ext4_seek_hole() retrieves the offset for SEEK_HOLE.
623 */
624 static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)
625 {
626 struct inode *inode = file->f_mapping->host;
627 struct extent_status es;
628 ext4_lblk_t start, last, end;
629 loff_t holeoff, isize;
630 int blkbits;
631 int ret;
632
633 inode_lock(inode);
634
635 isize = i_size_read(inode);
636 if (offset < 0 || offset >= isize) {
637 inode_unlock(inode);
638 return -ENXIO;
639 }
640
641 blkbits = inode->i_sb->s_blocksize_bits;
642 start = offset >> blkbits;
643 last = start;
644 end = isize >> blkbits;
645 holeoff = offset;
646
647 do {
648 ret = ext4_get_next_extent(inode, last, end - last + 1, &es);
649 if (ret < 0) {
650 inode_unlock(inode);
651 return ret;
652 }
653 /* Found a hole? */
654 if (ret == 0 || es.es_lblk > last) {
655 if (last != start)
656 holeoff = (loff_t)last << blkbits;
657 break;
658 }
659 /*
660 * If there is a unwritten extent at this offset,
661 * it will be as a data or a hole according to page
662 * cache that has data or not.
663 */
664 if (ext4_es_is_unwritten(&es) &&
665 ext4_find_unwritten_pgoff(inode, SEEK_HOLE,
666 last + es.es_len, &holeoff))
667 break;
668
669 last += es.es_len;
670 holeoff = (loff_t)last << blkbits;
671 cond_resched();
672 } while (last <= end);
673
674 inode_unlock(inode);
675
676 if (holeoff > isize)
677 holeoff = isize;
678
679 return vfs_setpos(file, holeoff, maxsize);
680 }
681
682 /*
683 * ext4_llseek() handles both block-mapped and extent-mapped maxbytes values
684 * by calling generic_file_llseek_size() with the appropriate maxbytes
685 * value for each.
686 */
687 loff_t ext4_llseek(struct file *file, loff_t offset, int whence)
688 {
689 struct inode *inode = file->f_mapping->host;
690 loff_t maxbytes;
691
692 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
693 maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes;
694 else
695 maxbytes = inode->i_sb->s_maxbytes;
696
697 switch (whence) {
698 case SEEK_SET:
699 case SEEK_CUR:
700 case SEEK_END:
701 return generic_file_llseek_size(file, offset, whence,
702 maxbytes, i_size_read(inode));
703 case SEEK_DATA:
704 return ext4_seek_data(file, offset, maxbytes);
705 case SEEK_HOLE:
706 return ext4_seek_hole(file, offset, maxbytes);
707 }
708
709 return -EINVAL;
710 }
711
712 const struct file_operations ext4_file_operations = {
713 .llseek = ext4_llseek,
714 .read_iter = ext4_file_read_iter,
715 .write_iter = ext4_file_write_iter,
716 .unlocked_ioctl = ext4_ioctl,
717 #ifdef CONFIG_COMPAT
718 .compat_ioctl = ext4_compat_ioctl,
719 #endif
720 .mmap = ext4_file_mmap,
721 .open = ext4_file_open,
722 .release = ext4_release_file,
723 .fsync = ext4_sync_file,
724 .get_unmapped_area = thp_get_unmapped_area,
725 .splice_read = generic_file_splice_read,
726 .splice_write = iter_file_splice_write,
727 .fallocate = ext4_fallocate,
728 };
729
730 const struct inode_operations ext4_file_inode_operations = {
731 .setattr = ext4_setattr,
732 .getattr = ext4_file_getattr,
733 .listxattr = ext4_listxattr,
734 .get_acl = ext4_get_acl,
735 .set_acl = ext4_set_acl,
736 .fiemap = ext4_fiemap,
737 };
738