aboutsummaryrefslogtreecommitdiffstats
path: root/fs/omfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/omfs/inode.c')
-rw-r--r--fs/omfs/inode.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index 56121debc22b..14a22863291a 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -19,6 +19,15 @@ MODULE_AUTHOR("Bob Copeland <me@bobcopeland.com>");
19MODULE_DESCRIPTION("OMFS (ReplayTV/Karma) Filesystem for Linux"); 19MODULE_DESCRIPTION("OMFS (ReplayTV/Karma) Filesystem for Linux");
20MODULE_LICENSE("GPL"); 20MODULE_LICENSE("GPL");
21 21
22struct buffer_head *omfs_bread(struct super_block *sb, sector_t block)
23{
24 struct omfs_sb_info *sbi = OMFS_SB(sb);
25 if (block >= sbi->s_num_blocks)
26 return NULL;
27
28 return sb_bread(sb, clus_to_blk(sbi, block));
29}
30
22struct inode *omfs_new_inode(struct inode *dir, int mode) 31struct inode *omfs_new_inode(struct inode *dir, int mode)
23{ 32{
24 struct inode *inode; 33 struct inode *inode;
@@ -93,15 +102,13 @@ static int __omfs_write_inode(struct inode *inode, int wait)
93 struct omfs_inode *oi; 102 struct omfs_inode *oi;
94 struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb); 103 struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
95 struct buffer_head *bh, *bh2; 104 struct buffer_head *bh, *bh2;
96 unsigned int block;
97 u64 ctime; 105 u64 ctime;
98 int i; 106 int i;
99 int ret = -EIO; 107 int ret = -EIO;
100 int sync_failed = 0; 108 int sync_failed = 0;
101 109
102 /* get current inode since we may have written sibling ptrs etc. */ 110 /* get current inode since we may have written sibling ptrs etc. */
103 block = clus_to_blk(sbi, inode->i_ino); 111 bh = omfs_bread(inode->i_sb, inode->i_ino);
104 bh = sb_bread(inode->i_sb, block);
105 if (!bh) 112 if (!bh)
106 goto out; 113 goto out;
107 114
@@ -140,8 +147,7 @@ static int __omfs_write_inode(struct inode *inode, int wait)
140 147
141 /* if mirroring writes, copy to next fsblock */ 148 /* if mirroring writes, copy to next fsblock */
142 for (i = 1; i < sbi->s_mirrors; i++) { 149 for (i = 1; i < sbi->s_mirrors; i++) {
143 bh2 = sb_bread(inode->i_sb, block + i * 150 bh2 = omfs_bread(inode->i_sb, inode->i_ino + i);
144 (sbi->s_blocksize / sbi->s_sys_blocksize));
145 if (!bh2) 151 if (!bh2)
146 goto out_brelse; 152 goto out_brelse;
147 153
@@ -196,7 +202,6 @@ struct inode *omfs_iget(struct super_block *sb, ino_t ino)
196 struct omfs_sb_info *sbi = OMFS_SB(sb); 202 struct omfs_sb_info *sbi = OMFS_SB(sb);
197 struct omfs_inode *oi; 203 struct omfs_inode *oi;
198 struct buffer_head *bh; 204 struct buffer_head *bh;
199 unsigned int block;
200 u64 ctime; 205 u64 ctime;
201 unsigned long nsecs; 206 unsigned long nsecs;
202 struct inode *inode; 207 struct inode *inode;
@@ -207,8 +212,7 @@ struct inode *omfs_iget(struct super_block *sb, ino_t ino)
207 if (!(inode->i_state & I_NEW)) 212 if (!(inode->i_state & I_NEW))
208 return inode; 213 return inode;
209 214
210 block = clus_to_blk(sbi, ino); 215 bh = omfs_bread(inode->i_sb, ino);
211 bh = sb_bread(inode->i_sb, block);
212 if (!bh) 216 if (!bh)
213 goto iget_failed; 217 goto iget_failed;
214 218
@@ -322,6 +326,9 @@ static int omfs_get_imap(struct super_block *sb)
322 goto nomem; 326 goto nomem;
323 327
324 block = clus_to_blk(sbi, sbi->s_bitmap_ino); 328 block = clus_to_blk(sbi, sbi->s_bitmap_ino);
329 if (block >= sbi->s_num_blocks)
330 goto nomem;
331
325 ptr = sbi->s_imap; 332 ptr = sbi->s_imap;
326 for (count = bitmap_size; count > 0; count -= sb->s_blocksize) { 333 for (count = bitmap_size; count > 0; count -= sb->s_blocksize) {
327 bh = sb_bread(sb, block++); 334 bh = sb_bread(sb, block++);
@@ -420,7 +427,6 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
420 struct omfs_root_block *omfs_rb; 427 struct omfs_root_block *omfs_rb;
421 struct omfs_sb_info *sbi; 428 struct omfs_sb_info *sbi;
422 struct inode *root; 429 struct inode *root;
423 sector_t start;
424 int ret = -EINVAL; 430 int ret = -EINVAL;
425 431
426 save_mount_options(sb, (char *) data); 432 save_mount_options(sb, (char *) data);
@@ -489,8 +495,7 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
489 sbi->s_block_shift = get_bitmask_order(sbi->s_blocksize) - 495 sbi->s_block_shift = get_bitmask_order(sbi->s_blocksize) -
490 get_bitmask_order(sbi->s_sys_blocksize); 496 get_bitmask_order(sbi->s_sys_blocksize);
491 497
492 start = clus_to_blk(sbi, be64_to_cpu(omfs_sb->s_root_block)); 498 bh2 = omfs_bread(sb, be64_to_cpu(omfs_sb->s_root_block));
493 bh2 = sb_bread(sb, start);
494 if (!bh2) 499 if (!bh2)
495 goto out_brelse_bh; 500 goto out_brelse_bh;
496 501
@@ -507,6 +512,21 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
507 goto out_brelse_bh2; 512 goto out_brelse_bh2;
508 } 513 }
509 514
515 if (sbi->s_bitmap_ino != ~0ULL &&
516 sbi->s_bitmap_ino > sbi->s_num_blocks) {
517 printk(KERN_ERR "omfs: free space bitmap location is corrupt "
518 "(%llx, total blocks %llx)\n",
519 (unsigned long long) sbi->s_bitmap_ino,
520 (unsigned long long) sbi->s_num_blocks);
521 goto out_brelse_bh2;
522 }
523 if (sbi->s_clustersize < 1 ||
524 sbi->s_clustersize > OMFS_MAX_CLUSTER_SIZE) {
525 printk(KERN_ERR "omfs: cluster size out of range (%d)",
526 sbi->s_clustersize);
527 goto out_brelse_bh2;
528 }
529
510 ret = omfs_get_imap(sb); 530 ret = omfs_get_imap(sb);
511 if (ret) 531 if (ret)
512 goto out_brelse_bh2; 532 goto out_brelse_bh2;
@@ -532,6 +552,8 @@ out_brelse_bh2:
532out_brelse_bh: 552out_brelse_bh:
533 brelse(bh); 553 brelse(bh);
534end: 554end:
555 if (ret)
556 kfree(sbi);
535 return ret; 557 return ret;
536} 558}
537 559