diff options
author | Andrew Morton <akpm@osdl.org> | 2005-06-21 20:16:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-21 22:07:38 -0400 |
commit | 9eb7f2c67c41d2cd730aedcd23e5baca09211d03 (patch) | |
tree | 63f6c759402fe69ee322c1e3c9738f4c52741a23 /fs/isofs/inode.c | |
parent | a089221c5e8a5ae8d74a919c8c7a4d2f68bd59e5 (diff) |
[PATCH] isofs: remove debug stuff
isofs/inode.c:
- Remove some crufty leak detection code
- coding style cleanups
- kfree(NULL) is permitted.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/isofs/inode.c')
-rw-r--r-- | fs/isofs/inode.c | 109 |
1 files changed, 32 insertions, 77 deletions
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index abd7b12eeca7..72cc9727dc07 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c | |||
@@ -28,11 +28,6 @@ | |||
28 | 28 | ||
29 | #define BEQUIET | 29 | #define BEQUIET |
30 | 30 | ||
31 | #ifdef LEAK_CHECK | ||
32 | static int check_malloc; | ||
33 | static int check_bread; | ||
34 | #endif | ||
35 | |||
36 | static int isofs_hashi(struct dentry *parent, struct qstr *qstr); | 31 | static int isofs_hashi(struct dentry *parent, struct qstr *qstr); |
37 | static int isofs_hash(struct dentry *parent, struct qstr *qstr); | 32 | static int isofs_hash(struct dentry *parent, struct qstr *qstr); |
38 | static int isofs_dentry_cmpi(struct dentry *dentry, struct qstr *a, struct qstr *b); | 33 | static int isofs_dentry_cmpi(struct dentry *dentry, struct qstr *a, struct qstr *b); |
@@ -55,11 +50,6 @@ static void isofs_put_super(struct super_block *sb) | |||
55 | } | 50 | } |
56 | #endif | 51 | #endif |
57 | 52 | ||
58 | #ifdef LEAK_CHECK | ||
59 | printk("Outstanding mallocs:%d, outstanding buffers: %d\n", | ||
60 | check_malloc, check_bread); | ||
61 | #endif | ||
62 | |||
63 | kfree(sbi); | 53 | kfree(sbi); |
64 | sb->s_fs_info = NULL; | 54 | sb->s_fs_info = NULL; |
65 | return; | 55 | return; |
@@ -73,7 +63,7 @@ static kmem_cache_t *isofs_inode_cachep; | |||
73 | static struct inode *isofs_alloc_inode(struct super_block *sb) | 63 | static struct inode *isofs_alloc_inode(struct super_block *sb) |
74 | { | 64 | { |
75 | struct iso_inode_info *ei; | 65 | struct iso_inode_info *ei; |
76 | ei = (struct iso_inode_info *)kmem_cache_alloc(isofs_inode_cachep, SLAB_KERNEL); | 66 | ei = kmem_cache_alloc(isofs_inode_cachep, SLAB_KERNEL); |
77 | if (!ei) | 67 | if (!ei) |
78 | return NULL; | 68 | return NULL; |
79 | return &ei->vfs_inode; | 69 | return &ei->vfs_inode; |
@@ -84,9 +74,9 @@ static void isofs_destroy_inode(struct inode *inode) | |||
84 | kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); | 74 | kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); |
85 | } | 75 | } |
86 | 76 | ||
87 | static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) | 77 | static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) |
88 | { | 78 | { |
89 | struct iso_inode_info *ei = (struct iso_inode_info *) foo; | 79 | struct iso_inode_info *ei = foo; |
90 | 80 | ||
91 | if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == | 81 | if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == |
92 | SLAB_CTOR_CONSTRUCTOR) | 82 | SLAB_CTOR_CONSTRUCTOR) |
@@ -107,7 +97,8 @@ static int init_inodecache(void) | |||
107 | static void destroy_inodecache(void) | 97 | static void destroy_inodecache(void) |
108 | { | 98 | { |
109 | if (kmem_cache_destroy(isofs_inode_cachep)) | 99 | if (kmem_cache_destroy(isofs_inode_cachep)) |
110 | printk(KERN_INFO "iso_inode_cache: not all structures were freed\n"); | 100 | printk(KERN_INFO "iso_inode_cache: not all structures were " |
101 | "freed\n"); | ||
111 | } | 102 | } |
112 | 103 | ||
113 | static int isofs_remount(struct super_block *sb, int *flags, char *data) | 104 | static int isofs_remount(struct super_block *sb, int *flags, char *data) |
@@ -144,7 +135,7 @@ static struct dentry_operations isofs_dentry_ops[] = { | |||
144 | { | 135 | { |
145 | .d_hash = isofs_hashi_ms, | 136 | .d_hash = isofs_hashi_ms, |
146 | .d_compare = isofs_dentry_cmpi_ms, | 137 | .d_compare = isofs_dentry_cmpi_ms, |
147 | } | 138 | }, |
148 | #endif | 139 | #endif |
149 | }; | 140 | }; |
150 | 141 | ||
@@ -219,8 +210,8 @@ isofs_hashi_common(struct dentry *dentry, struct qstr *qstr, int ms) | |||
219 | /* | 210 | /* |
220 | * Case insensitive compare of two isofs names. | 211 | * Case insensitive compare of two isofs names. |
221 | */ | 212 | */ |
222 | static int | 213 | static int isofs_dentry_cmpi_common(struct dentry *dentry, struct qstr *a, |
223 | isofs_dentry_cmpi_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int ms) | 214 | struct qstr *b, int ms) |
224 | { | 215 | { |
225 | int alen, blen; | 216 | int alen, blen; |
226 | 217 | ||
@@ -243,8 +234,8 @@ isofs_dentry_cmpi_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int | |||
243 | /* | 234 | /* |
244 | * Case sensitive compare of two isofs names. | 235 | * Case sensitive compare of two isofs names. |
245 | */ | 236 | */ |
246 | static int | 237 | static int isofs_dentry_cmp_common(struct dentry *dentry, struct qstr *a, |
247 | isofs_dentry_cmp_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int ms) | 238 | struct qstr *b, int ms) |
248 | { | 239 | { |
249 | int alen, blen; | 240 | int alen, blen; |
250 | 241 | ||
@@ -356,7 +347,7 @@ static match_table_t tokens = { | |||
356 | {Opt_err, NULL} | 347 | {Opt_err, NULL} |
357 | }; | 348 | }; |
358 | 349 | ||
359 | static int parse_options(char *options, struct iso9660_options * popt) | 350 | static int parse_options(char *options, struct iso9660_options *popt) |
360 | { | 351 | { |
361 | char *p; | 352 | char *p; |
362 | int option; | 353 | int option; |
@@ -493,7 +484,7 @@ static int parse_options(char *options, struct iso9660_options * popt) | |||
493 | */ | 484 | */ |
494 | #define WE_OBEY_THE_WRITTEN_STANDARDS 1 | 485 | #define WE_OBEY_THE_WRITTEN_STANDARDS 1 |
495 | 486 | ||
496 | static unsigned int isofs_get_last_session(struct super_block *sb,s32 session ) | 487 | static unsigned int isofs_get_last_session(struct super_block *sb, s32 session) |
497 | { | 488 | { |
498 | struct cdrom_multisession ms_info; | 489 | struct cdrom_multisession ms_info; |
499 | unsigned int vol_desc_start; | 490 | unsigned int vol_desc_start; |
@@ -518,7 +509,8 @@ static unsigned int isofs_get_last_session(struct super_block *sb,s32 session ) | |||
518 | printk(KERN_ERR "Invalid session number or type of track\n"); | 509 | printk(KERN_ERR "Invalid session number or type of track\n"); |
519 | } | 510 | } |
520 | i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info); | 511 | i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info); |
521 | if(session > 0) printk(KERN_ERR "Invalid session number\n"); | 512 | if (session > 0) |
513 | printk(KERN_ERR "Invalid session number\n"); | ||
522 | #if 0 | 514 | #if 0 |
523 | printk("isofs.inode: CDROMMULTISESSION: rc=%d\n",i); | 515 | printk("isofs.inode: CDROMMULTISESSION: rc=%d\n",i); |
524 | if (i==0) { | 516 | if (i==0) { |
@@ -557,13 +549,13 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) | |||
557 | struct iso9660_options opt; | 549 | struct iso9660_options opt; |
558 | struct isofs_sb_info * sbi; | 550 | struct isofs_sb_info * sbi; |
559 | 551 | ||
560 | sbi = kmalloc(sizeof(struct isofs_sb_info), GFP_KERNEL); | 552 | sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); |
561 | if (!sbi) | 553 | if (!sbi) |
562 | return -ENOMEM; | 554 | return -ENOMEM; |
563 | s->s_fs_info = sbi; | 555 | s->s_fs_info = sbi; |
564 | memset(sbi, 0, sizeof(struct isofs_sb_info)); | 556 | memset(sbi, 0, sizeof(*sbi)); |
565 | 557 | ||
566 | if (!parse_options((char *) data, &opt)) | 558 | if (!parse_options((char *)data, &opt)) |
567 | goto out_freesbi; | 559 | goto out_freesbi; |
568 | 560 | ||
569 | /* | 561 | /* |
@@ -1002,7 +994,6 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s, | |||
1002 | rv++; | 994 | rv++; |
1003 | } | 995 | } |
1004 | 996 | ||
1005 | |||
1006 | abort: | 997 | abort: |
1007 | unlock_kernel(); | 998 | unlock_kernel(); |
1008 | return rv; | 999 | return rv; |
@@ -1014,7 +1005,7 @@ abort: | |||
1014 | static int isofs_get_block(struct inode *inode, sector_t iblock, | 1005 | static int isofs_get_block(struct inode *inode, sector_t iblock, |
1015 | struct buffer_head *bh_result, int create) | 1006 | struct buffer_head *bh_result, int create) |
1016 | { | 1007 | { |
1017 | if ( create ) { | 1008 | if (create) { |
1018 | printk("isofs_get_block: Kernel tries to allocate a block\n"); | 1009 | printk("isofs_get_block: Kernel tries to allocate a block\n"); |
1019 | return -EROFS; | 1010 | return -EROFS; |
1020 | } | 1011 | } |
@@ -1061,19 +1052,17 @@ static struct address_space_operations isofs_aops = { | |||
1061 | 1052 | ||
1062 | static inline void test_and_set_uid(uid_t *p, uid_t value) | 1053 | static inline void test_and_set_uid(uid_t *p, uid_t value) |
1063 | { | 1054 | { |
1064 | if(value) { | 1055 | if (value) |
1065 | *p = value; | 1056 | *p = value; |
1066 | } | ||
1067 | } | 1057 | } |
1068 | 1058 | ||
1069 | static inline void test_and_set_gid(gid_t *p, gid_t value) | 1059 | static inline void test_and_set_gid(gid_t *p, gid_t value) |
1070 | { | 1060 | { |
1071 | if(value) { | 1061 | if (value) |
1072 | *p = value; | 1062 | *p = value; |
1073 | } | ||
1074 | } | 1063 | } |
1075 | 1064 | ||
1076 | static int isofs_read_level3_size(struct inode * inode) | 1065 | static int isofs_read_level3_size(struct inode *inode) |
1077 | { | 1066 | { |
1078 | unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); | 1067 | unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); |
1079 | int high_sierra = ISOFS_SB(inode->i_sb)->s_high_sierra; | 1068 | int high_sierra = ISOFS_SB(inode->i_sb)->s_high_sierra; |
@@ -1136,7 +1125,7 @@ static int isofs_read_level3_size(struct inode * inode) | |||
1136 | bh = sb_bread(inode->i_sb, block); | 1125 | bh = sb_bread(inode->i_sb, block); |
1137 | if (!bh) | 1126 | if (!bh) |
1138 | goto out_noread; | 1127 | goto out_noread; |
1139 | memcpy((void *) tmpde + slop, bh->b_data, offset); | 1128 | memcpy((void *)tmpde+slop, bh->b_data, offset); |
1140 | } | 1129 | } |
1141 | de = tmpde; | 1130 | de = tmpde; |
1142 | } | 1131 | } |
@@ -1150,12 +1139,11 @@ static int isofs_read_level3_size(struct inode * inode) | |||
1150 | more_entries = de->flags[-high_sierra] & 0x80; | 1139 | more_entries = de->flags[-high_sierra] & 0x80; |
1151 | 1140 | ||
1152 | i++; | 1141 | i++; |
1153 | if(i > 100) | 1142 | if (i > 100) |
1154 | goto out_toomany; | 1143 | goto out_toomany; |
1155 | } while(more_entries); | 1144 | } while (more_entries); |
1156 | out: | 1145 | out: |
1157 | if (tmpde) | 1146 | kfree(tmpde); |
1158 | kfree(tmpde); | ||
1159 | if (bh) | 1147 | if (bh) |
1160 | brelse(bh); | 1148 | brelse(bh); |
1161 | return 0; | 1149 | return 0; |
@@ -1179,7 +1167,7 @@ out_toomany: | |||
1179 | goto out; | 1167 | goto out; |
1180 | } | 1168 | } |
1181 | 1169 | ||
1182 | static void isofs_read_inode(struct inode * inode) | 1170 | static void isofs_read_inode(struct inode *inode) |
1183 | { | 1171 | { |
1184 | struct super_block *sb = inode->i_sb; | 1172 | struct super_block *sb = inode->i_sb; |
1185 | struct isofs_sb_info *sbi = ISOFS_SB(sb); | 1173 | struct isofs_sb_info *sbi = ISOFS_SB(sb); |
@@ -1249,7 +1237,7 @@ static void isofs_read_inode(struct inode * inode) | |||
1249 | ei->i_format_parm[2] = 0; | 1237 | ei->i_format_parm[2] = 0; |
1250 | 1238 | ||
1251 | ei->i_section_size = isonum_733 (de->size); | 1239 | ei->i_section_size = isonum_733 (de->size); |
1252 | if(de->flags[-high_sierra] & 0x80) { | 1240 | if (de->flags[-high_sierra] & 0x80) { |
1253 | if(isofs_read_level3_size(inode)) goto fail; | 1241 | if(isofs_read_level3_size(inode)) goto fail; |
1254 | } else { | 1242 | } else { |
1255 | ei->i_next_section_block = 0; | 1243 | ei->i_next_section_block = 0; |
@@ -1336,16 +1324,16 @@ static void isofs_read_inode(struct inode * inode) | |||
1336 | /* XXX - parse_rock_ridge_inode() had already set i_rdev. */ | 1324 | /* XXX - parse_rock_ridge_inode() had already set i_rdev. */ |
1337 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | 1325 | init_special_inode(inode, inode->i_mode, inode->i_rdev); |
1338 | 1326 | ||
1339 | out: | 1327 | out: |
1340 | if (tmpde) | 1328 | if (tmpde) |
1341 | kfree(tmpde); | 1329 | kfree(tmpde); |
1342 | if (bh) | 1330 | if (bh) |
1343 | brelse(bh); | 1331 | brelse(bh); |
1344 | return; | 1332 | return; |
1345 | 1333 | ||
1346 | out_badread: | 1334 | out_badread: |
1347 | printk(KERN_WARNING "ISOFS: unable to read i-node block\n"); | 1335 | printk(KERN_WARNING "ISOFS: unable to read i-node block\n"); |
1348 | fail: | 1336 | fail: |
1349 | make_bad_inode(inode); | 1337 | make_bad_inode(inode); |
1350 | goto out; | 1338 | goto out; |
1351 | } | 1339 | } |
@@ -1394,11 +1382,8 @@ struct inode *isofs_iget(struct super_block *sb, | |||
1394 | 1382 | ||
1395 | hashval = (block << sb->s_blocksize_bits) | offset; | 1383 | hashval = (block << sb->s_blocksize_bits) | offset; |
1396 | 1384 | ||
1397 | inode = iget5_locked(sb, | 1385 | inode = iget5_locked(sb, hashval, &isofs_iget5_test, |
1398 | hashval, | 1386 | &isofs_iget5_set, &data); |
1399 | &isofs_iget5_test, | ||
1400 | &isofs_iget5_set, | ||
1401 | &data); | ||
1402 | 1387 | ||
1403 | if (inode && (inode->i_state & I_NEW)) { | 1388 | if (inode && (inode->i_state & I_NEW)) { |
1404 | sb->s_op->read_inode(inode); | 1389 | sb->s_op->read_inode(inode); |
@@ -1408,36 +1393,6 @@ struct inode *isofs_iget(struct super_block *sb, | |||
1408 | return inode; | 1393 | return inode; |
1409 | } | 1394 | } |
1410 | 1395 | ||
1411 | #ifdef LEAK_CHECK | ||
1412 | #undef malloc | ||
1413 | #undef free_s | ||
1414 | #undef sb_bread | ||
1415 | #undef brelse | ||
1416 | |||
1417 | void * leak_check_malloc(unsigned int size){ | ||
1418 | void * tmp; | ||
1419 | check_malloc++; | ||
1420 | tmp = kmalloc(size, GFP_KERNEL); | ||
1421 | return tmp; | ||
1422 | } | ||
1423 | |||
1424 | void leak_check_free_s(void * obj, int size){ | ||
1425 | check_malloc--; | ||
1426 | return kfree(obj); | ||
1427 | } | ||
1428 | |||
1429 | struct buffer_head * leak_check_bread(struct super_block *sb, int block){ | ||
1430 | check_bread++; | ||
1431 | return sb_bread(sb, block); | ||
1432 | } | ||
1433 | |||
1434 | void leak_check_brelse(struct buffer_head * bh){ | ||
1435 | check_bread--; | ||
1436 | return brelse(bh); | ||
1437 | } | ||
1438 | |||
1439 | #endif | ||
1440 | |||
1441 | static struct super_block *isofs_get_sb(struct file_system_type *fs_type, | 1396 | static struct super_block *isofs_get_sb(struct file_system_type *fs_type, |
1442 | int flags, const char *dev_name, void *data) | 1397 | int flags, const char *dev_name, void *data) |
1443 | { | 1398 | { |