diff options
author | Theodore Ts'o <tytso@mit.edu> | 2013-08-16 21:22:41 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-08-16 21:22:41 -0400 |
commit | 3be78c73179c9347bdc0a92b2898063bd2300ff7 (patch) | |
tree | eb4147818a58e3dd80300fd09fc94ad344480231 /fs/ext4/extents_status.h | |
parent | c349179b4808f7c8e1ff1b4dd967c047eefd24bc (diff) |
ext4: use unsigned int for es_status values
Don't use an unsigned long long for the es_status flags; this requires
that we pass 64-bit values around which is painful on 32-bit systems.
Instead pass the extent status flags around using the low 4 bits of an
unsigned int, and shift them into place when we are reading or writing
es_pblk.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Diffstat (limited to 'fs/ext4/extents_status.h')
-rw-r--r-- | fs/ext4/extents_status.h | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/fs/ext4/extents_status.h b/fs/ext4/extents_status.h index e936730cc5b0..d72af848f989 100644 --- a/fs/ext4/extents_status.h +++ b/fs/ext4/extents_status.h | |||
@@ -29,16 +29,26 @@ | |||
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 EXTENT_STATUS_WRITTEN (1ULL << 63) | 32 | #define ES_SHIFT 60 |
33 | #define EXTENT_STATUS_UNWRITTEN (1ULL << 62) | 33 | |
34 | #define EXTENT_STATUS_DELAYED (1ULL << 61) | 34 | #define EXTENT_STATUS_WRITTEN (1 << 3) |
35 | #define EXTENT_STATUS_HOLE (1ULL << 60) | 35 | #define EXTENT_STATUS_UNWRITTEN (1 << 2) |
36 | #define EXTENT_STATUS_DELAYED (1 << 1) | ||
37 | #define EXTENT_STATUS_HOLE (1 << 0) | ||
36 | 38 | ||
37 | #define EXTENT_STATUS_FLAGS (EXTENT_STATUS_WRITTEN | \ | 39 | #define EXTENT_STATUS_FLAGS (EXTENT_STATUS_WRITTEN | \ |
38 | EXTENT_STATUS_UNWRITTEN | \ | 40 | EXTENT_STATUS_UNWRITTEN | \ |
39 | EXTENT_STATUS_DELAYED | \ | 41 | EXTENT_STATUS_DELAYED | \ |
40 | EXTENT_STATUS_HOLE) | 42 | EXTENT_STATUS_HOLE) |
41 | 43 | ||
44 | #define ES_WRITTEN (1ULL << 63) | ||
45 | #define ES_UNWRITTEN (1ULL << 62) | ||
46 | #define ES_DELAYED (1ULL << 61) | ||
47 | #define ES_HOLE (1ULL << 60) | ||
48 | |||
49 | #define ES_MASK (ES_WRITTEN | ES_UNWRITTEN | \ | ||
50 | ES_DELAYED | ES_HOLE) | ||
51 | |||
42 | struct ext4_sb_info; | 52 | struct ext4_sb_info; |
43 | struct ext4_extent; | 53 | struct ext4_extent; |
44 | 54 | ||
@@ -60,7 +70,7 @@ extern void ext4_es_init_tree(struct ext4_es_tree *tree); | |||
60 | 70 | ||
61 | extern int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, | 71 | extern int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, |
62 | ext4_lblk_t len, ext4_fsblk_t pblk, | 72 | ext4_lblk_t len, ext4_fsblk_t pblk, |
63 | unsigned long long status); | 73 | unsigned int status); |
64 | extern int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk, | 74 | extern int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk, |
65 | ext4_lblk_t len); | 75 | ext4_lblk_t len); |
66 | extern void ext4_es_find_delayed_extent_range(struct inode *inode, | 76 | extern void ext4_es_find_delayed_extent_range(struct inode *inode, |
@@ -72,32 +82,32 @@ extern int ext4_es_zeroout(struct inode *inode, struct ext4_extent *ex); | |||
72 | 82 | ||
73 | static inline int ext4_es_is_written(struct extent_status *es) | 83 | static inline int ext4_es_is_written(struct extent_status *es) |
74 | { | 84 | { |
75 | return (es->es_pblk & EXTENT_STATUS_WRITTEN) != 0; | 85 | return (es->es_pblk & ES_WRITTEN) != 0; |
76 | } | 86 | } |
77 | 87 | ||
78 | static inline int ext4_es_is_unwritten(struct extent_status *es) | 88 | static inline int ext4_es_is_unwritten(struct extent_status *es) |
79 | { | 89 | { |
80 | return (es->es_pblk & EXTENT_STATUS_UNWRITTEN) != 0; | 90 | return (es->es_pblk & ES_UNWRITTEN) != 0; |
81 | } | 91 | } |
82 | 92 | ||
83 | static inline int ext4_es_is_delayed(struct extent_status *es) | 93 | static inline int ext4_es_is_delayed(struct extent_status *es) |
84 | { | 94 | { |
85 | return (es->es_pblk & EXTENT_STATUS_DELAYED) != 0; | 95 | return (es->es_pblk & ES_DELAYED) != 0; |
86 | } | 96 | } |
87 | 97 | ||
88 | static inline int ext4_es_is_hole(struct extent_status *es) | 98 | static inline int ext4_es_is_hole(struct extent_status *es) |
89 | { | 99 | { |
90 | return (es->es_pblk & EXTENT_STATUS_HOLE) != 0; | 100 | return (es->es_pblk & ES_HOLE) != 0; |
91 | } | 101 | } |
92 | 102 | ||
93 | static inline ext4_fsblk_t ext4_es_status(struct extent_status *es) | 103 | static inline unsigned int ext4_es_status(struct extent_status *es) |
94 | { | 104 | { |
95 | return (es->es_pblk & EXTENT_STATUS_FLAGS); | 105 | return es->es_pblk >> ES_SHIFT; |
96 | } | 106 | } |
97 | 107 | ||
98 | static inline ext4_fsblk_t ext4_es_pblock(struct extent_status *es) | 108 | static inline ext4_fsblk_t ext4_es_pblock(struct extent_status *es) |
99 | { | 109 | { |
100 | return (es->es_pblk & ~EXTENT_STATUS_FLAGS); | 110 | return es->es_pblk & ~ES_MASK; |
101 | } | 111 | } |
102 | 112 | ||
103 | static inline void ext4_es_store_pblock(struct extent_status *es, | 113 | static inline void ext4_es_store_pblock(struct extent_status *es, |
@@ -105,19 +115,16 @@ static inline void ext4_es_store_pblock(struct extent_status *es, | |||
105 | { | 115 | { |
106 | ext4_fsblk_t block; | 116 | ext4_fsblk_t block; |
107 | 117 | ||
108 | block = (pb & ~EXTENT_STATUS_FLAGS) | | 118 | block = (pb & ~ES_MASK) | (es->es_pblk & ES_MASK); |
109 | (es->es_pblk & EXTENT_STATUS_FLAGS); | ||
110 | es->es_pblk = block; | 119 | es->es_pblk = block; |
111 | } | 120 | } |
112 | 121 | ||
113 | static inline void ext4_es_store_status(struct extent_status *es, | 122 | static inline void ext4_es_store_status(struct extent_status *es, |
114 | unsigned long long status) | 123 | unsigned int status) |
115 | { | 124 | { |
116 | ext4_fsblk_t block; | 125 | es->es_pblk = (((ext4_fsblk_t) |
117 | 126 | (status & EXTENT_STATUS_FLAGS) << ES_SHIFT) | | |
118 | block = (status & EXTENT_STATUS_FLAGS) | | 127 | (es->es_pblk & ~ES_MASK)); |
119 | (es->es_pblk & ~EXTENT_STATUS_FLAGS); | ||
120 | es->es_pblk = block; | ||
121 | } | 128 | } |
122 | 129 | ||
123 | extern void ext4_es_register_shrinker(struct ext4_sb_info *sbi); | 130 | extern void ext4_es_register_shrinker(struct ext4_sb_info *sbi); |