@@ -1143,25 +1143,20 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
1143
1143
unsigned long max_ino = le32_to_cpu (EXT4_SB (sb )-> s_es -> s_inodes_count );
1144
1144
ext4_group_t block_group ;
1145
1145
int bit ;
1146
- struct buffer_head * bitmap_bh ;
1146
+ struct buffer_head * bitmap_bh = NULL ;
1147
1147
struct inode * inode = NULL ;
1148
- long err = - EIO ;
1148
+ int err = - EFSCORRUPTED ;
1149
1149
1150
- /* Error cases - e2fsck has already cleaned up for us */
1151
- if (ino > max_ino ) {
1152
- ext4_warning (sb , "bad orphan ino %lu! e2fsck was run?" , ino );
1153
- err = - EFSCORRUPTED ;
1154
- goto error ;
1155
- }
1150
+ if (ino < EXT4_FIRST_INO (sb ) || ino > max_ino )
1151
+ goto bad_orphan ;
1156
1152
1157
1153
block_group = (ino - 1 ) / EXT4_INODES_PER_GROUP (sb );
1158
1154
bit = (ino - 1 ) % EXT4_INODES_PER_GROUP (sb );
1159
1155
bitmap_bh = ext4_read_inode_bitmap (sb , block_group );
1160
1156
if (IS_ERR (bitmap_bh )) {
1161
- err = PTR_ERR (bitmap_bh );
1162
- ext4_warning (sb , "inode bitmap error %ld for orphan %lu" ,
1163
- ino , err );
1164
- goto error ;
1157
+ ext4_error (sb , "inode bitmap error %ld for orphan %lu" ,
1158
+ ino , PTR_ERR (bitmap_bh ));
1159
+ return (struct inode * ) bitmap_bh ;
1165
1160
}
1166
1161
1167
1162
/* Having the inode bit set should be a 100% indicator that this
@@ -1172,8 +1167,12 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
1172
1167
goto bad_orphan ;
1173
1168
1174
1169
inode = ext4_iget (sb , ino );
1175
- if (IS_ERR (inode ))
1176
- goto iget_failed ;
1170
+ if (IS_ERR (inode )) {
1171
+ err = PTR_ERR (inode );
1172
+ ext4_error (sb , "couldn't read orphan inode %lu (err %d)" ,
1173
+ ino , err );
1174
+ return inode ;
1175
+ }
1177
1176
1178
1177
/*
1179
1178
* If the orphans has i_nlinks > 0 then it should be able to
@@ -1190,29 +1189,25 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
1190
1189
brelse (bitmap_bh );
1191
1190
return inode ;
1192
1191
1193
- iget_failed :
1194
- err = PTR_ERR (inode );
1195
- inode = NULL ;
1196
1192
bad_orphan :
1197
- ext4_warning (sb , "bad orphan inode %lu! e2fsck was run? " , ino );
1198
- printk ( KERN_WARNING "ext4_test_bit(bit=%d, block=%llu) = %d\n" ,
1199
- bit , ( unsigned long long ) bitmap_bh -> b_blocknr ,
1200
- ext4_test_bit ( bit , bitmap_bh -> b_data ));
1201
- printk ( KERN_WARNING "inode=%p\n" , inode );
1193
+ ext4_error (sb , "bad orphan inode %lu" , ino );
1194
+ if ( bitmap_bh )
1195
+ printk ( KERN_ERR "ext4_test_bit( bit=%d, block=%llu) = %d\n" ,
1196
+ bit , ( unsigned long long ) bitmap_bh -> b_blocknr ,
1197
+ ext4_test_bit ( bit , bitmap_bh -> b_data ) );
1202
1198
if (inode ) {
1203
- printk (KERN_WARNING "is_bad_inode(inode)=%d\n" ,
1199
+ printk (KERN_ERR "is_bad_inode(inode)=%d\n" ,
1204
1200
is_bad_inode (inode ));
1205
- printk (KERN_WARNING "NEXT_ORPHAN(inode)=%u\n" ,
1201
+ printk (KERN_ERR "NEXT_ORPHAN(inode)=%u\n" ,
1206
1202
NEXT_ORPHAN (inode ));
1207
- printk (KERN_WARNING "max_ino=%lu\n" , max_ino );
1208
- printk (KERN_WARNING "i_nlink=%u\n" , inode -> i_nlink );
1203
+ printk (KERN_ERR "max_ino=%lu\n" , max_ino );
1204
+ printk (KERN_ERR "i_nlink=%u\n" , inode -> i_nlink );
1209
1205
/* Avoid freeing blocks if we got a bad deleted inode */
1210
1206
if (inode -> i_nlink == 0 )
1211
1207
inode -> i_blocks = 0 ;
1212
1208
iput (inode );
1213
1209
}
1214
1210
brelse (bitmap_bh );
1215
- error :
1216
1211
return ERR_PTR (err );
1217
1212
}
1218
1213
0 commit comments