aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/extents_status.h
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-08-16 21:22:41 -0400
committerTheodore Ts'o <tytso@mit.edu>2013-08-16 21:22:41 -0400
commit3be78c73179c9347bdc0a92b2898063bd2300ff7 (patch)
treeeb4147818a58e3dd80300fd09fc94ad344480231 /fs/ext4/extents_status.h
parentc349179b4808f7c8e1ff1b4dd967c047eefd24bc (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.h47
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
42struct ext4_sb_info; 52struct ext4_sb_info;
43struct ext4_extent; 53struct ext4_extent;
44 54
@@ -60,7 +70,7 @@ extern void ext4_es_init_tree(struct ext4_es_tree *tree);
60 70
61extern int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, 71extern 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);
64extern int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk, 74extern int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
65 ext4_lblk_t len); 75 ext4_lblk_t len);
66extern void ext4_es_find_delayed_extent_range(struct inode *inode, 76extern 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
73static inline int ext4_es_is_written(struct extent_status *es) 83static 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
78static inline int ext4_es_is_unwritten(struct extent_status *es) 88static 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
83static inline int ext4_es_is_delayed(struct extent_status *es) 93static 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
88static inline int ext4_es_is_hole(struct extent_status *es) 98static 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
93static inline ext4_fsblk_t ext4_es_status(struct extent_status *es) 103static 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
98static inline ext4_fsblk_t ext4_es_pblock(struct extent_status *es) 108static 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
103static inline void ext4_es_store_pblock(struct extent_status *es, 113static 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
113static inline void ext4_es_store_status(struct extent_status *es, 122static 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
123extern void ext4_es_register_shrinker(struct ext4_sb_info *sbi); 130extern void ext4_es_register_shrinker(struct ext4_sb_info *sbi);