aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/extents_status.h
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-11-25 11:55:24 -0500
committerTheodore Ts'o <tytso@mit.edu>2014-11-25 11:55:24 -0500
commit2be12de98a1cc21c4de4e2d6fb2bf5aa0a279947 (patch)
tree4cd9da2b11616ee1a38bb1ac677ca7ec90bef2b7 /fs/ext4/extents_status.h
parent624d0f1dd7c80d2bac4fc3066b2ff3947f890883 (diff)
ext4: introduce aging to extent status tree
Introduce a simple aging to extent status tree. Each extent has a REFERENCED bit which gets set when the extent is used. Shrinker then skips entries with referenced bit set and clears the bit. Thus frequently used extents have higher chances of staying in memory. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents_status.h')
-rw-r--r--fs/ext4/extents_status.h35
1 files changed, 31 insertions, 4 deletions
diff --git a/fs/ext4/extents_status.h b/fs/ext4/extents_status.h
index e86b1f34cfec..691b52613ce4 100644
--- a/fs/ext4/extents_status.h
+++ b/fs/ext4/extents_status.h
@@ -34,6 +34,7 @@ enum {
34 ES_UNWRITTEN_B, 34 ES_UNWRITTEN_B,
35 ES_DELAYED_B, 35 ES_DELAYED_B,
36 ES_HOLE_B, 36 ES_HOLE_B,
37 ES_REFERENCED_B,
37 ES_FLAGS 38 ES_FLAGS
38}; 39};
39 40
@@ -44,6 +45,12 @@ enum {
44#define EXTENT_STATUS_UNWRITTEN (1 << ES_UNWRITTEN_B) 45#define EXTENT_STATUS_UNWRITTEN (1 << ES_UNWRITTEN_B)
45#define EXTENT_STATUS_DELAYED (1 << ES_DELAYED_B) 46#define EXTENT_STATUS_DELAYED (1 << ES_DELAYED_B)
46#define EXTENT_STATUS_HOLE (1 << ES_HOLE_B) 47#define EXTENT_STATUS_HOLE (1 << ES_HOLE_B)
48#define EXTENT_STATUS_REFERENCED (1 << ES_REFERENCED_B)
49
50#define ES_TYPE_MASK ((ext4_fsblk_t)(EXTENT_STATUS_WRITTEN | \
51 EXTENT_STATUS_UNWRITTEN | \
52 EXTENT_STATUS_DELAYED | \
53 EXTENT_STATUS_HOLE) << ES_SHIFT)
47 54
48struct ext4_sb_info; 55struct ext4_sb_info;
49struct ext4_extent; 56struct ext4_extent;
@@ -93,24 +100,44 @@ static inline unsigned int ext4_es_status(struct extent_status *es)
93 return es->es_pblk >> ES_SHIFT; 100 return es->es_pblk >> ES_SHIFT;
94} 101}
95 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 (ext4_es_status(es) & EXTENT_STATUS_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 (ext4_es_status(es) & EXTENT_STATUS_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 (ext4_es_status(es) & EXTENT_STATUS_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 (ext4_es_status(es) & EXTENT_STATUS_HOLE) != 0; 125 return (ext4_es_type(es) & EXTENT_STATUS_HOLE) != 0;
126}
127
128static inline void ext4_es_set_referenced(struct extent_status *es)
129{
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;
114} 141}
115 142
116static inline ext4_fsblk_t ext4_es_pblock(struct extent_status *es) 143static inline ext4_fsblk_t ext4_es_pblock(struct extent_status *es)