aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/bmap.h
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-05-23 14:25:44 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-06-10 10:41:10 -0400
commitd4b961576df2769b936bd967b01e8c607c3c9ad8 (patch)
tree3d5d31cb7b4ba31a5b8232d0cd0edac2cf368fae /fs/nilfs2/bmap.h
parent3033342a0b76048e32ce1faebfa85cf8f1aa93b5 (diff)
nilfs2: remove bmap pointer operations
Previously, the bmap codes of nilfs used three types of function tables. The abuse of indirect function calls decreased source readability and suffered many indirect jumps which would confuse branch prediction of processors. This eliminates one type of the function tables, nilfs_bmap_ptr_operations, which was used to dispatch low level pointer operations of the nilfs bmap. This adds a new integer variable "b_ptr_type" to nilfs_bmap struct, and uses the value to select the pointer operations. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/bmap.h')
-rw-r--r--fs/nilfs2/bmap.h110
1 files changed, 78 insertions, 32 deletions
diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h
index 28c77bb71bb7..47f5b74713c0 100644
--- a/fs/nilfs2/bmap.h
+++ b/fs/nilfs2/bmap.h
@@ -86,27 +86,6 @@ struct nilfs_bmap_operations {
86}; 86};
87 87
88 88
89/**
90 * struct nilfs_bmap_ptr_operations - bmap ptr operation table
91 */
92struct nilfs_bmap_ptr_operations {
93 int (*bpop_prepare_alloc_ptr)(struct nilfs_bmap *,
94 union nilfs_bmap_ptr_req *);
95 void (*bpop_commit_alloc_ptr)(struct nilfs_bmap *,
96 union nilfs_bmap_ptr_req *);
97 void (*bpop_abort_alloc_ptr)(struct nilfs_bmap *,
98 union nilfs_bmap_ptr_req *);
99 int (*bpop_prepare_end_ptr)(struct nilfs_bmap *,
100 union nilfs_bmap_ptr_req *);
101 void (*bpop_commit_end_ptr)(struct nilfs_bmap *,
102 union nilfs_bmap_ptr_req *);
103 void (*bpop_abort_end_ptr)(struct nilfs_bmap *,
104 union nilfs_bmap_ptr_req *);
105
106 int (*bpop_translate)(const struct nilfs_bmap *, __u64, __u64 *);
107};
108
109
110#define NILFS_BMAP_SIZE (NILFS_INODE_BMAP_SIZE * sizeof(__le64)) 89#define NILFS_BMAP_SIZE (NILFS_INODE_BMAP_SIZE * sizeof(__le64))
111#define NILFS_BMAP_KEY_BIT (sizeof(unsigned long) * 8 /* CHAR_BIT */) 90#define NILFS_BMAP_KEY_BIT (sizeof(unsigned long) * 8 /* CHAR_BIT */)
112#define NILFS_BMAP_NEW_PTR_INIT \ 91#define NILFS_BMAP_NEW_PTR_INIT \
@@ -124,9 +103,9 @@ static inline int nilfs_bmap_is_new_ptr(unsigned long ptr)
124 * @b_sem: semaphore 103 * @b_sem: semaphore
125 * @b_inode: owner of bmap 104 * @b_inode: owner of bmap
126 * @b_ops: bmap operation table 105 * @b_ops: bmap operation table
127 * @b_pops: bmap ptr operation table
128 * @b_last_allocated_key: last allocated key for data block 106 * @b_last_allocated_key: last allocated key for data block
129 * @b_last_allocated_ptr: last allocated ptr for data block 107 * @b_last_allocated_ptr: last allocated ptr for data block
108 * @b_ptr_type: pointer type
130 * @b_state: state 109 * @b_state: state
131 */ 110 */
132struct nilfs_bmap { 111struct nilfs_bmap {
@@ -137,12 +116,22 @@ struct nilfs_bmap {
137 struct rw_semaphore b_sem; 116 struct rw_semaphore b_sem;
138 struct inode *b_inode; 117 struct inode *b_inode;
139 const struct nilfs_bmap_operations *b_ops; 118 const struct nilfs_bmap_operations *b_ops;
140 const struct nilfs_bmap_ptr_operations *b_pops;
141 __u64 b_last_allocated_key; 119 __u64 b_last_allocated_key;
142 __u64 b_last_allocated_ptr; 120 __u64 b_last_allocated_ptr;
121 int b_ptr_type;
143 int b_state; 122 int b_state;
144}; 123};
145 124
125/* pointer type */
126#define NILFS_BMAP_PTR_P 0 /* physical block number (i.e. LBN) */
127#define NILFS_BMAP_PTR_VS 1 /* virtual block number (single
128 version) */
129#define NILFS_BMAP_PTR_VM 2 /* virtual block number (has multiple
130 versions) */
131#define NILFS_BMAP_PTR_U (-1) /* never perform pointer operations */
132
133#define NILFS_BMAP_USE_VBN(bmap) ((bmap)->b_ptr_type > 0)
134
146/* state */ 135/* state */
147#define NILFS_BMAP_DIRTY 0x00000001 136#define NILFS_BMAP_DIRTY 0x00000001
148 137
@@ -171,6 +160,63 @@ void nilfs_bmap_commit_gcdat(struct nilfs_bmap *, struct nilfs_bmap *);
171/* 160/*
172 * Internal use only 161 * Internal use only
173 */ 162 */
163int nilfs_bmap_prepare_alloc_v(struct nilfs_bmap *,
164 union nilfs_bmap_ptr_req *);
165void nilfs_bmap_commit_alloc_v(struct nilfs_bmap *,
166 union nilfs_bmap_ptr_req *);
167void nilfs_bmap_abort_alloc_v(struct nilfs_bmap *,
168 union nilfs_bmap_ptr_req *);
169
170static inline int nilfs_bmap_prepare_alloc_ptr(struct nilfs_bmap *bmap,
171 union nilfs_bmap_ptr_req *req)
172{
173 if (NILFS_BMAP_USE_VBN(bmap))
174 return nilfs_bmap_prepare_alloc_v(bmap, req);
175 /* ignore target ptr */
176 req->bpr_ptr = bmap->b_last_allocated_ptr++;
177 return 0;
178}
179
180static inline void nilfs_bmap_commit_alloc_ptr(struct nilfs_bmap *bmap,
181 union nilfs_bmap_ptr_req *req)
182{
183 if (NILFS_BMAP_USE_VBN(bmap))
184 nilfs_bmap_commit_alloc_v(bmap, req);
185}
186
187static inline void nilfs_bmap_abort_alloc_ptr(struct nilfs_bmap *bmap,
188 union nilfs_bmap_ptr_req *req)
189{
190 if (NILFS_BMAP_USE_VBN(bmap))
191 nilfs_bmap_abort_alloc_v(bmap, req);
192 else
193 bmap->b_last_allocated_ptr--;
194}
195
196int nilfs_bmap_prepare_end_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *);
197void nilfs_bmap_commit_end_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *);
198void nilfs_bmap_abort_end_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *);
199
200static inline int nilfs_bmap_prepare_end_ptr(struct nilfs_bmap *bmap,
201 union nilfs_bmap_ptr_req *req)
202{
203 return NILFS_BMAP_USE_VBN(bmap) ?
204 nilfs_bmap_prepare_end_v(bmap, req) : 0;
205}
206
207static inline void nilfs_bmap_commit_end_ptr(struct nilfs_bmap *bmap,
208 union nilfs_bmap_ptr_req *req)
209{
210 if (NILFS_BMAP_USE_VBN(bmap))
211 nilfs_bmap_commit_end_v(bmap, req);
212}
213
214static inline void nilfs_bmap_abort_end_ptr(struct nilfs_bmap *bmap,
215 union nilfs_bmap_ptr_req *req)
216{
217 if (NILFS_BMAP_USE_VBN(bmap))
218 nilfs_bmap_abort_end_v(bmap, req);
219}
174 220
175int nilfs_bmap_start_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *, 221int nilfs_bmap_start_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *,
176 sector_t); 222 sector_t);
@@ -184,15 +230,15 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *,
184__u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *, __u64); 230__u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *, __u64);
185__u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *); 231__u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *);
186 232
187int nilfs_bmap_prepare_update(struct nilfs_bmap *, 233int nilfs_bmap_prepare_update_v(struct nilfs_bmap *,
188 union nilfs_bmap_ptr_req *, 234 union nilfs_bmap_ptr_req *,
189 union nilfs_bmap_ptr_req *); 235 union nilfs_bmap_ptr_req *);
190void nilfs_bmap_commit_update(struct nilfs_bmap *, 236void nilfs_bmap_commit_update_v(struct nilfs_bmap *,
191 union nilfs_bmap_ptr_req *, 237 union nilfs_bmap_ptr_req *,
192 union nilfs_bmap_ptr_req *); 238 union nilfs_bmap_ptr_req *);
193void nilfs_bmap_abort_update(struct nilfs_bmap *, 239void nilfs_bmap_abort_update_v(struct nilfs_bmap *,
194 union nilfs_bmap_ptr_req *, 240 union nilfs_bmap_ptr_req *,
195 union nilfs_bmap_ptr_req *); 241 union nilfs_bmap_ptr_req *);
196 242
197void nilfs_bmap_add_blocks(const struct nilfs_bmap *, int); 243void nilfs_bmap_add_blocks(const struct nilfs_bmap *, int);
198void nilfs_bmap_sub_blocks(const struct nilfs_bmap *, int); 244void nilfs_bmap_sub_blocks(const struct nilfs_bmap *, int);