aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/extents_status.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/extents_status.h')
-rw-r--r--fs/ext4/extents_status.h82
1 files changed, 50 insertions, 32 deletions
diff --git a/fs/ext4/extents_status.h b/fs/ext4/extents_status.h
index efd5f970b501..691b52613ce4 100644
--- a/fs/ext4/extents_status.h
+++ b/fs/ext4/extents_status.h
@@ -29,25 +29,28 @@
29/* 29/*
30 * These flags live in the high bits of extent_status.es_pblk 30 * These flags live in the high bits of extent_status.es_pblk
31 */ 31 */
32#define ES_SHIFT 60 32enum {
33 33 ES_WRITTEN_B,
34#define EXTENT_STATUS_WRITTEN (1 << 3) 34 ES_UNWRITTEN_B,
35#define EXTENT_STATUS_UNWRITTEN (1 << 2) 35 ES_DELAYED_B,
36#define EXTENT_STATUS_DELAYED (1 << 1) 36 ES_HOLE_B,
37#define EXTENT_STATUS_HOLE (1 << 0) 37 ES_REFERENCED_B,
38 ES_FLAGS
39};
38 40
39#define EXTENT_STATUS_FLAGS (EXTENT_STATUS_WRITTEN | \ 41#define ES_SHIFT (sizeof(ext4_fsblk_t)*8 - ES_FLAGS)
40 EXTENT_STATUS_UNWRITTEN | \ 42#define ES_MASK (~((ext4_fsblk_t)0) << ES_SHIFT)
41 EXTENT_STATUS_DELAYED | \
42 EXTENT_STATUS_HOLE)
43 43
44#define ES_WRITTEN (1ULL << 63) 44#define EXTENT_STATUS_WRITTEN (1 << ES_WRITTEN_B)
45#define ES_UNWRITTEN (1ULL << 62) 45#define EXTENT_STATUS_UNWRITTEN (1 << ES_UNWRITTEN_B)
46#define ES_DELAYED (1ULL << 61) 46#define EXTENT_STATUS_DELAYED (1 << ES_DELAYED_B)
47#define ES_HOLE (1ULL << 60) 47#define EXTENT_STATUS_HOLE (1 << ES_HOLE_B)
48#define EXTENT_STATUS_REFERENCED (1 << ES_REFERENCED_B)
48 49
49#define ES_MASK (ES_WRITTEN | ES_UNWRITTEN | \ 50#define ES_TYPE_MASK ((ext4_fsblk_t)(EXTENT_STATUS_WRITTEN | \
50 ES_DELAYED | ES_HOLE) 51 EXTENT_STATUS_UNWRITTEN | \
52 EXTENT_STATUS_DELAYED | \
53 EXTENT_STATUS_HOLE) << ES_SHIFT)
51 54
52struct ext4_sb_info; 55struct ext4_sb_info;
53struct ext4_extent; 56struct ext4_extent;
@@ -65,14 +68,13 @@ struct ext4_es_tree {
65}; 68};
66 69
67struct ext4_es_stats { 70struct ext4_es_stats {
68 unsigned long es_stats_last_sorted;
69 unsigned long es_stats_shrunk; 71 unsigned long es_stats_shrunk;
70 unsigned long es_stats_cache_hits; 72 unsigned long es_stats_cache_hits;
71 unsigned long es_stats_cache_misses; 73 unsigned long es_stats_cache_misses;
72 u64 es_stats_scan_time; 74 u64 es_stats_scan_time;
73 u64 es_stats_max_scan_time; 75 u64 es_stats_max_scan_time;
74 struct percpu_counter es_stats_all_cnt; 76 struct percpu_counter es_stats_all_cnt;
75 struct percpu_counter es_stats_lru_cnt; 77 struct percpu_counter es_stats_shk_cnt;
76}; 78};
77 79
78extern int __init ext4_init_es(void); 80extern int __init ext4_init_es(void);
@@ -93,29 +95,49 @@ extern void ext4_es_find_delayed_extent_range(struct inode *inode,
93extern int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk, 95extern int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk,
94 struct extent_status *es); 96 struct extent_status *es);
95 97
98static inline unsigned int ext4_es_status(struct extent_status *es)
99{
100 return es->es_pblk >> ES_SHIFT;
101}
102
103static inline unsigned int ext4_es_type(struct extent_status *es)
104{
105 return (es->es_pblk & ES_TYPE_MASK) >> ES_SHIFT;
106}
107
96static inline int ext4_es_is_written(struct extent_status *es) 108static inline int ext4_es_is_written(struct extent_status *es)
97{ 109{
98 return (es->es_pblk & ES_WRITTEN) != 0; 110 return (ext4_es_type(es) & EXTENT_STATUS_WRITTEN) != 0;
99} 111}
100 112
101static inline int ext4_es_is_unwritten(struct extent_status *es) 113static inline int ext4_es_is_unwritten(struct extent_status *es)
102{ 114{
103 return (es->es_pblk & ES_UNWRITTEN) != 0; 115 return (ext4_es_type(es) & EXTENT_STATUS_UNWRITTEN) != 0;
104} 116}
105 117
106static inline int ext4_es_is_delayed(struct extent_status *es) 118static inline int ext4_es_is_delayed(struct extent_status *es)
107{ 119{
108 return (es->es_pblk & ES_DELAYED) != 0; 120 return (ext4_es_type(es) & EXTENT_STATUS_DELAYED) != 0;
109} 121}
110 122
111static inline int ext4_es_is_hole(struct extent_status *es) 123static inline int ext4_es_is_hole(struct extent_status *es)
112{ 124{
113 return (es->es_pblk & ES_HOLE) != 0; 125 return (ext4_es_type(es) & EXTENT_STATUS_HOLE) != 0;
114} 126}
115 127
116static inline unsigned int ext4_es_status(struct extent_status *es) 128static inline void ext4_es_set_referenced(struct extent_status *es)
117{ 129{
118 return es->es_pblk >> ES_SHIFT; 130 es->es_pblk |= ((ext4_fsblk_t)EXTENT_STATUS_REFERENCED) << ES_SHIFT;
131}
132
133static inline void ext4_es_clear_referenced(struct extent_status *es)
134{
135 es->es_pblk &= ~(((ext4_fsblk_t)EXTENT_STATUS_REFERENCED) << ES_SHIFT);
136}
137
138static inline int ext4_es_is_referenced(struct extent_status *es)
139{
140 return (ext4_es_status(es) & EXTENT_STATUS_REFERENCED) != 0;
119} 141}
120 142
121static inline ext4_fsblk_t ext4_es_pblock(struct extent_status *es) 143static inline ext4_fsblk_t ext4_es_pblock(struct extent_status *es)
@@ -135,23 +157,19 @@ static inline void ext4_es_store_pblock(struct extent_status *es,
135static inline void ext4_es_store_status(struct extent_status *es, 157static inline void ext4_es_store_status(struct extent_status *es,
136 unsigned int status) 158 unsigned int status)
137{ 159{
138 es->es_pblk = (((ext4_fsblk_t) 160 es->es_pblk = (((ext4_fsblk_t)status << ES_SHIFT) & ES_MASK) |
139 (status & EXTENT_STATUS_FLAGS) << ES_SHIFT) | 161 (es->es_pblk & ~ES_MASK);
140 (es->es_pblk & ~ES_MASK));
141} 162}
142 163
143static inline void ext4_es_store_pblock_status(struct extent_status *es, 164static inline void ext4_es_store_pblock_status(struct extent_status *es,
144 ext4_fsblk_t pb, 165 ext4_fsblk_t pb,
145 unsigned int status) 166 unsigned int status)
146{ 167{
147 es->es_pblk = (((ext4_fsblk_t) 168 es->es_pblk = (((ext4_fsblk_t)status << ES_SHIFT) & ES_MASK) |
148 (status & EXTENT_STATUS_FLAGS) << ES_SHIFT) | 169 (pb & ~ES_MASK);
149 (pb & ~ES_MASK));
150} 170}
151 171
152extern int ext4_es_register_shrinker(struct ext4_sb_info *sbi); 172extern int ext4_es_register_shrinker(struct ext4_sb_info *sbi);
153extern void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi); 173extern void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi);
154extern void ext4_es_lru_add(struct inode *inode);
155extern void ext4_es_lru_del(struct inode *inode);
156 174
157#endif /* _EXT4_EXTENTS_STATUS_H */ 175#endif /* _EXT4_EXTENTS_STATUS_H */