^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) * fs/ext4/extents_status.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Written by Yongqiang Yang <xiaoqiangnk@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Modified by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Allison Henderson <achender@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Zheng Liu <wenqing.lz@taobao.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #ifndef _EXT4_EXTENTS_STATUS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define _EXT4_EXTENTS_STATUS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Turn on ES_DEBUG__ to get lots of info about extent status operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #ifdef ES_DEBUG__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define es_debug(fmt, ...) printk(fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define es_debug(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * With ES_AGGRESSIVE_TEST defined, the result of es caching will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * checked with old map_block's result.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define ES_AGGRESSIVE_TEST__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * These flags live in the high bits of extent_status.es_pblk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) ES_WRITTEN_B,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) ES_UNWRITTEN_B,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) ES_DELAYED_B,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ES_HOLE_B,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) ES_REFERENCED_B,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) ES_FLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define ES_SHIFT (sizeof(ext4_fsblk_t)*8 - ES_FLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define ES_MASK (~((ext4_fsblk_t)0) << ES_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define EXTENT_STATUS_WRITTEN (1 << ES_WRITTEN_B)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define EXTENT_STATUS_UNWRITTEN (1 << ES_UNWRITTEN_B)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define EXTENT_STATUS_DELAYED (1 << ES_DELAYED_B)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define EXTENT_STATUS_HOLE (1 << ES_HOLE_B)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define EXTENT_STATUS_REFERENCED (1 << ES_REFERENCED_B)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define ES_TYPE_MASK ((ext4_fsblk_t)(EXTENT_STATUS_WRITTEN | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) EXTENT_STATUS_UNWRITTEN | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) EXTENT_STATUS_DELAYED | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) EXTENT_STATUS_HOLE) << ES_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct ext4_sb_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct ext4_extent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct extent_status {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct rb_node rb_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) ext4_lblk_t es_lblk; /* first logical block extent covers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ext4_lblk_t es_len; /* length of extent in block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) ext4_fsblk_t es_pblk; /* first physical block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct ext4_es_tree {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct rb_root root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct extent_status *cache_es; /* recently accessed extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct ext4_es_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) unsigned long es_stats_shrunk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct percpu_counter es_stats_cache_hits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct percpu_counter es_stats_cache_misses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) u64 es_stats_scan_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) u64 es_stats_max_scan_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct percpu_counter es_stats_all_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct percpu_counter es_stats_shk_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * Pending cluster reservations for bigalloc file systems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * A cluster with a pending reservation is a logical cluster shared by at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * least one extent in the extents status tree with delayed and unwritten
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * status and at least one other written or unwritten extent. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * reservation is said to be pending because a cluster reservation would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * have to be taken in the event all blocks in the cluster shared with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * written or unwritten extents were deleted while the delayed and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * unwritten blocks remained.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * The set of pending cluster reservations is an auxiliary data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * used with the extents status tree to implement reserved cluster/block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * accounting for bigalloc file systems. The set is kept in memory and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * records all pending cluster reservations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * Its primary function is to avoid the need to read extents from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * disk when invalidating pages as a result of a truncate, punch hole, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * collapse range operation. Page invalidation requires a decrease in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * reserved cluster count if it results in the removal of all delayed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * and unwritten extents (blocks) from a cluster that is not shared with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * written or unwritten extent, and no decrease otherwise. Determining
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * whether the cluster is shared can be done by searching for a pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * reservation on it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * Secondarily, it provides a potentially faster method for determining
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * whether the reserved cluster count should be increased when a physical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * cluster is deallocated as a result of a truncate, punch hole, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * collapse range operation. The necessary information is also present
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * in the extents status tree, but might be more rapidly accessed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * the pending reservation set in many cases due to smaller size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * The pending cluster reservation set is implemented as a red-black tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * with the goal of minimizing per page search time overhead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct pending_reservation {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct rb_node rb_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) ext4_lblk_t lclu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct ext4_pending_tree {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) struct rb_root root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) extern int __init ext4_init_es(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) extern void ext4_exit_es(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) extern void ext4_es_init_tree(struct ext4_es_tree *tree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) extern int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) ext4_lblk_t len, ext4_fsblk_t pblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) unsigned int status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) extern void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) ext4_lblk_t len, ext4_fsblk_t pblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) unsigned int status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) extern int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) ext4_lblk_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) extern void ext4_es_find_extent_range(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) int (*match_fn)(struct extent_status *es),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) ext4_lblk_t lblk, ext4_lblk_t end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct extent_status *es);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) extern int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) ext4_lblk_t *next_lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct extent_status *es);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) extern bool ext4_es_scan_range(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int (*matching_fn)(struct extent_status *es),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) ext4_lblk_t lblk, ext4_lblk_t end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) extern bool ext4_es_scan_clu(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) int (*matching_fn)(struct extent_status *es),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) ext4_lblk_t lblk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static inline unsigned int ext4_es_status(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) return es->es_pblk >> ES_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static inline unsigned int ext4_es_type(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return (es->es_pblk & ES_TYPE_MASK) >> ES_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static inline int ext4_es_is_written(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) return (ext4_es_type(es) & EXTENT_STATUS_WRITTEN) != 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static inline int ext4_es_is_unwritten(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return (ext4_es_type(es) & EXTENT_STATUS_UNWRITTEN) != 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static inline int ext4_es_is_delayed(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) return (ext4_es_type(es) & EXTENT_STATUS_DELAYED) != 0;
^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) static inline int ext4_es_is_hole(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) return (ext4_es_type(es) & EXTENT_STATUS_HOLE) != 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) static inline int ext4_es_is_mapped(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) return (ext4_es_is_written(es) || ext4_es_is_unwritten(es));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static inline int ext4_es_is_delonly(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return (ext4_es_is_delayed(es) && !ext4_es_is_unwritten(es));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static inline void ext4_es_set_referenced(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) es->es_pblk |= ((ext4_fsblk_t)EXTENT_STATUS_REFERENCED) << ES_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static inline void ext4_es_clear_referenced(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) es->es_pblk &= ~(((ext4_fsblk_t)EXTENT_STATUS_REFERENCED) << ES_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) static inline int ext4_es_is_referenced(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) return (ext4_es_status(es) & EXTENT_STATUS_REFERENCED) != 0;
^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) static inline ext4_fsblk_t ext4_es_pblock(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) return es->es_pblk & ~ES_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) static inline ext4_fsblk_t ext4_es_show_pblock(struct extent_status *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) ext4_fsblk_t pblock = ext4_es_pblock(es);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return pblock == ~ES_MASK ? 0 : pblock;
^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) static inline void ext4_es_store_pblock(struct extent_status *es,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) ext4_fsblk_t pb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) ext4_fsblk_t block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) block = (pb & ~ES_MASK) | (es->es_pblk & ES_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) es->es_pblk = block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static inline void ext4_es_store_status(struct extent_status *es,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) unsigned int status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) es->es_pblk = (((ext4_fsblk_t)status << ES_SHIFT) & ES_MASK) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) (es->es_pblk & ~ES_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static inline void ext4_es_store_pblock_status(struct extent_status *es,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) ext4_fsblk_t pb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) unsigned int status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) es->es_pblk = (((ext4_fsblk_t)status << ES_SHIFT) & ES_MASK) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) (pb & ~ES_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) extern int ext4_es_register_shrinker(struct ext4_sb_info *sbi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) extern void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) extern int ext4_seq_es_shrinker_info_show(struct seq_file *seq, void *v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) extern int __init ext4_init_pending(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) extern void ext4_exit_pending(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) extern void ext4_init_pending_tree(struct ext4_pending_tree *tree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) extern void ext4_remove_pending(struct inode *inode, ext4_lblk_t lblk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) extern bool ext4_is_pending(struct inode *inode, ext4_lblk_t lblk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) extern int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) bool allocated);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) extern unsigned int ext4_es_delayed_clu(struct inode *inode, ext4_lblk_t lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) ext4_lblk_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) extern void ext4_clear_inode_es(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) #endif /* _EXT4_EXTENTS_STATUS_H */