^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * ext4.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 1992, 1993, 1994, 1995
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Remy Card (card@masi.ibp.fr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Laboratoire MASI - Institut Blaise Pascal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Universite Pierre et Marie Curie (Paris VI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * linux/include/linux/minix_fs.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Copyright (C) 1991, 1992 Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #ifndef _EXT4_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define _EXT4_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/magic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/jbd2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/quota.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/rwsem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/rbtree.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/seqlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/blockgroup_lock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/percpu_counter.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/ratelimit.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <crypto/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <linux/falloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <linux/percpu-rwsem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/fiemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/compat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include <linux/fscrypt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <linux/fsverity.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * The fourth extended filesystem constants/structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * with AGGRESSIVE_CHECK allocator runs consistency checks over
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * structures. these checks slow things down a lot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define AGGRESSIVE_CHECK__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * with DOUBLE_CHECK defined mballoc creates persistent in-core
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * bitmaps, maintains and uses them to check for double allocations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define DOUBLE_CHECK__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * Define EXT4FS_DEBUG to produce debug messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #undef EXT4FS_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * Debug code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #ifdef EXT4FS_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define ext4_debug(f, a...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) printk(KERN_DEBUG "EXT4-fs DEBUG (%s, %d): %s:", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) __FILE__, __LINE__, __func__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) printk(KERN_DEBUG f, ## a); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define ext4_debug(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * Turn on EXT_DEBUG to enable ext4_ext_show_path/leaf/move in extents.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define EXT_DEBUG__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * Dynamic printk for controlled extents debugging.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #ifdef CONFIG_EXT4_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define ext_debug(ino, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) pr_debug("[%s/%d] EXT4-fs (%s): ino %lu: (%s, %d): %s:" fmt, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) current->comm, task_pid_nr(current), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) ino->i_sb->s_id, ino->i_ino, __FILE__, __LINE__, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) __func__, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define ext_debug(ino, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /* data type for block offset of block group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) typedef int ext4_grpblk_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /* data type for filesystem-wide blocks number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) typedef unsigned long long ext4_fsblk_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* data type for file logical block number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) typedef __u32 ext4_lblk_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /* data type for block group number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) typedef unsigned int ext4_group_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) enum SHIFT_DIRECTION {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) SHIFT_LEFT = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) SHIFT_RIGHT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * Flags used in mballoc's allocation_context flags field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * Also used to show what's going on for debugging purposes when the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * flag field is exported via the traceport interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* prefer goal again. length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define EXT4_MB_HINT_MERGE 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /* blocks already reserved */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #define EXT4_MB_HINT_RESERVED 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) /* metadata is being allocated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #define EXT4_MB_HINT_METADATA 0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /* first blocks in the file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #define EXT4_MB_HINT_FIRST 0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /* search for the best chunk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #define EXT4_MB_HINT_BEST 0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /* data is being allocated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define EXT4_MB_HINT_DATA 0x0020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /* don't preallocate (for tails) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #define EXT4_MB_HINT_NOPREALLOC 0x0040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /* allocate for locality group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #define EXT4_MB_HINT_GROUP_ALLOC 0x0080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /* allocate goal blocks or none */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #define EXT4_MB_HINT_GOAL_ONLY 0x0100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /* goal is meaningful */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #define EXT4_MB_HINT_TRY_GOAL 0x0200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /* blocks already pre-reserved by delayed allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #define EXT4_MB_DELALLOC_RESERVED 0x0400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /* We are doing stream allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define EXT4_MB_STREAM_ALLOC 0x0800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* Use reserved root blocks if needed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #define EXT4_MB_USE_ROOT_BLOCKS 0x1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /* Use blocks from reserved pool */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #define EXT4_MB_USE_RESERVED 0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* Do strict check for free blocks while retrying block allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #define EXT4_MB_STRICT_CHECK 0x4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct ext4_allocation_request {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /* target inode for block we're allocating */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /* how many blocks we want to allocate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) unsigned int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /* logical block in target inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) ext4_lblk_t logical;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /* the closest logical allocated block to the left */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) ext4_lblk_t lleft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /* the closest logical allocated block to the right */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) ext4_lblk_t lright;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /* phys. target (a hint) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) ext4_fsblk_t goal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* phys. block for the closest logical allocated block to the left */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) ext4_fsblk_t pleft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /* phys. block for the closest logical allocated block to the right */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) ext4_fsblk_t pright;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /* flags. see above EXT4_MB_HINT_* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) unsigned int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * Logical to physical block mapping, used by ext4_map_blocks()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * This structure is used to pass requests into ext4_map_blocks() as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * well as to store the information returned by ext4_map_blocks(). It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * takes less room on the stack than a struct buffer_head.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #define EXT4_MAP_NEW BIT(BH_New)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) #define EXT4_MAP_MAPPED BIT(BH_Mapped)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #define EXT4_MAP_UNWRITTEN BIT(BH_Unwritten)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) #define EXT4_MAP_BOUNDARY BIT(BH_Boundary)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) #define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) struct ext4_map_blocks {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) ext4_fsblk_t m_pblk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) ext4_lblk_t m_lblk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) unsigned int m_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) unsigned int m_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * Block validity checking, system zone rbtree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) struct ext4_system_blocks {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) struct rb_root root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * Flags for ext4_io_end->flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) #define EXT4_IO_END_UNWRITTEN 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct ext4_io_end_vec {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct list_head list; /* list of io_end_vec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) loff_t offset; /* offset in the file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) ssize_t size; /* size of the extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * For converting unwritten extents on a work queue. 'handle' is used for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * buffered writeback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) typedef struct ext4_io_end {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct list_head list; /* per-file finished IO list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) handle_t *handle; /* handle reserved for extent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * conversion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct inode *inode; /* file being written to */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) struct bio *bio; /* Linked list of completed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * bios covering the extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) unsigned int flag; /* unwritten or not */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) atomic_t count; /* reference counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct list_head list_vec; /* list of ext4_io_end_vec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) } ext4_io_end_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) struct ext4_io_submit {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) struct writeback_control *io_wbc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) struct bio *io_bio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) ext4_io_end_t *io_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) sector_t io_next_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * Special inodes numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #define EXT4_BAD_INO 1 /* Bad blocks inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) #define EXT4_ROOT_INO 2 /* Root inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) #define EXT4_USR_QUOTA_INO 3 /* User quota inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) #define EXT4_GRP_QUOTA_INO 4 /* Group quota inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) #define EXT4_BOOT_LOADER_INO 5 /* Boot loader inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) #define EXT4_UNDEL_DIR_INO 6 /* Undelete directory inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) #define EXT4_RESIZE_INO 7 /* Reserved group descriptors inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) #define EXT4_JOURNAL_INO 8 /* Journal inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) /* First non-reserved inode for old ext4 filesystems */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) #define EXT4_GOOD_OLD_FIRST_INO 11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * Maximal count of links to a file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) #define EXT4_LINK_MAX 65000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * Macro-instructions used to manage several block sizes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) #define EXT4_MIN_BLOCK_SIZE 1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) #define EXT4_MAX_BLOCK_SIZE 65536
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) #define EXT4_MIN_BLOCK_LOG_SIZE 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) #define EXT4_MAX_BLOCK_LOG_SIZE 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) #define EXT4_MAX_CLUSTER_LOG_SIZE 30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) # define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) # define EXT4_BLOCK_SIZE(s) (EXT4_MIN_BLOCK_SIZE << (s)->s_log_block_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) #define EXT4_ADDR_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / sizeof(__u32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) #define EXT4_CLUSTER_SIZE(s) (EXT4_BLOCK_SIZE(s) << \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) EXT4_SB(s)->s_cluster_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) # define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) # define EXT4_CLUSTER_BITS(s) (EXT4_SB(s)->s_cluster_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) # define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) #define EXT4_ADDR_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_addr_per_block_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) #define EXT4_INODE_SIZE(s) (EXT4_SB(s)->s_inode_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) #define EXT4_FIRST_INO(s) (EXT4_SB(s)->s_first_ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) #define EXT4_INODE_SIZE(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) EXT4_GOOD_OLD_INODE_SIZE : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) (s)->s_inode_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) #define EXT4_FIRST_INO(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) EXT4_GOOD_OLD_FIRST_INO : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) (s)->s_first_ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) #define EXT4_BLOCK_ALIGN(size, blkbits) ALIGN((size), (1 << (blkbits)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) #define EXT4_MAX_BLOCKS(size, offset, blkbits) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) ((EXT4_BLOCK_ALIGN(size + offset, blkbits) >> blkbits) - (offset >> \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) blkbits))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /* Translate a block number to a cluster number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) #define EXT4_B2C(sbi, blk) ((blk) >> (sbi)->s_cluster_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) /* Translate a cluster number to a block number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) #define EXT4_C2B(sbi, cluster) ((cluster) << (sbi)->s_cluster_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) /* Translate # of blks to # of clusters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) #define EXT4_NUM_B2C(sbi, blks) (((blks) + (sbi)->s_cluster_ratio - 1) >> \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) (sbi)->s_cluster_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) /* Mask out the low bits to get the starting block of the cluster */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) #define EXT4_PBLK_CMASK(s, pblk) ((pblk) & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) ~((ext4_fsblk_t) (s)->s_cluster_ratio - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) #define EXT4_LBLK_CMASK(s, lblk) ((lblk) & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) ~((ext4_lblk_t) (s)->s_cluster_ratio - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) /* Fill in the low bits to get the last block of the cluster */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) #define EXT4_LBLK_CFILL(sbi, lblk) ((lblk) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) ((ext4_lblk_t) (sbi)->s_cluster_ratio - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /* Get the cluster offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) #define EXT4_PBLK_COFF(s, pblk) ((pblk) & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) ((ext4_fsblk_t) (s)->s_cluster_ratio - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) #define EXT4_LBLK_COFF(s, lblk) ((lblk) & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) ((ext4_lblk_t) (s)->s_cluster_ratio - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) * Structure of a blocks group descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) struct ext4_group_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) __le32 bg_block_bitmap_lo; /* Blocks bitmap block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) __le32 bg_inode_bitmap_lo; /* Inodes bitmap block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) __le32 bg_inode_table_lo; /* Inodes table block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) __le16 bg_free_blocks_count_lo;/* Free blocks count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) __le16 bg_free_inodes_count_lo;/* Free inodes count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) __le16 bg_used_dirs_count_lo; /* Directories count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) __le16 bg_flags; /* EXT4_BG_flags (INODE_UNINIT, etc) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) __le32 bg_exclude_bitmap_lo; /* Exclude bitmap for snapshots */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) __le16 bg_block_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bbitmap) LE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) __le16 bg_inode_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+ibitmap) LE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) __le16 bg_itable_unused_lo; /* Unused inodes count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) __le16 bg_checksum; /* crc16(sb_uuid+group+desc) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) __le32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) __le32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) __le32 bg_inode_table_hi; /* Inodes table block MSB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) __le16 bg_free_blocks_count_hi;/* Free blocks count MSB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) __le16 bg_free_inodes_count_hi;/* Free inodes count MSB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) __le16 bg_used_dirs_count_hi; /* Directories count MSB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) __le16 bg_itable_unused_hi; /* Unused inodes count MSB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) __le32 bg_exclude_bitmap_hi; /* Exclude bitmap block MSB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) __le16 bg_block_bitmap_csum_hi;/* crc32c(s_uuid+grp_num+bbitmap) BE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) __le16 bg_inode_bitmap_csum_hi;/* crc32c(s_uuid+grp_num+ibitmap) BE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) __u32 bg_reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) #define EXT4_BG_INODE_BITMAP_CSUM_HI_END \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) (offsetof(struct ext4_group_desc, bg_inode_bitmap_csum_hi) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) #define EXT4_BG_BLOCK_BITMAP_CSUM_HI_END \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) (offsetof(struct ext4_group_desc, bg_block_bitmap_csum_hi) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) * Structure of a flex block group info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) struct flex_groups {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) atomic64_t free_clusters;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) atomic_t free_inodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) atomic_t used_dirs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) #define EXT4_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not in use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) #define EXT4_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not in use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) #define EXT4_BG_INODE_ZEROED 0x0004 /* On-disk itable initialized to zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * Macro-instructions used to manage group descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) #define EXT4_MIN_DESC_SIZE 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) #define EXT4_MIN_DESC_SIZE_64BIT 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) #define EXT4_MAX_DESC_SIZE EXT4_MIN_BLOCK_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) #define EXT4_DESC_SIZE(s) (EXT4_SB(s)->s_desc_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) # define EXT4_BLOCKS_PER_GROUP(s) (EXT4_SB(s)->s_blocks_per_group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) # define EXT4_CLUSTERS_PER_GROUP(s) (EXT4_SB(s)->s_clusters_per_group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) # define EXT4_DESC_PER_BLOCK(s) (EXT4_SB(s)->s_desc_per_block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) # define EXT4_INODES_PER_GROUP(s) (EXT4_SB(s)->s_inodes_per_group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) # define EXT4_DESC_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_desc_per_block_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) # define EXT4_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) # define EXT4_DESC_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / EXT4_DESC_SIZE(s))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) # define EXT4_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) * Constants relative to the data blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) #define EXT4_NDIR_BLOCKS 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) #define EXT4_IND_BLOCK EXT4_NDIR_BLOCKS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) #define EXT4_DIND_BLOCK (EXT4_IND_BLOCK + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) #define EXT4_TIND_BLOCK (EXT4_DIND_BLOCK + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) #define EXT4_N_BLOCKS (EXT4_TIND_BLOCK + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) * Inode flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) #define EXT4_SECRM_FL 0x00000001 /* Secure deletion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) #define EXT4_UNRM_FL 0x00000002 /* Undelete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) #define EXT4_COMPR_FL 0x00000004 /* Compress file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) #define EXT4_SYNC_FL 0x00000008 /* Synchronous updates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) #define EXT4_IMMUTABLE_FL 0x00000010 /* Immutable file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) #define EXT4_APPEND_FL 0x00000020 /* writes to file may only append */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) #define EXT4_NODUMP_FL 0x00000040 /* do not dump file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) #define EXT4_NOATIME_FL 0x00000080 /* do not update atime */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) /* Reserved for compression usage... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) #define EXT4_DIRTY_FL 0x00000100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) #define EXT4_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) #define EXT4_NOCOMPR_FL 0x00000400 /* Don't compress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) /* nb: was previously EXT2_ECOMPR_FL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) #define EXT4_ENCRYPT_FL 0x00000800 /* encrypted file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) /* End compression flags --- maybe not all used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) #define EXT4_INDEX_FL 0x00001000 /* hash-indexed directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) #define EXT4_IMAGIC_FL 0x00002000 /* AFS directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) #define EXT4_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) #define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) #define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) #define EXT4_VERITY_FL 0x00100000 /* Verity protected inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) /* 0x00400000 was formerly EXT4_EOFBLOCKS_FL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) #define EXT4_DAX_FL 0x02000000 /* Inode is DAX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) #define EXT4_INLINE_DATA_FL 0x10000000 /* Inode has inline data. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) #define EXT4_PROJINHERIT_FL 0x20000000 /* Create with parents projid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) #define EXT4_CASEFOLD_FL 0x40000000 /* Casefolded directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) /* User modifiable flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) #define EXT4_FL_USER_MODIFIABLE (EXT4_SECRM_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) EXT4_UNRM_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) EXT4_COMPR_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) EXT4_SYNC_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) EXT4_IMMUTABLE_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) EXT4_APPEND_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) EXT4_NODUMP_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) EXT4_NOATIME_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) EXT4_JOURNAL_DATA_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) EXT4_NOTAIL_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) EXT4_DIRSYNC_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) EXT4_TOPDIR_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) EXT4_EXTENTS_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 0x00400000 /* EXT4_EOFBLOCKS_FL */ | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) EXT4_DAX_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) EXT4_PROJINHERIT_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) EXT4_CASEFOLD_FL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) /* User visible flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) #define EXT4_FL_USER_VISIBLE (EXT4_FL_USER_MODIFIABLE | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) EXT4_DIRTY_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) EXT4_COMPRBLK_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) EXT4_NOCOMPR_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) EXT4_ENCRYPT_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) EXT4_INDEX_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) EXT4_VERITY_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) EXT4_INLINE_DATA_FL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) /* Flags we can manipulate with through FS_IOC_FSSETXATTR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) #define EXT4_FL_XFLAG_VISIBLE (EXT4_SYNC_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) EXT4_IMMUTABLE_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) EXT4_APPEND_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) EXT4_NODUMP_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) EXT4_NOATIME_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) EXT4_PROJINHERIT_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) EXT4_DAX_FL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) /* Flags that should be inherited by new inodes from their parent. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) EXT4_DAX_FL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) /* Flags that are appropriate for regular files (all but dir-specific ones). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) #define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL | EXT4_CASEFOLD_FL |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) EXT4_PROJINHERIT_FL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) /* Flags that are appropriate for non-directories/regular files. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) #define EXT4_OTHER_FLMASK (EXT4_NODUMP_FL | EXT4_NOATIME_FL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) /* The only flags that should be swapped */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) #define EXT4_FL_SHOULD_SWAP (EXT4_HUGE_FILE_FL | EXT4_EXTENTS_FL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) /* Flags which are mutually exclusive to DAX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) #define EXT4_DAX_MUT_EXCL (EXT4_VERITY_FL | EXT4_ENCRYPT_FL |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) EXT4_JOURNAL_DATA_FL | EXT4_INLINE_DATA_FL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) /* Mask out flags that are inappropriate for the given type of inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) if (S_ISDIR(mode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) return flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) else if (S_ISREG(mode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) return flags & EXT4_REG_FLMASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) return flags & EXT4_OTHER_FLMASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) * Inode flags used for atomic set/get
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) EXT4_INODE_SECRM = 0, /* Secure deletion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) EXT4_INODE_UNRM = 1, /* Undelete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) EXT4_INODE_COMPR = 2, /* Compress file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) EXT4_INODE_SYNC = 3, /* Synchronous updates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) EXT4_INODE_IMMUTABLE = 4, /* Immutable file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) EXT4_INODE_APPEND = 5, /* writes to file may only append */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) EXT4_INODE_NODUMP = 6, /* do not dump file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) EXT4_INODE_NOATIME = 7, /* do not update atime */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) /* Reserved for compression usage... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) EXT4_INODE_DIRTY = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) EXT4_INODE_COMPRBLK = 9, /* One or more compressed clusters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) EXT4_INODE_NOCOMPR = 10, /* Don't compress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) EXT4_INODE_ENCRYPT = 11, /* Encrypted file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) /* End compression flags --- maybe not all used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) EXT4_INODE_INDEX = 12, /* hash-indexed directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) EXT4_INODE_IMAGIC = 13, /* AFS directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) EXT4_INODE_JOURNAL_DATA = 14, /* file data should be journaled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) EXT4_INODE_NOTAIL = 15, /* file tail should not be merged */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) EXT4_INODE_DIRSYNC = 16, /* dirsync behaviour (directories only) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) EXT4_INODE_TOPDIR = 17, /* Top of directory hierarchies*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) EXT4_INODE_HUGE_FILE = 18, /* Set to each huge file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) EXT4_INODE_EXTENTS = 19, /* Inode uses extents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) EXT4_INODE_VERITY = 20, /* Verity protected inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) EXT4_INODE_EA_INODE = 21, /* Inode used for large EA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) /* 22 was formerly EXT4_INODE_EOFBLOCKS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) EXT4_INODE_DAX = 25, /* Inode is DAX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) EXT4_INODE_INLINE_DATA = 28, /* Data in inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) EXT4_INODE_PROJINHERIT = 29, /* Create with parents projid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) EXT4_INODE_CASEFOLD = 30, /* Casefolded directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) EXT4_INODE_RESERVED = 31, /* reserved for ext4 lib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * Since it's pretty easy to mix up bit numbers and hex values, we use a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * build-time check to make sure that EXT4_XXX_FL is consistent with respect to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * EXT4_INODE_XXX. If all is well, the macros will be dropped, so, it won't cost
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) * any extra space in the compiled kernel image, otherwise, the build will fail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * It's important that these values are the same, since we are using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * EXT4_INODE_XXX to test for flag values, but EXT4_XXX_FL must be consistent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) * with the values of FS_XXX_FL defined in include/linux/fs.h and the on-disk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) * values found in ext2, ext3 and ext4 filesystems, and of course the values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) * defined in e2fsprogs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) * It's not paranoia if the Murphy's Law really *is* out to get you. :-)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) #define TEST_FLAG_VALUE(FLAG) (EXT4_##FLAG##_FL == (1 << EXT4_INODE_##FLAG))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) #define CHECK_FLAG_VALUE(FLAG) BUILD_BUG_ON(!TEST_FLAG_VALUE(FLAG))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) static inline void ext4_check_flag_values(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) CHECK_FLAG_VALUE(SECRM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) CHECK_FLAG_VALUE(UNRM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) CHECK_FLAG_VALUE(COMPR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) CHECK_FLAG_VALUE(SYNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) CHECK_FLAG_VALUE(IMMUTABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) CHECK_FLAG_VALUE(APPEND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) CHECK_FLAG_VALUE(NODUMP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) CHECK_FLAG_VALUE(NOATIME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) CHECK_FLAG_VALUE(DIRTY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) CHECK_FLAG_VALUE(COMPRBLK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) CHECK_FLAG_VALUE(NOCOMPR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) CHECK_FLAG_VALUE(ENCRYPT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) CHECK_FLAG_VALUE(INDEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) CHECK_FLAG_VALUE(IMAGIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) CHECK_FLAG_VALUE(JOURNAL_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) CHECK_FLAG_VALUE(NOTAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) CHECK_FLAG_VALUE(DIRSYNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) CHECK_FLAG_VALUE(TOPDIR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) CHECK_FLAG_VALUE(HUGE_FILE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) CHECK_FLAG_VALUE(EXTENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) CHECK_FLAG_VALUE(VERITY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) CHECK_FLAG_VALUE(EA_INODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) CHECK_FLAG_VALUE(INLINE_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) CHECK_FLAG_VALUE(PROJINHERIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) CHECK_FLAG_VALUE(CASEFOLD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) CHECK_FLAG_VALUE(RESERVED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) /* Used to pass group descriptor data when online resize is done */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) struct ext4_new_group_input {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) __u32 group; /* Group number for this data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) __u64 block_bitmap; /* Absolute block number of block bitmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) __u64 inode_bitmap; /* Absolute block number of inode bitmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) __u64 inode_table; /* Absolute block number of inode table start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) __u32 blocks_count; /* Total number of blocks in this group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) __u16 reserved_blocks; /* Number of reserved blocks in this group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) __u16 unused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) struct compat_ext4_new_group_input {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) u32 group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) compat_u64 block_bitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) compat_u64 inode_bitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) compat_u64 inode_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) u32 blocks_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) u16 reserved_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) u16 unused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) /* The struct ext4_new_group_input in kernel space, with free_blocks_count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) struct ext4_new_group_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) __u32 group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) __u64 block_bitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) __u64 inode_bitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) __u64 inode_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) __u32 blocks_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) __u16 reserved_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) __u16 mdata_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) __u32 free_clusters_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) /* Indexes used to index group tables in ext4_new_group_data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) BLOCK_BITMAP = 0, /* block bitmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) INODE_BITMAP, /* inode bitmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) INODE_TABLE, /* inode tables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) GROUP_TABLE_COUNT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) * Flags used by ext4_map_blocks()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) /* Allocate any needed blocks and/or convert an unwritten
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) extent to be an initialized ext4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) #define EXT4_GET_BLOCKS_CREATE 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) /* Request the creation of an unwritten extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) #define EXT4_GET_BLOCKS_UNWRIT_EXT 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) #define EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT (EXT4_GET_BLOCKS_UNWRIT_EXT|\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) EXT4_GET_BLOCKS_CREATE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) /* Caller is from the delayed allocation writeout path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) * finally doing the actual allocation of delayed blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) #define EXT4_GET_BLOCKS_DELALLOC_RESERVE 0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) /* caller is from the direct IO path, request to creation of an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) unwritten extents if not allocated, split the unwritten
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) extent if blocks has been preallocated already*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) #define EXT4_GET_BLOCKS_PRE_IO 0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) #define EXT4_GET_BLOCKS_CONVERT 0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) #define EXT4_GET_BLOCKS_IO_CREATE_EXT (EXT4_GET_BLOCKS_PRE_IO|\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) /* Convert extent to initialized after IO complete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) #define EXT4_GET_BLOCKS_IO_CONVERT_EXT (EXT4_GET_BLOCKS_CONVERT|\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) /* Eventual metadata allocation (due to growing extent tree)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) * should not fail, so try to use reserved blocks for that.*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) #define EXT4_GET_BLOCKS_METADATA_NOFAIL 0x0020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) /* Don't normalize allocation size (used for fallocate) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) #define EXT4_GET_BLOCKS_NO_NORMALIZE 0x0040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) /* Convert written extents to unwritten */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) #define EXT4_GET_BLOCKS_CONVERT_UNWRITTEN 0x0100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) /* Write zeros to newly created written extents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) #define EXT4_GET_BLOCKS_ZERO 0x0200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) #define EXT4_GET_BLOCKS_CREATE_ZERO (EXT4_GET_BLOCKS_CREATE |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) EXT4_GET_BLOCKS_ZERO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) /* Caller will submit data before dropping transaction handle. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) * allows jbd2 to avoid submitting data before commit. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) #define EXT4_GET_BLOCKS_IO_SUBMIT 0x0400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) * The bit position of these flags must not overlap with any of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) * EXT4_GET_BLOCKS_*. They are used by ext4_find_extent(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) * read_extent_tree_block(), ext4_split_extent_at(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) * ext4_ext_insert_extent(), and ext4_ext_create_new_leaf().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) * EXT4_EX_NOCACHE is used to indicate that the we shouldn't be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) * caching the extents when reading from the extent tree while a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) * truncate or punch hole operation is in progress.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) #define EXT4_EX_NOCACHE 0x40000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) #define EXT4_EX_FORCE_CACHE 0x20000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) #define EXT4_EX_NOFAIL 0x10000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) * Flags used by ext4_free_blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) #define EXT4_FREE_BLOCKS_METADATA 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) #define EXT4_FREE_BLOCKS_FORGET 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) #define EXT4_FREE_BLOCKS_VALIDATED 0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) #define EXT4_FREE_BLOCKS_NO_QUOT_UPDATE 0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) #define EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER 0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) #define EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER 0x0020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) #define EXT4_FREE_BLOCKS_RERESERVE_CLUSTER 0x0040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) * ioctl commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) #define EXT4_IOC_GETVERSION _IOR('f', 3, long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) #define EXT4_IOC_SETVERSION _IOW('f', 4, long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) #define EXT4_IOC_GETVERSION_OLD FS_IOC_GETVERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) #define EXT4_IOC_SETVERSION_OLD FS_IOC_SETVERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) #define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) #define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) #define EXT4_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) #define EXT4_IOC_GROUP_ADD _IOW('f', 8, struct ext4_new_group_input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) #define EXT4_IOC_MIGRATE _IO('f', 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) /* note ioctl 10 reserved for an early version of the FIEMAP ioctl */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) /* note ioctl 11 reserved for filesystem-independent FIEMAP ioctl */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) #define EXT4_IOC_ALLOC_DA_BLKS _IO('f', 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) #define EXT4_IOC_MOVE_EXT _IOWR('f', 15, struct move_extent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) #define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) #define EXT4_IOC_SWAP_BOOT _IO('f', 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) #define EXT4_IOC_PRECACHE_EXTENTS _IO('f', 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) /* ioctl codes 19--39 are reserved for fscrypt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) #define EXT4_IOC_CLEAR_ES_CACHE _IO('f', 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) #define EXT4_IOC_GETSTATE _IOW('f', 41, __u32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) #define EXT4_IOC_GET_ES_CACHE _IOWR('f', 42, struct fiemap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) #define EXT4_IOC_SHUTDOWN _IOR ('X', 125, __u32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) * Flags for going down operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) #define EXT4_GOING_FLAGS_DEFAULT 0x0 /* going down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) #define EXT4_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) #define EXT4_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) * Flags returned by EXT4_IOC_GETSTATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) * We only expose to userspace a subset of the state flags in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) * i_state_flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) #define EXT4_STATE_FLAG_EXT_PRECACHED 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) #define EXT4_STATE_FLAG_NEW 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) #define EXT4_STATE_FLAG_NEWENTRY 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) #define EXT4_STATE_FLAG_DA_ALLOC_CLOSE 0x00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) * ioctl commands in 32 bit emulation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) #define EXT4_IOC32_GETVERSION _IOR('f', 3, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) #define EXT4_IOC32_SETVERSION _IOW('f', 4, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) #define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) #define EXT4_IOC32_SETRSVSZ _IOW('f', 6, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) #define EXT4_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) #define EXT4_IOC32_GROUP_ADD _IOW('f', 8, struct compat_ext4_new_group_input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) #define EXT4_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) #define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) * Returned by EXT4_IOC_GET_ES_CACHE as an additional possible flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) * It indicates that the entry in extent status cache is for a hole.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) #define EXT4_FIEMAP_EXTENT_HOLE 0x08000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) /* Max physical block we can address w/o extents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) #define EXT4_MAX_BLOCK_FILE_PHYS 0xFFFFFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) /* Max logical block we can support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) #define EXT4_MAX_LOGICAL_BLOCK 0xFFFFFFFE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) * Structure of an inode on the disk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) struct ext4_inode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) __le16 i_mode; /* File mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) __le16 i_uid; /* Low 16 bits of Owner Uid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) __le32 i_size_lo; /* Size in bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) __le32 i_atime; /* Access time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) __le32 i_ctime; /* Inode Change time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) __le32 i_mtime; /* Modification time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) __le32 i_dtime; /* Deletion Time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) __le16 i_gid; /* Low 16 bits of Group Id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) __le16 i_links_count; /* Links count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) __le32 i_blocks_lo; /* Blocks count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) __le32 i_flags; /* File flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) __le32 l_i_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) } linux1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) __u32 h_i_translator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) } hurd1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) __u32 m_i_reserved1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) } masix1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) } osd1; /* OS dependent 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) __le32 i_generation; /* File version (for NFS) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) __le32 i_file_acl_lo; /* File ACL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) __le32 i_size_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) __le32 i_obso_faddr; /* Obsoleted fragment address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) __le16 l_i_blocks_high; /* were l_i_reserved1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) __le16 l_i_file_acl_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) __le16 l_i_uid_high; /* these 2 fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) __le16 l_i_gid_high; /* were reserved2[0] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) __le16 l_i_checksum_lo;/* crc32c(uuid+inum+inode) LE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) __le16 l_i_reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) } linux2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) __u16 h_i_mode_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) __u16 h_i_uid_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) __u16 h_i_gid_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) __u32 h_i_author;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) } hurd2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) __le16 m_i_file_acl_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) __u32 m_i_reserved2[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) } masix2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) } osd2; /* OS dependent 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) __le16 i_extra_isize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) __le16 i_checksum_hi; /* crc32c(uuid+inum+inode) BE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) __le32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) __le32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) __le32 i_crtime; /* File Creation time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) __le32 i_version_hi; /* high 32 bits for 64-bit version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) __le32 i_projid; /* Project ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) struct move_extent {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) __u32 reserved; /* should be zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) __u32 donor_fd; /* donor file descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) __u64 orig_start; /* logical start offset in block for orig */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) __u64 donor_start; /* logical start offset in block for donor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) __u64 len; /* block length to be moved */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) __u64 moved_len; /* moved block length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) #define EXT4_EPOCH_BITS 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) #define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) #define EXT4_NSEC_MASK (~0UL << EXT4_EPOCH_BITS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) * Extended fields will fit into an inode if the filesystem was formatted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) * with large inodes (-I 256 or larger) and there are not currently any EAs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) * consuming all of the available space. For new inodes we always reserve
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) * enough space for the kernel's known extended fields, but for inodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) * created with an old kernel this might not have been the case. None of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) * the extended inode fields is critical for correct filesystem operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) * This macro checks if a certain field fits in the inode. Note that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) * inode-size = GOOD_OLD_INODE_SIZE + i_extra_isize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) #define EXT4_FITS_IN_INODE(ext4_inode, einode, field) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) ((offsetof(typeof(*ext4_inode), field) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) sizeof((ext4_inode)->field)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) <= (EXT4_GOOD_OLD_INODE_SIZE + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) (einode)->i_extra_isize)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) * We use an encoding that preserves the times for extra epoch "00":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) * extra msb of adjust for signed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) * epoch 32-bit 32-bit tv_sec to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) * bits time decoded 64-bit tv_sec 64-bit tv_sec valid time range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) * 0 0 1 -0x80000000..-0x00000001 0x000000000 1901-12-13..1969-12-31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) * 0 0 0 0x000000000..0x07fffffff 0x000000000 1970-01-01..2038-01-19
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) * 0 1 1 0x080000000..0x0ffffffff 0x100000000 2038-01-19..2106-02-07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) * 0 1 0 0x100000000..0x17fffffff 0x100000000 2106-02-07..2174-02-25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) * 1 0 1 0x180000000..0x1ffffffff 0x200000000 2174-02-25..2242-03-16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) * 1 0 0 0x200000000..0x27fffffff 0x200000000 2242-03-16..2310-04-04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) * 1 1 1 0x280000000..0x2ffffffff 0x300000000 2310-04-04..2378-04-22
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) * 1 1 0 0x300000000..0x37fffffff 0x300000000 2378-04-22..2446-05-10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) * Note that previous versions of the kernel on 64-bit systems would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) * incorrectly use extra epoch bits 1,1 for dates between 1901 and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) * 1970. e2fsck will correct this, assuming that it is run on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) * affected filesystem before 2242.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) static inline __le32 ext4_encode_extra_time(struct timespec64 *time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) u32 extra =((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) return cpu_to_le32(extra | (time->tv_nsec << EXT4_EPOCH_BITS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) static inline void ext4_decode_extra_time(struct timespec64 *time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) __le32 extra)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) if (unlikely(extra & cpu_to_le32(EXT4_EPOCH_MASK)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) time->tv_sec += (u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) << 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) {\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) (raw_inode)->xtime ## _extra = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) ext4_encode_extra_time(&(inode)->xtime); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) else \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) (raw_inode)->xtime = cpu_to_le32(clamp_t(int32_t, (inode)->xtime.tv_sec, S32_MIN, S32_MAX)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) #define EXT4_EINODE_SET_XTIME(xtime, einode, raw_inode) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) (raw_inode)->xtime = cpu_to_le32((einode)->xtime.tv_sec); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) (raw_inode)->xtime ## _extra = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) ext4_encode_extra_time(&(einode)->xtime); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) #define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) ext4_decode_extra_time(&(inode)->xtime, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) raw_inode->xtime ## _extra); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) else \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) (inode)->xtime.tv_nsec = 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) #define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) (einode)->xtime.tv_sec = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) (signed)le32_to_cpu((raw_inode)->xtime); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) else \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) (einode)->xtime.tv_sec = 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) ext4_decode_extra_time(&(einode)->xtime, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) raw_inode->xtime ## _extra); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) else \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) (einode)->xtime.tv_nsec = 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) #define i_disk_version osd1.linux1.l_i_version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) #if defined(__KERNEL__) || defined(__linux__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) #define i_reserved1 osd1.linux1.l_i_reserved1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) #define i_file_acl_high osd2.linux2.l_i_file_acl_high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) #define i_blocks_high osd2.linux2.l_i_blocks_high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) #define i_uid_low i_uid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) #define i_gid_low i_gid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) #define i_uid_high osd2.linux2.l_i_uid_high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) #define i_gid_high osd2.linux2.l_i_gid_high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) #define i_checksum_lo osd2.linux2.l_i_checksum_lo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) #elif defined(__GNU__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) #define i_translator osd1.hurd1.h_i_translator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) #define i_uid_high osd2.hurd2.h_i_uid_high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) #define i_gid_high osd2.hurd2.h_i_gid_high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) #define i_author osd2.hurd2.h_i_author
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) #elif defined(__masix__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) #define i_reserved1 osd1.masix1.m_i_reserved1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) #define i_file_acl_high osd2.masix2.m_i_file_acl_high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) #define i_reserved2 osd2.masix2.m_i_reserved2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) #endif /* defined(__KERNEL__) || defined(__linux__) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) #include "extents_status.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) #include "fast_commit.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) * Lock subclasses for i_data_sem in the ext4_inode_info structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) * These are needed to avoid lockdep false positives when we need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) * allocate blocks to the quota inode during ext4_map_blocks(), while
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) * holding i_data_sem for a normal (non-quota) inode. Since we don't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) * do quota tracking for the quota inode, this avoids deadlock (as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) * well as infinite recursion, since it isn't turtles all the way
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) * down...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) * I_DATA_SEM_NORMAL - Used for most inodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) * I_DATA_SEM_OTHER - Used by move_inode.c for the second normal inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) * where the second inode has larger inode number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) * than the first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) * I_DATA_SEM_QUOTA - Used for quota inodes only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) I_DATA_SEM_NORMAL = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) I_DATA_SEM_OTHER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) I_DATA_SEM_QUOTA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) * fourth extended file system inode data in memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) struct ext4_inode_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) __le32 i_data[15]; /* unconverted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) __u32 i_dtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) ext4_fsblk_t i_file_acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) * i_block_group is the number of the block group which contains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) * this file's inode. Constant across the lifetime of the inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) * it is used for making block allocation decisions - we try to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) * place a file's data blocks near its inode block, and new inodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) * near to their parent directory's inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) ext4_group_t i_block_group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) ext4_lblk_t i_dir_start_lookup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) #if (BITS_PER_LONG < 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) unsigned long i_state_flags; /* Dynamic state flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) unsigned long i_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) * Extended attributes can be read independently of the main file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) * data. Taking i_mutex even when reading would cause contention
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) * between readers of EAs and writers of regular file data, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) * instead we synchronize on xattr_sem when reading or changing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) * EAs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) struct rw_semaphore xattr_sem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) struct list_head i_orphan; /* unlinked but open inodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) /* Fast commit related info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) struct list_head i_fc_list; /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) * inodes that need fast commit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) * protected by sbi->s_fc_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) /* Start of lblk range that needs to be committed in this fast commit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) ext4_lblk_t i_fc_lblk_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) /* End of lblk range that needs to be committed in this fast commit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) ext4_lblk_t i_fc_lblk_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) /* Number of ongoing updates on this inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) atomic_t i_fc_updates;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) /* Fast commit wait queue for this inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) wait_queue_head_t i_fc_wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) /* Protect concurrent accesses on i_fc_lblk_start, i_fc_lblk_len */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) struct mutex i_fc_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) * i_disksize keeps track of what the inode size is ON DISK, not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) * in memory. During truncate, i_size is set to the new size by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) * the VFS prior to calling ext4_truncate(), but the filesystem won't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) * set i_disksize to 0 until the truncate is actually under way.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) * The intent is that i_disksize always represents the blocks which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) * are used by this file. This allows recovery to restart truncate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) * on orphans if we crash during truncate. We actually write i_disksize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) * into the on-disk inode when writing inodes out, instead of i_size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) * The only time when i_disksize and i_size may be different is when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) * a truncate is in progress. The only things which change i_disksize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) * are ext4_get_block (growth) and ext4_truncate (shrinkth).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) loff_t i_disksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) * i_data_sem is for serialising ext4_truncate() against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) * ext4_getblock(). In the 2.4 ext2 design, great chunks of inode's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) * data tree are chopped off during truncate. We can't do that in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) * ext4 because whenever we perform intermediate commits during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) * truncate, the inode and all the metadata blocks *must* be in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) * consistent state which allows truncation of the orphans to restart
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) * during recovery. Hence we must fix the get_block-vs-truncate race
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) * by other means, so we have i_data_sem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) struct rw_semaphore i_data_sem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) * i_mmap_sem is for serializing page faults with truncate / punch hole
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) * operations. We have to make sure that new page cannot be faulted in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) * a section of the inode that is being punched. We cannot easily use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) * i_data_sem for this since we need protection for the whole punch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) * operation and i_data_sem ranks below transaction start so we have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) * to occasionally drop it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) struct rw_semaphore i_mmap_sem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) struct inode vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) struct jbd2_inode *jinode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) spinlock_t i_raw_lock; /* protects updates to the raw inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) * File creation time. Its function is same as that of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) * struct timespec64 i_{a,c,m}time in the generic inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) struct timespec64 i_crtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) /* mballoc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) atomic_t i_prealloc_active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) struct list_head i_prealloc_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) spinlock_t i_prealloc_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) /* extents status tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) struct ext4_es_tree i_es_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) rwlock_t i_es_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) struct list_head i_es_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) unsigned int i_es_all_nr; /* protected by i_es_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) unsigned int i_es_shk_nr; /* protected by i_es_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) ext4_lblk_t i_es_shrink_lblk; /* Offset where we start searching for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) extents to shrink. Protected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) i_es_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) /* ialloc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) ext4_group_t i_last_alloc_group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) /* allocation reservation info for delalloc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) /* In case of bigalloc, this refer to clusters rather than blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) unsigned int i_reserved_data_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) /* pending cluster reservations for bigalloc file systems */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) struct ext4_pending_tree i_pending_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) /* on-disk additional length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) __u16 i_extra_isize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) /* Indicate the inline data space. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) u16 i_inline_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) u16 i_inline_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) #ifdef CONFIG_QUOTA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) /* quota space reservation, managed internally by quota code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) qsize_t i_reserved_quota;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) /* Lock protecting lists below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) spinlock_t i_completed_io_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) * Completed IOs that need unwritten extents handling and have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) * transaction reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) struct list_head i_rsv_conversion_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) struct work_struct i_rsv_conversion_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) atomic_t i_unwritten; /* Nr. of inflight conversions pending */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) spinlock_t i_block_reservation_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) * Transactions that contain inode's metadata needed to complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) * fsync and fdatasync, respectively.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) tid_t i_sync_tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) tid_t i_datasync_tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) #ifdef CONFIG_QUOTA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) struct dquot *i_dquot[MAXQUOTAS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) /* Precomputed uuid+inum+igen checksum for seeding inode checksums */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) __u32 i_csum_seed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) kprojid_t i_projid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) * File system states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) #define EXT4_VALID_FS 0x0001 /* Unmounted cleanly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) #define EXT4_ERROR_FS 0x0002 /* Errors detected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) #define EXT4_ORPHAN_FS 0x0004 /* Orphans being recovered */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) #define EXT4_FC_REPLAY 0x0020 /* Fast commit replay ongoing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) * Misc. filesystem flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) #define EXT2_FLAGS_SIGNED_HASH 0x0001 /* Signed dirhash in use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) #define EXT2_FLAGS_UNSIGNED_HASH 0x0002 /* Unsigned dirhash in use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) #define EXT2_FLAGS_TEST_FILESYS 0x0004 /* to test development code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) * Mount flags set via mount options or defaults
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) #define EXT4_MOUNT_NO_MBCACHE 0x00001 /* Do not use mbcache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) #define EXT4_MOUNT_GRPID 0x00004 /* Create files with directory's group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) #define EXT4_MOUNT_DEBUG 0x00008 /* Some debugging messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) #define EXT4_MOUNT_ERRORS_CONT 0x00010 /* Continue on errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) #define EXT4_MOUNT_ERRORS_RO 0x00020 /* Remount fs ro on errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) #define EXT4_MOUNT_ERRORS_PANIC 0x00040 /* Panic on errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) #define EXT4_MOUNT_ERRORS_MASK 0x00070
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) #define EXT4_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) #define EXT4_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) #ifdef CONFIG_FS_DAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) #define EXT4_MOUNT_DAX_ALWAYS 0x00200 /* Direct Access */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) #define EXT4_MOUNT_DAX_ALWAYS 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) #define EXT4_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) #define EXT4_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) #define EXT4_MOUNT_ORDERED_DATA 0x00800 /* Flush data before commit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) #define EXT4_MOUNT_WRITEBACK_DATA 0x00C00 /* No data ordering */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) #define EXT4_MOUNT_UPDATE_JOURNAL 0x01000 /* Update the journal format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) #define EXT4_MOUNT_NO_UID32 0x02000 /* Disable 32-bit UIDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) #define EXT4_MOUNT_XATTR_USER 0x04000 /* Extended user attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) #define EXT4_MOUNT_QUOTA 0x40000 /* Some quota option set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) #define EXT4_MOUNT_USRQUOTA 0x80000 /* "old" user quota,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) * enable enforcement for hidden
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) * quota files */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) #define EXT4_MOUNT_GRPQUOTA 0x100000 /* "old" group quota, enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) * enforcement for hidden quota
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) * files */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) #define EXT4_MOUNT_PRJQUOTA 0x200000 /* Enable project quota
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) * enforcement */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) #define EXT4_MOUNT_DIOREAD_NOLOCK 0x400000 /* Enable support for dio read nolocking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) #define EXT4_MOUNT_WARN_ON_ERROR 0x2000000 /* Trigger WARN_ON on error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) #define EXT4_MOUNT_PREFETCH_BLOCK_BITMAPS 0x4000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) #define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000 /* Block validity checking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) #define EXT4_MOUNT_DISCARD 0x40000000 /* Issue DISCARD requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) #define EXT4_MOUNT_INIT_INODE_TABLE 0x80000000 /* Initialize uninitialized itables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) * Mount flags set either automatically (could not be set by mount option)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) * based on per file system feature or property or in special cases such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) * distinguishing between explicit mount option definition and default.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) #define EXT4_MOUNT2_EXPLICIT_DELALLOC 0x00000001 /* User explicitly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) specified delalloc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) #define EXT4_MOUNT2_STD_GROUP_SIZE 0x00000002 /* We have standard group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) size of blocksize * 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) #define EXT4_MOUNT2_HURD_COMPAT 0x00000004 /* Support HURD-castrated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) file systems */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) #define EXT4_MOUNT2_EXPLICIT_JOURNAL_CHECKSUM 0x00000008 /* User explicitly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) specified journal checksum */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) #define EXT4_MOUNT2_JOURNAL_FAST_COMMIT 0x00000010 /* Journal fast commit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) #define EXT4_MOUNT2_DAX_NEVER 0x00000020 /* Do not allow Direct Access */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) #define EXT4_MOUNT2_DAX_INODE 0x00000040 /* For printing options only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) #define clear_opt(sb, opt) EXT4_SB(sb)->s_mount_opt &= \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) ~EXT4_MOUNT_##opt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) #define set_opt(sb, opt) EXT4_SB(sb)->s_mount_opt |= \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) EXT4_MOUNT_##opt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) #define test_opt(sb, opt) (EXT4_SB(sb)->s_mount_opt & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) EXT4_MOUNT_##opt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) #define clear_opt2(sb, opt) EXT4_SB(sb)->s_mount_opt2 &= \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) ~EXT4_MOUNT2_##opt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) #define set_opt2(sb, opt) EXT4_SB(sb)->s_mount_opt2 |= \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) EXT4_MOUNT2_##opt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) #define test_opt2(sb, opt) (EXT4_SB(sb)->s_mount_opt2 & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) EXT4_MOUNT2_##opt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) #define ext4_test_and_set_bit __test_and_set_bit_le
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) #define ext4_set_bit __set_bit_le
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) #define ext4_set_bit_atomic ext2_set_bit_atomic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) #define ext4_test_and_clear_bit __test_and_clear_bit_le
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) #define ext4_clear_bit __clear_bit_le
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) #define ext4_clear_bit_atomic ext2_clear_bit_atomic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) #define ext4_test_bit test_bit_le
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) #define ext4_find_next_zero_bit find_next_zero_bit_le
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) #define ext4_find_next_bit find_next_bit_le
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) extern void ext4_set_bits(void *bm, int cur, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) * Maximal mount counts between two filesystem checks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) #define EXT4_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) #define EXT4_DFL_CHECKINTERVAL 0 /* Don't use interval check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) * Behaviour when detecting errors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) #define EXT4_ERRORS_CONTINUE 1 /* Continue execution */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) #define EXT4_ERRORS_RO 2 /* Remount fs read-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) #define EXT4_ERRORS_PANIC 3 /* Panic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) #define EXT4_ERRORS_DEFAULT EXT4_ERRORS_CONTINUE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) /* Metadata checksum algorithm codes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) #define EXT4_CRC32C_CHKSUM 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) * Structure of the super block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) struct ext4_super_block {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) /*00*/ __le32 s_inodes_count; /* Inodes count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) __le32 s_blocks_count_lo; /* Blocks count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) __le32 s_r_blocks_count_lo; /* Reserved blocks count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) __le32 s_free_blocks_count_lo; /* Free blocks count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) /*10*/ __le32 s_free_inodes_count; /* Free inodes count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) __le32 s_first_data_block; /* First Data Block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) __le32 s_log_block_size; /* Block size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) __le32 s_log_cluster_size; /* Allocation cluster size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) /*20*/ __le32 s_blocks_per_group; /* # Blocks per group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) __le32 s_clusters_per_group; /* # Clusters per group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) __le32 s_inodes_per_group; /* # Inodes per group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) __le32 s_mtime; /* Mount time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) /*30*/ __le32 s_wtime; /* Write time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) __le16 s_mnt_count; /* Mount count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) __le16 s_max_mnt_count; /* Maximal mount count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) __le16 s_magic; /* Magic signature */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) __le16 s_state; /* File system state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) __le16 s_errors; /* Behaviour when detecting errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) __le16 s_minor_rev_level; /* minor revision level */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) /*40*/ __le32 s_lastcheck; /* time of last check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) __le32 s_checkinterval; /* max. time between checks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) __le32 s_creator_os; /* OS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) __le32 s_rev_level; /* Revision level */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) /*50*/ __le16 s_def_resuid; /* Default uid for reserved blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) __le16 s_def_resgid; /* Default gid for reserved blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) * These fields are for EXT4_DYNAMIC_REV superblocks only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) * Note: the difference between the compatible feature set and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) * the incompatible feature set is that if there is a bit set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) * in the incompatible feature set that the kernel doesn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) * know about, it should refuse to mount the filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) * e2fsck's requirements are more strict; if it doesn't know
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) * about a feature in either the compatible or incompatible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) * feature set, it must abort and not try to meddle with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) * things it doesn't understand...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) __le32 s_first_ino; /* First non-reserved inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) __le16 s_inode_size; /* size of inode structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) __le16 s_block_group_nr; /* block group # of this superblock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) __le32 s_feature_compat; /* compatible feature set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) /*60*/ __le32 s_feature_incompat; /* incompatible feature set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) __le32 s_feature_ro_compat; /* readonly-compatible feature set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) /*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) /*78*/ char s_volume_name[16]; /* volume name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) /*88*/ char s_last_mounted[64] __nonstring; /* directory where last mounted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) /*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) * Performance hints. Directory preallocation should only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) /*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) /*E0*/ __le32 s_journal_inum; /* inode number of journal file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) __le32 s_journal_dev; /* device number of journal file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) __le32 s_last_orphan; /* start of list of inodes to delete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) __le32 s_hash_seed[4]; /* HTREE hash seed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) __u8 s_def_hash_version; /* Default hash version to use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) __u8 s_jnl_backup_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) __le16 s_desc_size; /* size of group descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) /*100*/ __le32 s_default_mount_opts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) __le32 s_first_meta_bg; /* First metablock block group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) __le32 s_mkfs_time; /* When the filesystem was created */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) __le32 s_jnl_blocks[17]; /* Backup of the journal inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) /*150*/ __le32 s_blocks_count_hi; /* Blocks count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) __le32 s_r_blocks_count_hi; /* Reserved blocks count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) __le32 s_free_blocks_count_hi; /* Free blocks count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) __le16 s_min_extra_isize; /* All inodes have at least # bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) __le16 s_want_extra_isize; /* New inodes should reserve # bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) __le32 s_flags; /* Miscellaneous flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) __le16 s_raid_stride; /* RAID stride */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) __le16 s_mmp_update_interval; /* # seconds to wait in MMP checking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) __le64 s_mmp_block; /* Block for multi-mount protection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) __u8 s_log_groups_per_flex; /* FLEX_BG group size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) __u8 s_checksum_type; /* metadata checksum algorithm used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) __u8 s_encryption_level; /* versioning level for encryption */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) __u8 s_reserved_pad; /* Padding to next 32bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) __le64 s_kbytes_written; /* nr of lifetime kilobytes written */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) __le32 s_snapshot_inum; /* Inode number of active snapshot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) __le32 s_snapshot_id; /* sequential ID of active snapshot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) __le64 s_snapshot_r_blocks_count; /* reserved blocks for active
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) snapshot's future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) __le32 s_snapshot_list; /* inode number of the head of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) on-disk snapshot list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) #define EXT4_S_ERR_START offsetof(struct ext4_super_block, s_error_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) __le32 s_error_count; /* number of fs errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) __le32 s_first_error_time; /* first time an error happened */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) __le32 s_first_error_ino; /* inode involved in first error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) __le64 s_first_error_block; /* block involved of first error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) __u8 s_first_error_func[32] __nonstring; /* function where the error happened */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) __le32 s_first_error_line; /* line number where error happened */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) __le32 s_last_error_time; /* most recent time of an error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) __le32 s_last_error_ino; /* inode involved in last error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) __le32 s_last_error_line; /* line number where error happened */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) __le64 s_last_error_block; /* block involved of last error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) __u8 s_last_error_func[32] __nonstring; /* function where the error happened */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) #define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) __u8 s_mount_opts[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) __le32 s_usr_quota_inum; /* inode for tracking user quota */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) __le32 s_grp_quota_inum; /* inode for tracking group quota */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) __le32 s_overhead_clusters; /* overhead blocks/clusters in fs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) __le32 s_backup_bgs[2]; /* groups with sparse_super2 SBs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) __u8 s_encrypt_algos[4]; /* Encryption algorithms in use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) __u8 s_encrypt_pw_salt[16]; /* Salt used for string2key algorithm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) __le32 s_lpf_ino; /* Location of the lost+found inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) __le32 s_prj_quota_inum; /* inode for tracking project quota */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) __le32 s_checksum_seed; /* crc32c(uuid) if csum_seed set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) __u8 s_wtime_hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) __u8 s_mtime_hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) __u8 s_mkfs_time_hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) __u8 s_lastcheck_hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) __u8 s_first_error_time_hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) __u8 s_last_error_time_hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) __u8 s_first_error_errcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) __u8 s_last_error_errcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) __le16 s_encoding; /* Filename charset encoding */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) __le16 s_encoding_flags; /* Filename charset encoding flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) __le32 s_reserved[95]; /* Padding to the end of the block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) __le32 s_checksum; /* crc32c(superblock) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) #define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) #ifdef CONFIG_FS_ENCRYPTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) #define DUMMY_ENCRYPTION_ENABLED(sbi) ((sbi)->s_dummy_enc_policy.policy != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) #define DUMMY_ENCRYPTION_ENABLED(sbi) (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) /* Number of quota types we support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) #define EXT4_MAXQUOTAS 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) #define EXT4_ENC_UTF8_12_1 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) * fourth extended-fs super-block data in memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) struct ext4_sb_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) unsigned long s_desc_size; /* Size of a group descriptor in bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) unsigned long s_inodes_per_block;/* Number of inodes per block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) unsigned long s_blocks_per_group;/* Number of blocks in a group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) unsigned long s_clusters_per_group; /* Number of clusters in a group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) unsigned long s_inodes_per_group;/* Number of inodes in a group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) unsigned long s_itb_per_group; /* Number of inode table blocks per group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) unsigned long s_gdb_count; /* Number of group descriptor blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) unsigned long s_desc_per_block; /* Number of group descriptors per block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) ext4_group_t s_groups_count; /* Number of groups in the fs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) ext4_group_t s_blockfile_groups;/* Groups acceptable for non-extent files */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) unsigned long s_overhead; /* # of fs overhead clusters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) unsigned int s_cluster_ratio; /* Number of blocks per cluster */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) unsigned int s_cluster_bits; /* log2 of s_cluster_ratio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) loff_t s_bitmap_maxbytes; /* max bytes for bitmap files */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) struct buffer_head * s_sbh; /* Buffer containing the super block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) struct ext4_super_block *s_es; /* Pointer to the super block in the buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) struct buffer_head * __rcu *s_group_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) unsigned int s_mount_opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) unsigned int s_mount_opt2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) unsigned long s_mount_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) unsigned int s_def_mount_opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) ext4_fsblk_t s_sb_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) atomic64_t s_resv_clusters;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) kuid_t s_resuid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) kgid_t s_resgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) unsigned short s_mount_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) unsigned short s_pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) int s_addr_per_block_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) int s_desc_per_block_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) int s_inode_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) int s_first_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) unsigned int s_inode_readahead_blks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) unsigned int s_inode_goal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) u32 s_hash_seed[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) int s_def_hash_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) int s_hash_unsigned; /* 3 if hash should be signed, 0 if not */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) struct percpu_counter s_freeclusters_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) struct percpu_counter s_freeinodes_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) struct percpu_counter s_dirs_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) struct percpu_counter s_dirtyclusters_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) struct percpu_counter s_sra_exceeded_retry_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) struct blockgroup_lock *s_blockgroup_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) struct proc_dir_entry *s_proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) struct kobject s_kobj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) struct completion s_kobj_unregister;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) struct super_block *s_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) struct buffer_head *s_mmp_bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) /* Journaling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) struct journal_s *s_journal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) struct list_head s_orphan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) struct mutex s_orphan_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) unsigned long s_ext4_flags; /* Ext4 superblock flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) unsigned long s_commit_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) u32 s_max_batch_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) u32 s_min_batch_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) struct block_device *s_journal_bdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) #ifdef CONFIG_QUOTA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) /* Names of quota files with journalled quota */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) char __rcu *s_qf_names[EXT4_MAXQUOTAS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) int s_jquota_fmt; /* Format of quota to use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) struct ext4_system_blocks __rcu *s_system_blks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) #ifdef EXTENTS_STATS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) /* ext4 extents stats */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) unsigned long s_ext_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) unsigned long s_ext_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) unsigned long s_depth_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) spinlock_t s_ext_stats_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) unsigned long s_ext_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) unsigned long s_ext_extents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) /* for buddy allocator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) struct ext4_group_info ** __rcu *s_group_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) struct inode *s_buddy_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) spinlock_t s_md_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) unsigned short *s_mb_offsets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) unsigned int *s_mb_maxs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) unsigned int s_group_info_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) unsigned int s_mb_free_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) struct list_head s_freed_data_list; /* List of blocks to be freed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) after commit completed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) /* tunables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) unsigned long s_stripe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) unsigned int s_mb_stream_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) unsigned int s_mb_max_to_scan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) unsigned int s_mb_min_to_scan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) unsigned int s_mb_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) unsigned int s_mb_order2_reqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) unsigned int s_mb_group_prealloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) unsigned int s_mb_max_inode_prealloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) unsigned int s_max_dir_size_kb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) /* where last allocation was done - for stream allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) unsigned long s_mb_last_group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) unsigned long s_mb_last_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) unsigned int s_mb_prefetch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) unsigned int s_mb_prefetch_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) /* stats for buddy allocator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) atomic_t s_bal_reqs; /* number of reqs with len > 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) atomic_t s_bal_success; /* we found long enough chunks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) atomic_t s_bal_allocated; /* in blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) atomic_t s_bal_ex_scanned; /* total extents scanned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) atomic_t s_bal_goals; /* goal hits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) atomic_t s_bal_breaks; /* too long searches */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) atomic_t s_bal_2orders; /* 2^order hits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) spinlock_t s_bal_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) unsigned long s_mb_buddies_generated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) unsigned long long s_mb_generation_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) atomic_t s_mb_lost_chunks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) atomic_t s_mb_preallocated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) atomic_t s_mb_discarded;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) atomic_t s_lock_busy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) /* locality groups */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) struct ext4_locality_group __percpu *s_locality_groups;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) /* for write statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) unsigned long s_sectors_written_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) u64 s_kbytes_written;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) /* the size of zero-out chunk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) unsigned int s_extent_max_zeroout_kb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) unsigned int s_log_groups_per_flex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) struct flex_groups * __rcu *s_flex_groups;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) ext4_group_t s_flex_groups_allocated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) /* workqueue for reserved extent conversions (buffered io) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) struct workqueue_struct *rsv_conversion_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) /* timer for periodic error stats printing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) struct timer_list s_err_report;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) /* Lazy inode table initialization info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) struct ext4_li_request *s_li_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) /* Wait multiplier for lazy initialization thread */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) unsigned int s_li_wait_mult;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) /* Kernel thread for multiple mount protection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) struct task_struct *s_mmp_tsk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) /* record the last minlen when FITRIM is called. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) atomic_t s_last_trim_minblks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) /* Reference to checksum algorithm driver via cryptoapi */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) struct crypto_shash *s_chksum_driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) /* Precomputed FS UUID checksum for seeding other checksums */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) __u32 s_csum_seed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) /* Reclaim extents from extent status tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) struct shrinker s_es_shrinker;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) struct list_head s_es_list; /* List of inodes with reclaimable extents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) long s_es_nr_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) struct ext4_es_stats s_es_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) struct mb_cache *s_ea_block_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) struct mb_cache *s_ea_inode_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) spinlock_t s_es_lock ____cacheline_aligned_in_smp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) /* Ratelimit ext4 messages. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) struct ratelimit_state s_err_ratelimit_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) struct ratelimit_state s_warning_ratelimit_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) struct ratelimit_state s_msg_ratelimit_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) atomic_t s_warning_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) atomic_t s_msg_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) /* Encryption policy for '-o test_dummy_encryption' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) struct fscrypt_dummy_policy s_dummy_enc_policy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) * Barrier between writepages ops and changing any inode's JOURNAL_DATA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) * or EXTENTS flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) struct percpu_rw_semaphore s_writepages_rwsem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) struct dax_device *s_daxdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) #ifdef CONFIG_EXT4_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) unsigned long s_simulate_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) /* Record the errseq of the backing block device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) errseq_t s_bdev_wb_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) spinlock_t s_bdev_wb_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) /* Ext4 fast commit stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) atomic_t s_fc_subtid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) atomic_t s_fc_ineligible_updates;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) * After commit starts, the main queue gets locked, and the further
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) * updates get added in the staging queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) #define FC_Q_MAIN 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) #define FC_Q_STAGING 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) struct list_head s_fc_q[2]; /* Inodes staged for fast commit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) * that have data changes in them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) struct list_head s_fc_dentry_q[2]; /* directory entry updates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) unsigned int s_fc_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) * Main fast commit lock. This lock protects accesses to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) * following fields:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) * ei->i_fc_list, s_fc_dentry_q, s_fc_q, s_fc_bytes, s_fc_bh.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) spinlock_t s_fc_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) struct buffer_head *s_fc_bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) struct ext4_fc_stats s_fc_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) u64 s_fc_avg_commit_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) #ifdef CONFIG_EXT4_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) int s_fc_debug_max_replay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) struct ext4_fc_replay_state s_fc_replay_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) return sb->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) static inline struct ext4_inode_info *EXT4_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) return container_of(inode, struct ext4_inode_info, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) return ino == EXT4_ROOT_INO ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) (ino >= EXT4_FIRST_INO(sb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) ino <= le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) * Returns: sbi->field[index]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) * Used to access an array element from the following sbi fields which require
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) * rcu protection to avoid dereferencing an invalid pointer due to reassignment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) * - s_group_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) * - s_group_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) * - s_flex_group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) #define sbi_array_rcu_deref(sbi, field, index) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) typeof(*((sbi)->field)) _v; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) rcu_read_lock(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) _v = ((typeof(_v)*)rcu_dereference((sbi)->field))[index]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) rcu_read_unlock(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) _v; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) * run-time mount flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) EXT4_MF_MNTDIR_SAMPLED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) EXT4_MF_FS_ABORTED, /* Fatal error detected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) EXT4_MF_FC_INELIGIBLE, /* Fast commit ineligible */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) EXT4_MF_FC_COMMITTING /* File system underoing a fast
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) * commit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) static inline void ext4_set_mount_flag(struct super_block *sb, int bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) set_bit(bit, &EXT4_SB(sb)->s_mount_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) static inline void ext4_clear_mount_flag(struct super_block *sb, int bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) clear_bit(bit, &EXT4_SB(sb)->s_mount_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) static inline int ext4_test_mount_flag(struct super_block *sb, int bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) return test_bit(bit, &EXT4_SB(sb)->s_mount_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) * Simulate_fail codes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) #define EXT4_SIM_BBITMAP_EIO 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) #define EXT4_SIM_BBITMAP_CRC 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) #define EXT4_SIM_IBITMAP_EIO 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) #define EXT4_SIM_IBITMAP_CRC 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) #define EXT4_SIM_INODE_EIO 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) #define EXT4_SIM_INODE_CRC 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) #define EXT4_SIM_DIRBLOCK_EIO 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) #define EXT4_SIM_DIRBLOCK_CRC 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) static inline bool ext4_simulate_fail(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) unsigned long code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) #ifdef CONFIG_EXT4_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) struct ext4_sb_info *sbi = EXT4_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) if (unlikely(sbi->s_simulate_fail == code)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) sbi->s_simulate_fail = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) static inline void ext4_simulate_fail_bh(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) struct buffer_head *bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) unsigned long code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) if (!IS_ERR(bh) && ext4_simulate_fail(sb, code))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) clear_buffer_uptodate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) * Error number codes for s_{first,last}_error_errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) * Linux errno numbers are architecture specific, so we need to translate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) * them into something which is architecture independent. We don't define
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) * codes for all errno's; just the ones which are most likely to be the cause
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) * of an ext4_error() call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) #define EXT4_ERR_UNKNOWN 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) #define EXT4_ERR_EIO 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) #define EXT4_ERR_ENOMEM 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) #define EXT4_ERR_EFSBADCRC 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) #define EXT4_ERR_EFSCORRUPTED 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) #define EXT4_ERR_ENOSPC 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) #define EXT4_ERR_ENOKEY 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) #define EXT4_ERR_EROFS 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) #define EXT4_ERR_EFBIG 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) #define EXT4_ERR_EEXIST 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) #define EXT4_ERR_ERANGE 11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) #define EXT4_ERR_EOVERFLOW 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) #define EXT4_ERR_EBUSY 13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) #define EXT4_ERR_ENOTDIR 14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) #define EXT4_ERR_ENOTEMPTY 15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) #define EXT4_ERR_ESHUTDOWN 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) #define EXT4_ERR_EFAULT 17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) * Inode dynamic state flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) EXT4_STATE_JDATA, /* journaled data exists */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) EXT4_STATE_NEW, /* inode is newly created */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) EXT4_STATE_XATTR, /* has in-inode xattrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) EXT4_STATE_NO_EXPAND, /* No space for expansion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) EXT4_STATE_DA_ALLOC_CLOSE, /* Alloc DA blks on close */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) EXT4_STATE_EXT_MIGRATE, /* Inode is migrating */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) EXT4_STATE_NEWENTRY, /* File just added to dir */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) EXT4_STATE_MAY_INLINE_DATA, /* may have in-inode data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) EXT4_STATE_EXT_PRECACHED, /* extents have been precached */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) EXT4_STATE_LUSTRE_EA_INODE, /* Lustre-style ea_inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) EXT4_STATE_VERITY_IN_PROGRESS, /* building fs-verity Merkle tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) EXT4_STATE_FC_COMMITTING, /* Fast commit ongoing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) #define EXT4_INODE_BIT_FNS(name, field, offset) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) static inline int ext4_test_inode_##name(struct inode *inode, int bit) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) return test_bit(bit + (offset), &EXT4_I(inode)->i_##field); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) static inline void ext4_set_inode_##name(struct inode *inode, int bit) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) set_bit(bit + (offset), &EXT4_I(inode)->i_##field); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) static inline void ext4_clear_inode_##name(struct inode *inode, int bit) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) clear_bit(bit + (offset), &EXT4_I(inode)->i_##field); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) /* Add these declarations here only so that these functions can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) * found by name. Otherwise, they are very hard to locate. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) static inline int ext4_test_inode_flag(struct inode *inode, int bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) static inline void ext4_set_inode_flag(struct inode *inode, int bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) static inline void ext4_clear_inode_flag(struct inode *inode, int bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) EXT4_INODE_BIT_FNS(flag, flags, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) /* Add these declarations here only so that these functions can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) * found by name. Otherwise, they are very hard to locate. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) static inline int ext4_test_inode_state(struct inode *inode, int bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) static inline void ext4_set_inode_state(struct inode *inode, int bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) static inline void ext4_clear_inode_state(struct inode *inode, int bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) #if (BITS_PER_LONG < 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) EXT4_INODE_BIT_FNS(state, state_flags, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) (ei)->i_state_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) EXT4_INODE_BIT_FNS(state, flags, 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) /* We depend on the fact that callers will set i_flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) /* Assume that user mode programs are passing in an ext4fs superblock, not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) * a kernel struct super_block. This will allow us to call the feature-test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) * macros from user land. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) #define EXT4_SB(sb) (sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) static inline bool ext4_verity_in_progress(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) return IS_ENABLED(CONFIG_FS_VERITY) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) ext4_test_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) * Codes for operating systems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) #define EXT4_OS_LINUX 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) #define EXT4_OS_HURD 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) #define EXT4_OS_MASIX 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) #define EXT4_OS_FREEBSD 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) #define EXT4_OS_LITES 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) * Revision levels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) #define EXT4_GOOD_OLD_REV 0 /* The good old (original) format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) #define EXT4_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) #define EXT4_CURRENT_REV EXT4_GOOD_OLD_REV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) #define EXT4_MAX_SUPP_REV EXT4_DYNAMIC_REV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) #define EXT4_GOOD_OLD_INODE_SIZE 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) #define EXT4_EXTRA_TIMESTAMP_MAX (((s64)1 << 34) - 1 + S32_MIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) #define EXT4_NON_EXTRA_TIMESTAMP_MAX S32_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) #define EXT4_TIMESTAMP_MIN S32_MIN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) * Feature set definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) #define EXT4_FEATURE_COMPAT_DIR_PREALLOC 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) #define EXT4_FEATURE_COMPAT_IMAGIC_INODES 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) #define EXT4_FEATURE_COMPAT_HAS_JOURNAL 0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) #define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) #define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) #define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) #define EXT4_FEATURE_COMPAT_SPARSE_SUPER2 0x0200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) * The reason why "FAST_COMMIT" is a compat feature is that, FS becomes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) * incompatible only if fast commit blocks are present in the FS. Since we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) * clear the journal (and thus the fast commit blocks), we don't mark FS as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) * incompatible. We also have a JBD2 incompat feature, which gets set when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) * there are fast commit blocks present in the journal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) #define EXT4_FEATURE_COMPAT_FAST_COMMIT 0x0400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) #define EXT4_FEATURE_COMPAT_STABLE_INODES 0x0800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) #define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) #define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) #define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) #define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) #define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) #define EXT4_FEATURE_RO_COMPAT_BIGALLOC 0x0200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) * METADATA_CSUM also enables group descriptor checksums (GDT_CSUM). When
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) * METADATA_CSUM is set, group descriptor checksums use the same algorithm as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) * all other data structures' checksums. However, the METADATA_CSUM and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) * GDT_CSUM bits are mutually exclusive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) #define EXT4_FEATURE_RO_COMPAT_READONLY 0x1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) #define EXT4_FEATURE_RO_COMPAT_PROJECT 0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) #define EXT4_FEATURE_RO_COMPAT_VERITY 0x8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) #define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) #define EXT4_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) #define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) #define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) #define EXT4_FEATURE_INCOMPAT_MMP 0x0100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) #define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400 /* EA in inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) #define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000 /* data in dirent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) #define EXT4_FEATURE_INCOMPAT_CSUM_SEED 0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) #define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 /* >2GB or 3-lvl htree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) #define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) #define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) #define EXT4_FEATURE_INCOMPAT_CASEFOLD 0x20000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) extern void ext4_update_dynamic_rev(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) #define EXT4_FEATURE_COMPAT_FUNCS(name, flagname) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) static inline bool ext4_has_feature_##name(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) return ((EXT4_SB(sb)->s_es->s_feature_compat & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) cpu_to_le32(EXT4_FEATURE_COMPAT_##flagname)) != 0); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) static inline void ext4_set_feature_##name(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) ext4_update_dynamic_rev(sb); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) EXT4_SB(sb)->s_es->s_feature_compat |= \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) cpu_to_le32(EXT4_FEATURE_COMPAT_##flagname); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) static inline void ext4_clear_feature_##name(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) EXT4_SB(sb)->s_es->s_feature_compat &= \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) ~cpu_to_le32(EXT4_FEATURE_COMPAT_##flagname); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) #define EXT4_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) static inline bool ext4_has_feature_##name(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) return ((EXT4_SB(sb)->s_es->s_feature_ro_compat & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) cpu_to_le32(EXT4_FEATURE_RO_COMPAT_##flagname)) != 0); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) static inline void ext4_set_feature_##name(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) ext4_update_dynamic_rev(sb); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) EXT4_SB(sb)->s_es->s_feature_ro_compat |= \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) cpu_to_le32(EXT4_FEATURE_RO_COMPAT_##flagname); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) static inline void ext4_clear_feature_##name(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) EXT4_SB(sb)->s_es->s_feature_ro_compat &= \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) ~cpu_to_le32(EXT4_FEATURE_RO_COMPAT_##flagname); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) #define EXT4_FEATURE_INCOMPAT_FUNCS(name, flagname) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) static inline bool ext4_has_feature_##name(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) return ((EXT4_SB(sb)->s_es->s_feature_incompat & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) cpu_to_le32(EXT4_FEATURE_INCOMPAT_##flagname)) != 0); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) static inline void ext4_set_feature_##name(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) ext4_update_dynamic_rev(sb); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) EXT4_SB(sb)->s_es->s_feature_incompat |= \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) cpu_to_le32(EXT4_FEATURE_INCOMPAT_##flagname); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) static inline void ext4_clear_feature_##name(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) EXT4_SB(sb)->s_es->s_feature_incompat &= \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) ~cpu_to_le32(EXT4_FEATURE_INCOMPAT_##flagname); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) EXT4_FEATURE_COMPAT_FUNCS(dir_prealloc, DIR_PREALLOC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) EXT4_FEATURE_COMPAT_FUNCS(imagic_inodes, IMAGIC_INODES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) EXT4_FEATURE_COMPAT_FUNCS(journal, HAS_JOURNAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) EXT4_FEATURE_COMPAT_FUNCS(xattr, EXT_ATTR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) EXT4_FEATURE_COMPAT_FUNCS(resize_inode, RESIZE_INODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) EXT4_FEATURE_COMPAT_FUNCS(dir_index, DIR_INDEX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) EXT4_FEATURE_COMPAT_FUNCS(sparse_super2, SPARSE_SUPER2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) EXT4_FEATURE_COMPAT_FUNCS(fast_commit, FAST_COMMIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) EXT4_FEATURE_COMPAT_FUNCS(stable_inodes, STABLE_INODES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) EXT4_FEATURE_RO_COMPAT_FUNCS(sparse_super, SPARSE_SUPER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) EXT4_FEATURE_RO_COMPAT_FUNCS(large_file, LARGE_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) EXT4_FEATURE_RO_COMPAT_FUNCS(btree_dir, BTREE_DIR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) EXT4_FEATURE_RO_COMPAT_FUNCS(huge_file, HUGE_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) EXT4_FEATURE_RO_COMPAT_FUNCS(gdt_csum, GDT_CSUM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) EXT4_FEATURE_RO_COMPAT_FUNCS(dir_nlink, DIR_NLINK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) EXT4_FEATURE_RO_COMPAT_FUNCS(extra_isize, EXTRA_ISIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) EXT4_FEATURE_RO_COMPAT_FUNCS(quota, QUOTA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) EXT4_FEATURE_RO_COMPAT_FUNCS(bigalloc, BIGALLOC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) EXT4_FEATURE_RO_COMPAT_FUNCS(metadata_csum, METADATA_CSUM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) EXT4_FEATURE_RO_COMPAT_FUNCS(readonly, READONLY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) EXT4_FEATURE_RO_COMPAT_FUNCS(project, PROJECT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) EXT4_FEATURE_RO_COMPAT_FUNCS(verity, VERITY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) EXT4_FEATURE_INCOMPAT_FUNCS(compression, COMPRESSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) EXT4_FEATURE_INCOMPAT_FUNCS(filetype, FILETYPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) EXT4_FEATURE_INCOMPAT_FUNCS(journal_needs_recovery, RECOVER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) EXT4_FEATURE_INCOMPAT_FUNCS(journal_dev, JOURNAL_DEV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) EXT4_FEATURE_INCOMPAT_FUNCS(meta_bg, META_BG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) EXT4_FEATURE_INCOMPAT_FUNCS(extents, EXTENTS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) EXT4_FEATURE_INCOMPAT_FUNCS(64bit, 64BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) EXT4_FEATURE_INCOMPAT_FUNCS(mmp, MMP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) EXT4_FEATURE_INCOMPAT_FUNCS(flex_bg, FLEX_BG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) EXT4_FEATURE_INCOMPAT_FUNCS(ea_inode, EA_INODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) EXT4_FEATURE_INCOMPAT_FUNCS(dirdata, DIRDATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) EXT4_FEATURE_INCOMPAT_FUNCS(csum_seed, CSUM_SEED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) EXT4_FEATURE_INCOMPAT_FUNCS(largedir, LARGEDIR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) EXT4_FEATURE_INCOMPAT_FUNCS(inline_data, INLINE_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) EXT4_FEATURE_INCOMPAT_FUNCS(encrypt, ENCRYPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) EXT4_FEATURE_INCOMPAT_FUNCS(casefold, CASEFOLD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) #define EXT2_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) #define EXT2_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) EXT4_FEATURE_INCOMPAT_META_BG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) EXT4_FEATURE_RO_COMPAT_BTREE_DIR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) #define EXT3_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) #define EXT3_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) EXT4_FEATURE_INCOMPAT_RECOVER| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) EXT4_FEATURE_INCOMPAT_META_BG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) EXT4_FEATURE_RO_COMPAT_BTREE_DIR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) #define EXT4_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) #define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) EXT4_FEATURE_INCOMPAT_RECOVER| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) EXT4_FEATURE_INCOMPAT_META_BG| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) EXT4_FEATURE_INCOMPAT_EXTENTS| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) EXT4_FEATURE_INCOMPAT_64BIT| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) EXT4_FEATURE_INCOMPAT_FLEX_BG| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) EXT4_FEATURE_INCOMPAT_EA_INODE| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) EXT4_FEATURE_INCOMPAT_MMP | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) EXT4_FEATURE_INCOMPAT_INLINE_DATA | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) EXT4_FEATURE_INCOMPAT_ENCRYPT | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) EXT4_FEATURE_INCOMPAT_CASEFOLD | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) EXT4_FEATURE_INCOMPAT_CSUM_SEED | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) EXT4_FEATURE_INCOMPAT_LARGEDIR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) EXT4_FEATURE_RO_COMPAT_BTREE_DIR |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) EXT4_FEATURE_RO_COMPAT_HUGE_FILE |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) EXT4_FEATURE_RO_COMPAT_BIGALLOC |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) EXT4_FEATURE_RO_COMPAT_METADATA_CSUM|\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) EXT4_FEATURE_RO_COMPAT_QUOTA |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) EXT4_FEATURE_RO_COMPAT_PROJECT |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) EXT4_FEATURE_RO_COMPAT_VERITY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) #define EXTN_FEATURE_FUNCS(ver) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) static inline bool ext4_has_unknown_ext##ver##_compat_features(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) return ((EXT4_SB(sb)->s_es->s_feature_compat & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) cpu_to_le32(~EXT##ver##_FEATURE_COMPAT_SUPP)) != 0); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) static inline bool ext4_has_unknown_ext##ver##_ro_compat_features(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) return ((EXT4_SB(sb)->s_es->s_feature_ro_compat & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) cpu_to_le32(~EXT##ver##_FEATURE_RO_COMPAT_SUPP)) != 0); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) static inline bool ext4_has_unknown_ext##ver##_incompat_features(struct super_block *sb) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) return ((EXT4_SB(sb)->s_es->s_feature_incompat & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) cpu_to_le32(~EXT##ver##_FEATURE_INCOMPAT_SUPP)) != 0); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) EXTN_FEATURE_FUNCS(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) EXTN_FEATURE_FUNCS(3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) EXTN_FEATURE_FUNCS(4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) static inline bool ext4_has_compat_features(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) return (EXT4_SB(sb)->s_es->s_feature_compat != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) static inline bool ext4_has_ro_compat_features(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) return (EXT4_SB(sb)->s_es->s_feature_ro_compat != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) static inline bool ext4_has_incompat_features(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) return (EXT4_SB(sb)->s_es->s_feature_incompat != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) * Superblock flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) #define EXT4_FLAGS_RESIZING 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) #define EXT4_FLAGS_SHUTDOWN 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) #define EXT4_FLAGS_BDEV_IS_DAX 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) static inline int ext4_forced_shutdown(struct ext4_sb_info *sbi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) return test_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) * Default values for user and/or group using reserved blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) #define EXT4_DEF_RESUID 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) #define EXT4_DEF_RESGID 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) * Default project ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) #define EXT4_DEF_PROJID 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) #define EXT4_DEF_INODE_READAHEAD_BLKS 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) * Default mount options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) #define EXT4_DEFM_DEBUG 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) #define EXT4_DEFM_BSDGROUPS 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) #define EXT4_DEFM_XATTR_USER 0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) #define EXT4_DEFM_ACL 0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) #define EXT4_DEFM_UID16 0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) #define EXT4_DEFM_JMODE 0x0060
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) #define EXT4_DEFM_JMODE_DATA 0x0020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) #define EXT4_DEFM_JMODE_ORDERED 0x0040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) #define EXT4_DEFM_JMODE_WBACK 0x0060
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) #define EXT4_DEFM_NOBARRIER 0x0100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) #define EXT4_DEFM_BLOCK_VALIDITY 0x0200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) #define EXT4_DEFM_DISCARD 0x0400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) #define EXT4_DEFM_NODELALLOC 0x0800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) * Default journal batch times
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) #define EXT4_DEF_MIN_BATCH_TIME 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) #define EXT4_DEF_MAX_BATCH_TIME 15000 /* 15ms */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) * Minimum number of groups in a flexgroup before we separate out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) * directories into the first block group of a flexgroup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) #define EXT4_FLEX_SIZE_DIR_ALLOC_SCHEME 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) * Structure of a directory entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) #define EXT4_NAME_LEN 255
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) struct ext4_dir_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) __le32 inode; /* Inode number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) __le16 rec_len; /* Directory entry length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) __le16 name_len; /* Name length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) char name[EXT4_NAME_LEN]; /* File name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) * Encrypted Casefolded entries require saving the hash on disk. This structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) * followed ext4_dir_entry_2's name[name_len] at the next 4 byte aligned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) * boundary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) struct ext4_dir_entry_hash {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) __le32 hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) __le32 minor_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) * The new version of the directory entry. Since EXT4 structures are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) * stored in intel byte order, and the name_len field could never be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) * bigger than 255 chars, it's safe to reclaim the extra byte for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) * file_type field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) struct ext4_dir_entry_2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) __le32 inode; /* Inode number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) __le16 rec_len; /* Directory entry length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) __u8 name_len; /* Name length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) __u8 file_type; /* See file type macros EXT4_FT_* below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) char name[EXT4_NAME_LEN]; /* File name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) * Access the hashes at the end of ext4_dir_entry_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) #define EXT4_DIRENT_HASHES(entry) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) ((struct ext4_dir_entry_hash *) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) (((void *)(entry)) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) ((8 + (entry)->name_len + EXT4_DIR_ROUND) & ~EXT4_DIR_ROUND)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) #define EXT4_DIRENT_HASH(entry) le32_to_cpu(EXT4_DIRENT_HASHES(de)->hash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) #define EXT4_DIRENT_MINOR_HASH(entry) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) le32_to_cpu(EXT4_DIRENT_HASHES(de)->minor_hash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) static inline bool ext4_hash_in_dirent(const struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) return IS_CASEFOLDED(inode) && IS_ENCRYPTED(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) * This is a bogus directory entry at the end of each leaf block that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) * records checksums.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) struct ext4_dir_entry_tail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) __le32 det_reserved_zero1; /* Pretend to be unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) __le16 det_rec_len; /* 12 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) __u8 det_reserved_zero2; /* Zero name length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) __u8 det_reserved_ft; /* 0xDE, fake file type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) __le32 det_checksum; /* crc32c(uuid+inum+dirblock) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) #define EXT4_DIRENT_TAIL(block, blocksize) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) ((struct ext4_dir_entry_tail *)(((void *)(block)) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) ((blocksize) - \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) sizeof(struct ext4_dir_entry_tail))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) * Ext4 directory file types. Only the low 3 bits are used. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) * other bits are reserved for now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) #define EXT4_FT_UNKNOWN 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) #define EXT4_FT_REG_FILE 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) #define EXT4_FT_DIR 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) #define EXT4_FT_CHRDEV 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) #define EXT4_FT_BLKDEV 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) #define EXT4_FT_FIFO 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) #define EXT4_FT_SOCK 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) #define EXT4_FT_SYMLINK 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) #define EXT4_FT_MAX 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) #define EXT4_FT_DIR_CSUM 0xDE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) * EXT4_DIR_PAD defines the directory entries boundaries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) * NOTE: It must be a multiple of 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) #define EXT4_DIR_PAD 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) #define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) #define EXT4_MAX_REC_LEN ((1<<16)-1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) * The rec_len is dependent on the type of directory. Directories that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) * casefolded and encrypted need to store the hash as well, so we add room for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) * ext4_extended_dir_entry_2. For all entries related to '.' or '..' you should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) * pass NULL for dir, as those entries do not use the extra fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) static inline unsigned int ext4_dir_rec_len(__u8 name_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) const struct inode *dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) int rec_len = (name_len + 8 + EXT4_DIR_ROUND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) if (dir && ext4_hash_in_dirent(dir))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) rec_len += sizeof(struct ext4_dir_entry_hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) return (rec_len & ~EXT4_DIR_ROUND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) * If we ever get support for fs block sizes > page_size, we'll need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) * to remove the #if statements in the next two functions...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) static inline unsigned int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) unsigned len = le16_to_cpu(dlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) #if (PAGE_SIZE >= 65536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) if (len == EXT4_MAX_REC_LEN || len == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) return blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) return (len & 65532) | ((len & 3) << 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) #if (PAGE_SIZE >= 65536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) if (len < 65536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) return cpu_to_le16(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) if (len == blocksize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) if (blocksize == 65536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) return cpu_to_le16(EXT4_MAX_REC_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) return cpu_to_le16(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) return cpu_to_le16((len & 65532) | ((len >> 16) & 3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) return cpu_to_le16(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) * Hash Tree Directory indexing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) * (c) Daniel Phillips, 2001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) #define is_dx(dir) (ext4_has_feature_dir_index((dir)->i_sb) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) ext4_test_inode_flag((dir), EXT4_INODE_INDEX))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) #define EXT4_DIR_LINK_MAX(dir) unlikely((dir)->i_nlink >= EXT4_LINK_MAX && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) !(ext4_has_feature_dir_nlink((dir)->i_sb) && is_dx(dir)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) #define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) /* Legal values for the dx_root hash_version field: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) #define DX_HASH_LEGACY 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) #define DX_HASH_HALF_MD4 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) #define DX_HASH_TEA 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) #define DX_HASH_LEGACY_UNSIGNED 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) #define DX_HASH_HALF_MD4_UNSIGNED 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) #define DX_HASH_TEA_UNSIGNED 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) #define DX_HASH_SIPHASH 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) static inline u32 ext4_chksum(struct ext4_sb_info *sbi, u32 crc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) const void *address, unsigned int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) struct shash_desc shash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) char ctx[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) } desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) BUG_ON(crypto_shash_descsize(sbi->s_chksum_driver)!=sizeof(desc.ctx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) desc.shash.tfm = sbi->s_chksum_driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) *(u32 *)desc.ctx = crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) BUG_ON(crypto_shash_update(&desc.shash, address, length));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) return *(u32 *)desc.ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) /* hash info structure used by the directory hash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) struct dx_hash_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) u32 hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) u32 minor_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) int hash_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) u32 *seed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) /* 32 and 64 bit signed EOF for dx directories */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) #define EXT4_HTREE_EOF_32BIT ((1UL << (32 - 1)) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) #define EXT4_HTREE_EOF_64BIT ((1ULL << (64 - 1)) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) * Control parameters used by ext4_htree_next_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) #define HASH_NB_ALWAYS 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) struct ext4_filename {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) const struct qstr *usr_fname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) struct fscrypt_str disk_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) struct dx_hash_info hinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) #ifdef CONFIG_FS_ENCRYPTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) struct fscrypt_str crypto_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) #ifdef CONFIG_UNICODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) struct fscrypt_str cf_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) #define fname_name(p) ((p)->disk_name.name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) #define fname_usr_name(p) ((p)->usr_fname->name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) #define fname_len(p) ((p)->disk_name.len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) * Describe an inode's exact location on disk and in memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) struct ext4_iloc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) struct buffer_head *bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) unsigned long offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) ext4_group_t block_group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) return (struct ext4_inode *) (iloc->bh->b_data + iloc->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) static inline bool ext4_is_quota_file(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) return IS_NOQUOTA(inode) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) !(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) * This structure is stuffed into the struct file's private_data field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) * for directories. It is where we put information so that we can do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) * readdir operations in hash tree order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) struct dir_private_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) struct rb_root root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) struct rb_node *curr_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) struct fname *extra_fname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) loff_t last_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) __u32 curr_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) __u32 curr_minor_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) __u32 next_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) /* calculate the first block number of the group */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) static inline ext4_fsblk_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) ext4_group_first_block_no(struct super_block *sb, ext4_group_t group_no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) return group_no * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) * Special error return code only used by dx_probe() and its callers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) #define ERR_BAD_DX_DIR (-(MAX_ERRNO - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) /* htree levels for ext4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) #define EXT4_HTREE_LEVEL_COMPAT 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) #define EXT4_HTREE_LEVEL 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) static inline int ext4_dir_htree_level(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) return ext4_has_feature_largedir(sb) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) EXT4_HTREE_LEVEL : EXT4_HTREE_LEVEL_COMPAT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) * Timeout and state flag for lazy initialization inode thread.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) #define EXT4_DEF_LI_WAIT_MULT 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) #define EXT4_DEF_LI_MAX_START_DELAY 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) #define EXT4_LAZYINIT_QUIT 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) #define EXT4_LAZYINIT_RUNNING 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) * Lazy inode table initialization info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) struct ext4_lazy_init {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) unsigned long li_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) struct list_head li_request_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) struct mutex li_list_mtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) enum ext4_li_mode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) EXT4_LI_MODE_PREFETCH_BBITMAP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) EXT4_LI_MODE_ITABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) struct ext4_li_request {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) struct super_block *lr_super;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) enum ext4_li_mode lr_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) ext4_group_t lr_first_not_zeroed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) ext4_group_t lr_next_group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) struct list_head lr_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) unsigned long lr_next_sched;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) unsigned long lr_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) struct ext4_features {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) struct kobject f_kobj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) struct completion f_kobj_unregister;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) * This structure will be used for multiple mount protection. It will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) * written into the block number saved in the s_mmp_block field in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) * superblock. Programs that check MMP should assume that if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) * SEQ_FSCK (or any unknown code above SEQ_MAX) is present then it is NOT safe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) * to use the filesystem, regardless of how old the timestamp is.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) #define EXT4_MMP_MAGIC 0x004D4D50U /* ASCII for MMP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) #define EXT4_MMP_SEQ_CLEAN 0xFF4D4D50U /* mmp_seq value for clean unmount */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) #define EXT4_MMP_SEQ_FSCK 0xE24D4D50U /* mmp_seq value when being fscked */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) #define EXT4_MMP_SEQ_MAX 0xE24D4D4FU /* maximum valid mmp_seq value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) struct mmp_struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) __le32 mmp_magic; /* Magic number for MMP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) __le32 mmp_seq; /* Sequence no. updated periodically */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) * mmp_time, mmp_nodename & mmp_bdevname are only used for information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) * purposes and do not affect the correctness of the algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) __le64 mmp_time; /* Time last updated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) char mmp_nodename[64]; /* Node which last updated MMP block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) char mmp_bdevname[32]; /* Bdev which last updated MMP block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) * mmp_check_interval is used to verify if the MMP block has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) * updated on the block device. The value is updated based on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) * maximum time to write the MMP block during an update cycle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) __le16 mmp_check_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) __le16 mmp_pad1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) __le32 mmp_pad2[226];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) __le32 mmp_checksum; /* crc32c(uuid+mmp_block) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) /* arguments passed to the mmp thread */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) struct mmpd_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) struct buffer_head *bh; /* bh from initial read_mmp_block() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) struct super_block *sb; /* super block of the fs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) * Check interval multiplier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) * The MMP block is written every update interval and initially checked every
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) * update interval x the multiplier (the value is then adapted based on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) * write latency). The reason is that writes can be delayed under load and we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) * don't want readers to incorrectly assume that the filesystem is no longer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) * in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) #define EXT4_MMP_CHECK_MULT 2UL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) * Minimum interval for MMP checking in seconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) #define EXT4_MMP_MIN_CHECK_INTERVAL 5UL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) * Maximum interval for MMP checking in seconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) #define EXT4_MMP_MAX_CHECK_INTERVAL 300UL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) * Function prototypes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) * Ok, these declarations are also in <linux/kernel.h> but none of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) * ext4 source programs needs to include it so they are duplicated here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) # define NORET_TYPE /**/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) # define ATTRIB_NORET __attribute__((noreturn))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) # define NORET_AND noreturn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) /* bitmap.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) extern unsigned int ext4_count_free(char *bitmap, unsigned numchars);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) struct ext4_group_desc *gdp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) struct buffer_head *bh, int sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) struct ext4_group_desc *gdp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) struct buffer_head *bh, int sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) void ext4_block_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) struct ext4_group_desc *gdp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) struct buffer_head *bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) struct ext4_group_desc *gdp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) struct buffer_head *bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) /* balloc.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) extern void ext4_get_group_no_and_offset(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) ext4_fsblk_t blocknr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) ext4_group_t *blockgrpp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) ext4_grpblk_t *offsetp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) extern ext4_group_t ext4_get_group_number(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) ext4_fsblk_t block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) extern unsigned int ext4_block_group(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) ext4_fsblk_t blocknr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) ext4_fsblk_t blocknr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) extern int ext4_bg_has_super(struct super_block *sb, ext4_group_t group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) extern unsigned long ext4_bg_num_gdb(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) ext4_group_t group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) extern ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) ext4_fsblk_t goal,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) unsigned int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) unsigned long *count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) int *errp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) extern int ext4_claim_free_clusters(struct ext4_sb_info *sbi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) s64 nclusters, unsigned int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) extern ext4_fsblk_t ext4_count_free_clusters(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) extern void ext4_check_blocks_bitmap(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) ext4_group_t block_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) struct buffer_head ** bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) extern struct buffer_head *ext4_read_block_bitmap_nowait(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) ext4_group_t block_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) bool ignore_locked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) extern int ext4_wait_block_bitmap(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) ext4_group_t block_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) struct buffer_head *bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) extern struct buffer_head *ext4_read_block_bitmap(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) ext4_group_t block_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) extern unsigned ext4_free_clusters_after_init(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) ext4_group_t block_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) struct ext4_group_desc *gdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) ext4_fsblk_t ext4_inode_to_goal_block(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) #ifdef CONFIG_UNICODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) extern int ext4_fname_setup_ci_filename(struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) const struct qstr *iname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) struct ext4_filename *fname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) #ifdef CONFIG_FS_ENCRYPTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) static inline void ext4_fname_from_fscrypt_name(struct ext4_filename *dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) const struct fscrypt_name *src)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) memset(dst, 0, sizeof(*dst));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) dst->usr_fname = src->usr_fname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) dst->disk_name = src->disk_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) dst->hinfo.hash = src->hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) dst->hinfo.minor_hash = src->minor_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) dst->crypto_buf = src->crypto_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) static inline int ext4_fname_setup_filename(struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) const struct qstr *iname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) int lookup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) struct ext4_filename *fname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) struct fscrypt_name name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) err = fscrypt_setup_filename(dir, iname, lookup, &name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) ext4_fname_from_fscrypt_name(fname, &name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) #ifdef CONFIG_UNICODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) err = ext4_fname_setup_ci_filename(dir, iname, fname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) static inline int ext4_fname_prepare_lookup(struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) struct ext4_filename *fname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) struct fscrypt_name name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) err = fscrypt_prepare_lookup(dir, dentry, &name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) ext4_fname_from_fscrypt_name(fname, &name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) #ifdef CONFIG_UNICODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) static inline void ext4_fname_free_filename(struct ext4_filename *fname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) struct fscrypt_name name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) name.crypto_buf = fname->crypto_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) fscrypt_free_filename(&name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) fname->crypto_buf.name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) fname->usr_fname = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) fname->disk_name.name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) #ifdef CONFIG_UNICODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) kfree(fname->cf_name.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) fname->cf_name.name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) #else /* !CONFIG_FS_ENCRYPTION */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) static inline int ext4_fname_setup_filename(struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) const struct qstr *iname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) int lookup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) struct ext4_filename *fname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) fname->usr_fname = iname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) fname->disk_name.name = (unsigned char *) iname->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) fname->disk_name.len = iname->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) #ifdef CONFIG_UNICODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) err = ext4_fname_setup_ci_filename(dir, iname, fname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) static inline int ext4_fname_prepare_lookup(struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) struct ext4_filename *fname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) return ext4_fname_setup_filename(dir, &dentry->d_name, 1, fname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) static inline void ext4_fname_free_filename(struct ext4_filename *fname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) #ifdef CONFIG_UNICODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) kfree(fname->cf_name.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) fname->cf_name.name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) #endif /* !CONFIG_FS_ENCRYPTION */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) /* dir.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) extern int __ext4_check_dir_entry(const char *, unsigned int, struct inode *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) struct file *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) struct ext4_dir_entry_2 *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) struct buffer_head *, char *, int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) ext4_lblk_t, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) #define ext4_check_dir_entry(dir, filp, de, bh, buf, size, lblk, offset) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) unlikely(__ext4_check_dir_entry(__func__, __LINE__, (dir), (filp), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) (de), (bh), (buf), (size), (lblk), (offset)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) __u32 minor_hash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) struct ext4_dir_entry_2 *dirent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) struct fscrypt_str *ent_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) extern void ext4_htree_free_dir_info(struct dir_private_info *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) extern int ext4_find_dest_de(struct inode *dir, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) ext4_lblk_t lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) struct buffer_head *bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) void *buf, int buf_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) struct ext4_filename *fname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) struct ext4_dir_entry_2 **dest_de);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) void ext4_insert_dentry(struct inode *dir, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) struct ext4_dir_entry_2 *de,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) int buf_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) struct ext4_filename *fname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) static inline void ext4_update_dx_flag(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) if (!ext4_has_feature_dir_index(inode->i_sb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) ext4_test_inode_flag(inode, EXT4_INODE_INDEX)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) /* ext4_iget() should have caught this... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) WARN_ON_ONCE(ext4_has_feature_metadata_csum(inode->i_sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) ext4_clear_inode_flag(inode, EXT4_INODE_INDEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) static const unsigned char ext4_filetype_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) static inline unsigned char get_dtype(struct super_block *sb, int filetype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) if (!ext4_has_feature_filetype(sb) || filetype >= EXT4_FT_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) return DT_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) return ext4_filetype_table[filetype];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) extern int ext4_check_all_de(struct inode *dir, struct buffer_head *bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) void *buf, int buf_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) /* fsync.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) extern int ext4_sync_file(struct file *, loff_t, loff_t, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) /* hash.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) extern int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) struct dx_hash_info *hinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) /* ialloc.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) extern int ext4_mark_inode_used(struct super_block *sb, int ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) extern struct inode *__ext4_new_inode(handle_t *, struct inode *, umode_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) const struct qstr *qstr, __u32 goal,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) uid_t *owner, __u32 i_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) int handle_type, unsigned int line_no,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) int nblocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) #define ext4_new_inode(handle, dir, mode, qstr, goal, owner, i_flags) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) __ext4_new_inode((handle), (dir), (mode), (qstr), (goal), (owner), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) i_flags, 0, 0, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) #define ext4_new_inode_start_handle(dir, mode, qstr, goal, owner, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) type, nblocks) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) __ext4_new_inode(NULL, (dir), (mode), (qstr), (goal), (owner), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) 0, (type), __LINE__, (nblocks))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) extern void ext4_free_inode(handle_t *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) extern struct inode * ext4_orphan_get(struct super_block *, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) extern unsigned long ext4_count_free_inodes(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) extern unsigned long ext4_count_dirs(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) extern void ext4_check_inodes_bitmap(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) extern void ext4_mark_bitmap_end(int start_bit, int end_bit, char *bitmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) extern int ext4_init_inode_table(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) ext4_group_t group, int barrier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) extern void ext4_end_bitmap_read(struct buffer_head *bh, int uptodate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) /* fast_commit.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) int ext4_fc_info_show(struct seq_file *seq, void *v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) void ext4_fc_init(struct super_block *sb, journal_t *journal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) void ext4_fc_init_inode(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) void ext4_fc_track_range(handle_t *handle, struct inode *inode, ext4_lblk_t start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) ext4_lblk_t end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) void __ext4_fc_track_unlink(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) struct dentry *dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) void __ext4_fc_track_link(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) struct dentry *dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) void ext4_fc_track_link(handle_t *handle, struct dentry *dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) void __ext4_fc_track_create(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) struct dentry *dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) void ext4_fc_track_create(handle_t *handle, struct dentry *dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) void ext4_fc_track_inode(handle_t *handle, struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) void ext4_fc_mark_ineligible(struct super_block *sb, int reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) void ext4_fc_start_ineligible(struct super_block *sb, int reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) void ext4_fc_stop_ineligible(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) void ext4_fc_start_update(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) void ext4_fc_stop_update(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) void ext4_fc_del(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) bool ext4_fc_replay_check_excluded(struct super_block *sb, ext4_fsblk_t block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) void ext4_fc_replay_cleanup(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) int ext4_fc_commit(journal_t *journal, tid_t commit_tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) int __init ext4_fc_init_dentry_cache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) void ext4_fc_destroy_dentry_cache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) int ext4_fc_record_regions(struct super_block *sb, int ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) ext4_lblk_t lblk, ext4_fsblk_t pblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) int len, int replay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) /* mballoc.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) extern const struct seq_operations ext4_mb_seq_groups_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) extern long ext4_mb_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) extern long ext4_mb_max_to_scan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) extern int ext4_mb_init(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) extern int ext4_mb_release(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) extern ext4_fsblk_t ext4_mb_new_blocks(handle_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) struct ext4_allocation_request *, int *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) extern int ext4_mb_reserve_blocks(struct super_block *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) extern void ext4_discard_preallocations(struct inode *, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) extern int __init ext4_init_mballoc(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) extern void ext4_exit_mballoc(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) extern ext4_group_t ext4_mb_prefetch(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) ext4_group_t group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) unsigned int nr, int *cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) extern void ext4_mb_prefetch_fini(struct super_block *sb, ext4_group_t group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) unsigned int nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) extern void ext4_free_blocks(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) struct buffer_head *bh, ext4_fsblk_t block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) unsigned long count, int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) extern int ext4_mb_alloc_groupinfo(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) ext4_group_t ngroups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) extern int ext4_mb_add_groupinfo(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) ext4_group_t i, struct ext4_group_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) extern int ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) ext4_fsblk_t block, unsigned long count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) extern void ext4_process_freed_data(struct super_block *sb, tid_t commit_tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) extern void ext4_mb_mark_bb(struct super_block *sb, ext4_fsblk_t block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) int len, int state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) /* inode.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) void ext4_inode_csum_set(struct inode *inode, struct ext4_inode *raw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) struct ext4_inode_info *ei);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) int ext4_inode_is_fast_symlink(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) struct buffer_head *ext4_getblk(handle_t *, struct inode *, ext4_lblk_t, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) struct buffer_head *ext4_bread(handle_t *, struct inode *, ext4_lblk_t, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) int ext4_bread_batch(struct inode *inode, ext4_lblk_t block, int bh_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) bool wait, struct buffer_head **bhs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) int ext4_get_block_unwritten(struct inode *inode, sector_t iblock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) struct buffer_head *bh_result, int create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) int ext4_get_block(struct inode *inode, sector_t iblock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) struct buffer_head *bh_result, int create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) struct buffer_head *bh, int create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) int ext4_walk_page_buffers(handle_t *handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) struct buffer_head *head,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) unsigned from,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) unsigned to,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) int *partial,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) int (*fn)(handle_t *handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) struct buffer_head *bh));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) int do_journal_get_write_access(handle_t *handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) struct buffer_head *bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) #define FALL_BACK_TO_NONDELALLOC 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) #define CONVERT_INLINE_DATA 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) EXT4_IGET_NORMAL = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) EXT4_IGET_SPECIAL = 0x0001, /* OK to iget a system inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) EXT4_IGET_HANDLE = 0x0002 /* Inode # is from a handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) } ext4_iget_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) extern struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) ext4_iget_flags flags, const char *function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) unsigned int line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) #define ext4_iget(sb, ino, flags) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) __ext4_iget((sb), (ino), (flags), __func__, __LINE__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) extern int ext4_write_inode(struct inode *, struct writeback_control *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) extern int ext4_setattr(struct dentry *, struct iattr *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) extern int ext4_getattr(const struct path *, struct kstat *, u32, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) extern void ext4_evict_inode(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) extern void ext4_clear_inode(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) extern int ext4_file_getattr(const struct path *, struct kstat *, u32, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) extern int ext4_sync_inode(handle_t *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) extern void ext4_dirty_inode(struct inode *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) extern int ext4_change_inode_journal_flag(struct inode *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) extern int ext4_get_fc_inode_loc(struct super_block *sb, unsigned long ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) struct ext4_iloc *iloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) extern int ext4_inode_attach_jinode(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) extern int ext4_can_truncate(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) extern int ext4_truncate(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) extern int ext4_break_layouts(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) extern int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) extern void ext4_set_inode_flags(struct inode *, bool init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) extern int ext4_alloc_da_blocks(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) extern void ext4_set_aops(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) extern int ext4_writepage_trans_blocks(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) loff_t lstart, loff_t lend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) extern vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) extern vm_fault_t ext4_filemap_fault(struct vm_fault *vmf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) extern qsize_t *ext4_get_reserved_space(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) extern int ext4_get_projid(struct inode *inode, kprojid_t *projid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) extern void ext4_da_release_space(struct inode *inode, int to_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) extern void ext4_da_update_reserve_space(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) int used, int quota_claim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) extern int ext4_issue_zeroout(struct inode *inode, ext4_lblk_t lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) ext4_fsblk_t pblk, ext4_lblk_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) /* indirect.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) extern int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) struct ext4_map_blocks *map, int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) extern int ext4_ind_trans_blocks(struct inode *inode, int nrblocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) extern void ext4_ind_truncate(handle_t *, struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) extern int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) ext4_lblk_t start, ext4_lblk_t end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) /* ioctl.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) extern void ext4_reset_inode_seed(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) /* migrate.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) extern int ext4_ext_migrate(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) extern int ext4_ind_migrate(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) /* namei.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) extern int ext4_init_new_dir(handle_t *handle, struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) extern int ext4_dirblock_csum_verify(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) struct buffer_head *bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) extern int ext4_orphan_add(handle_t *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) extern int ext4_orphan_del(handle_t *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) __u32 start_minor_hash, __u32 *next_hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) extern int ext4_search_dir(struct buffer_head *bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) char *search_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) int buf_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) struct ext4_filename *fname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) ext4_lblk_t lblk, unsigned int offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) struct ext4_dir_entry_2 **res_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) extern int ext4_generic_delete_entry(struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) struct ext4_dir_entry_2 *de_del,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) ext4_lblk_t lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) struct buffer_head *bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) void *entry_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) int buf_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) int csum_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) extern bool ext4_empty_dir(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) /* resize.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) extern void ext4_kvfree_array_rcu(void *to_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) extern int ext4_group_add(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) struct ext4_new_group_data *input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) extern int ext4_group_extend(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) struct ext4_super_block *es,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) ext4_fsblk_t n_blocks_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) extern int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) /* super.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) extern struct buffer_head *ext4_sb_bread(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) sector_t block, int op_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) extern struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) sector_t block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) extern void ext4_read_bh_nowait(struct buffer_head *bh, int op_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) bh_end_io_t *end_io);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) extern int ext4_read_bh(struct buffer_head *bh, int op_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) bh_end_io_t *end_io);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) extern int ext4_read_bh_lock(struct buffer_head *bh, int op_flags, bool wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) extern void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) extern int ext4_seq_options_show(struct seq_file *seq, void *offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) extern int ext4_calculate_overhead(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) extern void ext4_superblock_csum_set(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) extern int ext4_alloc_flex_bg_array(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) ext4_group_t ngroup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003) extern const char *ext4_decode_error(struct super_block *sb, int errno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) char nbuf[16]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) extern void ext4_mark_group_bitmap_corrupted(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) ext4_group_t block_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) unsigned int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) extern __printf(6, 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) void __ext4_error(struct super_block *, const char *, unsigned int, int, __u64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) const char *, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) extern __printf(6, 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) void __ext4_error_inode(struct inode *, const char *, unsigned int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) ext4_fsblk_t, int, const char *, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) extern __printf(5, 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) void __ext4_error_file(struct file *, const char *, unsigned int, ext4_fsblk_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) const char *, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) extern void __ext4_std_error(struct super_block *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) unsigned int, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) extern __printf(5, 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) void __ext4_abort(struct super_block *, const char *, unsigned int, int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) const char *, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) extern __printf(4, 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) void __ext4_warning(struct super_block *, const char *, unsigned int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) const char *, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) extern __printf(4, 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) void __ext4_warning_inode(const struct inode *inode, const char *function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) unsigned int line, const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) extern __printf(3, 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030) void __ext4_msg(struct super_block *, const char *, const char *, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) extern void __dump_mmp_msg(struct super_block *, struct mmp_struct *mmp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) const char *, unsigned int, const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) extern __printf(7, 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) void __ext4_grp_locked_error(const char *, unsigned int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) struct super_block *, ext4_group_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) unsigned long, ext4_fsblk_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) const char *, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) #define EXT4_ERROR_INODE(inode, fmt, a...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) ext4_error_inode((inode), __func__, __LINE__, 0, (fmt), ## a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) #define EXT4_ERROR_INODE_ERR(inode, err, fmt, a...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) __ext4_error_inode((inode), __func__, __LINE__, 0, (err), (fmt), ## a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) #define ext4_error_inode_block(inode, block, err, fmt, a...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) __ext4_error_inode((inode), __func__, __LINE__, (block), (err), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) (fmt), ## a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) #define EXT4_ERROR_FILE(file, block, fmt, a...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) ext4_error_file((file), __func__, __LINE__, (block), (fmt), ## a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) #ifdef CONFIG_PRINTK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) #define ext4_error_inode(inode, func, line, block, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) __ext4_error_inode(inode, func, line, block, 0, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) #define ext4_error_inode_err(inode, func, line, block, err, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) __ext4_error_inode((inode), (func), (line), (block), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) (err), (fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) #define ext4_error_file(file, func, line, block, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) __ext4_error_file(file, func, line, block, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) #define ext4_error(sb, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) __ext4_error((sb), __func__, __LINE__, 0, 0, (fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) #define ext4_error_err(sb, err, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) __ext4_error((sb), __func__, __LINE__, (err), 0, (fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) #define ext4_abort(sb, err, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) __ext4_abort((sb), __func__, __LINE__, (err), (fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) #define ext4_warning(sb, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) __ext4_warning(sb, __func__, __LINE__, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) #define ext4_warning_inode(inode, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) __ext4_warning_inode(inode, __func__, __LINE__, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) #define ext4_msg(sb, level, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) __ext4_msg(sb, level, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) #define dump_mmp_msg(sb, mmp, msg) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) __dump_mmp_msg(sb, mmp, __func__, __LINE__, msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) #define ext4_grp_locked_error(sb, grp, ino, block, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) __ext4_grp_locked_error(__func__, __LINE__, sb, grp, ino, block, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) #define ext4_error_inode(inode, func, line, block, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) no_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) __ext4_error_inode(inode, "", 0, block, 0, " "); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) #define ext4_error_inode_err(inode, func, line, block, err, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) no_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) __ext4_error_inode(inode, "", 0, block, err, " "); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) #define ext4_error_file(file, func, line, block, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) no_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) __ext4_error_file(file, "", 0, block, " "); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) #define ext4_error(sb, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) no_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) __ext4_error(sb, "", 0, 0, 0, " "); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) #define ext4_error_err(sb, err, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) no_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) __ext4_error(sb, "", 0, err, 0, " "); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) #define ext4_abort(sb, err, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) no_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) __ext4_abort(sb, "", 0, err, " "); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) #define ext4_warning(sb, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) no_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) __ext4_warning(sb, "", 0, " "); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) #define ext4_warning_inode(inode, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) no_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) __ext4_warning_inode(inode, "", 0, " "); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) #define ext4_msg(sb, level, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) no_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124) __ext4_msg(sb, "", " "); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) #define dump_mmp_msg(sb, mmp, msg) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) __dump_mmp_msg(sb, mmp, "", 0, "")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) #define ext4_grp_locked_error(sb, grp, ino, block, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) no_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) __ext4_grp_locked_error("", 0, sb, grp, ino, block, " "); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) struct ext4_group_desc *bg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) struct ext4_group_desc *bg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) extern ext4_fsblk_t ext4_inode_table(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) struct ext4_group_desc *bg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) extern __u32 ext4_free_group_clusters(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) struct ext4_group_desc *bg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) extern __u32 ext4_free_inodes_count(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) struct ext4_group_desc *bg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) extern __u32 ext4_used_dirs_count(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) struct ext4_group_desc *bg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) extern __u32 ext4_itable_unused_count(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) struct ext4_group_desc *bg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) extern void ext4_block_bitmap_set(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) struct ext4_group_desc *bg, ext4_fsblk_t blk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) extern void ext4_inode_bitmap_set(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) struct ext4_group_desc *bg, ext4_fsblk_t blk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) extern void ext4_inode_table_set(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) struct ext4_group_desc *bg, ext4_fsblk_t blk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156) extern void ext4_free_group_clusters_set(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) struct ext4_group_desc *bg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158) __u32 count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) extern void ext4_free_inodes_set(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) struct ext4_group_desc *bg, __u32 count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) extern void ext4_used_dirs_set(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) struct ext4_group_desc *bg, __u32 count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) extern void ext4_itable_unused_set(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) struct ext4_group_desc *bg, __u32 count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) extern int ext4_group_desc_csum_verify(struct super_block *sb, __u32 group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) struct ext4_group_desc *gdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) extern void ext4_group_desc_csum_set(struct super_block *sb, __u32 group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) struct ext4_group_desc *gdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) extern int ext4_register_li_request(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) ext4_group_t first_not_zeroed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) static inline int ext4_has_metadata_csum(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) WARN_ON_ONCE(ext4_has_feature_metadata_csum(sb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) !EXT4_SB(sb)->s_chksum_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) return ext4_has_feature_metadata_csum(sb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) (EXT4_SB(sb)->s_chksum_driver != NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) static inline int ext4_has_group_desc_csum(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) return ext4_has_feature_gdt_csum(sb) || ext4_has_metadata_csum(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) #define ext4_read_incompat_64bit_val(es, name) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) (((es)->s_feature_incompat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_64BIT) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) ? (ext4_fsblk_t)le32_to_cpu(es->name##_hi) << 32 : 0) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189) le32_to_cpu(es->name##_lo))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193) return ext4_read_incompat_64bit_val(es, s_blocks_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) static inline ext4_fsblk_t ext4_r_blocks_count(struct ext4_super_block *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) return ext4_read_incompat_64bit_val(es, s_r_blocks_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) static inline ext4_fsblk_t ext4_free_blocks_count(struct ext4_super_block *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) return ext4_read_incompat_64bit_val(es, s_free_blocks_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) static inline void ext4_blocks_count_set(struct ext4_super_block *es,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) ext4_fsblk_t blk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) es->s_blocks_count_lo = cpu_to_le32((u32)blk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) es->s_blocks_count_hi = cpu_to_le32(blk >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) static inline void ext4_free_blocks_count_set(struct ext4_super_block *es,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) ext4_fsblk_t blk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) es->s_free_blocks_count_lo = cpu_to_le32((u32)blk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) static inline void ext4_r_blocks_count_set(struct ext4_super_block *es,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) ext4_fsblk_t blk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) es->s_r_blocks_count_lo = cpu_to_le32((u32)blk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224) es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) static inline loff_t ext4_isize(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) struct ext4_inode *raw_inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) if (ext4_has_feature_largedir(sb) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) S_ISREG(le16_to_cpu(raw_inode->i_mode)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) return ((loff_t)le32_to_cpu(raw_inode->i_size_high) << 32) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) le32_to_cpu(raw_inode->i_size_lo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) return (loff_t) le32_to_cpu(raw_inode->i_size_lo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) static inline void ext4_isize_set(struct ext4_inode *raw_inode, loff_t i_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) raw_inode->i_size_lo = cpu_to_le32(i_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) raw_inode->i_size_high = cpu_to_le32(i_size >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) struct ext4_group_info *ext4_get_group_info(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) ext4_group_t group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) struct ext4_group_info **grp_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) long indexv, indexh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) BUG_ON(group >= EXT4_SB(sb)->s_groups_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) indexv = group >> (EXT4_DESC_PER_BLOCK_BITS(sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) indexh = group & ((EXT4_DESC_PER_BLOCK(sb)) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) grp_info = sbi_array_rcu_deref(EXT4_SB(sb), s_group_info, indexv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) return grp_info[indexh];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) * Reading s_groups_count requires using smp_rmb() afterwards. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) * the locking protocol documented in the comments of ext4_group_add()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) * in resize.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) static inline ext4_group_t ext4_get_groups_count(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) smp_rmb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) return ngroups;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) static inline ext4_group_t ext4_flex_group(struct ext4_sb_info *sbi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) ext4_group_t block_group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) return block_group >> sbi->s_log_groups_per_flex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) static inline unsigned int ext4_flex_bg_size(struct ext4_sb_info *sbi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) return 1 << sbi->s_log_groups_per_flex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) #define ext4_std_error(sb, errno) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) if ((errno)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) __ext4_std_error((sb), __func__, __LINE__, (errno)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) /* Each CPU can accumulate percpu_counter_batch clusters in their local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) * counters. So we need to make sure we have free clusters more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) * than percpu_counter_batch * nr_cpu_ids. Also add a window of 4 times.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) #define EXT4_FREECLUSTERS_WATERMARK (4 * (percpu_counter_batch * nr_cpu_ids))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) #define EXT4_FREECLUSTERS_WATERMARK 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) /* Update i_disksize. Requires i_mutex to avoid races with truncate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) WARN_ON_ONCE(S_ISREG(inode->i_mode) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) !inode_is_locked(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) down_write(&EXT4_I(inode)->i_data_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) if (newsize > EXT4_I(inode)->i_disksize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) WRITE_ONCE(EXT4_I(inode)->i_disksize, newsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) up_write(&EXT4_I(inode)->i_data_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) /* Update i_size, i_disksize. Requires i_mutex to avoid races with truncate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) static inline int ext4_update_inode_size(struct inode *inode, loff_t newsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) int changed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) if (newsize > inode->i_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) i_size_write(inode, newsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) changed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) if (newsize > EXT4_I(inode)->i_disksize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) ext4_update_i_disksize(inode, newsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) changed |= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) return changed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) loff_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) struct ext4_group_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) unsigned long bb_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) #ifdef AGGRESSIVE_CHECK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) unsigned long bb_check_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) struct rb_root bb_free_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) ext4_grpblk_t bb_first_free; /* first free block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) ext4_grpblk_t bb_free; /* total free blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) ext4_grpblk_t bb_fragments; /* nr of freespace fragments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) ext4_grpblk_t bb_largest_free_order;/* order of largest frag in BG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) struct list_head bb_prealloc_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) #ifdef DOUBLE_CHECK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) void *bb_bitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) struct rw_semaphore alloc_sem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) ext4_grpblk_t bb_counters[]; /* Nr of free power-of-two-block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) * regions, index is order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) * bb_counters[3] = 5 means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) * 5 free 8-block regions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) #define EXT4_GROUP_INFO_NEED_INIT_BIT 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) #define EXT4_GROUP_INFO_WAS_TRIMMED_BIT 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) #define EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) #define EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) #define EXT4_GROUP_INFO_BBITMAP_CORRUPT \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) (1 << EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) #define EXT4_GROUP_INFO_IBITMAP_CORRUPT \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) (1 << EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) #define EXT4_GROUP_INFO_BBITMAP_READ_BIT 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) #define EXT4_MB_GRP_NEED_INIT(grp) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) #define EXT4_MB_GRP_BBITMAP_CORRUPT(grp) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) (test_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &((grp)->bb_state)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) #define EXT4_MB_GRP_IBITMAP_CORRUPT(grp) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) (test_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &((grp)->bb_state)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) #define EXT4_MB_GRP_WAS_TRIMMED(grp) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) (test_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) #define EXT4_MB_GRP_SET_TRIMMED(grp) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) (set_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) #define EXT4_MB_GRP_CLEAR_TRIMMED(grp) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) (clear_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) #define EXT4_MB_GRP_TEST_AND_SET_READ(grp) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) (test_and_set_bit(EXT4_GROUP_INFO_BBITMAP_READ_BIT, &((grp)->bb_state)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) #define EXT4_MAX_CONTENTION 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) #define EXT4_CONTENTION_THRESHOLD 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) static inline spinlock_t *ext4_group_lock_ptr(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) ext4_group_t group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) return bgl_lock_ptr(EXT4_SB(sb)->s_blockgroup_lock, group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) * Returns true if the filesystem is busy enough that attempts to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) * access the block group locks has run into contention.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) static inline int ext4_fs_is_busy(struct ext4_sb_info *sbi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) return (atomic_read(&sbi->s_lock_busy) > EXT4_CONTENTION_THRESHOLD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) static inline void ext4_lock_group(struct super_block *sb, ext4_group_t group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) spinlock_t *lock = ext4_group_lock_ptr(sb, group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) if (spin_trylock(lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) * We're able to grab the lock right away, so drop the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) * lock contention counter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) atomic_add_unless(&EXT4_SB(sb)->s_lock_busy, -1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) * The lock is busy, so bump the contention counter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) * and then wait on the spin lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) atomic_add_unless(&EXT4_SB(sb)->s_lock_busy, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) EXT4_MAX_CONTENTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) spin_lock(lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) static inline void ext4_unlock_group(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) ext4_group_t group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) spin_unlock(ext4_group_lock_ptr(sb, group));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) * Block validity checking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) #define ext4_check_indirect_blockref(inode, bh) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) ext4_check_blockref(__func__, __LINE__, inode, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) (__le32 *)(bh)->b_data, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) EXT4_ADDR_PER_BLOCK((inode)->i_sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) #define ext4_ind_check_inode(inode) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) ext4_check_blockref(__func__, __LINE__, inode, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) EXT4_I(inode)->i_data, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) EXT4_NDIR_BLOCKS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) * Inodes and files operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) /* dir.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) extern const struct file_operations ext4_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) /* file.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) extern const struct inode_operations ext4_file_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) extern const struct file_operations ext4_file_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) extern loff_t ext4_llseek(struct file *file, loff_t offset, int origin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) /* inline.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) extern int ext4_get_max_inline_size(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) extern int ext4_find_inline_data_nolock(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) extern int ext4_init_inline_data(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) unsigned int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) extern int ext4_destroy_inline_data(handle_t *handle, struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) extern int ext4_readpage_inline(struct inode *inode, struct page *page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) extern int ext4_try_to_write_inline_data(struct address_space *mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) loff_t pos, unsigned len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) unsigned flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) struct page **pagep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) extern int ext4_write_inline_data_end(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) loff_t pos, unsigned len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) unsigned copied,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) struct page *page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) extern struct buffer_head *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) ext4_journalled_write_inline_data(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) unsigned len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) struct page *page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) extern int ext4_da_write_inline_data_begin(struct address_space *mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) loff_t pos, unsigned len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) unsigned flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) struct page **pagep,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) void **fsdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) extern int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) unsigned len, unsigned copied,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) struct page *page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) extern int ext4_try_add_inline_entry(handle_t *handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) struct ext4_filename *fname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) struct inode *dir, struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476) extern int ext4_try_create_inline_dir(handle_t *handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) struct inode *parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) extern int ext4_read_inline_dir(struct file *filp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) struct dir_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) int *has_inline_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) extern int ext4_inlinedir_to_tree(struct file *dir_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) struct inode *dir, ext4_lblk_t block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) struct dx_hash_info *hinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) __u32 start_hash, __u32 start_minor_hash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) int *has_inline_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487) extern struct buffer_head *ext4_find_inline_entry(struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) struct ext4_filename *fname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) struct ext4_dir_entry_2 **res_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) int *has_inline_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) extern int ext4_delete_inline_entry(handle_t *handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) struct ext4_dir_entry_2 *de_del,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) struct buffer_head *bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) int *has_inline_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) extern bool empty_inline_dir(struct inode *dir, int *has_inline_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) extern struct buffer_head *ext4_get_first_inline_block(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498) struct ext4_dir_entry_2 **parent_de,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) int *retval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) extern int ext4_inline_data_fiemap(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) struct fiemap_extent_info *fieinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) int *has_inline, __u64 start, __u64 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) struct iomap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) extern int ext4_inline_data_iomap(struct inode *inode, struct iomap *iomap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) extern int ext4_inline_data_truncate(struct inode *inode, int *has_inline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) extern int ext4_convert_inline_data(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) static inline int ext4_has_inline_data(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) return ext4_test_inode_flag(inode, EXT4_INODE_INLINE_DATA) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) EXT4_I(inode)->i_inline_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) /* namei.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) extern const struct inode_operations ext4_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) extern const struct inode_operations ext4_special_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) extern struct dentry *ext4_get_parent(struct dentry *child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) extern struct ext4_dir_entry_2 *ext4_init_dot_dotdot(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) struct ext4_dir_entry_2 *de,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) int blocksize, int csum_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) unsigned int parent_ino, int dotdot_real_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) extern void ext4_initialize_dirent_tail(struct buffer_head *bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) unsigned int blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) extern int ext4_handle_dirty_dirblock(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) struct buffer_head *bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) extern int __ext4_unlink(handle_t *handle, struct inode *dir, const struct qstr *d_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) extern int __ext4_link(struct inode *dir, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) struct dentry *dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) #define S_SHIFT 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) static const unsigned char ext4_type_by_mode[(S_IFMT >> S_SHIFT) + 1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) [S_IFREG >> S_SHIFT] = EXT4_FT_REG_FILE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) [S_IFDIR >> S_SHIFT] = EXT4_FT_DIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) [S_IFCHR >> S_SHIFT] = EXT4_FT_CHRDEV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) [S_IFBLK >> S_SHIFT] = EXT4_FT_BLKDEV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) [S_IFIFO >> S_SHIFT] = EXT4_FT_FIFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) [S_IFSOCK >> S_SHIFT] = EXT4_FT_SOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) [S_IFLNK >> S_SHIFT] = EXT4_FT_SYMLINK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) static inline void ext4_set_de_type(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) struct ext4_dir_entry_2 *de,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) umode_t mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) if (ext4_has_feature_filetype(sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) de->file_type = ext4_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) /* readpages.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) extern int ext4_mpage_readpages(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) struct readahead_control *rac, struct page *page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) extern int __init ext4_init_post_read_processing(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) extern void ext4_exit_post_read_processing(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) /* symlink.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) extern const struct inode_operations ext4_encrypted_symlink_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) extern const struct inode_operations ext4_symlink_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) extern const struct inode_operations ext4_fast_symlink_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) /* sysfs.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) extern int ext4_register_sysfs(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) extern void ext4_unregister_sysfs(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) extern int __init ext4_init_sysfs(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) extern void ext4_exit_sysfs(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) /* block_validity */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) extern void ext4_release_system_zone(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) extern int ext4_setup_system_zone(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) extern int __init ext4_init_system_zone(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) extern void ext4_exit_system_zone(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) extern int ext4_inode_block_valid(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) ext4_fsblk_t start_blk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) unsigned int count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) extern int ext4_check_blockref(const char *, unsigned int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) struct inode *, __le32 *, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) /* extents.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) struct ext4_ext_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) struct ext4_extent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) * Maximum number of logical blocks in a file; ext4_extent's ee_block is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) * __le32.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) #define EXT_MAX_BLOCKS 0xffffffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) extern void ext4_ext_tree_init(handle_t *handle, struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591) extern int ext4_ext_index_trans_blocks(struct inode *inode, int extents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) struct ext4_map_blocks *map, int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) extern int ext4_ext_truncate(handle_t *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) extern int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) ext4_lblk_t end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) extern void ext4_ext_init(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) extern void ext4_ext_release(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) extern long ext4_fallocate(struct file *file, int mode, loff_t offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) loff_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) extern int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) loff_t offset, ssize_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) extern int ext4_convert_unwritten_io_end_vec(handle_t *handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) ext4_io_end_t *io_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) extern int ext4_map_blocks(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) struct ext4_map_blocks *map, int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) int num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) struct ext4_ext_path *path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) extern int ext4_ext_insert_extent(handle_t *, struct inode *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) struct ext4_ext_path **,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) struct ext4_extent *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) extern struct ext4_ext_path *ext4_find_extent(struct inode *, ext4_lblk_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) struct ext4_ext_path **,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) extern void ext4_ext_drop_refs(struct ext4_ext_path *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) extern int ext4_ext_check_inode(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) extern ext4_lblk_t ext4_ext_next_allocated_block(struct ext4_ext_path *path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) __u64 start, __u64 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) extern int ext4_get_es_cache(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) struct fiemap_extent_info *fieinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) __u64 start, __u64 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) extern int ext4_ext_precache(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) extern int ext4_swap_extents(handle_t *handle, struct inode *inode1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) struct inode *inode2, ext4_lblk_t lblk1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) ext4_lblk_t lblk2, ext4_lblk_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) int mark_unwritten,int *err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) extern int ext4_clu_mapped(struct inode *inode, ext4_lblk_t lclu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) extern int ext4_datasem_ensure_credits(handle_t *handle, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) int check_cred, int restart_cred,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) int revoke_cred);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) extern void ext4_ext_replay_shrink_inode(struct inode *inode, ext4_lblk_t end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) extern int ext4_ext_replay_set_iblocks(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635) extern int ext4_ext_replay_update_ex(struct inode *inode, ext4_lblk_t start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) int len, int unwritten, ext4_fsblk_t pblk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) extern int ext4_ext_clear_bb(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) /* move_extent.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) extern void ext4_double_down_write_data_sem(struct inode *first,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) struct inode *second);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) extern void ext4_double_up_write_data_sem(struct inode *orig_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) struct inode *donor_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) __u64 start_orig, __u64 start_donor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) __u64 len, __u64 *moved_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) /* page-io.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) extern int __init ext4_init_pageio(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) extern void ext4_exit_pageio(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) extern ext4_io_end_t *ext4_init_io_end(struct inode *inode, gfp_t flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) extern ext4_io_end_t *ext4_get_io_end(ext4_io_end_t *io_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) extern int ext4_put_io_end(ext4_io_end_t *io_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) extern void ext4_put_io_end_defer(ext4_io_end_t *io_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) extern void ext4_io_submit_init(struct ext4_io_submit *io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) struct writeback_control *wbc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) extern void ext4_end_io_rsv_work(struct work_struct *work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) extern void ext4_io_submit(struct ext4_io_submit *io);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) extern int ext4_bio_write_page(struct ext4_io_submit *io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) struct writeback_control *wbc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) bool keep_towrite);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) extern struct ext4_io_end_vec *ext4_alloc_io_end_vec(ext4_io_end_t *io_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) extern struct ext4_io_end_vec *ext4_last_io_end_vec(ext4_io_end_t *io_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) /* mmp.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) extern int ext4_multi_mount_protect(struct super_block *, ext4_fsblk_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) /* mmp.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) extern void ext4_stop_mmpd(struct ext4_sb_info *sbi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) /* verity.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675) extern const struct fsverity_operations ext4_verityops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) * Add new method to test whether block and inode bitmaps are properly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) * initialized. With uninit_bg reading the block from disk is not enough
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680) * to mark the bitmap uptodate. We need to also zero-out the bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) #define BH_BITMAP_UPTODATE BH_JBDPrivateStart
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) static inline int bitmap_uptodate(struct buffer_head *bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) return (buffer_uptodate(bh) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) test_bit(BH_BITMAP_UPTODATE, &(bh)->b_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) static inline void set_bitmap_uptodate(struct buffer_head *bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) set_bit(BH_BITMAP_UPTODATE, &(bh)->b_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) #define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) /* For ioend & aio unwritten conversion wait queues */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) #define EXT4_WQ_HASH_SZ 37
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) #define ext4_ioend_wq(v) (&ext4__ioend_wq[((unsigned long)(v)) %\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699) EXT4_WQ_HASH_SZ])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700) extern wait_queue_head_t ext4__ioend_wq[EXT4_WQ_HASH_SZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) extern int ext4_resize_begin(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) extern void ext4_resize_end(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705) static inline void ext4_set_io_unwritten_flag(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) struct ext4_io_end *io_end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) io_end->flag |= EXT4_IO_END_UNWRITTEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) atomic_inc(&EXT4_I(inode)->i_unwritten);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) static inline void ext4_clear_io_unwritten_flag(ext4_io_end_t *io_end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716) struct inode *inode = io_end->inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) io_end->flag &= ~EXT4_IO_END_UNWRITTEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720) /* Wake up anyone waiting on unwritten extent conversion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) wake_up_all(ext4_ioend_wq(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) extern const struct iomap_ops ext4_iomap_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) extern const struct iomap_ops ext4_iomap_overwrite_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) extern const struct iomap_ops ext4_iomap_report_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) static inline int ext4_buffer_uptodate(struct buffer_head *bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) * If the buffer has the write error flag, we have failed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) * to write out data in the block. In this case, we don't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) * have to read the block because we may read the old data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) * successfully.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) if (!buffer_uptodate(bh) && buffer_write_io_error(bh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) set_buffer_uptodate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) return buffer_uptodate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) #endif /* __KERNEL__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) #define EFSBADCRC EBADMSG /* Bad CRC detected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) #endif /* _EXT4_H */