diff options
Diffstat (limited to 'fs/nilfs2/bmap.h')
-rw-r--r-- | fs/nilfs2/bmap.h | 110 |
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 | */ | ||
92 | struct 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 | */ |
132 | struct nilfs_bmap { | 111 | struct 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 | */ |
163 | int nilfs_bmap_prepare_alloc_v(struct nilfs_bmap *, | ||
164 | union nilfs_bmap_ptr_req *); | ||
165 | void nilfs_bmap_commit_alloc_v(struct nilfs_bmap *, | ||
166 | union nilfs_bmap_ptr_req *); | ||
167 | void nilfs_bmap_abort_alloc_v(struct nilfs_bmap *, | ||
168 | union nilfs_bmap_ptr_req *); | ||
169 | |||
170 | static 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 | |||
180 | static 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 | |||
187 | static 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 | |||
196 | int nilfs_bmap_prepare_end_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *); | ||
197 | void nilfs_bmap_commit_end_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *); | ||
198 | void nilfs_bmap_abort_end_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *); | ||
199 | |||
200 | static 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 | |||
207 | static 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 | |||
214 | static 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 | ||
175 | int nilfs_bmap_start_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *, | 221 | int 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 | ||
187 | int nilfs_bmap_prepare_update(struct nilfs_bmap *, | 233 | int 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 *); |
190 | void nilfs_bmap_commit_update(struct nilfs_bmap *, | 236 | void 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 *); |
193 | void nilfs_bmap_abort_update(struct nilfs_bmap *, | 239 | void 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 | ||
197 | void nilfs_bmap_add_blocks(const struct nilfs_bmap *, int); | 243 | void nilfs_bmap_add_blocks(const struct nilfs_bmap *, int); |
198 | void nilfs_bmap_sub_blocks(const struct nilfs_bmap *, int); | 244 | void nilfs_bmap_sub_blocks(const struct nilfs_bmap *, int); |