.. | .. |
---|
27 | 27 | #include <linux/seqlock.h> |
---|
28 | 28 | #include <linux/mutex.h> |
---|
29 | 29 | #include <linux/timer.h> |
---|
30 | | -#include <linux/version.h> |
---|
31 | 30 | #include <linux/wait.h> |
---|
32 | 31 | #include <linux/sched/signal.h> |
---|
33 | 32 | #include <linux/blockgroup_lock.h> |
---|
.. | .. |
---|
36 | 35 | #include <crypto/hash.h> |
---|
37 | 36 | #include <linux/falloc.h> |
---|
38 | 37 | #include <linux/percpu-rwsem.h> |
---|
| 38 | +#include <linux/fiemap.h> |
---|
39 | 39 | #ifdef __KERNEL__ |
---|
40 | 40 | #include <linux/compat.h> |
---|
41 | 41 | #endif |
---|
.. | .. |
---|
44 | 44 | #include <linux/fsverity.h> |
---|
45 | 45 | |
---|
46 | 46 | #include <linux/compiler.h> |
---|
47 | | - |
---|
48 | | -/* Until this gets included into linux/compiler-gcc.h */ |
---|
49 | | -#ifndef __nonstring |
---|
50 | | -#if defined(GCC_VERSION) && (GCC_VERSION >= 80000) |
---|
51 | | -#define __nonstring __attribute__((nonstring)) |
---|
52 | | -#else |
---|
53 | | -#define __nonstring |
---|
54 | | -#endif |
---|
55 | | -#endif |
---|
56 | 47 | |
---|
57 | 48 | /* |
---|
58 | 49 | * The fourth extended filesystem constants/structures |
---|
.. | .. |
---|
89 | 80 | #define ext4_debug(fmt, ...) no_printk(fmt, ##__VA_ARGS__) |
---|
90 | 81 | #endif |
---|
91 | 82 | |
---|
92 | | -/* |
---|
93 | | - * Turn on EXT_DEBUG to get lots of info about extents operations. |
---|
94 | | - */ |
---|
| 83 | + /* |
---|
| 84 | + * Turn on EXT_DEBUG to enable ext4_ext_show_path/leaf/move in extents.c |
---|
| 85 | + */ |
---|
95 | 86 | #define EXT_DEBUG__ |
---|
96 | | -#ifdef EXT_DEBUG |
---|
97 | | -#define ext_debug(fmt, ...) printk(fmt, ##__VA_ARGS__) |
---|
| 87 | + |
---|
| 88 | +/* |
---|
| 89 | + * Dynamic printk for controlled extents debugging. |
---|
| 90 | + */ |
---|
| 91 | +#ifdef CONFIG_EXT4_DEBUG |
---|
| 92 | +#define ext_debug(ino, fmt, ...) \ |
---|
| 93 | + pr_debug("[%s/%d] EXT4-fs (%s): ino %lu: (%s, %d): %s:" fmt, \ |
---|
| 94 | + current->comm, task_pid_nr(current), \ |
---|
| 95 | + ino->i_sb->s_id, ino->i_ino, __FILE__, __LINE__, \ |
---|
| 96 | + __func__, ##__VA_ARGS__) |
---|
98 | 97 | #else |
---|
99 | | -#define ext_debug(fmt, ...) no_printk(fmt, ##__VA_ARGS__) |
---|
| 98 | +#define ext_debug(ino, fmt, ...) no_printk(fmt, ##__VA_ARGS__) |
---|
100 | 99 | #endif |
---|
101 | 100 | |
---|
102 | 101 | /* data type for block offset of block group */ |
---|
.. | .. |
---|
151 | 150 | #define EXT4_MB_USE_ROOT_BLOCKS 0x1000 |
---|
152 | 151 | /* Use blocks from reserved pool */ |
---|
153 | 152 | #define EXT4_MB_USE_RESERVED 0x2000 |
---|
| 153 | +/* Do strict check for free blocks while retrying block allocation */ |
---|
| 154 | +#define EXT4_MB_STRICT_CHECK 0x4000 |
---|
154 | 155 | |
---|
155 | 156 | struct ext4_allocation_request { |
---|
156 | 157 | /* target inode for block we're allocating */ |
---|
.. | .. |
---|
180 | 181 | * well as to store the information returned by ext4_map_blocks(). It |
---|
181 | 182 | * takes less room on the stack than a struct buffer_head. |
---|
182 | 183 | */ |
---|
183 | | -#define EXT4_MAP_NEW (1 << BH_New) |
---|
184 | | -#define EXT4_MAP_MAPPED (1 << BH_Mapped) |
---|
185 | | -#define EXT4_MAP_UNWRITTEN (1 << BH_Unwritten) |
---|
186 | | -#define EXT4_MAP_BOUNDARY (1 << BH_Boundary) |
---|
| 184 | +#define EXT4_MAP_NEW BIT(BH_New) |
---|
| 185 | +#define EXT4_MAP_MAPPED BIT(BH_Mapped) |
---|
| 186 | +#define EXT4_MAP_UNWRITTEN BIT(BH_Unwritten) |
---|
| 187 | +#define EXT4_MAP_BOUNDARY BIT(BH_Boundary) |
---|
187 | 188 | #define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\ |
---|
188 | 189 | EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY) |
---|
189 | 190 | |
---|
.. | .. |
---|
207 | 208 | */ |
---|
208 | 209 | #define EXT4_IO_END_UNWRITTEN 0x0001 |
---|
209 | 210 | |
---|
| 211 | +struct ext4_io_end_vec { |
---|
| 212 | + struct list_head list; /* list of io_end_vec */ |
---|
| 213 | + loff_t offset; /* offset in the file */ |
---|
| 214 | + ssize_t size; /* size of the extent */ |
---|
| 215 | +}; |
---|
| 216 | + |
---|
210 | 217 | /* |
---|
211 | 218 | * For converting unwritten extents on a work queue. 'handle' is used for |
---|
212 | 219 | * buffered writeback. |
---|
.. | .. |
---|
220 | 227 | * bios covering the extent */ |
---|
221 | 228 | unsigned int flag; /* unwritten or not */ |
---|
222 | 229 | atomic_t count; /* reference counter */ |
---|
223 | | - loff_t offset; /* offset in the file */ |
---|
224 | | - ssize_t size; /* size of the extent */ |
---|
| 230 | + struct list_head list_vec; /* list of ext4_io_end_vec */ |
---|
225 | 231 | } ext4_io_end_t; |
---|
226 | 232 | |
---|
227 | 233 | struct ext4_io_submit { |
---|
.. | .. |
---|
302 | 308 | ~((ext4_fsblk_t) (s)->s_cluster_ratio - 1)) |
---|
303 | 309 | #define EXT4_LBLK_CMASK(s, lblk) ((lblk) & \ |
---|
304 | 310 | ~((ext4_lblk_t) (s)->s_cluster_ratio - 1)) |
---|
| 311 | +/* Fill in the low bits to get the last block of the cluster */ |
---|
| 312 | +#define EXT4_LBLK_CFILL(sbi, lblk) ((lblk) | \ |
---|
| 313 | + ((ext4_lblk_t) (sbi)->s_cluster_ratio - 1)) |
---|
305 | 314 | /* Get the cluster offset */ |
---|
306 | 315 | #define EXT4_PBLK_COFF(s, pblk) ((pblk) & \ |
---|
307 | 316 | ((ext4_fsblk_t) (s)->s_cluster_ratio - 1)) |
---|
.. | .. |
---|
415 | 424 | #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */ |
---|
416 | 425 | #define EXT4_VERITY_FL 0x00100000 /* Verity protected inode */ |
---|
417 | 426 | #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */ |
---|
418 | | -#define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */ |
---|
| 427 | +/* 0x00400000 was formerly EXT4_EOFBLOCKS_FL */ |
---|
| 428 | + |
---|
| 429 | +#define EXT4_DAX_FL 0x02000000 /* Inode is DAX */ |
---|
| 430 | + |
---|
419 | 431 | #define EXT4_INLINE_DATA_FL 0x10000000 /* Inode has inline data. */ |
---|
420 | 432 | #define EXT4_PROJINHERIT_FL 0x20000000 /* Create with parents projid */ |
---|
421 | | -#define EXT4_CASEFOLD_FL 0x40000000 /* Casefolded file */ |
---|
| 433 | +#define EXT4_CASEFOLD_FL 0x40000000 /* Casefolded directory */ |
---|
422 | 434 | #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */ |
---|
423 | 435 | |
---|
424 | | -#define EXT4_FL_USER_VISIBLE 0x705BDFFF /* User visible flags */ |
---|
425 | | -#define EXT4_FL_USER_MODIFIABLE 0x604BC0FF /* User modifiable flags */ |
---|
| 436 | +/* User modifiable flags */ |
---|
| 437 | +#define EXT4_FL_USER_MODIFIABLE (EXT4_SECRM_FL | \ |
---|
| 438 | + EXT4_UNRM_FL | \ |
---|
| 439 | + EXT4_COMPR_FL | \ |
---|
| 440 | + EXT4_SYNC_FL | \ |
---|
| 441 | + EXT4_IMMUTABLE_FL | \ |
---|
| 442 | + EXT4_APPEND_FL | \ |
---|
| 443 | + EXT4_NODUMP_FL | \ |
---|
| 444 | + EXT4_NOATIME_FL | \ |
---|
| 445 | + EXT4_JOURNAL_DATA_FL | \ |
---|
| 446 | + EXT4_NOTAIL_FL | \ |
---|
| 447 | + EXT4_DIRSYNC_FL | \ |
---|
| 448 | + EXT4_TOPDIR_FL | \ |
---|
| 449 | + EXT4_EXTENTS_FL | \ |
---|
| 450 | + 0x00400000 /* EXT4_EOFBLOCKS_FL */ | \ |
---|
| 451 | + EXT4_DAX_FL | \ |
---|
| 452 | + EXT4_PROJINHERIT_FL | \ |
---|
| 453 | + EXT4_CASEFOLD_FL) |
---|
426 | 454 | |
---|
427 | | -/* Flags we can manipulate with through EXT4_IOC_FSSETXATTR */ |
---|
| 455 | +/* User visible flags */ |
---|
| 456 | +#define EXT4_FL_USER_VISIBLE (EXT4_FL_USER_MODIFIABLE | \ |
---|
| 457 | + EXT4_DIRTY_FL | \ |
---|
| 458 | + EXT4_COMPRBLK_FL | \ |
---|
| 459 | + EXT4_NOCOMPR_FL | \ |
---|
| 460 | + EXT4_ENCRYPT_FL | \ |
---|
| 461 | + EXT4_INDEX_FL | \ |
---|
| 462 | + EXT4_VERITY_FL | \ |
---|
| 463 | + EXT4_INLINE_DATA_FL) |
---|
| 464 | + |
---|
| 465 | +/* Flags we can manipulate with through FS_IOC_FSSETXATTR */ |
---|
428 | 466 | #define EXT4_FL_XFLAG_VISIBLE (EXT4_SYNC_FL | \ |
---|
429 | 467 | EXT4_IMMUTABLE_FL | \ |
---|
430 | 468 | EXT4_APPEND_FL | \ |
---|
431 | 469 | EXT4_NODUMP_FL | \ |
---|
432 | 470 | EXT4_NOATIME_FL | \ |
---|
433 | | - EXT4_PROJINHERIT_FL) |
---|
| 471 | + EXT4_PROJINHERIT_FL | \ |
---|
| 472 | + EXT4_DAX_FL) |
---|
434 | 473 | |
---|
435 | 474 | /* Flags that should be inherited by new inodes from their parent. */ |
---|
436 | 475 | #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\ |
---|
437 | 476 | EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\ |
---|
438 | 477 | EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL |\ |
---|
439 | 478 | EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL |\ |
---|
440 | | - EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL) |
---|
| 479 | + EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL |\ |
---|
| 480 | + EXT4_DAX_FL) |
---|
441 | 481 | |
---|
442 | 482 | /* Flags that are appropriate for regular files (all but dir-specific ones). */ |
---|
443 | | -#define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL | EXT4_CASEFOLD_FL)) |
---|
| 483 | +#define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL | EXT4_CASEFOLD_FL |\ |
---|
| 484 | + EXT4_PROJINHERIT_FL)) |
---|
444 | 485 | |
---|
445 | 486 | /* Flags that are appropriate for non-directories/regular files. */ |
---|
446 | 487 | #define EXT4_OTHER_FLMASK (EXT4_NODUMP_FL | EXT4_NOATIME_FL) |
---|
447 | 488 | |
---|
448 | 489 | /* The only flags that should be swapped */ |
---|
449 | 490 | #define EXT4_FL_SHOULD_SWAP (EXT4_HUGE_FILE_FL | EXT4_EXTENTS_FL) |
---|
| 491 | + |
---|
| 492 | +/* Flags which are mutually exclusive to DAX */ |
---|
| 493 | +#define EXT4_DAX_MUT_EXCL (EXT4_VERITY_FL | EXT4_ENCRYPT_FL |\ |
---|
| 494 | + EXT4_JOURNAL_DATA_FL | EXT4_INLINE_DATA_FL) |
---|
450 | 495 | |
---|
451 | 496 | /* Mask out flags that are inappropriate for the given type of inode. */ |
---|
452 | 497 | static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags) |
---|
.. | .. |
---|
487 | 532 | EXT4_INODE_EXTENTS = 19, /* Inode uses extents */ |
---|
488 | 533 | EXT4_INODE_VERITY = 20, /* Verity protected inode */ |
---|
489 | 534 | EXT4_INODE_EA_INODE = 21, /* Inode used for large EA */ |
---|
490 | | - EXT4_INODE_EOFBLOCKS = 22, /* Blocks allocated beyond EOF */ |
---|
| 535 | +/* 22 was formerly EXT4_INODE_EOFBLOCKS */ |
---|
| 536 | + EXT4_INODE_DAX = 25, /* Inode is DAX */ |
---|
491 | 537 | EXT4_INODE_INLINE_DATA = 28, /* Data in inode. */ |
---|
492 | 538 | EXT4_INODE_PROJINHERIT = 29, /* Create with parents projid */ |
---|
| 539 | + EXT4_INODE_CASEFOLD = 30, /* Casefolded directory */ |
---|
493 | 540 | EXT4_INODE_RESERVED = 31, /* reserved for ext4 lib */ |
---|
494 | 541 | }; |
---|
495 | 542 | |
---|
.. | .. |
---|
533 | 580 | CHECK_FLAG_VALUE(EXTENTS); |
---|
534 | 581 | CHECK_FLAG_VALUE(VERITY); |
---|
535 | 582 | CHECK_FLAG_VALUE(EA_INODE); |
---|
536 | | - CHECK_FLAG_VALUE(EOFBLOCKS); |
---|
537 | 583 | CHECK_FLAG_VALUE(INLINE_DATA); |
---|
538 | 584 | CHECK_FLAG_VALUE(PROJINHERIT); |
---|
| 585 | + CHECK_FLAG_VALUE(CASEFOLD); |
---|
539 | 586 | CHECK_FLAG_VALUE(RESERVED); |
---|
540 | 587 | } |
---|
541 | 588 | |
---|
.. | .. |
---|
610 | 657 | #define EXT4_GET_BLOCKS_METADATA_NOFAIL 0x0020 |
---|
611 | 658 | /* Don't normalize allocation size (used for fallocate) */ |
---|
612 | 659 | #define EXT4_GET_BLOCKS_NO_NORMALIZE 0x0040 |
---|
613 | | - /* Request will not result in inode size update (user for fallocate) */ |
---|
614 | | -#define EXT4_GET_BLOCKS_KEEP_SIZE 0x0080 |
---|
615 | 660 | /* Convert written extents to unwritten */ |
---|
616 | 661 | #define EXT4_GET_BLOCKS_CONVERT_UNWRITTEN 0x0100 |
---|
617 | 662 | /* Write zeros to newly created written extents */ |
---|
.. | .. |
---|
633 | 678 | */ |
---|
634 | 679 | #define EXT4_EX_NOCACHE 0x40000000 |
---|
635 | 680 | #define EXT4_EX_FORCE_CACHE 0x20000000 |
---|
| 681 | +#define EXT4_EX_NOFAIL 0x10000000 |
---|
636 | 682 | |
---|
637 | 683 | /* |
---|
638 | 684 | * Flags used by ext4_free_blocks |
---|
.. | .. |
---|
643 | 689 | #define EXT4_FREE_BLOCKS_NO_QUOT_UPDATE 0x0008 |
---|
644 | 690 | #define EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER 0x0010 |
---|
645 | 691 | #define EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER 0x0020 |
---|
| 692 | +#define EXT4_FREE_BLOCKS_RERESERVE_CLUSTER 0x0040 |
---|
646 | 693 | |
---|
647 | 694 | /* |
---|
648 | 695 | * ioctl commands |
---|
649 | 696 | */ |
---|
650 | | -#define EXT4_IOC_GETFLAGS FS_IOC_GETFLAGS |
---|
651 | | -#define EXT4_IOC_SETFLAGS FS_IOC_SETFLAGS |
---|
652 | 697 | #define EXT4_IOC_GETVERSION _IOR('f', 3, long) |
---|
653 | 698 | #define EXT4_IOC_SETVERSION _IOW('f', 4, long) |
---|
654 | 699 | #define EXT4_IOC_GETVERSION_OLD FS_IOC_GETVERSION |
---|
.. | .. |
---|
665 | 710 | #define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64) |
---|
666 | 711 | #define EXT4_IOC_SWAP_BOOT _IO('f', 17) |
---|
667 | 712 | #define EXT4_IOC_PRECACHE_EXTENTS _IO('f', 18) |
---|
668 | | -#define EXT4_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY |
---|
669 | | -#define EXT4_IOC_GET_ENCRYPTION_PWSALT FS_IOC_GET_ENCRYPTION_PWSALT |
---|
670 | | -#define EXT4_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY |
---|
671 | | - |
---|
672 | | -#define EXT4_IOC_FSGETXATTR FS_IOC_FSGETXATTR |
---|
673 | | -#define EXT4_IOC_FSSETXATTR FS_IOC_FSSETXATTR |
---|
| 713 | +/* ioctl codes 19--39 are reserved for fscrypt */ |
---|
| 714 | +#define EXT4_IOC_CLEAR_ES_CACHE _IO('f', 40) |
---|
| 715 | +#define EXT4_IOC_GETSTATE _IOW('f', 41, __u32) |
---|
| 716 | +#define EXT4_IOC_GET_ES_CACHE _IOWR('f', 42, struct fiemap) |
---|
674 | 717 | |
---|
675 | 718 | #define EXT4_IOC_SHUTDOWN _IOR ('X', 125, __u32) |
---|
676 | 719 | |
---|
.. | .. |
---|
681 | 724 | #define EXT4_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */ |
---|
682 | 725 | #define EXT4_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */ |
---|
683 | 726 | |
---|
| 727 | +/* |
---|
| 728 | + * Flags returned by EXT4_IOC_GETSTATE |
---|
| 729 | + * |
---|
| 730 | + * We only expose to userspace a subset of the state flags in |
---|
| 731 | + * i_state_flags |
---|
| 732 | + */ |
---|
| 733 | +#define EXT4_STATE_FLAG_EXT_PRECACHED 0x00000001 |
---|
| 734 | +#define EXT4_STATE_FLAG_NEW 0x00000002 |
---|
| 735 | +#define EXT4_STATE_FLAG_NEWENTRY 0x00000004 |
---|
| 736 | +#define EXT4_STATE_FLAG_DA_ALLOC_CLOSE 0x00000008 |
---|
684 | 737 | |
---|
685 | 738 | #if defined(__KERNEL__) && defined(CONFIG_COMPAT) |
---|
686 | 739 | /* |
---|
687 | 740 | * ioctl commands in 32 bit emulation |
---|
688 | 741 | */ |
---|
689 | | -#define EXT4_IOC32_GETFLAGS FS_IOC32_GETFLAGS |
---|
690 | | -#define EXT4_IOC32_SETFLAGS FS_IOC32_SETFLAGS |
---|
691 | 742 | #define EXT4_IOC32_GETVERSION _IOR('f', 3, int) |
---|
692 | 743 | #define EXT4_IOC32_SETVERSION _IOW('f', 4, int) |
---|
693 | 744 | #define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int) |
---|
.. | .. |
---|
698 | 749 | #define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION |
---|
699 | 750 | #endif |
---|
700 | 751 | |
---|
| 752 | +/* |
---|
| 753 | + * Returned by EXT4_IOC_GET_ES_CACHE as an additional possible flag. |
---|
| 754 | + * It indicates that the entry in extent status cache is for a hole. |
---|
| 755 | + */ |
---|
| 756 | +#define EXT4_FIEMAP_EXTENT_HOLE 0x08000000 |
---|
| 757 | + |
---|
701 | 758 | /* Max physical block we can address w/o extents */ |
---|
702 | 759 | #define EXT4_MAX_BLOCK_FILE_PHYS 0xFFFFFFFF |
---|
703 | 760 | |
---|
704 | 761 | /* Max logical block we can support */ |
---|
705 | | -#define EXT4_MAX_LOGICAL_BLOCK 0xFFFFFFFF |
---|
| 762 | +#define EXT4_MAX_LOGICAL_BLOCK 0xFFFFFFFE |
---|
706 | 763 | |
---|
707 | 764 | /* |
---|
708 | 765 | * Structure of an inode on the disk |
---|
.. | .. |
---|
827 | 884 | static inline void ext4_decode_extra_time(struct timespec64 *time, |
---|
828 | 885 | __le32 extra) |
---|
829 | 886 | { |
---|
830 | | - if (unlikely(extra & cpu_to_le32(EXT4_EPOCH_MASK))) { |
---|
831 | | - |
---|
832 | | -#if 1 |
---|
833 | | - /* Handle legacy encoding of pre-1970 dates with epoch |
---|
834 | | - * bits 1,1. (This backwards compatibility may be removed |
---|
835 | | - * at the discretion of the ext4 developers.) |
---|
836 | | - */ |
---|
837 | | - u64 extra_bits = le32_to_cpu(extra) & EXT4_EPOCH_MASK; |
---|
838 | | - if (extra_bits == 3 && ((time->tv_sec) & 0x80000000) != 0) |
---|
839 | | - extra_bits = 0; |
---|
840 | | - time->tv_sec += extra_bits << 32; |
---|
841 | | -#else |
---|
| 887 | + if (unlikely(extra & cpu_to_le32(EXT4_EPOCH_MASK))) |
---|
842 | 888 | time->tv_sec += (u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) << 32; |
---|
843 | | -#endif |
---|
844 | | - } |
---|
845 | 889 | time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS; |
---|
846 | 890 | } |
---|
847 | 891 | |
---|
848 | 892 | #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \ |
---|
849 | 893 | do { \ |
---|
850 | | - (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \ |
---|
851 | 894 | if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) {\ |
---|
| 895 | + (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \ |
---|
852 | 896 | (raw_inode)->xtime ## _extra = \ |
---|
853 | 897 | ext4_encode_extra_time(&(inode)->xtime); \ |
---|
854 | 898 | } \ |
---|
| 899 | + else \ |
---|
| 900 | + (raw_inode)->xtime = cpu_to_le32(clamp_t(int32_t, (inode)->xtime.tv_sec, S32_MIN, S32_MAX)); \ |
---|
855 | 901 | } while (0) |
---|
856 | 902 | |
---|
857 | 903 | #define EXT4_EINODE_SET_XTIME(xtime, einode, raw_inode) \ |
---|
.. | .. |
---|
917 | 963 | #endif /* defined(__KERNEL__) || defined(__linux__) */ |
---|
918 | 964 | |
---|
919 | 965 | #include "extents_status.h" |
---|
| 966 | +#include "fast_commit.h" |
---|
920 | 967 | |
---|
921 | 968 | /* |
---|
922 | 969 | * Lock subclasses for i_data_sem in the ext4_inode_info structure. |
---|
.. | .. |
---|
974 | 1021 | |
---|
975 | 1022 | struct list_head i_orphan; /* unlinked but open inodes */ |
---|
976 | 1023 | |
---|
| 1024 | + /* Fast commit related info */ |
---|
| 1025 | + |
---|
| 1026 | + struct list_head i_fc_list; /* |
---|
| 1027 | + * inodes that need fast commit |
---|
| 1028 | + * protected by sbi->s_fc_lock. |
---|
| 1029 | + */ |
---|
| 1030 | + |
---|
| 1031 | + /* Start of lblk range that needs to be committed in this fast commit */ |
---|
| 1032 | + ext4_lblk_t i_fc_lblk_start; |
---|
| 1033 | + |
---|
| 1034 | + /* End of lblk range that needs to be committed in this fast commit */ |
---|
| 1035 | + ext4_lblk_t i_fc_lblk_len; |
---|
| 1036 | + |
---|
| 1037 | + /* Number of ongoing updates on this inode */ |
---|
| 1038 | + atomic_t i_fc_updates; |
---|
| 1039 | + |
---|
| 1040 | + /* Fast commit wait queue for this inode */ |
---|
| 1041 | + wait_queue_head_t i_fc_wait; |
---|
| 1042 | + |
---|
| 1043 | + /* Protect concurrent accesses on i_fc_lblk_start, i_fc_lblk_len */ |
---|
| 1044 | + struct mutex i_fc_lock; |
---|
| 1045 | + |
---|
977 | 1046 | /* |
---|
978 | 1047 | * i_disksize keeps track of what the inode size is ON DISK, not |
---|
979 | 1048 | * in memory. During truncate, i_size is set to the new size by |
---|
.. | .. |
---|
1023 | 1092 | struct timespec64 i_crtime; |
---|
1024 | 1093 | |
---|
1025 | 1094 | /* mballoc */ |
---|
| 1095 | + atomic_t i_prealloc_active; |
---|
1026 | 1096 | struct list_head i_prealloc_list; |
---|
1027 | 1097 | spinlock_t i_prealloc_lock; |
---|
1028 | 1098 | |
---|
.. | .. |
---|
1042 | 1112 | /* allocation reservation info for delalloc */ |
---|
1043 | 1113 | /* In case of bigalloc, this refer to clusters rather than blocks */ |
---|
1044 | 1114 | unsigned int i_reserved_data_blocks; |
---|
1045 | | - ext4_lblk_t i_da_metadata_calc_last_lblock; |
---|
1046 | | - int i_da_metadata_calc_len; |
---|
| 1115 | + |
---|
| 1116 | + /* pending cluster reservations for bigalloc file systems */ |
---|
| 1117 | + struct ext4_pending_tree i_pending_tree; |
---|
1047 | 1118 | |
---|
1048 | 1119 | /* on-disk additional length */ |
---|
1049 | 1120 | __u16 i_extra_isize; |
---|
.. | .. |
---|
1092 | 1163 | #define EXT4_VALID_FS 0x0001 /* Unmounted cleanly */ |
---|
1093 | 1164 | #define EXT4_ERROR_FS 0x0002 /* Errors detected */ |
---|
1094 | 1165 | #define EXT4_ORPHAN_FS 0x0004 /* Orphans being recovered */ |
---|
| 1166 | +#define EXT4_FC_REPLAY 0x0020 /* Fast commit replay ongoing */ |
---|
1095 | 1167 | |
---|
1096 | 1168 | /* |
---|
1097 | 1169 | * Misc. filesystem flags |
---|
.. | .. |
---|
1113 | 1185 | #define EXT4_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */ |
---|
1114 | 1186 | #define EXT4_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/ |
---|
1115 | 1187 | #ifdef CONFIG_FS_DAX |
---|
1116 | | -#define EXT4_MOUNT_DAX 0x00200 /* Direct Access */ |
---|
| 1188 | +#define EXT4_MOUNT_DAX_ALWAYS 0x00200 /* Direct Access */ |
---|
1117 | 1189 | #else |
---|
1118 | | -#define EXT4_MOUNT_DAX 0 |
---|
| 1190 | +#define EXT4_MOUNT_DAX_ALWAYS 0 |
---|
1119 | 1191 | #endif |
---|
1120 | 1192 | #define EXT4_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */ |
---|
1121 | 1193 | #define EXT4_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */ |
---|
.. | .. |
---|
1140 | 1212 | #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */ |
---|
1141 | 1213 | #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */ |
---|
1142 | 1214 | #define EXT4_MOUNT_WARN_ON_ERROR 0x2000000 /* Trigger WARN_ON on error */ |
---|
1143 | | -#define EXT4_MOUNT_INLINECRYPT 0x4000000 /* Inline encryption support */ |
---|
| 1215 | +#define EXT4_MOUNT_PREFETCH_BLOCK_BITMAPS 0x4000000 |
---|
1144 | 1216 | #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */ |
---|
1145 | 1217 | #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */ |
---|
1146 | 1218 | #define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000 /* Block validity checking */ |
---|
.. | .. |
---|
1159 | 1231 | blocks */ |
---|
1160 | 1232 | #define EXT4_MOUNT2_HURD_COMPAT 0x00000004 /* Support HURD-castrated |
---|
1161 | 1233 | file systems */ |
---|
1162 | | - |
---|
1163 | 1234 | #define EXT4_MOUNT2_EXPLICIT_JOURNAL_CHECKSUM 0x00000008 /* User explicitly |
---|
1164 | 1235 | specified journal checksum */ |
---|
| 1236 | + |
---|
| 1237 | +#define EXT4_MOUNT2_JOURNAL_FAST_COMMIT 0x00000010 /* Journal fast commit */ |
---|
| 1238 | +#define EXT4_MOUNT2_DAX_NEVER 0x00000020 /* Do not allow Direct Access */ |
---|
| 1239 | +#define EXT4_MOUNT2_DAX_INODE 0x00000040 /* For printing options only */ |
---|
| 1240 | + |
---|
1165 | 1241 | |
---|
1166 | 1242 | #define clear_opt(sb, opt) EXT4_SB(sb)->s_mount_opt &= \ |
---|
1167 | 1243 | ~EXT4_MOUNT_##opt |
---|
.. | .. |
---|
1331 | 1407 | __u8 s_lastcheck_hi; |
---|
1332 | 1408 | __u8 s_first_error_time_hi; |
---|
1333 | 1409 | __u8 s_last_error_time_hi; |
---|
1334 | | - __u8 s_pad[2]; |
---|
| 1410 | + __u8 s_first_error_errcode; |
---|
| 1411 | + __u8 s_last_error_errcode; |
---|
1335 | 1412 | __le16 s_encoding; /* Filename charset encoding */ |
---|
1336 | 1413 | __le16 s_encoding_flags; /* Filename charset encoding flags */ |
---|
1337 | 1414 | __le32 s_reserved[95]; /* Padding to the end of the block */ |
---|
.. | .. |
---|
1341 | 1418 | #define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START) |
---|
1342 | 1419 | |
---|
1343 | 1420 | #ifdef __KERNEL__ |
---|
1344 | | - |
---|
1345 | | -/* |
---|
1346 | | - * run-time mount flags |
---|
1347 | | - */ |
---|
1348 | | -#define EXT4_MF_MNTDIR_SAMPLED 0x0001 |
---|
1349 | | -#define EXT4_MF_FS_ABORTED 0x0002 /* Fatal error detected */ |
---|
1350 | | - |
---|
1351 | | -#ifdef CONFIG_FS_ENCRYPTION |
---|
1352 | | -#define DUMMY_ENCRYPTION_ENABLED(sbi) ((sbi)->s_dummy_enc_ctx.ctx != NULL) |
---|
1353 | | -#else |
---|
1354 | | -#define DUMMY_ENCRYPTION_ENABLED(sbi) (0) |
---|
1355 | | -#endif |
---|
1356 | 1421 | |
---|
1357 | 1422 | /* Number of quota types we support */ |
---|
1358 | 1423 | #define EXT4_MAXQUOTAS 3 |
---|
.. | .. |
---|
1382 | 1447 | struct buffer_head * __rcu *s_group_desc; |
---|
1383 | 1448 | unsigned int s_mount_opt; |
---|
1384 | 1449 | unsigned int s_mount_opt2; |
---|
1385 | | - unsigned int s_mount_flags; |
---|
| 1450 | + unsigned long s_mount_flags; |
---|
1386 | 1451 | unsigned int s_def_mount_opt; |
---|
1387 | 1452 | ext4_fsblk_t s_sb_block; |
---|
1388 | 1453 | atomic64_t s_resv_clusters; |
---|
.. | .. |
---|
1403 | 1468 | struct percpu_counter s_freeinodes_counter; |
---|
1404 | 1469 | struct percpu_counter s_dirs_counter; |
---|
1405 | 1470 | struct percpu_counter s_dirtyclusters_counter; |
---|
| 1471 | + struct percpu_counter s_sra_exceeded_retry_limit; |
---|
1406 | 1472 | struct blockgroup_lock *s_blockgroup_lock; |
---|
1407 | 1473 | struct proc_dir_entry *s_proc; |
---|
1408 | 1474 | struct kobject s_kobj; |
---|
1409 | 1475 | struct completion s_kobj_unregister; |
---|
1410 | 1476 | struct super_block *s_sb; |
---|
| 1477 | + struct buffer_head *s_mmp_bh; |
---|
1411 | 1478 | |
---|
1412 | 1479 | /* Journaling */ |
---|
1413 | 1480 | struct journal_s *s_journal; |
---|
.. | .. |
---|
1417 | 1484 | unsigned long s_commit_interval; |
---|
1418 | 1485 | u32 s_max_batch_time; |
---|
1419 | 1486 | u32 s_min_batch_time; |
---|
1420 | | - struct block_device *journal_bdev; |
---|
| 1487 | + struct block_device *s_journal_bdev; |
---|
1421 | 1488 | #ifdef CONFIG_QUOTA |
---|
1422 | 1489 | /* Names of quota files with journalled quota */ |
---|
1423 | 1490 | char __rcu *s_qf_names[EXT4_MAXQUOTAS]; |
---|
1424 | 1491 | int s_jquota_fmt; /* Format of quota to use */ |
---|
1425 | 1492 | #endif |
---|
1426 | 1493 | unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */ |
---|
1427 | | - struct ext4_system_blocks __rcu *system_blks; |
---|
| 1494 | + struct ext4_system_blocks __rcu *s_system_blks; |
---|
1428 | 1495 | |
---|
1429 | 1496 | #ifdef EXTENTS_STATS |
---|
1430 | 1497 | /* ext4 extents stats */ |
---|
.. | .. |
---|
1455 | 1522 | unsigned int s_mb_stats; |
---|
1456 | 1523 | unsigned int s_mb_order2_reqs; |
---|
1457 | 1524 | unsigned int s_mb_group_prealloc; |
---|
| 1525 | + unsigned int s_mb_max_inode_prealloc; |
---|
1458 | 1526 | unsigned int s_max_dir_size_kb; |
---|
1459 | 1527 | /* where last allocation was done - for stream allocation */ |
---|
1460 | 1528 | unsigned long s_mb_last_group; |
---|
1461 | 1529 | unsigned long s_mb_last_start; |
---|
| 1530 | + unsigned int s_mb_prefetch; |
---|
| 1531 | + unsigned int s_mb_prefetch_limit; |
---|
1462 | 1532 | |
---|
1463 | 1533 | /* stats for buddy allocator */ |
---|
1464 | 1534 | atomic_t s_bal_reqs; /* number of reqs with len > 1 */ |
---|
.. | .. |
---|
1526 | 1596 | struct ratelimit_state s_err_ratelimit_state; |
---|
1527 | 1597 | struct ratelimit_state s_warning_ratelimit_state; |
---|
1528 | 1598 | struct ratelimit_state s_msg_ratelimit_state; |
---|
| 1599 | + atomic_t s_warning_count; |
---|
| 1600 | + atomic_t s_msg_count; |
---|
1529 | 1601 | |
---|
1530 | | - /* Encryption context for '-o test_dummy_encryption' */ |
---|
1531 | | - struct fscrypt_dummy_context s_dummy_enc_ctx; |
---|
| 1602 | + /* Encryption policy for '-o test_dummy_encryption' */ |
---|
| 1603 | + struct fscrypt_dummy_policy s_dummy_enc_policy; |
---|
1532 | 1604 | |
---|
1533 | 1605 | /* |
---|
1534 | 1606 | * Barrier between writepages ops and changing any inode's JOURNAL_DATA |
---|
.. | .. |
---|
1536 | 1608 | */ |
---|
1537 | 1609 | struct percpu_rw_semaphore s_writepages_rwsem; |
---|
1538 | 1610 | struct dax_device *s_daxdev; |
---|
| 1611 | +#ifdef CONFIG_EXT4_DEBUG |
---|
| 1612 | + unsigned long s_simulate_fail; |
---|
| 1613 | +#endif |
---|
| 1614 | + /* Record the errseq of the backing block device */ |
---|
| 1615 | + errseq_t s_bdev_wb_err; |
---|
| 1616 | + spinlock_t s_bdev_wb_lock; |
---|
| 1617 | + |
---|
| 1618 | + /* Ext4 fast commit stuff */ |
---|
| 1619 | + atomic_t s_fc_subtid; |
---|
| 1620 | + atomic_t s_fc_ineligible_updates; |
---|
| 1621 | + /* |
---|
| 1622 | + * After commit starts, the main queue gets locked, and the further |
---|
| 1623 | + * updates get added in the staging queue. |
---|
| 1624 | + */ |
---|
| 1625 | +#define FC_Q_MAIN 0 |
---|
| 1626 | +#define FC_Q_STAGING 1 |
---|
| 1627 | + struct list_head s_fc_q[2]; /* Inodes staged for fast commit |
---|
| 1628 | + * that have data changes in them. |
---|
| 1629 | + */ |
---|
| 1630 | + struct list_head s_fc_dentry_q[2]; /* directory entry updates */ |
---|
| 1631 | + unsigned int s_fc_bytes; |
---|
| 1632 | + /* |
---|
| 1633 | + * Main fast commit lock. This lock protects accesses to the |
---|
| 1634 | + * following fields: |
---|
| 1635 | + * ei->i_fc_list, s_fc_dentry_q, s_fc_q, s_fc_bytes, s_fc_bh. |
---|
| 1636 | + */ |
---|
| 1637 | + spinlock_t s_fc_lock; |
---|
| 1638 | + struct buffer_head *s_fc_bh; |
---|
| 1639 | + struct ext4_fc_stats s_fc_stats; |
---|
| 1640 | + u64 s_fc_avg_commit_time; |
---|
| 1641 | +#ifdef CONFIG_EXT4_DEBUG |
---|
| 1642 | + int s_fc_debug_max_replay; |
---|
| 1643 | +#endif |
---|
| 1644 | + struct ext4_fc_replay_state s_fc_replay_state; |
---|
1539 | 1645 | }; |
---|
1540 | 1646 | |
---|
1541 | 1647 | static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) |
---|
.. | .. |
---|
1572 | 1678 | }) |
---|
1573 | 1679 | |
---|
1574 | 1680 | /* |
---|
| 1681 | + * run-time mount flags |
---|
| 1682 | + */ |
---|
| 1683 | +enum { |
---|
| 1684 | + EXT4_MF_MNTDIR_SAMPLED, |
---|
| 1685 | + EXT4_MF_FS_ABORTED, /* Fatal error detected */ |
---|
| 1686 | + EXT4_MF_FC_INELIGIBLE, /* Fast commit ineligible */ |
---|
| 1687 | + EXT4_MF_FC_COMMITTING /* File system underoing a fast |
---|
| 1688 | + * commit. |
---|
| 1689 | + */ |
---|
| 1690 | +}; |
---|
| 1691 | + |
---|
| 1692 | +static inline void ext4_set_mount_flag(struct super_block *sb, int bit) |
---|
| 1693 | +{ |
---|
| 1694 | + set_bit(bit, &EXT4_SB(sb)->s_mount_flags); |
---|
| 1695 | +} |
---|
| 1696 | + |
---|
| 1697 | +static inline void ext4_clear_mount_flag(struct super_block *sb, int bit) |
---|
| 1698 | +{ |
---|
| 1699 | + clear_bit(bit, &EXT4_SB(sb)->s_mount_flags); |
---|
| 1700 | +} |
---|
| 1701 | + |
---|
| 1702 | +static inline int ext4_test_mount_flag(struct super_block *sb, int bit) |
---|
| 1703 | +{ |
---|
| 1704 | + return test_bit(bit, &EXT4_SB(sb)->s_mount_flags); |
---|
| 1705 | +} |
---|
| 1706 | + |
---|
| 1707 | + |
---|
| 1708 | +/* |
---|
| 1709 | + * Simulate_fail codes |
---|
| 1710 | + */ |
---|
| 1711 | +#define EXT4_SIM_BBITMAP_EIO 1 |
---|
| 1712 | +#define EXT4_SIM_BBITMAP_CRC 2 |
---|
| 1713 | +#define EXT4_SIM_IBITMAP_EIO 3 |
---|
| 1714 | +#define EXT4_SIM_IBITMAP_CRC 4 |
---|
| 1715 | +#define EXT4_SIM_INODE_EIO 5 |
---|
| 1716 | +#define EXT4_SIM_INODE_CRC 6 |
---|
| 1717 | +#define EXT4_SIM_DIRBLOCK_EIO 7 |
---|
| 1718 | +#define EXT4_SIM_DIRBLOCK_CRC 8 |
---|
| 1719 | + |
---|
| 1720 | +static inline bool ext4_simulate_fail(struct super_block *sb, |
---|
| 1721 | + unsigned long code) |
---|
| 1722 | +{ |
---|
| 1723 | +#ifdef CONFIG_EXT4_DEBUG |
---|
| 1724 | + struct ext4_sb_info *sbi = EXT4_SB(sb); |
---|
| 1725 | + |
---|
| 1726 | + if (unlikely(sbi->s_simulate_fail == code)) { |
---|
| 1727 | + sbi->s_simulate_fail = 0; |
---|
| 1728 | + return true; |
---|
| 1729 | + } |
---|
| 1730 | +#endif |
---|
| 1731 | + return false; |
---|
| 1732 | +} |
---|
| 1733 | + |
---|
| 1734 | +static inline void ext4_simulate_fail_bh(struct super_block *sb, |
---|
| 1735 | + struct buffer_head *bh, |
---|
| 1736 | + unsigned long code) |
---|
| 1737 | +{ |
---|
| 1738 | + if (!IS_ERR(bh) && ext4_simulate_fail(sb, code)) |
---|
| 1739 | + clear_buffer_uptodate(bh); |
---|
| 1740 | +} |
---|
| 1741 | + |
---|
| 1742 | +/* |
---|
| 1743 | + * Error number codes for s_{first,last}_error_errno |
---|
| 1744 | + * |
---|
| 1745 | + * Linux errno numbers are architecture specific, so we need to translate |
---|
| 1746 | + * them into something which is architecture independent. We don't define |
---|
| 1747 | + * codes for all errno's; just the ones which are most likely to be the cause |
---|
| 1748 | + * of an ext4_error() call. |
---|
| 1749 | + */ |
---|
| 1750 | +#define EXT4_ERR_UNKNOWN 1 |
---|
| 1751 | +#define EXT4_ERR_EIO 2 |
---|
| 1752 | +#define EXT4_ERR_ENOMEM 3 |
---|
| 1753 | +#define EXT4_ERR_EFSBADCRC 4 |
---|
| 1754 | +#define EXT4_ERR_EFSCORRUPTED 5 |
---|
| 1755 | +#define EXT4_ERR_ENOSPC 6 |
---|
| 1756 | +#define EXT4_ERR_ENOKEY 7 |
---|
| 1757 | +#define EXT4_ERR_EROFS 8 |
---|
| 1758 | +#define EXT4_ERR_EFBIG 9 |
---|
| 1759 | +#define EXT4_ERR_EEXIST 10 |
---|
| 1760 | +#define EXT4_ERR_ERANGE 11 |
---|
| 1761 | +#define EXT4_ERR_EOVERFLOW 12 |
---|
| 1762 | +#define EXT4_ERR_EBUSY 13 |
---|
| 1763 | +#define EXT4_ERR_ENOTDIR 14 |
---|
| 1764 | +#define EXT4_ERR_ENOTEMPTY 15 |
---|
| 1765 | +#define EXT4_ERR_ESHUTDOWN 16 |
---|
| 1766 | +#define EXT4_ERR_EFAULT 17 |
---|
| 1767 | + |
---|
| 1768 | +/* |
---|
1575 | 1769 | * Inode dynamic state flags |
---|
1576 | 1770 | */ |
---|
1577 | 1771 | enum { |
---|
.. | .. |
---|
1581 | 1775 | EXT4_STATE_NO_EXPAND, /* No space for expansion */ |
---|
1582 | 1776 | EXT4_STATE_DA_ALLOC_CLOSE, /* Alloc DA blks on close */ |
---|
1583 | 1777 | EXT4_STATE_EXT_MIGRATE, /* Inode is migrating */ |
---|
1584 | | - EXT4_STATE_DIO_UNWRITTEN, /* need convert on dio done*/ |
---|
1585 | 1778 | EXT4_STATE_NEWENTRY, /* File just added to dir */ |
---|
1586 | 1779 | EXT4_STATE_MAY_INLINE_DATA, /* may have in-inode data */ |
---|
1587 | 1780 | EXT4_STATE_EXT_PRECACHED, /* extents have been precached */ |
---|
1588 | 1781 | EXT4_STATE_LUSTRE_EA_INODE, /* Lustre-style ea_inode */ |
---|
1589 | 1782 | EXT4_STATE_VERITY_IN_PROGRESS, /* building fs-verity Merkle tree */ |
---|
| 1783 | + EXT4_STATE_FC_COMMITTING, /* Fast commit ongoing */ |
---|
1590 | 1784 | }; |
---|
1591 | 1785 | |
---|
1592 | 1786 | #define EXT4_INODE_BIT_FNS(name, field, offset) \ |
---|
.. | .. |
---|
1665 | 1859 | |
---|
1666 | 1860 | #define EXT4_GOOD_OLD_INODE_SIZE 128 |
---|
1667 | 1861 | |
---|
| 1862 | +#define EXT4_EXTRA_TIMESTAMP_MAX (((s64)1 << 34) - 1 + S32_MIN) |
---|
| 1863 | +#define EXT4_NON_EXTRA_TIMESTAMP_MAX S32_MAX |
---|
| 1864 | +#define EXT4_TIMESTAMP_MIN S32_MIN |
---|
| 1865 | + |
---|
1668 | 1866 | /* |
---|
1669 | 1867 | * Feature set definitions |
---|
1670 | 1868 | */ |
---|
.. | .. |
---|
1676 | 1874 | #define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010 |
---|
1677 | 1875 | #define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020 |
---|
1678 | 1876 | #define EXT4_FEATURE_COMPAT_SPARSE_SUPER2 0x0200 |
---|
| 1877 | +/* |
---|
| 1878 | + * The reason why "FAST_COMMIT" is a compat feature is that, FS becomes |
---|
| 1879 | + * incompatible only if fast commit blocks are present in the FS. Since we |
---|
| 1880 | + * clear the journal (and thus the fast commit blocks), we don't mark FS as |
---|
| 1881 | + * incompatible. We also have a JBD2 incompat feature, which gets set when |
---|
| 1882 | + * there are fast commit blocks present in the journal. |
---|
| 1883 | + */ |
---|
| 1884 | +#define EXT4_FEATURE_COMPAT_FAST_COMMIT 0x0400 |
---|
1679 | 1885 | #define EXT4_FEATURE_COMPAT_STABLE_INODES 0x0800 |
---|
1680 | 1886 | |
---|
1681 | 1887 | #define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 |
---|
.. | .. |
---|
1778 | 1984 | EXT4_FEATURE_COMPAT_FUNCS(resize_inode, RESIZE_INODE) |
---|
1779 | 1985 | EXT4_FEATURE_COMPAT_FUNCS(dir_index, DIR_INDEX) |
---|
1780 | 1986 | EXT4_FEATURE_COMPAT_FUNCS(sparse_super2, SPARSE_SUPER2) |
---|
| 1987 | +EXT4_FEATURE_COMPAT_FUNCS(fast_commit, FAST_COMMIT) |
---|
1781 | 1988 | EXT4_FEATURE_COMPAT_FUNCS(stable_inodes, STABLE_INODES) |
---|
1782 | 1989 | |
---|
1783 | 1990 | EXT4_FEATURE_RO_COMPAT_FUNCS(sparse_super, SPARSE_SUPER) |
---|
.. | .. |
---|
1892 | 2099 | */ |
---|
1893 | 2100 | #define EXT4_FLAGS_RESIZING 0 |
---|
1894 | 2101 | #define EXT4_FLAGS_SHUTDOWN 1 |
---|
| 2102 | +#define EXT4_FLAGS_BDEV_IS_DAX 2 |
---|
1895 | 2103 | |
---|
1896 | 2104 | static inline int ext4_forced_shutdown(struct ext4_sb_info *sbi) |
---|
1897 | 2105 | { |
---|
.. | .. |
---|
1945 | 2153 | * Structure of a directory entry |
---|
1946 | 2154 | */ |
---|
1947 | 2155 | #define EXT4_NAME_LEN 255 |
---|
| 2156 | +/* |
---|
| 2157 | + * Base length of the ext4 directory entry excluding the name length |
---|
| 2158 | + */ |
---|
| 2159 | +#define EXT4_BASE_DIR_LEN (sizeof(struct ext4_dir_entry_2) - EXT4_NAME_LEN) |
---|
1948 | 2160 | |
---|
1949 | 2161 | struct ext4_dir_entry { |
---|
1950 | 2162 | __le32 inode; /* Inode number */ |
---|
.. | .. |
---|
1974 | 2186 | __le32 inode; /* Inode number */ |
---|
1975 | 2187 | __le16 rec_len; /* Directory entry length */ |
---|
1976 | 2188 | __u8 name_len; /* Name length */ |
---|
1977 | | - __u8 file_type; |
---|
| 2189 | + __u8 file_type; /* See file type macros EXT4_FT_* below */ |
---|
1978 | 2190 | char name[EXT4_NAME_LEN]; /* File name */ |
---|
1979 | 2191 | }; |
---|
1980 | 2192 | |
---|
.. | .. |
---|
2122 | 2334 | BUG_ON(crypto_shash_descsize(sbi->s_chksum_driver)!=sizeof(desc.ctx)); |
---|
2123 | 2335 | |
---|
2124 | 2336 | desc.shash.tfm = sbi->s_chksum_driver; |
---|
2125 | | - desc.shash.flags = 0; |
---|
2126 | 2337 | *(u32 *)desc.ctx = crc; |
---|
2127 | 2338 | |
---|
2128 | 2339 | BUG_ON(crypto_shash_update(&desc.shash, address, length)); |
---|
.. | .. |
---|
2244 | 2455 | struct mutex li_list_mtx; |
---|
2245 | 2456 | }; |
---|
2246 | 2457 | |
---|
| 2458 | +enum ext4_li_mode { |
---|
| 2459 | + EXT4_LI_MODE_PREFETCH_BBITMAP, |
---|
| 2460 | + EXT4_LI_MODE_ITABLE, |
---|
| 2461 | +}; |
---|
| 2462 | + |
---|
2247 | 2463 | struct ext4_li_request { |
---|
2248 | 2464 | struct super_block *lr_super; |
---|
2249 | | - struct ext4_sb_info *lr_sbi; |
---|
| 2465 | + enum ext4_li_mode lr_mode; |
---|
| 2466 | + ext4_group_t lr_first_not_zeroed; |
---|
2250 | 2467 | ext4_group_t lr_next_group; |
---|
2251 | 2468 | struct list_head lr_request; |
---|
2252 | 2469 | unsigned long lr_next_sched; |
---|
.. | .. |
---|
2377 | 2594 | extern int ext4_should_retry_alloc(struct super_block *sb, int *retries); |
---|
2378 | 2595 | |
---|
2379 | 2596 | extern struct buffer_head *ext4_read_block_bitmap_nowait(struct super_block *sb, |
---|
2380 | | - ext4_group_t block_group); |
---|
| 2597 | + ext4_group_t block_group, |
---|
| 2598 | + bool ignore_locked); |
---|
2381 | 2599 | extern int ext4_wait_block_bitmap(struct super_block *sb, |
---|
2382 | 2600 | ext4_group_t block_group, |
---|
2383 | 2601 | struct buffer_head *bh); |
---|
.. | .. |
---|
2551 | 2769 | struct dx_hash_info *hinfo); |
---|
2552 | 2770 | |
---|
2553 | 2771 | /* ialloc.c */ |
---|
| 2772 | +extern int ext4_mark_inode_used(struct super_block *sb, int ino); |
---|
2554 | 2773 | extern struct inode *__ext4_new_inode(handle_t *, struct inode *, umode_t, |
---|
2555 | 2774 | const struct qstr *qstr, __u32 goal, |
---|
2556 | 2775 | uid_t *owner, __u32 i_flags, |
---|
.. | .. |
---|
2576 | 2795 | ext4_group_t group, int barrier); |
---|
2577 | 2796 | extern void ext4_end_bitmap_read(struct buffer_head *bh, int uptodate); |
---|
2578 | 2797 | |
---|
| 2798 | +/* fast_commit.c */ |
---|
| 2799 | +int ext4_fc_info_show(struct seq_file *seq, void *v); |
---|
| 2800 | +void ext4_fc_init(struct super_block *sb, journal_t *journal); |
---|
| 2801 | +void ext4_fc_init_inode(struct inode *inode); |
---|
| 2802 | +void ext4_fc_track_range(handle_t *handle, struct inode *inode, ext4_lblk_t start, |
---|
| 2803 | + ext4_lblk_t end); |
---|
| 2804 | +void __ext4_fc_track_unlink(handle_t *handle, struct inode *inode, |
---|
| 2805 | + struct dentry *dentry); |
---|
| 2806 | +void __ext4_fc_track_link(handle_t *handle, struct inode *inode, |
---|
| 2807 | + struct dentry *dentry); |
---|
| 2808 | +void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry); |
---|
| 2809 | +void ext4_fc_track_link(handle_t *handle, struct dentry *dentry); |
---|
| 2810 | +void __ext4_fc_track_create(handle_t *handle, struct inode *inode, |
---|
| 2811 | + struct dentry *dentry); |
---|
| 2812 | +void ext4_fc_track_create(handle_t *handle, struct dentry *dentry); |
---|
| 2813 | +void ext4_fc_track_inode(handle_t *handle, struct inode *inode); |
---|
| 2814 | +void ext4_fc_mark_ineligible(struct super_block *sb, int reason); |
---|
| 2815 | +void ext4_fc_start_ineligible(struct super_block *sb, int reason); |
---|
| 2816 | +void ext4_fc_stop_ineligible(struct super_block *sb); |
---|
| 2817 | +void ext4_fc_start_update(struct inode *inode); |
---|
| 2818 | +void ext4_fc_stop_update(struct inode *inode); |
---|
| 2819 | +void ext4_fc_del(struct inode *inode); |
---|
| 2820 | +bool ext4_fc_replay_check_excluded(struct super_block *sb, ext4_fsblk_t block); |
---|
| 2821 | +void ext4_fc_replay_cleanup(struct super_block *sb); |
---|
| 2822 | +int ext4_fc_commit(journal_t *journal, tid_t commit_tid); |
---|
| 2823 | +int __init ext4_fc_init_dentry_cache(void); |
---|
| 2824 | +void ext4_fc_destroy_dentry_cache(void); |
---|
| 2825 | +int ext4_fc_record_regions(struct super_block *sb, int ino, |
---|
| 2826 | + ext4_lblk_t lblk, ext4_fsblk_t pblk, |
---|
| 2827 | + int len, int replay); |
---|
| 2828 | + |
---|
2579 | 2829 | /* mballoc.c */ |
---|
2580 | 2830 | extern const struct seq_operations ext4_mb_seq_groups_ops; |
---|
2581 | 2831 | extern long ext4_mb_stats; |
---|
.. | .. |
---|
2585 | 2835 | extern ext4_fsblk_t ext4_mb_new_blocks(handle_t *, |
---|
2586 | 2836 | struct ext4_allocation_request *, int *); |
---|
2587 | 2837 | extern int ext4_mb_reserve_blocks(struct super_block *, int); |
---|
2588 | | -extern void ext4_discard_preallocations(struct inode *); |
---|
| 2838 | +extern void ext4_discard_preallocations(struct inode *, unsigned int); |
---|
2589 | 2839 | extern int __init ext4_init_mballoc(void); |
---|
2590 | 2840 | extern void ext4_exit_mballoc(void); |
---|
| 2841 | +extern ext4_group_t ext4_mb_prefetch(struct super_block *sb, |
---|
| 2842 | + ext4_group_t group, |
---|
| 2843 | + unsigned int nr, int *cnt); |
---|
| 2844 | +extern void ext4_mb_prefetch_fini(struct super_block *sb, ext4_group_t group, |
---|
| 2845 | + unsigned int nr); |
---|
| 2846 | + |
---|
2591 | 2847 | extern void ext4_free_blocks(handle_t *handle, struct inode *inode, |
---|
2592 | 2848 | struct buffer_head *bh, ext4_fsblk_t block, |
---|
2593 | 2849 | unsigned long count, int flags); |
---|
.. | .. |
---|
2599 | 2855 | ext4_fsblk_t block, unsigned long count); |
---|
2600 | 2856 | extern int ext4_trim_fs(struct super_block *, struct fstrim_range *); |
---|
2601 | 2857 | extern void ext4_process_freed_data(struct super_block *sb, tid_t commit_tid); |
---|
| 2858 | +extern void ext4_mb_mark_bb(struct super_block *sb, ext4_fsblk_t block, |
---|
| 2859 | + int len, int state); |
---|
2602 | 2860 | |
---|
2603 | 2861 | /* inode.c */ |
---|
| 2862 | +void ext4_inode_csum_set(struct inode *inode, struct ext4_inode *raw, |
---|
| 2863 | + struct ext4_inode_info *ei); |
---|
2604 | 2864 | int ext4_inode_is_fast_symlink(struct inode *inode); |
---|
2605 | 2865 | struct buffer_head *ext4_getblk(handle_t *, struct inode *, ext4_lblk_t, int); |
---|
2606 | 2866 | struct buffer_head *ext4_bread(handle_t *, struct inode *, ext4_lblk_t, int); |
---|
.. | .. |
---|
2610 | 2870 | struct buffer_head *bh_result, int create); |
---|
2611 | 2871 | int ext4_get_block(struct inode *inode, sector_t iblock, |
---|
2612 | 2872 | struct buffer_head *bh_result, int create); |
---|
2613 | | -int ext4_dio_get_block(struct inode *inode, sector_t iblock, |
---|
2614 | | - struct buffer_head *bh_result, int create); |
---|
2615 | 2873 | int ext4_da_get_block_prep(struct inode *inode, sector_t iblock, |
---|
2616 | 2874 | struct buffer_head *bh, int create); |
---|
2617 | 2875 | int ext4_walk_page_buffers(handle_t *handle, |
---|
.. | .. |
---|
2649 | 2907 | extern void ext4_dirty_inode(struct inode *, int); |
---|
2650 | 2908 | extern int ext4_change_inode_journal_flag(struct inode *, int); |
---|
2651 | 2909 | extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *); |
---|
| 2910 | +extern int ext4_get_fc_inode_loc(struct super_block *sb, unsigned long ino, |
---|
| 2911 | + struct ext4_iloc *iloc); |
---|
2652 | 2912 | extern int ext4_inode_attach_jinode(struct inode *inode); |
---|
2653 | 2913 | extern int ext4_can_truncate(struct inode *inode); |
---|
2654 | 2914 | extern int ext4_truncate(struct inode *); |
---|
2655 | 2915 | extern int ext4_break_layouts(struct inode *); |
---|
2656 | | -extern int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length); |
---|
2657 | | -extern int ext4_truncate_restart_trans(handle_t *, struct inode *, int nblocks); |
---|
2658 | | -extern void ext4_set_inode_flags(struct inode *); |
---|
| 2916 | +extern int ext4_punch_hole(struct file *file, loff_t offset, loff_t length); |
---|
| 2917 | +extern void ext4_set_inode_flags(struct inode *, bool init); |
---|
2659 | 2918 | extern int ext4_alloc_da_blocks(struct inode *inode); |
---|
2660 | 2919 | extern void ext4_set_aops(struct inode *inode); |
---|
2661 | 2920 | extern int ext4_writepage_trans_blocks(struct inode *); |
---|
2662 | 2921 | extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks); |
---|
2663 | 2922 | extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode, |
---|
2664 | 2923 | loff_t lstart, loff_t lend); |
---|
2665 | | -extern int ext4_page_mkwrite(struct vm_fault *vmf); |
---|
2666 | | -extern int ext4_filemap_fault(struct vm_fault *vmf); |
---|
| 2924 | +extern vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf); |
---|
| 2925 | +extern vm_fault_t ext4_filemap_fault(struct vm_fault *vmf); |
---|
2667 | 2926 | extern qsize_t *ext4_get_reserved_space(struct inode *inode); |
---|
2668 | 2927 | extern int ext4_get_projid(struct inode *inode, kprojid_t *projid); |
---|
| 2928 | +extern void ext4_da_release_space(struct inode *inode, int to_free); |
---|
2669 | 2929 | extern void ext4_da_update_reserve_space(struct inode *inode, |
---|
2670 | 2930 | int used, int quota_claim); |
---|
2671 | 2931 | extern int ext4_issue_zeroout(struct inode *inode, ext4_lblk_t lblk, |
---|
.. | .. |
---|
2674 | 2934 | /* indirect.c */ |
---|
2675 | 2935 | extern int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, |
---|
2676 | 2936 | struct ext4_map_blocks *map, int flags); |
---|
2677 | | -extern int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock); |
---|
2678 | 2937 | extern int ext4_ind_trans_blocks(struct inode *inode, int nrblocks); |
---|
2679 | 2938 | extern void ext4_ind_truncate(handle_t *, struct inode *inode); |
---|
2680 | 2939 | extern int ext4_ind_remove_space(handle_t *handle, struct inode *inode, |
---|
.. | .. |
---|
2683 | 2942 | /* ioctl.c */ |
---|
2684 | 2943 | extern long ext4_ioctl(struct file *, unsigned int, unsigned long); |
---|
2685 | 2944 | extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long); |
---|
| 2945 | +extern void ext4_reset_inode_seed(struct inode *inode); |
---|
2686 | 2946 | |
---|
2687 | 2947 | /* migrate.c */ |
---|
2688 | 2948 | extern int ext4_ext_migrate(struct inode *); |
---|
2689 | 2949 | extern int ext4_ind_migrate(struct inode *inode); |
---|
2690 | 2950 | |
---|
2691 | 2951 | /* namei.c */ |
---|
2692 | | -extern int ext4_dirent_csum_verify(struct inode *inode, |
---|
2693 | | - struct ext4_dir_entry *dirent); |
---|
| 2952 | +extern int ext4_init_new_dir(handle_t *handle, struct inode *dir, |
---|
| 2953 | + struct inode *inode); |
---|
| 2954 | +extern int ext4_dirblock_csum_verify(struct inode *inode, |
---|
| 2955 | + struct buffer_head *bh); |
---|
2694 | 2956 | extern int ext4_orphan_add(handle_t *, struct inode *); |
---|
2695 | 2957 | extern int ext4_orphan_del(handle_t *, struct inode *); |
---|
2696 | 2958 | extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, |
---|
.. | .. |
---|
2702 | 2964 | struct ext4_filename *fname, |
---|
2703 | 2965 | ext4_lblk_t lblk, unsigned int offset, |
---|
2704 | 2966 | struct ext4_dir_entry_2 **res_dir); |
---|
2705 | | -extern int ext4_generic_delete_entry(handle_t *handle, |
---|
2706 | | - struct inode *dir, |
---|
| 2967 | +extern int ext4_generic_delete_entry(struct inode *dir, |
---|
2707 | 2968 | struct ext4_dir_entry_2 *de_del, |
---|
2708 | 2969 | ext4_lblk_t lblk, |
---|
2709 | 2970 | struct buffer_head *bh, |
---|
.. | .. |
---|
2724 | 2985 | /* super.c */ |
---|
2725 | 2986 | extern struct buffer_head *ext4_sb_bread(struct super_block *sb, |
---|
2726 | 2987 | sector_t block, int op_flags); |
---|
| 2988 | +extern struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb, |
---|
| 2989 | + sector_t block); |
---|
| 2990 | +extern void ext4_read_bh_nowait(struct buffer_head *bh, int op_flags, |
---|
| 2991 | + bh_end_io_t *end_io); |
---|
| 2992 | +extern int ext4_read_bh(struct buffer_head *bh, int op_flags, |
---|
| 2993 | + bh_end_io_t *end_io); |
---|
| 2994 | +extern int ext4_read_bh_lock(struct buffer_head *bh, int op_flags, bool wait); |
---|
| 2995 | +extern void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block); |
---|
2727 | 2996 | extern int ext4_seq_options_show(struct seq_file *seq, void *offset); |
---|
2728 | 2997 | extern int ext4_calculate_overhead(struct super_block *sb); |
---|
2729 | 2998 | extern void ext4_superblock_csum_set(struct super_block *sb); |
---|
2730 | | -extern void *ext4_kvmalloc(size_t size, gfp_t flags); |
---|
2731 | | -extern void *ext4_kvzalloc(size_t size, gfp_t flags); |
---|
2732 | 2999 | extern int ext4_alloc_flex_bg_array(struct super_block *sb, |
---|
2733 | 3000 | ext4_group_t ngroup); |
---|
2734 | 3001 | extern const char *ext4_decode_error(struct super_block *sb, int errno, |
---|
.. | .. |
---|
2737 | 3004 | ext4_group_t block_group, |
---|
2738 | 3005 | unsigned int flags); |
---|
2739 | 3006 | |
---|
2740 | | -extern __printf(4, 5) |
---|
2741 | | -void __ext4_error(struct super_block *, const char *, unsigned int, |
---|
| 3007 | +extern __printf(6, 7) |
---|
| 3008 | +void __ext4_error(struct super_block *, const char *, unsigned int, int, __u64, |
---|
2742 | 3009 | const char *, ...); |
---|
2743 | | -extern __printf(5, 6) |
---|
2744 | | -void __ext4_error_inode(struct inode *, const char *, unsigned int, ext4_fsblk_t, |
---|
2745 | | - const char *, ...); |
---|
| 3010 | +extern __printf(6, 7) |
---|
| 3011 | +void __ext4_error_inode(struct inode *, const char *, unsigned int, |
---|
| 3012 | + ext4_fsblk_t, int, const char *, ...); |
---|
2746 | 3013 | extern __printf(5, 6) |
---|
2747 | 3014 | void __ext4_error_file(struct file *, const char *, unsigned int, ext4_fsblk_t, |
---|
2748 | 3015 | const char *, ...); |
---|
2749 | 3016 | extern void __ext4_std_error(struct super_block *, const char *, |
---|
2750 | 3017 | unsigned int, int); |
---|
2751 | | -extern __printf(4, 5) |
---|
2752 | | -void __ext4_abort(struct super_block *, const char *, unsigned int, |
---|
| 3018 | +extern __printf(5, 6) |
---|
| 3019 | +void __ext4_abort(struct super_block *, const char *, unsigned int, int, |
---|
2753 | 3020 | const char *, ...); |
---|
2754 | 3021 | extern __printf(4, 5) |
---|
2755 | 3022 | void __ext4_warning(struct super_block *, const char *, unsigned int, |
---|
.. | .. |
---|
2770 | 3037 | #define EXT4_ERROR_INODE(inode, fmt, a...) \ |
---|
2771 | 3038 | ext4_error_inode((inode), __func__, __LINE__, 0, (fmt), ## a) |
---|
2772 | 3039 | |
---|
2773 | | -#define EXT4_ERROR_INODE_BLOCK(inode, block, fmt, a...) \ |
---|
2774 | | - ext4_error_inode((inode), __func__, __LINE__, (block), (fmt), ## a) |
---|
| 3040 | +#define EXT4_ERROR_INODE_ERR(inode, err, fmt, a...) \ |
---|
| 3041 | + __ext4_error_inode((inode), __func__, __LINE__, 0, (err), (fmt), ## a) |
---|
| 3042 | + |
---|
| 3043 | +#define ext4_error_inode_block(inode, block, err, fmt, a...) \ |
---|
| 3044 | + __ext4_error_inode((inode), __func__, __LINE__, (block), (err), \ |
---|
| 3045 | + (fmt), ## a) |
---|
2775 | 3046 | |
---|
2776 | 3047 | #define EXT4_ERROR_FILE(file, block, fmt, a...) \ |
---|
2777 | 3048 | ext4_error_file((file), __func__, __LINE__, (block), (fmt), ## a) |
---|
.. | .. |
---|
2779 | 3050 | #ifdef CONFIG_PRINTK |
---|
2780 | 3051 | |
---|
2781 | 3052 | #define ext4_error_inode(inode, func, line, block, fmt, ...) \ |
---|
2782 | | - __ext4_error_inode(inode, func, line, block, fmt, ##__VA_ARGS__) |
---|
| 3053 | + __ext4_error_inode(inode, func, line, block, 0, fmt, ##__VA_ARGS__) |
---|
| 3054 | +#define ext4_error_inode_err(inode, func, line, block, err, fmt, ...) \ |
---|
| 3055 | + __ext4_error_inode((inode), (func), (line), (block), \ |
---|
| 3056 | + (err), (fmt), ##__VA_ARGS__) |
---|
2783 | 3057 | #define ext4_error_file(file, func, line, block, fmt, ...) \ |
---|
2784 | 3058 | __ext4_error_file(file, func, line, block, fmt, ##__VA_ARGS__) |
---|
2785 | 3059 | #define ext4_error(sb, fmt, ...) \ |
---|
2786 | | - __ext4_error(sb, __func__, __LINE__, fmt, ##__VA_ARGS__) |
---|
2787 | | -#define ext4_abort(sb, fmt, ...) \ |
---|
2788 | | - __ext4_abort(sb, __func__, __LINE__, fmt, ##__VA_ARGS__) |
---|
| 3060 | + __ext4_error((sb), __func__, __LINE__, 0, 0, (fmt), ##__VA_ARGS__) |
---|
| 3061 | +#define ext4_error_err(sb, err, fmt, ...) \ |
---|
| 3062 | + __ext4_error((sb), __func__, __LINE__, (err), 0, (fmt), ##__VA_ARGS__) |
---|
| 3063 | +#define ext4_abort(sb, err, fmt, ...) \ |
---|
| 3064 | + __ext4_abort((sb), __func__, __LINE__, (err), (fmt), ##__VA_ARGS__) |
---|
2789 | 3065 | #define ext4_warning(sb, fmt, ...) \ |
---|
2790 | 3066 | __ext4_warning(sb, __func__, __LINE__, fmt, ##__VA_ARGS__) |
---|
2791 | 3067 | #define ext4_warning_inode(inode, fmt, ...) \ |
---|
.. | .. |
---|
2803 | 3079 | #define ext4_error_inode(inode, func, line, block, fmt, ...) \ |
---|
2804 | 3080 | do { \ |
---|
2805 | 3081 | no_printk(fmt, ##__VA_ARGS__); \ |
---|
2806 | | - __ext4_error_inode(inode, "", 0, block, " "); \ |
---|
| 3082 | + __ext4_error_inode(inode, "", 0, block, 0, " "); \ |
---|
| 3083 | +} while (0) |
---|
| 3084 | +#define ext4_error_inode_err(inode, func, line, block, err, fmt, ...) \ |
---|
| 3085 | +do { \ |
---|
| 3086 | + no_printk(fmt, ##__VA_ARGS__); \ |
---|
| 3087 | + __ext4_error_inode(inode, "", 0, block, err, " "); \ |
---|
2807 | 3088 | } while (0) |
---|
2808 | 3089 | #define ext4_error_file(file, func, line, block, fmt, ...) \ |
---|
2809 | 3090 | do { \ |
---|
.. | .. |
---|
2813 | 3094 | #define ext4_error(sb, fmt, ...) \ |
---|
2814 | 3095 | do { \ |
---|
2815 | 3096 | no_printk(fmt, ##__VA_ARGS__); \ |
---|
2816 | | - __ext4_error(sb, "", 0, " "); \ |
---|
| 3097 | + __ext4_error(sb, "", 0, 0, 0, " "); \ |
---|
2817 | 3098 | } while (0) |
---|
2818 | | -#define ext4_abort(sb, fmt, ...) \ |
---|
| 3099 | +#define ext4_error_err(sb, err, fmt, ...) \ |
---|
2819 | 3100 | do { \ |
---|
2820 | 3101 | no_printk(fmt, ##__VA_ARGS__); \ |
---|
2821 | | - __ext4_abort(sb, "", 0, " "); \ |
---|
| 3102 | + __ext4_error(sb, "", 0, err, 0, " "); \ |
---|
| 3103 | +} while (0) |
---|
| 3104 | +#define ext4_abort(sb, err, fmt, ...) \ |
---|
| 3105 | +do { \ |
---|
| 3106 | + no_printk(fmt, ##__VA_ARGS__); \ |
---|
| 3107 | + __ext4_abort(sb, "", 0, err, " "); \ |
---|
2822 | 3108 | } while (0) |
---|
2823 | 3109 | #define ext4_warning(sb, fmt, ...) \ |
---|
2824 | 3110 | do { \ |
---|
.. | .. |
---|
2845 | 3131 | |
---|
2846 | 3132 | #endif |
---|
2847 | 3133 | |
---|
2848 | | -extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb, |
---|
2849 | | - __u32 compat); |
---|
2850 | | -extern int ext4_update_rocompat_feature(handle_t *handle, |
---|
2851 | | - struct super_block *sb, __u32 rocompat); |
---|
2852 | | -extern int ext4_update_incompat_feature(handle_t *handle, |
---|
2853 | | - struct super_block *sb, __u32 incompat); |
---|
2854 | 3134 | extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, |
---|
2855 | 3135 | struct ext4_group_desc *bg); |
---|
2856 | 3136 | extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, |
---|
.. | .. |
---|
2901 | 3181 | return ext4_has_feature_gdt_csum(sb) || ext4_has_metadata_csum(sb); |
---|
2902 | 3182 | } |
---|
2903 | 3183 | |
---|
| 3184 | +#define ext4_read_incompat_64bit_val(es, name) \ |
---|
| 3185 | + (((es)->s_feature_incompat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_64BIT) \ |
---|
| 3186 | + ? (ext4_fsblk_t)le32_to_cpu(es->name##_hi) << 32 : 0) | \ |
---|
| 3187 | + le32_to_cpu(es->name##_lo)) |
---|
| 3188 | + |
---|
2904 | 3189 | static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es) |
---|
2905 | 3190 | { |
---|
2906 | | - return ((ext4_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) | |
---|
2907 | | - le32_to_cpu(es->s_blocks_count_lo); |
---|
| 3191 | + return ext4_read_incompat_64bit_val(es, s_blocks_count); |
---|
2908 | 3192 | } |
---|
2909 | 3193 | |
---|
2910 | 3194 | static inline ext4_fsblk_t ext4_r_blocks_count(struct ext4_super_block *es) |
---|
2911 | 3195 | { |
---|
2912 | | - return ((ext4_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) | |
---|
2913 | | - le32_to_cpu(es->s_r_blocks_count_lo); |
---|
| 3196 | + return ext4_read_incompat_64bit_val(es, s_r_blocks_count); |
---|
2914 | 3197 | } |
---|
2915 | 3198 | |
---|
2916 | 3199 | static inline ext4_fsblk_t ext4_free_blocks_count(struct ext4_super_block *es) |
---|
2917 | 3200 | { |
---|
2918 | | - return ((ext4_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) | |
---|
2919 | | - le32_to_cpu(es->s_free_blocks_count_lo); |
---|
| 3201 | + return ext4_read_incompat_64bit_val(es, s_free_blocks_count); |
---|
2920 | 3202 | } |
---|
2921 | 3203 | |
---|
2922 | 3204 | static inline void ext4_blocks_count_set(struct ext4_super_block *es, |
---|
.. | .. |
---|
3042 | 3324 | |
---|
3043 | 3325 | struct ext4_group_info { |
---|
3044 | 3326 | unsigned long bb_state; |
---|
| 3327 | +#ifdef AGGRESSIVE_CHECK |
---|
| 3328 | + unsigned long bb_check_counter; |
---|
| 3329 | +#endif |
---|
3045 | 3330 | struct rb_root bb_free_root; |
---|
3046 | 3331 | ext4_grpblk_t bb_first_free; /* first free block */ |
---|
3047 | 3332 | ext4_grpblk_t bb_free; /* total free blocks */ |
---|
.. | .. |
---|
3066 | 3351 | (1 << EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT) |
---|
3067 | 3352 | #define EXT4_GROUP_INFO_IBITMAP_CORRUPT \ |
---|
3068 | 3353 | (1 << EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT) |
---|
| 3354 | +#define EXT4_GROUP_INFO_BBITMAP_READ_BIT 4 |
---|
3069 | 3355 | |
---|
3070 | 3356 | #define EXT4_MB_GRP_NEED_INIT(grp) \ |
---|
3071 | 3357 | (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state))) |
---|
.. | .. |
---|
3080 | 3366 | (set_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state))) |
---|
3081 | 3367 | #define EXT4_MB_GRP_CLEAR_TRIMMED(grp) \ |
---|
3082 | 3368 | (clear_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state))) |
---|
| 3369 | +#define EXT4_MB_GRP_TEST_AND_SET_READ(grp) \ |
---|
| 3370 | + (test_and_set_bit(EXT4_GROUP_INFO_BBITMAP_READ_BIT, &((grp)->bb_state))) |
---|
3083 | 3371 | |
---|
3084 | 3372 | #define EXT4_MAX_CONTENTION 8 |
---|
3085 | 3373 | #define EXT4_CONTENTION_THRESHOLD 2 |
---|
.. | .. |
---|
3145 | 3433 | /* dir.c */ |
---|
3146 | 3434 | extern const struct file_operations ext4_dir_operations; |
---|
3147 | 3435 | |
---|
3148 | | -#ifdef CONFIG_UNICODE |
---|
3149 | | -extern const struct dentry_operations ext4_dentry_ops; |
---|
3150 | | -#endif |
---|
3151 | | - |
---|
3152 | 3436 | /* file.c */ |
---|
3153 | 3437 | extern const struct inode_operations ext4_file_inode_operations; |
---|
3154 | 3438 | extern const struct file_operations ext4_file_operations; |
---|
.. | .. |
---|
3193 | 3477 | extern int ext4_read_inline_dir(struct file *filp, |
---|
3194 | 3478 | struct dir_context *ctx, |
---|
3195 | 3479 | int *has_inline_data); |
---|
3196 | | -extern int htree_inlinedir_to_tree(struct file *dir_file, |
---|
3197 | | - struct inode *dir, ext4_lblk_t block, |
---|
3198 | | - struct dx_hash_info *hinfo, |
---|
3199 | | - __u32 start_hash, __u32 start_minor_hash, |
---|
3200 | | - int *has_inline_data); |
---|
| 3480 | +extern int ext4_inlinedir_to_tree(struct file *dir_file, |
---|
| 3481 | + struct inode *dir, ext4_lblk_t block, |
---|
| 3482 | + struct dx_hash_info *hinfo, |
---|
| 3483 | + __u32 start_hash, __u32 start_minor_hash, |
---|
| 3484 | + int *has_inline_data); |
---|
3201 | 3485 | extern struct buffer_head *ext4_find_inline_entry(struct inode *dir, |
---|
3202 | 3486 | struct ext4_filename *fname, |
---|
3203 | 3487 | struct ext4_dir_entry_2 **res_dir, |
---|
.. | .. |
---|
3236 | 3520 | struct ext4_dir_entry_2 *de, |
---|
3237 | 3521 | int blocksize, int csum_size, |
---|
3238 | 3522 | unsigned int parent_ino, int dotdot_real_len); |
---|
3239 | | -extern void initialize_dirent_tail(struct ext4_dir_entry_tail *t, |
---|
3240 | | - unsigned int blocksize); |
---|
3241 | | -extern int ext4_handle_dirty_dirent_node(handle_t *handle, |
---|
3242 | | - struct inode *inode, |
---|
3243 | | - struct buffer_head *bh); |
---|
| 3523 | +extern void ext4_initialize_dirent_tail(struct buffer_head *bh, |
---|
| 3524 | + unsigned int blocksize); |
---|
| 3525 | +extern int ext4_handle_dirty_dirblock(handle_t *handle, struct inode *inode, |
---|
| 3526 | + struct buffer_head *bh); |
---|
| 3527 | +extern int __ext4_unlink(handle_t *handle, struct inode *dir, const struct qstr *d_name, |
---|
| 3528 | + struct inode *inode); |
---|
| 3529 | +extern int __ext4_link(struct inode *dir, struct inode *inode, |
---|
| 3530 | + struct dentry *dentry); |
---|
3244 | 3531 | |
---|
3245 | 3532 | #define S_SHIFT 12 |
---|
3246 | 3533 | static const unsigned char ext4_type_by_mode[(S_IFMT >> S_SHIFT) + 1] = { |
---|
.. | .. |
---|
3261 | 3548 | } |
---|
3262 | 3549 | |
---|
3263 | 3550 | /* readpages.c */ |
---|
3264 | | -extern int ext4_mpage_readpages(struct address_space *mapping, |
---|
3265 | | - struct list_head *pages, struct page *page, |
---|
3266 | | - unsigned nr_pages, bool is_readahead); |
---|
| 3551 | +extern int ext4_mpage_readpages(struct inode *inode, |
---|
| 3552 | + struct readahead_control *rac, struct page *page); |
---|
3267 | 3553 | extern int __init ext4_init_post_read_processing(void); |
---|
3268 | 3554 | extern void ext4_exit_post_read_processing(void); |
---|
3269 | 3555 | |
---|
.. | .. |
---|
3299 | 3585 | */ |
---|
3300 | 3586 | #define EXT_MAX_BLOCKS 0xffffffff |
---|
3301 | 3587 | |
---|
3302 | | -extern int ext4_ext_tree_init(handle_t *handle, struct inode *); |
---|
3303 | | -extern int ext4_ext_writepage_trans_blocks(struct inode *, int); |
---|
| 3588 | +extern void ext4_ext_tree_init(handle_t *handle, struct inode *inode); |
---|
3304 | 3589 | extern int ext4_ext_index_trans_blocks(struct inode *inode, int extents); |
---|
3305 | 3590 | extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, |
---|
3306 | 3591 | struct ext4_map_blocks *map, int flags); |
---|
.. | .. |
---|
3313 | 3598 | loff_t len); |
---|
3314 | 3599 | extern int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode, |
---|
3315 | 3600 | loff_t offset, ssize_t len); |
---|
| 3601 | +extern int ext4_convert_unwritten_io_end_vec(handle_t *handle, |
---|
| 3602 | + ext4_io_end_t *io_end); |
---|
3316 | 3603 | extern int ext4_map_blocks(handle_t *handle, struct inode *inode, |
---|
3317 | 3604 | struct ext4_map_blocks *map, int flags); |
---|
3318 | | -extern int ext4_ext_calc_metadata_amount(struct inode *inode, |
---|
3319 | | - ext4_lblk_t lblocks); |
---|
3320 | 3605 | extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode, |
---|
3321 | 3606 | int num, |
---|
3322 | 3607 | struct ext4_ext_path *path); |
---|
3323 | | -extern int ext4_can_extents_be_merged(struct inode *inode, |
---|
3324 | | - struct ext4_extent *ex1, |
---|
3325 | | - struct ext4_extent *ex2); |
---|
3326 | 3608 | extern int ext4_ext_insert_extent(handle_t *, struct inode *, |
---|
3327 | 3609 | struct ext4_ext_path **, |
---|
3328 | 3610 | struct ext4_extent *, int); |
---|
.. | .. |
---|
3331 | 3613 | int flags); |
---|
3332 | 3614 | extern void ext4_ext_drop_refs(struct ext4_ext_path *); |
---|
3333 | 3615 | extern int ext4_ext_check_inode(struct inode *inode); |
---|
3334 | | -extern int ext4_find_delalloc_range(struct inode *inode, |
---|
3335 | | - ext4_lblk_t lblk_start, |
---|
3336 | | - ext4_lblk_t lblk_end); |
---|
3337 | | -extern int ext4_find_delalloc_cluster(struct inode *inode, ext4_lblk_t lblk); |
---|
3338 | 3616 | extern ext4_lblk_t ext4_ext_next_allocated_block(struct ext4_ext_path *path); |
---|
3339 | 3617 | extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, |
---|
3340 | 3618 | __u64 start, __u64 len); |
---|
| 3619 | +extern int ext4_get_es_cache(struct inode *inode, |
---|
| 3620 | + struct fiemap_extent_info *fieinfo, |
---|
| 3621 | + __u64 start, __u64 len); |
---|
3341 | 3622 | extern int ext4_ext_precache(struct inode *inode); |
---|
3342 | | -extern int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len); |
---|
3343 | | -extern int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len); |
---|
3344 | 3623 | extern int ext4_swap_extents(handle_t *handle, struct inode *inode1, |
---|
3345 | 3624 | struct inode *inode2, ext4_lblk_t lblk1, |
---|
3346 | 3625 | ext4_lblk_t lblk2, ext4_lblk_t count, |
---|
3347 | 3626 | int mark_unwritten,int *err); |
---|
| 3627 | +extern int ext4_clu_mapped(struct inode *inode, ext4_lblk_t lclu); |
---|
| 3628 | +extern int ext4_datasem_ensure_credits(handle_t *handle, struct inode *inode, |
---|
| 3629 | + int check_cred, int restart_cred, |
---|
| 3630 | + int revoke_cred); |
---|
| 3631 | +extern void ext4_ext_replay_shrink_inode(struct inode *inode, ext4_lblk_t end); |
---|
| 3632 | +extern int ext4_ext_replay_set_iblocks(struct inode *inode); |
---|
| 3633 | +extern int ext4_ext_replay_update_ex(struct inode *inode, ext4_lblk_t start, |
---|
| 3634 | + int len, int unwritten, ext4_fsblk_t pblk); |
---|
| 3635 | +extern int ext4_ext_clear_bb(struct inode *inode); |
---|
| 3636 | + |
---|
3348 | 3637 | |
---|
3349 | 3638 | /* move_extent.c */ |
---|
3350 | 3639 | extern void ext4_double_down_write_data_sem(struct inode *first, |
---|
.. | .. |
---|
3371 | 3660 | int len, |
---|
3372 | 3661 | struct writeback_control *wbc, |
---|
3373 | 3662 | bool keep_towrite); |
---|
| 3663 | +extern struct ext4_io_end_vec *ext4_alloc_io_end_vec(ext4_io_end_t *io_end); |
---|
| 3664 | +extern struct ext4_io_end_vec *ext4_last_io_end_vec(ext4_io_end_t *io_end); |
---|
3374 | 3665 | |
---|
3375 | 3666 | /* mmp.c */ |
---|
3376 | 3667 | extern int ext4_multi_mount_protect(struct super_block *, ext4_fsblk_t); |
---|
| 3668 | + |
---|
| 3669 | +/* mmp.c */ |
---|
| 3670 | +extern void ext4_stop_mmpd(struct ext4_sb_info *sbi); |
---|
3377 | 3671 | |
---|
3378 | 3672 | /* verity.c */ |
---|
3379 | 3673 | extern const struct fsverity_operations ext4_verityops; |
---|
.. | .. |
---|
3428 | 3722 | } |
---|
3429 | 3723 | |
---|
3430 | 3724 | extern const struct iomap_ops ext4_iomap_ops; |
---|
| 3725 | +extern const struct iomap_ops ext4_iomap_overwrite_ops; |
---|
| 3726 | +extern const struct iomap_ops ext4_iomap_report_ops; |
---|
| 3727 | + |
---|
| 3728 | +static inline int ext4_buffer_uptodate(struct buffer_head *bh) |
---|
| 3729 | +{ |
---|
| 3730 | + /* |
---|
| 3731 | + * If the buffer has the write error flag, we have failed |
---|
| 3732 | + * to write out data in the block. In this case, we don't |
---|
| 3733 | + * have to read the block because we may read the old data |
---|
| 3734 | + * successfully. |
---|
| 3735 | + */ |
---|
| 3736 | + if (!buffer_uptodate(bh) && buffer_write_io_error(bh)) |
---|
| 3737 | + set_buffer_uptodate(bh); |
---|
| 3738 | + return buffer_uptodate(bh); |
---|
| 3739 | +} |
---|
3431 | 3740 | |
---|
3432 | 3741 | #endif /* __KERNEL__ */ |
---|
3433 | 3742 | |
---|