@@ -127,10 +127,12 @@ static int verify_group_input(struct super_block *sb,
127
127
else if (free_blocks_count < 0 )
128
128
ext4_warning (sb , "Bad blocks count %u" ,
129
129
input -> blocks_count );
130
- else if (!(bh = sb_bread (sb , end - 1 )))
130
+ else if (IS_ERR (bh = ext4_sb_bread (sb , end - 1 , 0 ))) {
131
+ err = PTR_ERR (bh );
132
+ bh = NULL ;
131
133
ext4_warning (sb , "Cannot read last block (%llu)" ,
132
134
end - 1 );
133
- else if (outside (input -> block_bitmap , start , end ))
135
+ } else if (outside (input -> block_bitmap , start , end ))
134
136
ext4_warning (sb , "Block bitmap not in group (block %llu)" ,
135
137
(unsigned long long )input -> block_bitmap );
136
138
else if (outside (input -> inode_bitmap , start , end ))
@@ -781,11 +783,11 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
781
783
struct ext4_super_block * es = EXT4_SB (sb )-> s_es ;
782
784
unsigned long gdb_num = group / EXT4_DESC_PER_BLOCK (sb );
783
785
ext4_fsblk_t gdblock = EXT4_SB (sb )-> s_sbh -> b_blocknr + 1 + gdb_num ;
784
- struct buffer_head * * o_group_desc , * * n_group_desc ;
785
- struct buffer_head * dind ;
786
- struct buffer_head * gdb_bh ;
786
+ struct buffer_head * * o_group_desc , * * n_group_desc = NULL ;
787
+ struct buffer_head * dind = NULL ;
788
+ struct buffer_head * gdb_bh = NULL ;
787
789
int gdbackups ;
788
- struct ext4_iloc iloc ;
790
+ struct ext4_iloc iloc = { . bh = NULL } ;
789
791
__le32 * data ;
790
792
int err ;
791
793
@@ -794,40 +796,41 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
794
796
"EXT4-fs: ext4_add_new_gdb: adding group block %lu\n" ,
795
797
gdb_num );
796
798
797
- gdb_bh = sb_bread (sb , gdblock );
798
- if (! gdb_bh )
799
- return - EIO ;
799
+ gdb_bh = ext4_sb_bread (sb , gdblock , 0 );
800
+ if (IS_ERR ( gdb_bh ) )
801
+ return PTR_ERR ( gdb_bh ) ;
800
802
801
803
gdbackups = verify_reserved_gdb (sb , group , gdb_bh );
802
804
if (gdbackups < 0 ) {
803
805
err = gdbackups ;
804
- goto exit_bh ;
806
+ goto errout ;
805
807
}
806
808
807
809
data = EXT4_I (inode )-> i_data + EXT4_DIND_BLOCK ;
808
- dind = sb_bread (sb , le32_to_cpu (* data ));
809
- if (!dind ) {
810
- err = - EIO ;
811
- goto exit_bh ;
810
+ dind = ext4_sb_bread (sb , le32_to_cpu (* data ), 0 );
811
+ if (IS_ERR (dind )) {
812
+ err = PTR_ERR (dind );
813
+ dind = NULL ;
814
+ goto errout ;
812
815
}
813
816
814
817
data = (__le32 * )dind -> b_data ;
815
818
if (le32_to_cpu (data [gdb_num % EXT4_ADDR_PER_BLOCK (sb )]) != gdblock ) {
816
819
ext4_warning (sb , "new group %u GDT block %llu not reserved" ,
817
820
group , gdblock );
818
821
err = - EINVAL ;
819
- goto exit_dind ;
822
+ goto errout ;
820
823
}
821
824
822
825
BUFFER_TRACE (EXT4_SB (sb )-> s_sbh , "get_write_access" );
823
826
err = ext4_journal_get_write_access (handle , EXT4_SB (sb )-> s_sbh );
824
827
if (unlikely (err ))
825
- goto exit_dind ;
828
+ goto errout ;
826
829
827
830
BUFFER_TRACE (gdb_bh , "get_write_access" );
828
831
err = ext4_journal_get_write_access (handle , gdb_bh );
829
832
if (unlikely (err ))
830
- goto exit_dind ;
833
+ goto errout ;
831
834
832
835
BUFFER_TRACE (dind , "get_write_access" );
833
836
err = ext4_journal_get_write_access (handle , dind );
@@ -837,7 +840,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
837
840
/* ext4_reserve_inode_write() gets a reference on the iloc */
838
841
err = ext4_reserve_inode_write (handle , inode , & iloc );
839
842
if (unlikely (err ))
840
- goto exit_dind ;
843
+ goto errout ;
841
844
842
845
n_group_desc = ext4_kvmalloc ((gdb_num + 1 ) *
843
846
sizeof (struct buffer_head * ),
@@ -846,7 +849,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
846
849
err = - ENOMEM ;
847
850
ext4_warning (sb , "not enough memory for %lu groups" ,
848
851
gdb_num + 1 );
849
- goto exit_inode ;
852
+ goto errout ;
850
853
}
851
854
852
855
/*
@@ -862,7 +865,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
862
865
err = ext4_handle_dirty_metadata (handle , NULL , dind );
863
866
if (unlikely (err )) {
864
867
ext4_std_error (sb , err );
865
- goto exit_inode ;
868
+ goto errout ;
866
869
}
867
870
inode -> i_blocks -= (gdbackups + 1 ) * sb -> s_blocksize >>
868
871
(9 - EXT4_SB (sb )-> s_cluster_bits );
@@ -871,8 +874,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
871
874
err = ext4_handle_dirty_metadata (handle , NULL , gdb_bh );
872
875
if (unlikely (err )) {
873
876
ext4_std_error (sb , err );
874
- iloc .bh = NULL ;
875
- goto exit_inode ;
877
+ goto errout ;
876
878
}
877
879
brelse (dind );
878
880
@@ -888,15 +890,11 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
888
890
err = ext4_handle_dirty_super (handle , sb );
889
891
if (err )
890
892
ext4_std_error (sb , err );
891
-
892
893
return err ;
893
-
894
- exit_inode :
894
+ errout :
895
895
kvfree (n_group_desc );
896
896
brelse (iloc .bh );
897
- exit_dind :
898
897
brelse (dind );
899
- exit_bh :
900
898
brelse (gdb_bh );
901
899
902
900
ext4_debug ("leaving with error %d\n" , err );
@@ -916,9 +914,9 @@ static int add_new_gdb_meta_bg(struct super_block *sb,
916
914
917
915
gdblock = ext4_meta_bg_first_block_no (sb , group ) +
918
916
ext4_bg_has_super (sb , group );
919
- gdb_bh = sb_bread (sb , gdblock );
920
- if (! gdb_bh )
921
- return - EIO ;
917
+ gdb_bh = ext4_sb_bread (sb , gdblock , 0 );
918
+ if (IS_ERR ( gdb_bh ) )
919
+ return PTR_ERR ( gdb_bh ) ;
922
920
n_group_desc = ext4_kvmalloc ((gdb_num + 1 ) *
923
921
sizeof (struct buffer_head * ),
924
922
GFP_NOFS );
@@ -975,9 +973,10 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
975
973
return - ENOMEM ;
976
974
977
975
data = EXT4_I (inode )-> i_data + EXT4_DIND_BLOCK ;
978
- dind = sb_bread (sb , le32_to_cpu (* data ));
979
- if (!dind ) {
980
- err = - EIO ;
976
+ dind = ext4_sb_bread (sb , le32_to_cpu (* data ), 0 );
977
+ if (IS_ERR (dind )) {
978
+ err = PTR_ERR (dind );
979
+ dind = NULL ;
981
980
goto exit_free ;
982
981
}
983
982
@@ -996,9 +995,10 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
996
995
err = - EINVAL ;
997
996
goto exit_bh ;
998
997
}
999
- primary [res ] = sb_bread (sb , blk );
1000
- if (!primary [res ]) {
1001
- err = - EIO ;
998
+ primary [res ] = ext4_sb_bread (sb , blk , 0 );
999
+ if (IS_ERR (primary [res ])) {
1000
+ err = PTR_ERR (primary [res ]);
1001
+ primary [res ] = NULL ;
1002
1002
goto exit_bh ;
1003
1003
}
1004
1004
gdbackups = verify_reserved_gdb (sb , group , primary [res ]);
0 commit comments