diff options
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/extents_status.c | 2 | ||||
-rw-r--r-- | fs/ext4/extents_status.h | 58 |
2 files changed, 28 insertions, 32 deletions
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index 8f2aac4006d2..30596498ed0b 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c | |||
@@ -1174,6 +1174,8 @@ int ext4_es_register_shrinker(struct ext4_sb_info *sbi) | |||
1174 | { | 1174 | { |
1175 | int err; | 1175 | int err; |
1176 | 1176 | ||
1177 | /* Make sure we have enough bits for physical block number */ | ||
1178 | BUILD_BUG_ON(ES_SHIFT < 48); | ||
1177 | INIT_LIST_HEAD(&sbi->s_es_list); | 1179 | INIT_LIST_HEAD(&sbi->s_es_list); |
1178 | sbi->s_es_nr_inode = 0; | 1180 | sbi->s_es_nr_inode = 0; |
1179 | spin_lock_init(&sbi->s_es_lock); | 1181 | spin_lock_init(&sbi->s_es_lock); |
diff --git a/fs/ext4/extents_status.h b/fs/ext4/extents_status.h index b0b78b95f481..e86b1f34cfec 100644 --- a/fs/ext4/extents_status.h +++ b/fs/ext4/extents_status.h | |||
@@ -29,25 +29,21 @@ | |||
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 | 32 | enum { |
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_FLAGS |
38 | 38 | }; | |
39 | #define EXTENT_STATUS_FLAGS (EXTENT_STATUS_WRITTEN | \ | ||
40 | EXTENT_STATUS_UNWRITTEN | \ | ||
41 | EXTENT_STATUS_DELAYED | \ | ||
42 | EXTENT_STATUS_HOLE) | ||
43 | 39 | ||
44 | #define ES_WRITTEN (1ULL << 63) | 40 | #define ES_SHIFT (sizeof(ext4_fsblk_t)*8 - ES_FLAGS) |
45 | #define ES_UNWRITTEN (1ULL << 62) | 41 | #define ES_MASK (~((ext4_fsblk_t)0) << ES_SHIFT) |
46 | #define ES_DELAYED (1ULL << 61) | ||
47 | #define ES_HOLE (1ULL << 60) | ||
48 | 42 | ||
49 | #define ES_MASK (ES_WRITTEN | ES_UNWRITTEN | \ | 43 | #define EXTENT_STATUS_WRITTEN (1 << ES_WRITTEN_B) |
50 | ES_DELAYED | ES_HOLE) | 44 | #define EXTENT_STATUS_UNWRITTEN (1 << ES_UNWRITTEN_B) |
45 | #define EXTENT_STATUS_DELAYED (1 << ES_DELAYED_B) | ||
46 | #define EXTENT_STATUS_HOLE (1 << ES_HOLE_B) | ||
51 | 47 | ||
52 | struct ext4_sb_info; | 48 | struct ext4_sb_info; |
53 | struct ext4_extent; | 49 | struct ext4_extent; |
@@ -92,29 +88,29 @@ extern void ext4_es_find_delayed_extent_range(struct inode *inode, | |||
92 | extern int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk, | 88 | extern int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk, |
93 | struct extent_status *es); | 89 | struct extent_status *es); |
94 | 90 | ||
91 | static inline unsigned int ext4_es_status(struct extent_status *es) | ||
92 | { | ||
93 | return es->es_pblk >> ES_SHIFT; | ||
94 | } | ||
95 | |||
95 | static inline int ext4_es_is_written(struct extent_status *es) | 96 | static inline int ext4_es_is_written(struct extent_status *es) |
96 | { | 97 | { |
97 | return (es->es_pblk & ES_WRITTEN) != 0; | 98 | return (ext4_es_status(es) & EXTENT_STATUS_WRITTEN) != 0; |
98 | } | 99 | } |
99 | 100 | ||
100 | static inline int ext4_es_is_unwritten(struct extent_status *es) | 101 | static inline int ext4_es_is_unwritten(struct extent_status *es) |
101 | { | 102 | { |
102 | return (es->es_pblk & ES_UNWRITTEN) != 0; | 103 | return (ext4_es_status(es) & EXTENT_STATUS_UNWRITTEN) != 0; |
103 | } | 104 | } |
104 | 105 | ||
105 | static inline int ext4_es_is_delayed(struct extent_status *es) | 106 | static inline int ext4_es_is_delayed(struct extent_status *es) |
106 | { | 107 | { |
107 | return (es->es_pblk & ES_DELAYED) != 0; | 108 | return (ext4_es_status(es) & EXTENT_STATUS_DELAYED) != 0; |
108 | } | 109 | } |
109 | 110 | ||
110 | static inline int ext4_es_is_hole(struct extent_status *es) | 111 | static inline int ext4_es_is_hole(struct extent_status *es) |
111 | { | 112 | { |
112 | return (es->es_pblk & ES_HOLE) != 0; | 113 | return (ext4_es_status(es) & EXTENT_STATUS_HOLE) != 0; |
113 | } | ||
114 | |||
115 | static inline unsigned int ext4_es_status(struct extent_status *es) | ||
116 | { | ||
117 | return es->es_pblk >> ES_SHIFT; | ||
118 | } | 114 | } |
119 | 115 | ||
120 | static inline ext4_fsblk_t ext4_es_pblock(struct extent_status *es) | 116 | static inline ext4_fsblk_t ext4_es_pblock(struct extent_status *es) |
@@ -134,18 +130,16 @@ static inline void ext4_es_store_pblock(struct extent_status *es, | |||
134 | static inline void ext4_es_store_status(struct extent_status *es, | 130 | static inline void ext4_es_store_status(struct extent_status *es, |
135 | unsigned int status) | 131 | unsigned int status) |
136 | { | 132 | { |
137 | es->es_pblk = (((ext4_fsblk_t) | 133 | es->es_pblk = (((ext4_fsblk_t)status << ES_SHIFT) & ES_MASK) | |
138 | (status & EXTENT_STATUS_FLAGS) << ES_SHIFT) | | 134 | (es->es_pblk & ~ES_MASK); |
139 | (es->es_pblk & ~ES_MASK)); | ||
140 | } | 135 | } |
141 | 136 | ||
142 | static inline void ext4_es_store_pblock_status(struct extent_status *es, | 137 | static inline void ext4_es_store_pblock_status(struct extent_status *es, |
143 | ext4_fsblk_t pb, | 138 | ext4_fsblk_t pb, |
144 | unsigned int status) | 139 | unsigned int status) |
145 | { | 140 | { |
146 | es->es_pblk = (((ext4_fsblk_t) | 141 | es->es_pblk = (((ext4_fsblk_t)status << ES_SHIFT) & ES_MASK) | |
147 | (status & EXTENT_STATUS_FLAGS) << ES_SHIFT) | | 142 | (pb & ~ES_MASK); |
148 | (pb & ~ES_MASK)); | ||
149 | } | 143 | } |
150 | 144 | ||
151 | extern int ext4_es_register_shrinker(struct ext4_sb_info *sbi); | 145 | extern int ext4_es_register_shrinker(struct ext4_sb_info *sbi); |