• Home
  • Raw
  • Download

Lines Matching +full:mmp +full:- +full:timer

1 // SPDX-License-Identifier: GPL-2.0
7 * Laboratoire MASI - Institut Blaise Pascal
29 #include <linux/timer.h>
38 #include <linux/percpu-rwsem.h>
48 /* Until this gets included into linux/compiler-gcc.h */
68 * with DOUBLE_CHECK defined mballoc creates persistent in-core
84 printk(KERN_DEBUG "EXT4-fs DEBUG (%s, %d): %s:", \
105 /* data type for filesystem-wide blocks number */
146 /* blocks already pre-reserved by delayed allocation */
206 * Flags for ext4_io_end->flags
215 struct list_head list; /* per-file finished IO list */
246 /* First non-reserved inode for old ext4 filesystems */
255 * Macro-instructions used to manage several block sizes
263 # define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize)
265 # define EXT4_BLOCK_SIZE(s) (EXT4_MIN_BLOCK_SIZE << (s)->s_log_block_size)
269 EXT4_SB(s)->s_cluster_bits)
271 # define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
272 # define EXT4_CLUSTER_BITS(s) (EXT4_SB(s)->s_cluster_bits)
274 # define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
277 #define EXT4_ADDR_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_addr_per_block_bits)
278 #define EXT4_INODE_SIZE(s) (EXT4_SB(s)->s_inode_size)
279 #define EXT4_FIRST_INO(s) (EXT4_SB(s)->s_first_ino)
281 #define EXT4_INODE_SIZE(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
283 (s)->s_inode_size)
284 #define EXT4_FIRST_INO(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
286 (s)->s_first_ino)
290 ((EXT4_BLOCK_ALIGN(size + offset, blkbits) >> blkbits) - (offset >> \
294 #define EXT4_B2C(sbi, blk) ((blk) >> (sbi)->s_cluster_bits)
296 #define EXT4_C2B(sbi, cluster) ((cluster) << (sbi)->s_cluster_bits)
298 #define EXT4_NUM_B2C(sbi, blks) (((blks) + (sbi)->s_cluster_ratio - 1) >> \
299 (sbi)->s_cluster_bits)
302 ~((ext4_fsblk_t) (s)->s_cluster_ratio - 1))
304 ~((ext4_lblk_t) (s)->s_cluster_ratio - 1))
307 ((ext4_fsblk_t) (s)->s_cluster_ratio - 1))
309 ((ext4_lblk_t) (s)->s_cluster_ratio - 1))
360 #define EXT4_BG_INODE_ZEROED 0x0004 /* On-disk itable initialized to zero */
363 * Macro-instructions used to manage group descriptors
368 #define EXT4_DESC_SIZE(s) (EXT4_SB(s)->s_desc_size)
370 # define EXT4_BLOCKS_PER_GROUP(s) (EXT4_SB(s)->s_blocks_per_group)
371 # define EXT4_CLUSTERS_PER_GROUP(s) (EXT4_SB(s)->s_clusters_per_group)
372 # define EXT4_DESC_PER_BLOCK(s) (EXT4_SB(s)->s_desc_per_block)
373 # define EXT4_INODES_PER_GROUP(s) (EXT4_SB(s)->s_inodes_per_group)
374 # define EXT4_DESC_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_desc_per_block_bits)
376 # define EXT4_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
378 # define EXT4_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
407 /* End compression flags --- maybe not all used */
408 #define EXT4_INDEX_FL 0x00001000 /* hash-indexed directory */
440 /* Flags that are appropriate for regular files (all but dir-specific ones). */
443 /* Flags that are appropriate for non-directories/regular files. */
477 /* End compression flags --- maybe not all used */
478 EXT4_INODE_INDEX = 12, /* hash-indexed directory */
495 * build-time check to make sure that EXT4_XXX_FL is consistent with respect to
500 * with the values of FS_XXX_FL defined in include/linux/fs.h and the on-disk
504 * It's not paranoia if the Murphy's Law really *is* out to get you. :-)
658 /* note ioctl 11 reserved for filesystem-independent FIEMAP ioctl */
763 __le32 i_version_hi; /* high 32 bits for 64-bit version */
777 #define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
782 * with large inodes (-I 256 or larger) and there are not currently any EAs
788 * inode-size = GOOD_OLD_INODE_SIZE + i_extra_isize
792 sizeof((ext4_inode)->field)) \
794 (einode)->i_extra_isize)) \
800 * epoch 32-bit 32-bit tv_sec to
801 * bits time decoded 64-bit tv_sec 64-bit tv_sec valid time range
802 * 0 0 1 -0x80000000..-0x00000001 0x000000000 1901-12-13..1969-12-31
803 * 0 0 0 0x000000000..0x07fffffff 0x000000000 1970-01-01..2038-01-19
804 * 0 1 1 0x080000000..0x0ffffffff 0x100000000 2038-01-19..2106-02-07
805 * 0 1 0 0x100000000..0x17fffffff 0x100000000 2106-02-07..2174-02-25
806 * 1 0 1 0x180000000..0x1ffffffff 0x200000000 2174-02-25..2242-03-16
807 * 1 0 0 0x200000000..0x27fffffff 0x200000000 2242-03-16..2310-04-04
808 * 1 1 1 0x280000000..0x2ffffffff 0x300000000 2310-04-04..2378-04-22
809 * 1 1 0 0x300000000..0x37fffffff 0x300000000 2378-04-22..2446-05-10
811 * Note that previous versions of the kernel on 64-bit systems would
819 u32 extra =((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK; in ext4_encode_extra_time()
820 return cpu_to_le32(extra | (time->tv_nsec << EXT4_EPOCH_BITS)); in ext4_encode_extra_time()
829 /* Handle legacy encoding of pre-1970 dates with epoch in ext4_decode_extra_time()
834 if (extra_bits == 3 && ((time->tv_sec) & 0x80000000) != 0) in ext4_decode_extra_time()
836 time->tv_sec += extra_bits << 32; in ext4_decode_extra_time()
838 time->tv_sec += (u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) << 32; in ext4_decode_extra_time()
841 time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS; in ext4_decode_extra_time()
846 (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \
848 (raw_inode)->xtime ## _extra = \
849 ext4_encode_extra_time(&(inode)->xtime); \
856 (raw_inode)->xtime = cpu_to_le32((einode)->xtime.tv_sec); \
858 (raw_inode)->xtime ## _extra = \
859 ext4_encode_extra_time(&(einode)->xtime); \
864 (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime); \
866 ext4_decode_extra_time(&(inode)->xtime, \
867 raw_inode->xtime ## _extra); \
870 (inode)->xtime.tv_nsec = 0; \
877 (einode)->xtime.tv_sec = \
878 (signed)le32_to_cpu((raw_inode)->xtime); \
880 (einode)->xtime.tv_sec = 0; \
882 ext4_decode_extra_time(&(einode)->xtime, \
883 raw_inode->xtime ## _extra); \
885 (einode)->xtime.tv_nsec = 0; \
922 * holding i_data_sem for a normal (non-quota) inode. Since we don't
927 * I_DATA_SEM_NORMAL - Used for most inodes
928 * I_DATA_SEM_OTHER - Used by move_inode.c for the second normal inode
931 * I_DATA_SEM_QUOTA - Used for quota inodes only
951 * it is used for making block allocation decisions - we try to
982 * into the on-disk inode when writing inodes out, instead of i_size.
997 * during recovery. Hence we must fix the get_block-vs-truncate race
1044 /* on-disk additional length */
1121 #define EXT4_MOUNT_NO_UID32 0x02000 /* Disable 32-bit UIDs */
1155 #define EXT4_MOUNT2_HURD_COMPAT 0x00000004 /* Support HURD-castrated
1161 #define clear_opt(sb, opt) EXT4_SB(sb)->s_mount_opt &= \
1163 #define set_opt(sb, opt) EXT4_SB(sb)->s_mount_opt |= \
1165 #define test_opt(sb, opt) (EXT4_SB(sb)->s_mount_opt & \
1168 #define clear_opt2(sb, opt) EXT4_SB(sb)->s_mount_opt2 &= \
1170 #define set_opt2(sb, opt) EXT4_SB(sb)->s_mount_opt2 |= \
1172 #define test_opt2(sb, opt) (EXT4_SB(sb)->s_mount_opt2 & \
1197 #define EXT4_ERRORS_RO 2 /* Remount fs read-only */
1246 __le32 s_first_ino; /* First non-reserved inode */
1251 __le32 s_feature_ro_compat; /* readonly-compatible feature set */
1252 /*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
1286 __le16 s_mmp_update_interval; /* # seconds to wait in MMP checking */
1287 __le64 s_mmp_block; /* Block for multi-mount protection */
1299 on-disk snapshot list */
1334 #define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START)
1339 * run-time mount flags
1346 #define DUMMY_ENCRYPTION_ENABLED(sbi) (unlikely((sbi)->s_mount_flags & \
1356 * fourth extended-fs super-block data in memory
1368 ext4_group_t s_blockfile_groups;/* Groups acceptable for non-extent files */
1452 /* where last allocation was done - for stream allocation */
1479 /* the size of zero-out chunk */
1489 /* timer for periodic error stats printing */
1533 return sb->s_fs_info; in EXT4_SB()
1544 ino <= le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count)); in ext4_valid_inum()
1548 * Returns: sbi->field[index]
1551 * - s_group_desc
1552 * - s_group_info
1553 * - s_flex_group
1557 typeof(*((sbi)->field)) _v; \
1559 _v = ((typeof(_v)*)rcu_dereference((sbi)->field))[index]; \
1570 EXT4_STATE_XATTR, /* has in-inode xattrs */
1576 EXT4_STATE_MAY_INLINE_DATA, /* may have in-inode data */
1578 EXT4_STATE_LUSTRE_EA_INODE, /* Lustre-style ea_inode */
1584 return test_bit(bit + (offset), &EXT4_I(inode)->i_##field); \
1588 set_bit(bit + (offset), &EXT4_I(inode)->i_##field); \
1592 clear_bit(bit + (offset), &EXT4_I(inode)->i_##field); \
1612 (ei)->i_state_flags = 0; in ext4_clear_state_flags()
1624 * a kernel struct super_block. This will allow us to call the feature-test
1632 #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
1697 #define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 /* >2GB or 3-lvl htree */
1706 return ((EXT4_SB(sb)->s_es->s_feature_compat & \
1712 EXT4_SB(sb)->s_es->s_feature_compat |= \
1717 EXT4_SB(sb)->s_es->s_feature_compat &= \
1724 return ((EXT4_SB(sb)->s_es->s_feature_ro_compat & \
1730 EXT4_SB(sb)->s_es->s_feature_ro_compat |= \
1735 EXT4_SB(sb)->s_es->s_feature_ro_compat &= \
1742 return ((EXT4_SB(sb)->s_es->s_feature_incompat & \
1748 EXT4_SB(sb)->s_es->s_feature_incompat |= \
1753 EXT4_SB(sb)->s_es->s_feature_incompat &= \
1785 EXT4_FEATURE_INCOMPAT_FUNCS(mmp, MMP) in EXT4_FEATURE_COMPAT_FUNCS()
1837 return ((EXT4_SB(sb)->s_es->s_feature_compat & \ in EXT4_FEATURE_COMPAT_FUNCS()
1842 return ((EXT4_SB(sb)->s_es->s_feature_ro_compat & \
1847 return ((EXT4_SB(sb)->s_es->s_feature_incompat & \
1857 return (EXT4_SB(sb)->s_es->s_feature_compat != 0);
1861 return (EXT4_SB(sb)->s_es->s_feature_ro_compat != 0); in ext4_has_ro_compat_features()
1865 return (EXT4_SB(sb)->s_es->s_feature_incompat != 0); in ext4_has_incompat_features()
1876 return test_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); in ext4_forced_shutdown()
1962 ((blocksize) - \
1988 #define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
1991 #define EXT4_MAX_REC_LEN ((1<<16)-1)
2035 #define is_dx(dir) (ext4_has_feature_dir_index((dir)->i_sb) && \
2037 #define EXT4_DIR_LINK_MAX(dir) unlikely((dir)->i_nlink >= EXT4_LINK_MAX && \
2038 !(ext4_has_feature_dir_nlink((dir)->i_sb) && is_dx(dir)))
2039 #define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
2058 BUG_ON(crypto_shash_descsize(sbi->s_chksum_driver)!=sizeof(desc.ctx)); in ext4_chksum()
2060 desc.shash.tfm = sbi->s_chksum_driver; in ext4_chksum()
2082 #define EXT4_HTREE_EOF_32BIT ((1UL << (32 - 1)) - 1)
2083 #define EXT4_HTREE_EOF_64BIT ((1ULL << (64 - 1)) - 1)
2100 #define fname_name(p) ((p)->disk_name.name)
2101 #define fname_len(p) ((p)->disk_name.len)
2115 return (struct ext4_inode *) (iloc->bh->b_data + iloc->offset); in ext4_raw_inode()
2121 !(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL); in ext4_is_quota_file()
2144 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); in ext4_group_first_block_no()
2150 #define ERR_BAD_DX_DIR (-(MAX_ERRNO - 1))
2196 * superblock. Programs that check MMP should assume that if
2200 #define EXT4_MMP_MAGIC 0x004D4D50U /* ASCII for MMP */
2206 __le32 mmp_magic; /* Magic number for MMP */
2214 char mmp_nodename[64]; /* Node which last updated MMP block */
2215 char mmp_bdevname[32]; /* Bdev which last updated MMP block */
2218 * mmp_check_interval is used to verify if the MMP block has been
2220 * maximum time to write the MMP block during an update cycle.
2229 /* arguments passed to the mmp thread */
2237 * The MMP block is written every update interval and initially checked every
2246 * Minimum interval for MMP checking in seconds.
2251 * Maximum interval for MMP checking in seconds.
2334 dst->usr_fname = src->usr_fname; in ext4_fname_from_fscrypt_name()
2335 dst->disk_name = src->disk_name; in ext4_fname_from_fscrypt_name()
2336 dst->hinfo.hash = src->hash; in ext4_fname_from_fscrypt_name()
2337 dst->hinfo.minor_hash = src->minor_hash; in ext4_fname_from_fscrypt_name()
2338 dst->crypto_buf = src->crypto_buf; in ext4_fname_from_fscrypt_name()
2376 name.crypto_buf = fname->crypto_buf; in ext4_fname_free_filename()
2379 fname->crypto_buf.name = NULL; in ext4_fname_free_filename()
2380 fname->usr_fname = NULL; in ext4_fname_free_filename()
2381 fname->disk_name.name = NULL; in ext4_fname_free_filename()
2389 fname->usr_fname = iname; in ext4_fname_setup_filename()
2390 fname->disk_name.name = (unsigned char *) iname->name; in ext4_fname_setup_filename()
2391 fname->disk_name.len = iname->len; in ext4_fname_setup_filename()
2399 return ext4_fname_setup_filename(dir, &dentry->d_name, 1, fname); in ext4_fname_prepare_lookup()
2430 if (!ext4_has_feature_dir_index(inode->i_sb)) { in ext4_update_dx_flag()
2432 WARN_ON_ONCE(ext4_has_feature_metadata_csum(inode->i_sb)); in ext4_update_dx_flag()
2665 extern void __dump_mmp_msg(struct super_block *, struct mmp_struct *mmp,
2698 #define dump_mmp_msg(sb, mmp, msg) \ argument
2699 __dump_mmp_msg(sb, mmp, __func__, __LINE__, msg)
2741 #define dump_mmp_msg(sb, mmp, msg) \ argument
2742 __dump_mmp_msg(sb, mmp, "", 0, "")
2796 !EXT4_SB(sb)->s_chksum_driver); in ext4_has_metadata_csum()
2799 (EXT4_SB(sb)->s_chksum_driver != NULL); in ext4_has_metadata_csum()
2809 return ((ext4_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) | in ext4_blocks_count()
2810 le32_to_cpu(es->s_blocks_count_lo); in ext4_blocks_count()
2815 return ((ext4_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) | in ext4_r_blocks_count()
2816 le32_to_cpu(es->s_r_blocks_count_lo); in ext4_r_blocks_count()
2821 return ((ext4_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) | in ext4_free_blocks_count()
2822 le32_to_cpu(es->s_free_blocks_count_lo); in ext4_free_blocks_count()
2828 es->s_blocks_count_lo = cpu_to_le32((u32)blk); in ext4_blocks_count_set()
2829 es->s_blocks_count_hi = cpu_to_le32(blk >> 32); in ext4_blocks_count_set()
2835 es->s_free_blocks_count_lo = cpu_to_le32((u32)blk); in ext4_free_blocks_count_set()
2836 es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32); in ext4_free_blocks_count_set()
2842 es->s_r_blocks_count_lo = cpu_to_le32((u32)blk); in ext4_r_blocks_count_set()
2843 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32); in ext4_r_blocks_count_set()
2850 S_ISREG(le16_to_cpu(raw_inode->i_mode))) in ext4_isize()
2851 return ((loff_t)le32_to_cpu(raw_inode->i_size_high) << 32) | in ext4_isize()
2852 le32_to_cpu(raw_inode->i_size_lo); in ext4_isize()
2854 return (loff_t) le32_to_cpu(raw_inode->i_size_lo); in ext4_isize()
2859 raw_inode->i_size_lo = cpu_to_le32(i_size); in ext4_isize_set()
2860 raw_inode->i_size_high = cpu_to_le32(i_size >> 32); in ext4_isize_set()
2869 BUG_ON(group >= EXT4_SB(sb)->s_groups_count); in ext4_get_group_info()
2871 indexh = group & ((EXT4_DESC_PER_BLOCK(sb)) - 1); in ext4_get_group_info()
2883 ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count; in ext4_get_groups_count()
2892 return block_group >> sbi->s_log_groups_per_flex; in ext4_flex_group()
2897 return 1 << sbi->s_log_groups_per_flex; in ext4_flex_bg_size()
2919 WARN_ON_ONCE(S_ISREG(inode->i_mode) && in ext4_update_i_disksize()
2921 down_write(&EXT4_I(inode)->i_data_sem); in ext4_update_i_disksize()
2922 if (newsize > EXT4_I(inode)->i_disksize) in ext4_update_i_disksize()
2923 WRITE_ONCE(EXT4_I(inode)->i_disksize, newsize); in ext4_update_i_disksize()
2924 up_write(&EXT4_I(inode)->i_data_sem); in ext4_update_i_disksize()
2932 if (newsize > inode->i_size) { in ext4_update_inode_size()
2936 if (newsize > EXT4_I(inode)->i_disksize) { in ext4_update_inode_size()
2958 ext4_grpblk_t bb_counters[]; /* Nr of free power-of-two-block
2961 * 5 free 8-block regions. */
2974 (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state)))
2976 (test_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &((grp)->bb_state)))
2978 (test_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &((grp)->bb_state)))
2981 (test_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
2983 (set_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
2985 (clear_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
2993 return bgl_lock_ptr(EXT4_SB(sb)->s_blockgroup_lock, group); in ext4_group_lock_ptr()
3002 return (atomic_read(&sbi->s_lock_busy) > EXT4_CONTENTION_THRESHOLD); in ext4_fs_is_busy()
3013 atomic_add_unless(&EXT4_SB(sb)->s_lock_busy, -1, 0); in ext4_lock_group()
3019 atomic_add_unless(&EXT4_SB(sb)->s_lock_busy, 1, in ext4_lock_group()
3036 (__le32 *)(bh)->b_data, \
3037 EXT4_ADDR_PER_BLOCK((inode)->i_sb))
3041 EXT4_I(inode)->i_data, \
3127 EXT4_I(inode)->i_inline_off; in ext4_has_inline_data()
3158 de->file_type = ext4_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; in ext4_set_de_type()
3254 /* page-io.c */
3271 /* mmp.c */
3277 * to mark the bitmap uptodate. We need to also zero-out the bitmap
3284 test_bit(BH_BITMAP_UPTODATE, &(bh)->b_state)); in bitmap_uptodate()
3288 set_bit(BH_BITMAP_UPTODATE, &(bh)->b_state); in set_bitmap_uptodate()
3291 #define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1)
3305 if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) { in ext4_set_io_unwritten_flag()
3306 io_end->flag |= EXT4_IO_END_UNWRITTEN; in ext4_set_io_unwritten_flag()
3307 atomic_inc(&EXT4_I(inode)->i_unwritten); in ext4_set_io_unwritten_flag()
3313 struct inode *inode = io_end->inode; in ext4_clear_io_unwritten_flag()
3315 if (io_end->flag & EXT4_IO_END_UNWRITTEN) { in ext4_clear_io_unwritten_flag()
3316 io_end->flag &= ~EXT4_IO_END_UNWRITTEN; in ext4_clear_io_unwritten_flag()
3318 if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten)) in ext4_clear_io_unwritten_flag()