diff options
author | Jan Kara <jack@suse.cz> | 2014-09-04 10:15:51 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2014-09-04 15:36:35 -0400 |
commit | 6d3d5e860a114ae606b1af2ba7f64cb19fbeb414 (patch) | |
tree | 81d9443311a711bf56bc07f82cbd5328fcd376a7 /fs/udf | |
parent | c03aa9f6e1f938618e6db2e23afef0574efeeb65 (diff) |
udf: Make udf_read_inode() and udf_iget() return error
Currently __udf_read_inode() wasn't returning anything and we found out
whether we succeeded reading inode by checking whether inode is bad or
not. udf_iget() returned NULL on failure and inode pointer otherwise.
Make these two functions properly propagate errors up the call stack and
use the return value in callers.
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf')
-rw-r--r-- | fs/udf/inode.c | 99 | ||||
-rw-r--r-- | fs/udf/namei.c | 22 | ||||
-rw-r--r-- | fs/udf/super.c | 69 | ||||
-rw-r--r-- | fs/udf/udfdecl.h | 1 |
4 files changed, 96 insertions, 95 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index a6a40536ebf1..788fc58ea78e 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -1277,7 +1277,7 @@ update_time: | |||
1277 | */ | 1277 | */ |
1278 | #define UDF_MAX_ICB_NESTING 1024 | 1278 | #define UDF_MAX_ICB_NESTING 1024 |
1279 | 1279 | ||
1280 | static void __udf_read_inode(struct inode *inode) | 1280 | static int udf_read_inode(struct inode *inode) |
1281 | { | 1281 | { |
1282 | struct buffer_head *bh = NULL; | 1282 | struct buffer_head *bh = NULL; |
1283 | struct fileEntry *fe; | 1283 | struct fileEntry *fe; |
@@ -1285,10 +1285,19 @@ static void __udf_read_inode(struct inode *inode) | |||
1285 | uint16_t ident; | 1285 | uint16_t ident; |
1286 | struct udf_inode_info *iinfo = UDF_I(inode); | 1286 | struct udf_inode_info *iinfo = UDF_I(inode); |
1287 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); | 1287 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); |
1288 | struct kernel_lb_addr *iloc = &iinfo->i_location; | ||
1288 | unsigned int link_count; | 1289 | unsigned int link_count; |
1289 | unsigned int indirections = 0; | 1290 | unsigned int indirections = 0; |
1291 | int ret = -EIO; | ||
1290 | 1292 | ||
1291 | reread: | 1293 | reread: |
1294 | if (iloc->logicalBlockNum >= | ||
1295 | sbi->s_partmaps[iloc->partitionReferenceNum].s_partition_len) { | ||
1296 | udf_debug("block=%d, partition=%d out of range\n", | ||
1297 | iloc->logicalBlockNum, iloc->partitionReferenceNum); | ||
1298 | return -EIO; | ||
1299 | } | ||
1300 | |||
1292 | /* | 1301 | /* |
1293 | * Set defaults, but the inode is still incomplete! | 1302 | * Set defaults, but the inode is still incomplete! |
1294 | * Note: get_new_inode() sets the following on a new inode: | 1303 | * Note: get_new_inode() sets the following on a new inode: |
@@ -1301,20 +1310,17 @@ reread: | |||
1301 | * i_nlink = 1 | 1310 | * i_nlink = 1 |
1302 | * i_op = NULL; | 1311 | * i_op = NULL; |
1303 | */ | 1312 | */ |
1304 | bh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 0, &ident); | 1313 | bh = udf_read_ptagged(inode->i_sb, iloc, 0, &ident); |
1305 | if (!bh) { | 1314 | if (!bh) { |
1306 | udf_err(inode->i_sb, "(ino %ld) failed !bh\n", inode->i_ino); | 1315 | udf_err(inode->i_sb, "(ino %ld) failed !bh\n", inode->i_ino); |
1307 | make_bad_inode(inode); | 1316 | return -EIO; |
1308 | return; | ||
1309 | } | 1317 | } |
1310 | 1318 | ||
1311 | if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && | 1319 | if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && |
1312 | ident != TAG_IDENT_USE) { | 1320 | ident != TAG_IDENT_USE) { |
1313 | udf_err(inode->i_sb, "(ino %ld) failed ident=%d\n", | 1321 | udf_err(inode->i_sb, "(ino %ld) failed ident=%d\n", |
1314 | inode->i_ino, ident); | 1322 | inode->i_ino, ident); |
1315 | brelse(bh); | 1323 | goto out; |
1316 | make_bad_inode(inode); | ||
1317 | return; | ||
1318 | } | 1324 | } |
1319 | 1325 | ||
1320 | fe = (struct fileEntry *)bh->b_data; | 1326 | fe = (struct fileEntry *)bh->b_data; |
@@ -1323,8 +1329,7 @@ reread: | |||
1323 | if (fe->icbTag.strategyType == cpu_to_le16(4096)) { | 1329 | if (fe->icbTag.strategyType == cpu_to_le16(4096)) { |
1324 | struct buffer_head *ibh; | 1330 | struct buffer_head *ibh; |
1325 | 1331 | ||
1326 | ibh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 1, | 1332 | ibh = udf_read_ptagged(inode->i_sb, iloc, 1, &ident); |
1327 | &ident); | ||
1328 | if (ident == TAG_IDENT_IE && ibh) { | 1333 | if (ident == TAG_IDENT_IE && ibh) { |
1329 | struct kernel_lb_addr loc; | 1334 | struct kernel_lb_addr loc; |
1330 | struct indirectEntry *ie; | 1335 | struct indirectEntry *ie; |
@@ -1333,7 +1338,6 @@ reread: | |||
1333 | loc = lelb_to_cpu(ie->indirectICB.extLocation); | 1338 | loc = lelb_to_cpu(ie->indirectICB.extLocation); |
1334 | 1339 | ||
1335 | if (ie->indirectICB.extLength) { | 1340 | if (ie->indirectICB.extLength) { |
1336 | brelse(bh); | ||
1337 | brelse(ibh); | 1341 | brelse(ibh); |
1338 | memcpy(&iinfo->i_location, &loc, | 1342 | memcpy(&iinfo->i_location, &loc, |
1339 | sizeof(struct kernel_lb_addr)); | 1343 | sizeof(struct kernel_lb_addr)); |
@@ -1342,9 +1346,9 @@ reread: | |||
1342 | "too many ICBs in ICB hierarchy" | 1346 | "too many ICBs in ICB hierarchy" |
1343 | " (max %d supported)\n", | 1347 | " (max %d supported)\n", |
1344 | UDF_MAX_ICB_NESTING); | 1348 | UDF_MAX_ICB_NESTING); |
1345 | make_bad_inode(inode); | 1349 | goto out; |
1346 | return; | ||
1347 | } | 1350 | } |
1351 | brelse(bh); | ||
1348 | goto reread; | 1352 | goto reread; |
1349 | } | 1353 | } |
1350 | } | 1354 | } |
@@ -1352,9 +1356,7 @@ reread: | |||
1352 | } else if (fe->icbTag.strategyType != cpu_to_le16(4)) { | 1356 | } else if (fe->icbTag.strategyType != cpu_to_le16(4)) { |
1353 | udf_err(inode->i_sb, "unsupported strategy type: %d\n", | 1357 | udf_err(inode->i_sb, "unsupported strategy type: %d\n", |
1354 | le16_to_cpu(fe->icbTag.strategyType)); | 1358 | le16_to_cpu(fe->icbTag.strategyType)); |
1355 | brelse(bh); | 1359 | goto out; |
1356 | make_bad_inode(inode); | ||
1357 | return; | ||
1358 | } | 1360 | } |
1359 | if (fe->icbTag.strategyType == cpu_to_le16(4)) | 1361 | if (fe->icbTag.strategyType == cpu_to_le16(4)) |
1360 | iinfo->i_strat4096 = 0; | 1362 | iinfo->i_strat4096 = 0; |
@@ -1372,11 +1374,10 @@ reread: | |||
1372 | if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_EFE)) { | 1374 | if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_EFE)) { |
1373 | iinfo->i_efe = 1; | 1375 | iinfo->i_efe = 1; |
1374 | iinfo->i_use = 0; | 1376 | iinfo->i_use = 0; |
1375 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - | 1377 | ret = udf_alloc_i_data(inode, inode->i_sb->s_blocksize - |
1376 | sizeof(struct extendedFileEntry))) { | 1378 | sizeof(struct extendedFileEntry)); |
1377 | make_bad_inode(inode); | 1379 | if (ret) |
1378 | return; | 1380 | goto out; |
1379 | } | ||
1380 | memcpy(iinfo->i_ext.i_data, | 1381 | memcpy(iinfo->i_ext.i_data, |
1381 | bh->b_data + sizeof(struct extendedFileEntry), | 1382 | bh->b_data + sizeof(struct extendedFileEntry), |
1382 | inode->i_sb->s_blocksize - | 1383 | inode->i_sb->s_blocksize - |
@@ -1384,11 +1385,10 @@ reread: | |||
1384 | } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_FE)) { | 1385 | } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_FE)) { |
1385 | iinfo->i_efe = 0; | 1386 | iinfo->i_efe = 0; |
1386 | iinfo->i_use = 0; | 1387 | iinfo->i_use = 0; |
1387 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - | 1388 | ret = udf_alloc_i_data(inode, inode->i_sb->s_blocksize - |
1388 | sizeof(struct fileEntry))) { | 1389 | sizeof(struct fileEntry)); |
1389 | make_bad_inode(inode); | 1390 | if (ret) |
1390 | return; | 1391 | goto out; |
1391 | } | ||
1392 | memcpy(iinfo->i_ext.i_data, | 1392 | memcpy(iinfo->i_ext.i_data, |
1393 | bh->b_data + sizeof(struct fileEntry), | 1393 | bh->b_data + sizeof(struct fileEntry), |
1394 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); | 1394 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); |
@@ -1398,18 +1398,18 @@ reread: | |||
1398 | iinfo->i_lenAlloc = le32_to_cpu( | 1398 | iinfo->i_lenAlloc = le32_to_cpu( |
1399 | ((struct unallocSpaceEntry *)bh->b_data)-> | 1399 | ((struct unallocSpaceEntry *)bh->b_data)-> |
1400 | lengthAllocDescs); | 1400 | lengthAllocDescs); |
1401 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - | 1401 | ret = udf_alloc_i_data(inode, inode->i_sb->s_blocksize - |
1402 | sizeof(struct unallocSpaceEntry))) { | 1402 | sizeof(struct unallocSpaceEntry)); |
1403 | make_bad_inode(inode); | 1403 | if (ret) |
1404 | return; | 1404 | goto out; |
1405 | } | ||
1406 | memcpy(iinfo->i_ext.i_data, | 1405 | memcpy(iinfo->i_ext.i_data, |
1407 | bh->b_data + sizeof(struct unallocSpaceEntry), | 1406 | bh->b_data + sizeof(struct unallocSpaceEntry), |
1408 | inode->i_sb->s_blocksize - | 1407 | inode->i_sb->s_blocksize - |
1409 | sizeof(struct unallocSpaceEntry)); | 1408 | sizeof(struct unallocSpaceEntry)); |
1410 | return; | 1409 | return 0; |
1411 | } | 1410 | } |
1412 | 1411 | ||
1412 | ret = -EIO; | ||
1413 | read_lock(&sbi->s_cred_lock); | 1413 | read_lock(&sbi->s_cred_lock); |
1414 | i_uid_write(inode, le32_to_cpu(fe->uid)); | 1414 | i_uid_write(inode, le32_to_cpu(fe->uid)); |
1415 | if (!uid_valid(inode->i_uid) || | 1415 | if (!uid_valid(inode->i_uid) || |
@@ -1531,8 +1531,7 @@ reread: | |||
1531 | default: | 1531 | default: |
1532 | udf_err(inode->i_sb, "(ino %ld) failed unknown file type=%d\n", | 1532 | udf_err(inode->i_sb, "(ino %ld) failed unknown file type=%d\n", |
1533 | inode->i_ino, fe->icbTag.fileType); | 1533 | inode->i_ino, fe->icbTag.fileType); |
1534 | make_bad_inode(inode); | 1534 | goto out; |
1535 | return; | ||
1536 | } | 1535 | } |
1537 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { | 1536 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { |
1538 | struct deviceSpec *dsea = | 1537 | struct deviceSpec *dsea = |
@@ -1543,9 +1542,12 @@ reread: | |||
1543 | le32_to_cpu(dsea->minorDeviceIdent))); | 1542 | le32_to_cpu(dsea->minorDeviceIdent))); |
1544 | /* Developer ID ??? */ | 1543 | /* Developer ID ??? */ |
1545 | } else | 1544 | } else |
1546 | make_bad_inode(inode); | 1545 | goto out; |
1547 | } | 1546 | } |
1547 | ret = 0; | ||
1548 | out: | ||
1548 | brelse(bh); | 1549 | brelse(bh); |
1550 | return ret; | ||
1549 | } | 1551 | } |
1550 | 1552 | ||
1551 | static int udf_alloc_i_data(struct inode *inode, size_t size) | 1553 | static int udf_alloc_i_data(struct inode *inode, size_t size) |
@@ -1825,32 +1827,23 @@ struct inode *udf_iget(struct super_block *sb, struct kernel_lb_addr *ino) | |||
1825 | { | 1827 | { |
1826 | unsigned long block = udf_get_lb_pblock(sb, ino, 0); | 1828 | unsigned long block = udf_get_lb_pblock(sb, ino, 0); |
1827 | struct inode *inode = iget_locked(sb, block); | 1829 | struct inode *inode = iget_locked(sb, block); |
1830 | int err; | ||
1828 | 1831 | ||
1829 | if (!inode) | 1832 | if (!inode) |
1830 | return NULL; | 1833 | return ERR_PTR(-ENOMEM); |
1831 | |||
1832 | if (inode->i_state & I_NEW) { | ||
1833 | memcpy(&UDF_I(inode)->i_location, ino, sizeof(struct kernel_lb_addr)); | ||
1834 | __udf_read_inode(inode); | ||
1835 | unlock_new_inode(inode); | ||
1836 | } | ||
1837 | 1834 | ||
1838 | if (is_bad_inode(inode)) | 1835 | if (!(inode->i_state & I_NEW)) |
1839 | goto out_iput; | 1836 | return inode; |
1840 | 1837 | ||
1841 | if (ino->logicalBlockNum >= UDF_SB(sb)-> | 1838 | memcpy(&UDF_I(inode)->i_location, ino, sizeof(struct kernel_lb_addr)); |
1842 | s_partmaps[ino->partitionReferenceNum].s_partition_len) { | 1839 | err = udf_read_inode(inode); |
1843 | udf_debug("block=%d, partition=%d out of range\n", | 1840 | if (err < 0) { |
1844 | ino->logicalBlockNum, ino->partitionReferenceNum); | 1841 | iget_failed(inode); |
1845 | make_bad_inode(inode); | 1842 | return ERR_PTR(err); |
1846 | goto out_iput; | ||
1847 | } | 1843 | } |
1844 | unlock_new_inode(inode); | ||
1848 | 1845 | ||
1849 | return inode; | 1846 | return inode; |
1850 | |||
1851 | out_iput: | ||
1852 | iput(inode); | ||
1853 | return NULL; | ||
1854 | } | 1847 | } |
1855 | 1848 | ||
1856 | int udf_add_aext(struct inode *inode, struct extent_position *epos, | 1849 | int udf_add_aext(struct inode *inode, struct extent_position *epos, |
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 83a06001742b..e041fd9c6816 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -270,9 +270,8 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, | |||
270 | NULL, 0), | 270 | NULL, 0), |
271 | }; | 271 | }; |
272 | inode = udf_iget(dir->i_sb, lb); | 272 | inode = udf_iget(dir->i_sb, lb); |
273 | if (!inode) { | 273 | if (IS_ERR(inode)) |
274 | return ERR_PTR(-EACCES); | 274 | return inode; |
275 | } | ||
276 | } else | 275 | } else |
277 | #endif /* UDF_RECOVERY */ | 276 | #endif /* UDF_RECOVERY */ |
278 | 277 | ||
@@ -285,9 +284,8 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, | |||
285 | 284 | ||
286 | loc = lelb_to_cpu(cfi.icb.extLocation); | 285 | loc = lelb_to_cpu(cfi.icb.extLocation); |
287 | inode = udf_iget(dir->i_sb, &loc); | 286 | inode = udf_iget(dir->i_sb, &loc); |
288 | if (!inode) { | 287 | if (IS_ERR(inode)) |
289 | return ERR_PTR(-EACCES); | 288 | return ERR_CAST(inode); |
290 | } | ||
291 | } | 289 | } |
292 | 290 | ||
293 | return d_splice_alias(inode, dentry); | 291 | return d_splice_alias(inode, dentry); |
@@ -1222,7 +1220,7 @@ static struct dentry *udf_get_parent(struct dentry *child) | |||
1222 | struct udf_fileident_bh fibh; | 1220 | struct udf_fileident_bh fibh; |
1223 | 1221 | ||
1224 | if (!udf_find_entry(child->d_inode, &dotdot, &fibh, &cfi)) | 1222 | if (!udf_find_entry(child->d_inode, &dotdot, &fibh, &cfi)) |
1225 | goto out_unlock; | 1223 | return ERR_PTR(-EACCES); |
1226 | 1224 | ||
1227 | if (fibh.sbh != fibh.ebh) | 1225 | if (fibh.sbh != fibh.ebh) |
1228 | brelse(fibh.ebh); | 1226 | brelse(fibh.ebh); |
@@ -1230,12 +1228,10 @@ static struct dentry *udf_get_parent(struct dentry *child) | |||
1230 | 1228 | ||
1231 | tloc = lelb_to_cpu(cfi.icb.extLocation); | 1229 | tloc = lelb_to_cpu(cfi.icb.extLocation); |
1232 | inode = udf_iget(child->d_inode->i_sb, &tloc); | 1230 | inode = udf_iget(child->d_inode->i_sb, &tloc); |
1233 | if (!inode) | 1231 | if (IS_ERR(inode)) |
1234 | goto out_unlock; | 1232 | return ERR_CAST(inode); |
1235 | 1233 | ||
1236 | return d_obtain_alias(inode); | 1234 | return d_obtain_alias(inode); |
1237 | out_unlock: | ||
1238 | return ERR_PTR(-EACCES); | ||
1239 | } | 1235 | } |
1240 | 1236 | ||
1241 | 1237 | ||
@@ -1252,8 +1248,8 @@ static struct dentry *udf_nfs_get_inode(struct super_block *sb, u32 block, | |||
1252 | loc.partitionReferenceNum = partref; | 1248 | loc.partitionReferenceNum = partref; |
1253 | inode = udf_iget(sb, &loc); | 1249 | inode = udf_iget(sb, &loc); |
1254 | 1250 | ||
1255 | if (inode == NULL) | 1251 | if (IS_ERR(inode)) |
1256 | return ERR_PTR(-ENOMEM); | 1252 | return ERR_CAST(inode); |
1257 | 1253 | ||
1258 | if (generation && inode->i_generation != generation) { | 1254 | if (generation && inode->i_generation != generation) { |
1259 | iput(inode); | 1255 | iput(inode); |
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 | ||
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index be7dabbbcb49..41a8115c9345 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h | |||
@@ -143,7 +143,6 @@ extern int udf_expand_file_adinicb(struct inode *); | |||
143 | extern struct buffer_head *udf_expand_dir_adinicb(struct inode *, int *, int *); | 143 | extern struct buffer_head *udf_expand_dir_adinicb(struct inode *, int *, int *); |
144 | extern struct buffer_head *udf_bread(struct inode *, int, int, int *); | 144 | extern struct buffer_head *udf_bread(struct inode *, int, int, int *); |
145 | extern int udf_setsize(struct inode *, loff_t); | 145 | extern int udf_setsize(struct inode *, loff_t); |
146 | extern void udf_read_inode(struct inode *); | ||
147 | extern void udf_evict_inode(struct inode *); | 146 | extern void udf_evict_inode(struct inode *); |
148 | extern int udf_write_inode(struct inode *, struct writeback_control *wbc); | 147 | extern int udf_write_inode(struct inode *, struct writeback_control *wbc); |
149 | extern long udf_block_map(struct inode *, sector_t); | 148 | extern long udf_block_map(struct inode *, sector_t); |