diff options
Diffstat (limited to 'fs/udf/super.c')
-rw-r--r-- | fs/udf/super.c | 69 |
1 files changed, 41 insertions, 28 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c index 813da94d447b..5401fc33f5cc 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -961,12 +961,14 @@ struct inode *udf_find_metadata_inode_efe(struct super_block *sb, | |||
961 | 961 | ||
962 | metadata_fe = udf_iget(sb, &addr); | 962 | metadata_fe = udf_iget(sb, &addr); |
963 | 963 | ||
964 | if (metadata_fe == NULL) | 964 | if (IS_ERR(metadata_fe)) { |
965 | udf_warn(sb, "metadata inode efe not found\n"); | 965 | udf_warn(sb, "metadata inode efe not found\n"); |
966 | else if (UDF_I(metadata_fe)->i_alloc_type != ICBTAG_FLAG_AD_SHORT) { | 966 | return metadata_fe; |
967 | } | ||
968 | if (UDF_I(metadata_fe)->i_alloc_type != ICBTAG_FLAG_AD_SHORT) { | ||
967 | udf_warn(sb, "metadata inode efe does not have short allocation descriptors!\n"); | 969 | udf_warn(sb, "metadata inode efe does not have short allocation descriptors!\n"); |
968 | iput(metadata_fe); | 970 | iput(metadata_fe); |
969 | metadata_fe = NULL; | 971 | return ERR_PTR(-EIO); |
970 | } | 972 | } |
971 | 973 | ||
972 | return metadata_fe; | 974 | return metadata_fe; |
@@ -978,6 +980,7 @@ static int udf_load_metadata_files(struct super_block *sb, int partition) | |||
978 | struct udf_part_map *map; | 980 | struct udf_part_map *map; |
979 | struct udf_meta_data *mdata; | 981 | struct udf_meta_data *mdata; |
980 | struct kernel_lb_addr addr; | 982 | struct kernel_lb_addr addr; |
983 | struct inode *fe; | ||
981 | 984 | ||
982 | map = &sbi->s_partmaps[partition]; | 985 | map = &sbi->s_partmaps[partition]; |
983 | mdata = &map->s_type_specific.s_metadata; | 986 | mdata = &map->s_type_specific.s_metadata; |
@@ -986,22 +989,24 @@ static int udf_load_metadata_files(struct super_block *sb, int partition) | |||
986 | udf_debug("Metadata file location: block = %d part = %d\n", | 989 | udf_debug("Metadata file location: block = %d part = %d\n", |
987 | mdata->s_meta_file_loc, map->s_partition_num); | 990 | mdata->s_meta_file_loc, map->s_partition_num); |
988 | 991 | ||
989 | mdata->s_metadata_fe = udf_find_metadata_inode_efe(sb, | 992 | fe = udf_find_metadata_inode_efe(sb, mdata->s_meta_file_loc, |
990 | mdata->s_meta_file_loc, map->s_partition_num); | 993 | map->s_partition_num); |
991 | 994 | if (IS_ERR(fe)) { | |
992 | if (mdata->s_metadata_fe == NULL) { | ||
993 | /* mirror file entry */ | 995 | /* mirror file entry */ |
994 | udf_debug("Mirror metadata file location: block = %d part = %d\n", | 996 | udf_debug("Mirror metadata file location: block = %d part = %d\n", |
995 | mdata->s_mirror_file_loc, map->s_partition_num); | 997 | mdata->s_mirror_file_loc, map->s_partition_num); |
996 | 998 | ||
997 | mdata->s_mirror_fe = udf_find_metadata_inode_efe(sb, | 999 | fe = udf_find_metadata_inode_efe(sb, mdata->s_mirror_file_loc, |
998 | mdata->s_mirror_file_loc, map->s_partition_num); | 1000 | map->s_partition_num); |
999 | 1001 | ||
1000 | if (mdata->s_mirror_fe == NULL) { | 1002 | if (IS_ERR(fe)) { |
1001 | udf_err(sb, "Both metadata and mirror metadata inode efe can not found\n"); | 1003 | udf_err(sb, "Both metadata and mirror metadata inode efe can not found\n"); |
1002 | return -EIO; | 1004 | return PTR_ERR(fe); |
1003 | } | 1005 | } |
1004 | } | 1006 | mdata->s_mirror_fe = fe; |
1007 | } else | ||
1008 | mdata->s_metadata_fe = fe; | ||
1009 | |||
1005 | 1010 | ||
1006 | /* | 1011 | /* |
1007 | * bitmap file entry | 1012 | * bitmap file entry |
@@ -1015,15 +1020,16 @@ static int udf_load_metadata_files(struct super_block *sb, int partition) | |||
1015 | udf_debug("Bitmap file location: block = %d part = %d\n", | 1020 | udf_debug("Bitmap file location: block = %d part = %d\n", |
1016 | addr.logicalBlockNum, addr.partitionReferenceNum); | 1021 | addr.logicalBlockNum, addr.partitionReferenceNum); |
1017 | 1022 | ||
1018 | mdata->s_bitmap_fe = udf_iget(sb, &addr); | 1023 | fe = udf_iget(sb, &addr); |
1019 | if (mdata->s_bitmap_fe == NULL) { | 1024 | if (IS_ERR(fe)) { |
1020 | if (sb->s_flags & MS_RDONLY) | 1025 | if (sb->s_flags & MS_RDONLY) |
1021 | udf_warn(sb, "bitmap inode efe not found but it's ok since the disc is mounted read-only\n"); | 1026 | udf_warn(sb, "bitmap inode efe not found but it's ok since the disc is mounted read-only\n"); |
1022 | else { | 1027 | else { |
1023 | udf_err(sb, "bitmap inode efe not found and attempted read-write mount\n"); | 1028 | udf_err(sb, "bitmap inode efe not found and attempted read-write mount\n"); |
1024 | return -EIO; | 1029 | return PTR_ERR(fe); |
1025 | } | 1030 | } |
1026 | } | 1031 | } else |
1032 | mdata->s_bitmap_fe = fe; | ||
1027 | } | 1033 | } |
1028 | 1034 | ||
1029 | udf_debug("udf_load_metadata_files Ok\n"); | 1035 | udf_debug("udf_load_metadata_files Ok\n"); |
@@ -1111,13 +1117,15 @@ static int udf_fill_partdesc_info(struct super_block *sb, | |||
1111 | phd->unallocSpaceTable.extPosition), | 1117 | phd->unallocSpaceTable.extPosition), |
1112 | .partitionReferenceNum = p_index, | 1118 | .partitionReferenceNum = p_index, |
1113 | }; | 1119 | }; |
1120 | struct inode *inode; | ||
1114 | 1121 | ||
1115 | map->s_uspace.s_table = udf_iget(sb, &loc); | 1122 | inode = udf_iget(sb, &loc); |
1116 | if (!map->s_uspace.s_table) { | 1123 | if (IS_ERR(inode)) { |
1117 | udf_debug("cannot load unallocSpaceTable (part %d)\n", | 1124 | udf_debug("cannot load unallocSpaceTable (part %d)\n", |
1118 | p_index); | 1125 | p_index); |
1119 | return -EIO; | 1126 | return PTR_ERR(inode); |
1120 | } | 1127 | } |
1128 | map->s_uspace.s_table = inode; | ||
1121 | map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE; | 1129 | map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE; |
1122 | udf_debug("unallocSpaceTable (part %d) @ %ld\n", | 1130 | udf_debug("unallocSpaceTable (part %d) @ %ld\n", |
1123 | p_index, map->s_uspace.s_table->i_ino); | 1131 | p_index, map->s_uspace.s_table->i_ino); |
@@ -1144,14 +1152,15 @@ static int udf_fill_partdesc_info(struct super_block *sb, | |||
1144 | phd->freedSpaceTable.extPosition), | 1152 | phd->freedSpaceTable.extPosition), |
1145 | .partitionReferenceNum = p_index, | 1153 | .partitionReferenceNum = p_index, |
1146 | }; | 1154 | }; |
1155 | struct inode *inode; | ||
1147 | 1156 | ||
1148 | map->s_fspace.s_table = udf_iget(sb, &loc); | 1157 | inode = udf_iget(sb, &loc); |
1149 | if (!map->s_fspace.s_table) { | 1158 | if (IS_ERR(inode)) { |
1150 | udf_debug("cannot load freedSpaceTable (part %d)\n", | 1159 | udf_debug("cannot load freedSpaceTable (part %d)\n", |
1151 | p_index); | 1160 | p_index); |
1152 | return -EIO; | 1161 | return PTR_ERR(inode); |
1153 | } | 1162 | } |
1154 | 1163 | map->s_fspace.s_table = inode; | |
1155 | map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE; | 1164 | map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE; |
1156 | udf_debug("freedSpaceTable (part %d) @ %ld\n", | 1165 | udf_debug("freedSpaceTable (part %d) @ %ld\n", |
1157 | p_index, map->s_fspace.s_table->i_ino); | 1166 | p_index, map->s_fspace.s_table->i_ino); |
@@ -1178,6 +1187,7 @@ static void udf_find_vat_block(struct super_block *sb, int p_index, | |||
1178 | struct udf_part_map *map = &sbi->s_partmaps[p_index]; | 1187 | struct udf_part_map *map = &sbi->s_partmaps[p_index]; |
1179 | sector_t vat_block; | 1188 | sector_t vat_block; |
1180 | struct kernel_lb_addr ino; | 1189 | struct kernel_lb_addr ino; |
1190 | struct inode *inode; | ||
1181 | 1191 | ||
1182 | /* | 1192 | /* |
1183 | * VAT file entry is in the last recorded block. Some broken disks have | 1193 | * VAT file entry is in the last recorded block. Some broken disks have |
@@ -1186,10 +1196,13 @@ static void udf_find_vat_block(struct super_block *sb, int p_index, | |||
1186 | ino.partitionReferenceNum = type1_index; | 1196 | ino.partitionReferenceNum = type1_index; |
1187 | for (vat_block = start_block; | 1197 | for (vat_block = start_block; |
1188 | vat_block >= map->s_partition_root && | 1198 | vat_block >= map->s_partition_root && |
1189 | vat_block >= start_block - 3 && | 1199 | vat_block >= start_block - 3; vat_block--) { |
1190 | !sbi->s_vat_inode; vat_block--) { | ||
1191 | ino.logicalBlockNum = vat_block - map->s_partition_root; | 1200 | ino.logicalBlockNum = vat_block - map->s_partition_root; |
1192 | sbi->s_vat_inode = udf_iget(sb, &ino); | 1201 | inode = udf_iget(sb, &ino); |
1202 | if (!IS_ERR(inode)) { | ||
1203 | sbi->s_vat_inode = inode; | ||
1204 | break; | ||
1205 | } | ||
1193 | } | 1206 | } |
1194 | } | 1207 | } |
1195 | 1208 | ||
@@ -2205,10 +2218,10 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
2205 | /* assign inodes by physical block number */ | 2218 | /* assign inodes by physical block number */ |
2206 | /* perhaps it's not extensible enough, but for now ... */ | 2219 | /* perhaps it's not extensible enough, but for now ... */ |
2207 | inode = udf_iget(sb, &rootdir); | 2220 | inode = udf_iget(sb, &rootdir); |
2208 | if (!inode) { | 2221 | if (IS_ERR(inode)) { |
2209 | udf_err(sb, "Error in udf_iget, block=%d, partition=%d\n", | 2222 | udf_err(sb, "Error in udf_iget, block=%d, partition=%d\n", |
2210 | rootdir.logicalBlockNum, rootdir.partitionReferenceNum); | 2223 | rootdir.logicalBlockNum, rootdir.partitionReferenceNum); |
2211 | ret = -EIO; | 2224 | ret = PTR_ERR(inode); |
2212 | goto error_out; | 2225 | goto error_out; |
2213 | } | 2226 | } |
2214 | 2227 | ||