@@ -144,40 +144,6 @@ static void debug_print_tree(struct ext4_sb_info *sbi)
144
144
printk (KERN_CONT "\n" );
145
145
}
146
146
147
- /*
148
- * Returns 1 if the passed-in block region (start_blk,
149
- * start_blk+count) is valid; 0 if some part of the block region
150
- * overlaps with filesystem metadata blocks.
151
- */
152
- static int ext4_data_block_valid_rcu (struct ext4_sb_info * sbi ,
153
- struct ext4_system_blocks * system_blks ,
154
- ext4_fsblk_t start_blk ,
155
- unsigned int count , ino_t ino )
156
- {
157
- struct ext4_system_zone * entry ;
158
- struct rb_node * n ;
159
-
160
- if ((start_blk <= le32_to_cpu (sbi -> s_es -> s_first_data_block )) ||
161
- (start_blk + count < start_blk ) ||
162
- (start_blk + count > ext4_blocks_count (sbi -> s_es )))
163
- return 0 ;
164
-
165
- if (system_blks == NULL )
166
- return 1 ;
167
-
168
- n = system_blks -> root .rb_node ;
169
- while (n ) {
170
- entry = rb_entry (n , struct ext4_system_zone , node );
171
- if (start_blk + count - 1 < entry -> start_blk )
172
- n = n -> rb_left ;
173
- else if (start_blk >= (entry -> start_blk + entry -> count ))
174
- n = n -> rb_right ;
175
- else
176
- return entry -> ino == ino ;
177
- }
178
- return 1 ;
179
- }
180
-
181
147
static int ext4_protect_reserved_inode (struct super_block * sb ,
182
148
struct ext4_system_blocks * system_blks ,
183
149
u32 ino )
@@ -333,21 +299,48 @@ void ext4_release_system_zone(struct super_block *sb)
333
299
call_rcu (& system_blks -> rcu , ext4_destroy_system_zone );
334
300
}
335
301
302
+ /*
303
+ * Returns 1 if the passed-in block region (start_blk,
304
+ * start_blk+count) is valid; 0 if some part of the block region
305
+ * overlaps with some other filesystem metadata blocks.
306
+ */
336
307
int ext4_inode_block_valid (struct inode * inode , ext4_fsblk_t start_blk ,
337
308
unsigned int count )
338
309
{
310
+ struct ext4_sb_info * sbi = EXT4_SB (inode -> i_sb );
339
311
struct ext4_system_blocks * system_blks ;
340
- int ret ;
312
+ struct ext4_system_zone * entry ;
313
+ struct rb_node * n ;
314
+ int ret = 1 ;
315
+
316
+ if ((start_blk <= le32_to_cpu (sbi -> s_es -> s_first_data_block )) ||
317
+ (start_blk + count < start_blk ) ||
318
+ (start_blk + count > ext4_blocks_count (sbi -> s_es )))
319
+ return 0 ;
341
320
342
321
/*
343
322
* Lock the system zone to prevent it being released concurrently
344
323
* when doing a remount which inverse current "[no]block_validity"
345
324
* mount option.
346
325
*/
347
326
rcu_read_lock ();
348
- system_blks = rcu_dereference (EXT4_SB (inode -> i_sb )-> system_blks );
349
- ret = ext4_data_block_valid_rcu (EXT4_SB (inode -> i_sb ), system_blks ,
350
- start_blk , count , inode -> i_ino );
327
+ system_blks = rcu_dereference (sbi -> system_blks );
328
+ if (system_blks == NULL )
329
+ goto out_rcu ;
330
+
331
+ n = system_blks -> root .rb_node ;
332
+ while (n ) {
333
+ entry = rb_entry (n , struct ext4_system_zone , node );
334
+ if (start_blk + count - 1 < entry -> start_blk )
335
+ n = n -> rb_left ;
336
+ else if (start_blk >= (entry -> start_blk + entry -> count ))
337
+ n = n -> rb_right ;
338
+ else {
339
+ ret = (entry -> ino == inode -> i_ino );
340
+ break ;
341
+ }
342
+ }
343
+ out_rcu :
351
344
rcu_read_unlock ();
352
345
return ret ;
353
346
}
0 commit comments