]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - fs/ext4/extents_status.h
2 * fs/ext4/extents_status.h
4 * Written by Yongqiang Yang <xiaoqiangnk@gmail.com>
6 * Allison Henderson <achender@linux.vnet.ibm.com>
7 * Zheng Liu <wenqing.lz@taobao.com>
11 #ifndef _EXT4_EXTENTS_STATUS_H
12 #define _EXT4_EXTENTS_STATUS_H
15 * Turn on ES_DEBUG__ to get lots of info about extent status operations.
18 #define es_debug(fmt, ...) printk(fmt, ##__VA_ARGS__)
20 #define es_debug(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
24 * With ES_AGGRESSIVE_TEST defined, the result of es caching will be
25 * checked with old map_block's result.
27 #define ES_AGGRESSIVE_TEST__
30 * These flags live in the high bits of extent_status.es_pblk
34 #define EXTENT_STATUS_WRITTEN (1 << 3)
35 #define EXTENT_STATUS_UNWRITTEN (1 << 2)
36 #define EXTENT_STATUS_DELAYED (1 << 1)
37 #define EXTENT_STATUS_HOLE (1 << 0)
39 #define EXTENT_STATUS_FLAGS (EXTENT_STATUS_WRITTEN | \
40 EXTENT_STATUS_UNWRITTEN | \
41 EXTENT_STATUS_DELAYED | \
44 #define ES_WRITTEN (1ULL << 63)
45 #define ES_UNWRITTEN (1ULL << 62)
46 #define ES_DELAYED (1ULL << 61)
47 #define ES_HOLE (1ULL << 60)
49 #define ES_MASK (ES_WRITTEN | ES_UNWRITTEN | \
55 struct extent_status
{
56 struct rb_node rb_node
;
57 ext4_lblk_t es_lblk
; /* first logical block extent covers */
58 ext4_lblk_t es_len
; /* length of extent in block */
59 ext4_fsblk_t es_pblk
; /* first physical block */
64 struct extent_status
*cache_es
; /* recently accessed extent */
67 extern int __init
ext4_init_es(void);
68 extern void ext4_exit_es(void);
69 extern void ext4_es_init_tree(struct ext4_es_tree
*tree
);
71 extern int ext4_es_insert_extent(struct inode
*inode
, ext4_lblk_t lblk
,
72 ext4_lblk_t len
, ext4_fsblk_t pblk
,
74 extern void ext4_es_cache_extent(struct inode
*inode
, ext4_lblk_t lblk
,
75 ext4_lblk_t len
, ext4_fsblk_t pblk
,
77 extern int ext4_es_remove_extent(struct inode
*inode
, ext4_lblk_t lblk
,
79 extern void ext4_es_find_delayed_extent_range(struct inode
*inode
,
80 ext4_lblk_t lblk
, ext4_lblk_t end
,
81 struct extent_status
*es
);
82 extern int ext4_es_lookup_extent(struct inode
*inode
, ext4_lblk_t lblk
,
83 struct extent_status
*es
);
84 extern int ext4_es_zeroout(struct inode
*inode
, struct ext4_extent
*ex
);
86 static inline int ext4_es_is_written(struct extent_status
*es
)
88 return (es
->es_pblk
& ES_WRITTEN
) != 0;
91 static inline int ext4_es_is_unwritten(struct extent_status
*es
)
93 return (es
->es_pblk
& ES_UNWRITTEN
) != 0;
96 static inline int ext4_es_is_delayed(struct extent_status
*es
)
98 return (es
->es_pblk
& ES_DELAYED
) != 0;
101 static inline int ext4_es_is_hole(struct extent_status
*es
)
103 return (es
->es_pblk
& ES_HOLE
) != 0;
106 static inline unsigned int ext4_es_status(struct extent_status
*es
)
108 return es
->es_pblk
>> ES_SHIFT
;
111 static inline ext4_fsblk_t
ext4_es_pblock(struct extent_status
*es
)
113 return es
->es_pblk
& ~ES_MASK
;
116 static inline void ext4_es_store_pblock(struct extent_status
*es
,
121 block
= (pb
& ~ES_MASK
) | (es
->es_pblk
& ES_MASK
);
125 static inline void ext4_es_store_status(struct extent_status
*es
,
128 es
->es_pblk
= (((ext4_fsblk_t
)
129 (status
& EXTENT_STATUS_FLAGS
) << ES_SHIFT
) |
130 (es
->es_pblk
& ~ES_MASK
));
133 extern void ext4_es_register_shrinker(struct ext4_sb_info
*sbi
);
134 extern void ext4_es_unregister_shrinker(struct ext4_sb_info
*sbi
);
135 extern void ext4_es_lru_add(struct inode
*inode
);
136 extern void ext4_es_lru_del(struct inode
*inode
);
138 #endif /* _EXT4_EXTENTS_STATUS_H */