@@ -4337,99 +4337,93 @@ static int __ext4_get_inode_loc(struct super_block *sb, unsigned long ino,
4337
4337
bh = sb_getblk (sb , block );
4338
4338
if (unlikely (!bh ))
4339
4339
return - ENOMEM ;
4340
- if (!buffer_uptodate (bh )) {
4341
- lock_buffer (bh );
4342
-
4343
- if (ext4_buffer_uptodate (bh )) {
4344
- /* someone brought it uptodate while we waited */
4345
- unlock_buffer (bh );
4346
- goto has_buffer ;
4347
- }
4340
+ if (ext4_buffer_uptodate (bh ))
4341
+ goto has_buffer ;
4348
4342
4349
- /*
4350
- * If we have all information of the inode in memory and this
4351
- * is the only valid inode in the block, we need not read the
4352
- * block.
4353
- */
4354
- if (in_mem ) {
4355
- struct buffer_head * bitmap_bh ;
4356
- int i , start ;
4343
+ lock_buffer (bh );
4344
+ /*
4345
+ * If we have all information of the inode in memory and this
4346
+ * is the only valid inode in the block, we need not read the
4347
+ * block.
4348
+ */
4349
+ if (in_mem ) {
4350
+ struct buffer_head * bitmap_bh ;
4351
+ int i , start ;
4357
4352
4358
- start = inode_offset & ~(inodes_per_block - 1 );
4353
+ start = inode_offset & ~(inodes_per_block - 1 );
4359
4354
4360
- /* Is the inode bitmap in cache? */
4361
- bitmap_bh = sb_getblk (sb , ext4_inode_bitmap (sb , gdp ));
4362
- if (unlikely (!bitmap_bh ))
4363
- goto make_io ;
4355
+ /* Is the inode bitmap in cache? */
4356
+ bitmap_bh = sb_getblk (sb , ext4_inode_bitmap (sb , gdp ));
4357
+ if (unlikely (!bitmap_bh ))
4358
+ goto make_io ;
4364
4359
4365
- /*
4366
- * If the inode bitmap isn't in cache then the
4367
- * optimisation may end up performing two reads instead
4368
- * of one, so skip it.
4369
- */
4370
- if (!buffer_uptodate (bitmap_bh )) {
4371
- brelse (bitmap_bh );
4372
- goto make_io ;
4373
- }
4374
- for (i = start ; i < start + inodes_per_block ; i ++ ) {
4375
- if (i == inode_offset )
4376
- continue ;
4377
- if (ext4_test_bit (i , bitmap_bh -> b_data ))
4378
- break ;
4379
- }
4360
+ /*
4361
+ * If the inode bitmap isn't in cache then the
4362
+ * optimisation may end up performing two reads instead
4363
+ * of one, so skip it.
4364
+ */
4365
+ if (!buffer_uptodate (bitmap_bh )) {
4380
4366
brelse (bitmap_bh );
4381
- if ( i == start + inodes_per_block ) {
4382
- /* all other inodes are free, so skip I/O */
4383
- memset ( bh -> b_data , 0 , bh -> b_size );
4384
- set_buffer_uptodate ( bh );
4385
- unlock_buffer ( bh ) ;
4386
- goto has_buffer ;
4387
- }
4367
+ goto make_io ;
4368
+ }
4369
+ for ( i = start ; i < start + inodes_per_block ; i ++ ) {
4370
+ if ( i == inode_offset )
4371
+ continue ;
4372
+ if ( ext4_test_bit ( i , bitmap_bh -> b_data ))
4373
+ break ;
4388
4374
}
4375
+ brelse (bitmap_bh );
4376
+ if (i == start + inodes_per_block ) {
4377
+ /* all other inodes are free, so skip I/O */
4378
+ memset (bh -> b_data , 0 , bh -> b_size );
4379
+ set_buffer_uptodate (bh );
4380
+ unlock_buffer (bh );
4381
+ goto has_buffer ;
4382
+ }
4383
+ }
4389
4384
4390
4385
make_io :
4391
- /*
4392
- * If we need to do any I/O, try to pre-readahead extra
4393
- * blocks from the inode table.
4394
- */
4395
- blk_start_plug (& plug );
4396
- if (EXT4_SB (sb )-> s_inode_readahead_blks ) {
4397
- ext4_fsblk_t b , end , table ;
4398
- unsigned num ;
4399
- __u32 ra_blks = EXT4_SB (sb )-> s_inode_readahead_blks ;
4400
-
4401
- table = ext4_inode_table (sb , gdp );
4402
- /* s_inode_readahead_blks is always a power of 2 */
4403
- b = block & ~((ext4_fsblk_t ) ra_blks - 1 );
4404
- if (table > b )
4405
- b = table ;
4406
- end = b + ra_blks ;
4407
- num = EXT4_INODES_PER_GROUP (sb );
4408
- if (ext4_has_group_desc_csum (sb ))
4409
- num -= ext4_itable_unused_count (sb , gdp );
4410
- table += num / inodes_per_block ;
4411
- if (end > table )
4412
- end = table ;
4413
- while (b <= end )
4414
- ext4_sb_breadahead_unmovable (sb , b ++ );
4415
- }
4386
+ /*
4387
+ * If we need to do any I/O, try to pre-readahead extra
4388
+ * blocks from the inode table.
4389
+ */
4390
+ blk_start_plug (& plug );
4391
+ if (EXT4_SB (sb )-> s_inode_readahead_blks ) {
4392
+ ext4_fsblk_t b , end , table ;
4393
+ unsigned num ;
4394
+ __u32 ra_blks = EXT4_SB (sb )-> s_inode_readahead_blks ;
4395
+
4396
+ table = ext4_inode_table (sb , gdp );
4397
+ /* s_inode_readahead_blks is always a power of 2 */
4398
+ b = block & ~((ext4_fsblk_t ) ra_blks - 1 );
4399
+ if (table > b )
4400
+ b = table ;
4401
+ end = b + ra_blks ;
4402
+ num = EXT4_INODES_PER_GROUP (sb );
4403
+ if (ext4_has_group_desc_csum (sb ))
4404
+ num -= ext4_itable_unused_count (sb , gdp );
4405
+ table += num / inodes_per_block ;
4406
+ if (end > table )
4407
+ end = table ;
4408
+ while (b <= end )
4409
+ ext4_sb_breadahead_unmovable (sb , b ++ );
4410
+ }
4416
4411
4417
- /*
4418
- * There are other valid inodes in the buffer, this inode
4419
- * has in-inode xattrs, or we don't have this inode in memory.
4420
- * Read the block from disk.
4421
- */
4422
- trace_ext4_load_inode (sb , ino );
4423
- ext4_read_bh_nowait (bh , REQ_META | REQ_PRIO , NULL );
4424
- blk_finish_plug (& plug );
4425
- wait_on_buffer (bh );
4426
- ext4_simulate_fail_bh (sb , bh , EXT4_SIM_INODE_EIO );
4427
- if (!buffer_uptodate (bh )) {
4428
- if (ret_block )
4429
- * ret_block = block ;
4430
- brelse (bh );
4431
- return - EIO ;
4432
- }
4412
+ /*
4413
+ * There are other valid inodes in the buffer, this inode
4414
+ * has in-inode xattrs, or we don't have this inode in memory.
4415
+ * Read the block from disk.
4416
+ */
4417
+ trace_ext4_load_inode (sb , ino );
4418
+ ext4_read_bh_nowait (bh , REQ_META | REQ_PRIO , NULL );
4419
+ blk_finish_plug (& plug );
4420
+ wait_on_buffer (bh );
4421
+ ext4_simulate_fail_bh (sb , bh , EXT4_SIM_INODE_EIO );
4422
+ if (!buffer_uptodate (bh )) {
4423
+ if (ret_block )
4424
+ * ret_block = block ;
4425
+ brelse (bh );
4426
+ return - EIO ;
4433
4427
}
4434
4428
has_buffer :
4435
4429
iloc -> bh = bh ;
0 commit comments