aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-02-07 03:15:41 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:28 -0500
commitc4386c83bf849c56b1f49951595aeb7c9a719d21 (patch)
tree44248ee7c540d9992fc3c0b4ac73d30c0bc0a136
parent635253915b3297435e178371407d568522aae3d4 (diff)
iget: stop ISOFS from using read_inode()
Stop the ISOFS filesystem from using read_inode(). Make isofs_read_inode() return an error code, and make isofs_iget() pass it on. Signed-off-by: David Howells <dhowells@redhat.com> Cc: Jan Kara <jack@ucw.cz> Acked-by: Christoph Hellwig <hch@lst.de> Cc: "Dave Young" <hidave.darkstar@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/isofs/export.c14
-rw-r--r--fs/isofs/inode.c68
-rw-r--r--fs/isofs/namei.c4
-rw-r--r--fs/isofs/rock.c4
4 files changed, 58 insertions, 32 deletions
diff --git a/fs/isofs/export.c b/fs/isofs/export.c
index 29f9753ae5e5..bb219138331a 100644
--- a/fs/isofs/export.c
+++ b/fs/isofs/export.c
@@ -26,11 +26,9 @@ isofs_export_iget(struct super_block *sb,
26 if (block == 0) 26 if (block == 0)
27 return ERR_PTR(-ESTALE); 27 return ERR_PTR(-ESTALE);
28 inode = isofs_iget(sb, block, offset); 28 inode = isofs_iget(sb, block, offset);
29 if (inode == NULL) 29 if (IS_ERR(inode))
30 return ERR_PTR(-ENOMEM); 30 return ERR_CAST(inode);
31 if (is_bad_inode(inode) 31 if (generation && inode->i_generation != generation) {
32 || (generation && inode->i_generation != generation))
33 {
34 iput(inode); 32 iput(inode);
35 return ERR_PTR(-ESTALE); 33 return ERR_PTR(-ESTALE);
36 } 34 }
@@ -110,8 +108,10 @@ static struct dentry *isofs_export_get_parent(struct dentry *child)
110 parent_inode = isofs_iget(child_inode->i_sb, 108 parent_inode = isofs_iget(child_inode->i_sb,
111 parent_block, 109 parent_block,
112 parent_offset); 110 parent_offset);
113 if (parent_inode == NULL) { 111 if (IS_ERR(parent_inode)) {
114 rv = ERR_PTR(-EACCES); 112 rv = ERR_CAST(parent_inode);
113 if (rv != ERR_PTR(-ENOMEM))
114 rv = ERR_PTR(-EACCES);
115 goto out; 115 goto out;
116 } 116 }
117 117
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 09e3d306e96f..875d37fb6c70 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -54,7 +54,7 @@ static void isofs_put_super(struct super_block *sb)
54 return; 54 return;
55} 55}
56 56
57static void isofs_read_inode(struct inode *); 57static int isofs_read_inode(struct inode *);
58static int isofs_statfs (struct dentry *, struct kstatfs *); 58static int isofs_statfs (struct dentry *, struct kstatfs *);
59 59
60static struct kmem_cache *isofs_inode_cachep; 60static struct kmem_cache *isofs_inode_cachep;
@@ -107,7 +107,6 @@ static int isofs_remount(struct super_block *sb, int *flags, char *data)
107static const struct super_operations isofs_sops = { 107static const struct super_operations isofs_sops = {
108 .alloc_inode = isofs_alloc_inode, 108 .alloc_inode = isofs_alloc_inode,
109 .destroy_inode = isofs_destroy_inode, 109 .destroy_inode = isofs_destroy_inode,
110 .read_inode = isofs_read_inode,
111 .put_super = isofs_put_super, 110 .put_super = isofs_put_super,
112 .statfs = isofs_statfs, 111 .statfs = isofs_statfs,
113 .remount_fs = isofs_remount, 112 .remount_fs = isofs_remount,
@@ -552,7 +551,7 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
552 int joliet_level = 0; 551 int joliet_level = 0;
553 int iso_blknum, block; 552 int iso_blknum, block;
554 int orig_zonesize; 553 int orig_zonesize;
555 int table; 554 int table, error = -EINVAL;
556 unsigned int vol_desc_start; 555 unsigned int vol_desc_start;
557 556
558 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 557 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
@@ -810,6 +809,8 @@ root_found:
810 * we then decide whether to use the Joliet descriptor. 809 * we then decide whether to use the Joliet descriptor.
811 */ 810 */
812 inode = isofs_iget(s, sbi->s_firstdatazone, 0); 811 inode = isofs_iget(s, sbi->s_firstdatazone, 0);
812 if (IS_ERR(inode))
813 goto out_no_root;
813 814
814 /* 815 /*
815 * If this disk has both Rock Ridge and Joliet on it, then we 816 * If this disk has both Rock Ridge and Joliet on it, then we
@@ -829,6 +830,8 @@ root_found:
829 "ISOFS: changing to secondary root\n"); 830 "ISOFS: changing to secondary root\n");
830 iput(inode); 831 iput(inode);
831 inode = isofs_iget(s, sbi->s_firstdatazone, 0); 832 inode = isofs_iget(s, sbi->s_firstdatazone, 0);
833 if (IS_ERR(inode))
834 goto out_no_root;
832 } 835 }
833 } 836 }
834 837
@@ -842,8 +845,6 @@ root_found:
842 sbi->s_joliet_level = joliet_level; 845 sbi->s_joliet_level = joliet_level;
843 846
844 /* check the root inode */ 847 /* check the root inode */
845 if (!inode)
846 goto out_no_root;
847 if (!inode->i_op) 848 if (!inode->i_op)
848 goto out_bad_root; 849 goto out_bad_root;
849 850
@@ -876,11 +877,14 @@ root_found:
876 */ 877 */
877out_bad_root: 878out_bad_root:
878 printk(KERN_WARNING "%s: root inode not initialized\n", __func__); 879 printk(KERN_WARNING "%s: root inode not initialized\n", __func__);
879 goto out_iput;
880out_no_root:
881 printk(KERN_WARNING "%s: get root inode failed\n", __func__);
882out_iput: 880out_iput:
883 iput(inode); 881 iput(inode);
882 goto out_no_inode;
883out_no_root:
884 error = PTR_ERR(inode);
885 if (error != -ENOMEM)
886 printk(KERN_WARNING "%s: get root inode failed\n", __func__);
887out_no_inode:
884#ifdef CONFIG_JOLIET 888#ifdef CONFIG_JOLIET
885 if (sbi->s_nls_iocharset) 889 if (sbi->s_nls_iocharset)
886 unload_nls(sbi->s_nls_iocharset); 890 unload_nls(sbi->s_nls_iocharset);
@@ -908,7 +912,7 @@ out_freesbi:
908 kfree(opt.iocharset); 912 kfree(opt.iocharset);
909 kfree(sbi); 913 kfree(sbi);
910 s->s_fs_info = NULL; 914 s->s_fs_info = NULL;
911 return -EINVAL; 915 return error;
912} 916}
913 917
914static int isofs_statfs (struct dentry *dentry, struct kstatfs *buf) 918static int isofs_statfs (struct dentry *dentry, struct kstatfs *buf)
@@ -930,7 +934,7 @@ static int isofs_statfs (struct dentry *dentry, struct kstatfs *buf)
930/* 934/*
931 * Get a set of blocks; filling in buffer_heads if already allocated 935 * Get a set of blocks; filling in buffer_heads if already allocated
932 * or getblk() if they are not. Returns the number of blocks inserted 936 * or getblk() if they are not. Returns the number of blocks inserted
933 * (0 == error.) 937 * (-ve == error.)
934 */ 938 */
935int isofs_get_blocks(struct inode *inode, sector_t iblock_s, 939int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
936 struct buffer_head **bh, unsigned long nblocks) 940 struct buffer_head **bh, unsigned long nblocks)
@@ -940,11 +944,12 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
940 unsigned int firstext; 944 unsigned int firstext;
941 unsigned long nextblk, nextoff; 945 unsigned long nextblk, nextoff;
942 long iblock = (long)iblock_s; 946 long iblock = (long)iblock_s;
943 int section, rv; 947 int section, rv, error;
944 struct iso_inode_info *ei = ISOFS_I(inode); 948 struct iso_inode_info *ei = ISOFS_I(inode);
945 949
946 lock_kernel(); 950 lock_kernel();
947 951
952 error = -EIO;
948 rv = 0; 953 rv = 0;
949 if (iblock < 0 || iblock != iblock_s) { 954 if (iblock < 0 || iblock != iblock_s) {
950 printk(KERN_DEBUG "%s: block number too large\n", __func__); 955 printk(KERN_DEBUG "%s: block number too large\n", __func__);
@@ -983,8 +988,10 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
983 988
984 offset += sect_size; 989 offset += sect_size;
985 ninode = isofs_iget(inode->i_sb, nextblk, nextoff); 990 ninode = isofs_iget(inode->i_sb, nextblk, nextoff);
986 if (!ninode) 991 if (IS_ERR(ninode)) {
992 error = PTR_ERR(ninode);
987 goto abort; 993 goto abort;
994 }
988 firstext = ISOFS_I(ninode)->i_first_extent; 995 firstext = ISOFS_I(ninode)->i_first_extent;
989 sect_size = ISOFS_I(ninode)->i_section_size >> ISOFS_BUFFER_BITS(ninode); 996 sect_size = ISOFS_I(ninode)->i_section_size >> ISOFS_BUFFER_BITS(ninode);
990 nextblk = ISOFS_I(ninode)->i_next_section_block; 997 nextblk = ISOFS_I(ninode)->i_next_section_block;
@@ -1015,9 +1022,10 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
1015 rv++; 1022 rv++;
1016 } 1023 }
1017 1024
1025 error = 0;
1018abort: 1026abort:
1019 unlock_kernel(); 1027 unlock_kernel();
1020 return rv; 1028 return rv != 0 ? rv : error;
1021} 1029}
1022 1030
1023/* 1031/*
@@ -1026,12 +1034,15 @@ abort:
1026static int isofs_get_block(struct inode *inode, sector_t iblock, 1034static int isofs_get_block(struct inode *inode, sector_t iblock,
1027 struct buffer_head *bh_result, int create) 1035 struct buffer_head *bh_result, int create)
1028{ 1036{
1037 int ret;
1038
1029 if (create) { 1039 if (create) {
1030 printk(KERN_DEBUG "%s: Kernel tries to allocate a block\n", __func__); 1040 printk(KERN_DEBUG "%s: Kernel tries to allocate a block\n", __func__);
1031 return -EROFS; 1041 return -EROFS;
1032 } 1042 }
1033 1043
1034 return isofs_get_blocks(inode, iblock, &bh_result, 1) ? 0 : -EIO; 1044 ret = isofs_get_blocks(inode, iblock, &bh_result, 1);
1045 return ret < 0 ? ret : 0;
1035} 1046}
1036 1047
1037static int isofs_bmap(struct inode *inode, sector_t block) 1048static int isofs_bmap(struct inode *inode, sector_t block)
@@ -1186,7 +1197,7 @@ out_toomany:
1186 goto out; 1197 goto out;
1187} 1198}
1188 1199
1189static void isofs_read_inode(struct inode *inode) 1200static int isofs_read_inode(struct inode *inode)
1190{ 1201{
1191 struct super_block *sb = inode->i_sb; 1202 struct super_block *sb = inode->i_sb;
1192 struct isofs_sb_info *sbi = ISOFS_SB(sb); 1203 struct isofs_sb_info *sbi = ISOFS_SB(sb);
@@ -1199,6 +1210,7 @@ static void isofs_read_inode(struct inode *inode)
1199 unsigned int de_len; 1210 unsigned int de_len;
1200 unsigned long offset; 1211 unsigned long offset;
1201 struct iso_inode_info *ei = ISOFS_I(inode); 1212 struct iso_inode_info *ei = ISOFS_I(inode);
1213 int ret = -EIO;
1202 1214
1203 block = ei->i_iget5_block; 1215 block = ei->i_iget5_block;
1204 bh = sb_bread(inode->i_sb, block); 1216 bh = sb_bread(inode->i_sb, block);
@@ -1216,6 +1228,7 @@ static void isofs_read_inode(struct inode *inode)
1216 tmpde = kmalloc(de_len, GFP_KERNEL); 1228 tmpde = kmalloc(de_len, GFP_KERNEL);
1217 if (tmpde == NULL) { 1229 if (tmpde == NULL) {
1218 printk(KERN_INFO "%s: out of memory\n", __func__); 1230 printk(KERN_INFO "%s: out of memory\n", __func__);
1231 ret = -ENOMEM;
1219 goto fail; 1232 goto fail;
1220 } 1233 }
1221 memcpy(tmpde, bh->b_data + offset, frag1); 1234 memcpy(tmpde, bh->b_data + offset, frag1);
@@ -1259,8 +1272,10 @@ static void isofs_read_inode(struct inode *inode)
1259 1272
1260 ei->i_section_size = isonum_733(de->size); 1273 ei->i_section_size = isonum_733(de->size);
1261 if (de->flags[-high_sierra] & 0x80) { 1274 if (de->flags[-high_sierra] & 0x80) {
1262 if(isofs_read_level3_size(inode)) 1275 ret = isofs_read_level3_size(inode);
1276 if (ret < 0)
1263 goto fail; 1277 goto fail;
1278 ret = -EIO;
1264 } else { 1279 } else {
1265 ei->i_next_section_block = 0; 1280 ei->i_next_section_block = 0;
1266 ei->i_next_section_offset = 0; 1281 ei->i_next_section_offset = 0;
@@ -1346,16 +1361,16 @@ static void isofs_read_inode(struct inode *inode)
1346 /* XXX - parse_rock_ridge_inode() had already set i_rdev. */ 1361 /* XXX - parse_rock_ridge_inode() had already set i_rdev. */
1347 init_special_inode(inode, inode->i_mode, inode->i_rdev); 1362 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1348 1363
1364 ret = 0;
1349out: 1365out:
1350 kfree(tmpde); 1366 kfree(tmpde);
1351 if (bh) 1367 if (bh)
1352 brelse(bh); 1368 brelse(bh);
1353 return; 1369 return ret;
1354 1370
1355out_badread: 1371out_badread:
1356 printk(KERN_WARNING "ISOFS: unable to read i-node block\n"); 1372 printk(KERN_WARNING "ISOFS: unable to read i-node block\n");
1357fail: 1373fail:
1358 make_bad_inode(inode);
1359 goto out; 1374 goto out;
1360} 1375}
1361 1376
@@ -1394,9 +1409,10 @@ struct inode *isofs_iget(struct super_block *sb,
1394 unsigned long hashval; 1409 unsigned long hashval;
1395 struct inode *inode; 1410 struct inode *inode;
1396 struct isofs_iget5_callback_data data; 1411 struct isofs_iget5_callback_data data;
1412 long ret;
1397 1413
1398 if (offset >= 1ul << sb->s_blocksize_bits) 1414 if (offset >= 1ul << sb->s_blocksize_bits)
1399 return NULL; 1415 return ERR_PTR(-EINVAL);
1400 1416
1401 data.block = block; 1417 data.block = block;
1402 data.offset = offset; 1418 data.offset = offset;
@@ -1406,9 +1422,17 @@ struct inode *isofs_iget(struct super_block *sb,
1406 inode = iget5_locked(sb, hashval, &isofs_iget5_test, 1422 inode = iget5_locked(sb, hashval, &isofs_iget5_test,
1407 &isofs_iget5_set, &data); 1423 &isofs_iget5_set, &data);
1408 1424
1409 if (inode && (inode->i_state & I_NEW)) { 1425 if (!inode)
1410 sb->s_op->read_inode(inode); 1426 return ERR_PTR(-ENOMEM);
1411 unlock_new_inode(inode); 1427
1428 if (inode->i_state & I_NEW) {
1429 ret = isofs_read_inode(inode);
1430 if (ret < 0) {
1431 iget_failed(inode);
1432 inode = ERR_PTR(ret);
1433 } else {
1434 unlock_new_inode(inode);
1435 }
1412 } 1436 }
1413 1437
1414 return inode; 1438 return inode;
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index e2b4dad39ca9..344b247bc29a 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -179,9 +179,9 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam
179 inode = NULL; 179 inode = NULL;
180 if (found) { 180 if (found) {
181 inode = isofs_iget(dir->i_sb, block, offset); 181 inode = isofs_iget(dir->i_sb, block, offset);
182 if (!inode) { 182 if (IS_ERR(inode)) {
183 unlock_kernel(); 183 unlock_kernel();
184 return ERR_PTR(-EACCES); 184 return ERR_CAST(inode);
185 } 185 }
186 } 186 }
187 unlock_kernel(); 187 unlock_kernel();
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index f3a1db3098de..6bd48f0a7047 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -474,8 +474,10 @@ repeat:
474 isofs_iget(inode->i_sb, 474 isofs_iget(inode->i_sb,
475 ISOFS_I(inode)->i_first_extent, 475 ISOFS_I(inode)->i_first_extent,
476 0); 476 0);
477 if (!reloc) 477 if (IS_ERR(reloc)) {
478 ret = PTR_ERR(reloc);
478 goto out; 479 goto out;
480 }
479 inode->i_mode = reloc->i_mode; 481 inode->i_mode = reloc->i_mode;
480 inode->i_nlink = reloc->i_nlink; 482 inode->i_nlink = reloc->i_nlink;
481 inode->i_uid = reloc->i_uid; 483 inode->i_uid = reloc->i_uid;