diff options
Diffstat (limited to 'fs/bfs/inode.c')
-rw-r--r-- | fs/bfs/inode.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index 6f60336c6628..f22a7d3dc362 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/smp_lock.h> | 15 | #include <linux/smp_lock.h> |
16 | #include <linux/buffer_head.h> | 16 | #include <linux/buffer_head.h> |
17 | #include <linux/vfs.h> | 17 | #include <linux/vfs.h> |
18 | #include <linux/writeback.h> | ||
18 | #include <asm/uaccess.h> | 19 | #include <asm/uaccess.h> |
19 | #include "bfs.h" | 20 | #include "bfs.h" |
20 | 21 | ||
@@ -98,7 +99,7 @@ error: | |||
98 | return ERR_PTR(-EIO); | 99 | return ERR_PTR(-EIO); |
99 | } | 100 | } |
100 | 101 | ||
101 | static int bfs_write_inode(struct inode *inode, int wait) | 102 | static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc) |
102 | { | 103 | { |
103 | struct bfs_sb_info *info = BFS_SB(inode->i_sb); | 104 | struct bfs_sb_info *info = BFS_SB(inode->i_sb); |
104 | unsigned int ino = (u16)inode->i_ino; | 105 | unsigned int ino = (u16)inode->i_ino; |
@@ -147,7 +148,7 @@ static int bfs_write_inode(struct inode *inode, int wait) | |||
147 | di->i_eoffset = cpu_to_le32(i_sblock * BFS_BSIZE + inode->i_size - 1); | 148 | di->i_eoffset = cpu_to_le32(i_sblock * BFS_BSIZE + inode->i_size - 1); |
148 | 149 | ||
149 | mark_buffer_dirty(bh); | 150 | mark_buffer_dirty(bh); |
150 | if (wait) { | 151 | if (wbc->sync_mode == WB_SYNC_ALL) { |
151 | sync_dirty_buffer(bh); | 152 | sync_dirty_buffer(bh); |
152 | if (buffer_req(bh) && !buffer_uptodate(bh)) | 153 | if (buffer_req(bh) && !buffer_uptodate(bh)) |
153 | err = -EIO; | 154 | err = -EIO; |
@@ -353,35 +354,35 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
353 | struct inode *inode; | 354 | struct inode *inode; |
354 | unsigned i, imap_len; | 355 | unsigned i, imap_len; |
355 | struct bfs_sb_info *info; | 356 | struct bfs_sb_info *info; |
356 | long ret = -EINVAL; | 357 | int ret = -EINVAL; |
357 | unsigned long i_sblock, i_eblock, i_eoff, s_size; | 358 | unsigned long i_sblock, i_eblock, i_eoff, s_size; |
358 | 359 | ||
359 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 360 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
360 | if (!info) | 361 | if (!info) |
361 | return -ENOMEM; | 362 | return -ENOMEM; |
363 | mutex_init(&info->bfs_lock); | ||
362 | s->s_fs_info = info; | 364 | s->s_fs_info = info; |
363 | 365 | ||
364 | sb_set_blocksize(s, BFS_BSIZE); | 366 | sb_set_blocksize(s, BFS_BSIZE); |
365 | 367 | ||
366 | bh = sb_bread(s, 0); | 368 | info->si_sbh = sb_bread(s, 0); |
367 | if(!bh) | 369 | if (!info->si_sbh) |
368 | goto out; | 370 | goto out; |
369 | bfs_sb = (struct bfs_super_block *)bh->b_data; | 371 | bfs_sb = (struct bfs_super_block *)info->si_sbh->b_data; |
370 | if (le32_to_cpu(bfs_sb->s_magic) != BFS_MAGIC) { | 372 | if (le32_to_cpu(bfs_sb->s_magic) != BFS_MAGIC) { |
371 | if (!silent) | 373 | if (!silent) |
372 | printf("No BFS filesystem on %s (magic=%08x)\n", | 374 | printf("No BFS filesystem on %s (magic=%08x)\n", |
373 | s->s_id, le32_to_cpu(bfs_sb->s_magic)); | 375 | s->s_id, le32_to_cpu(bfs_sb->s_magic)); |
374 | goto out; | 376 | goto out1; |
375 | } | 377 | } |
376 | if (BFS_UNCLEAN(bfs_sb, s) && !silent) | 378 | if (BFS_UNCLEAN(bfs_sb, s) && !silent) |
377 | printf("%s is unclean, continuing\n", s->s_id); | 379 | printf("%s is unclean, continuing\n", s->s_id); |
378 | 380 | ||
379 | s->s_magic = BFS_MAGIC; | 381 | s->s_magic = BFS_MAGIC; |
380 | info->si_sbh = bh; | ||
381 | 382 | ||
382 | if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end)) { | 383 | if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end)) { |
383 | printf("Superblock is corrupted\n"); | 384 | printf("Superblock is corrupted\n"); |
384 | goto out; | 385 | goto out1; |
385 | } | 386 | } |
386 | 387 | ||
387 | info->si_lasti = (le32_to_cpu(bfs_sb->s_start) - BFS_BSIZE) / | 388 | info->si_lasti = (le32_to_cpu(bfs_sb->s_start) - BFS_BSIZE) / |
@@ -390,7 +391,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
390 | imap_len = (info->si_lasti / 8) + 1; | 391 | imap_len = (info->si_lasti / 8) + 1; |
391 | info->si_imap = kzalloc(imap_len, GFP_KERNEL); | 392 | info->si_imap = kzalloc(imap_len, GFP_KERNEL); |
392 | if (!info->si_imap) | 393 | if (!info->si_imap) |
393 | goto out; | 394 | goto out1; |
394 | for (i = 0; i < BFS_ROOT_INO; i++) | 395 | for (i = 0; i < BFS_ROOT_INO; i++) |
395 | set_bit(i, info->si_imap); | 396 | set_bit(i, info->si_imap); |
396 | 397 | ||
@@ -398,15 +399,13 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
398 | inode = bfs_iget(s, BFS_ROOT_INO); | 399 | inode = bfs_iget(s, BFS_ROOT_INO); |
399 | if (IS_ERR(inode)) { | 400 | if (IS_ERR(inode)) { |
400 | ret = PTR_ERR(inode); | 401 | ret = PTR_ERR(inode); |
401 | kfree(info->si_imap); | 402 | goto out2; |
402 | goto out; | ||
403 | } | 403 | } |
404 | s->s_root = d_alloc_root(inode); | 404 | s->s_root = d_alloc_root(inode); |
405 | if (!s->s_root) { | 405 | if (!s->s_root) { |
406 | iput(inode); | 406 | iput(inode); |
407 | ret = -ENOMEM; | 407 | ret = -ENOMEM; |
408 | kfree(info->si_imap); | 408 | goto out2; |
409 | goto out; | ||
410 | } | 409 | } |
411 | 410 | ||
412 | info->si_blocks = (le32_to_cpu(bfs_sb->s_end) + 1) >> BFS_BSIZE_BITS; | 411 | info->si_blocks = (le32_to_cpu(bfs_sb->s_end) + 1) >> BFS_BSIZE_BITS; |
@@ -419,10 +418,8 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
419 | bh = sb_bread(s, info->si_blocks - 1); | 418 | bh = sb_bread(s, info->si_blocks - 1); |
420 | if (!bh) { | 419 | if (!bh) { |
421 | printf("Last block not available: %lu\n", info->si_blocks - 1); | 420 | printf("Last block not available: %lu\n", info->si_blocks - 1); |
422 | iput(inode); | ||
423 | ret = -EIO; | 421 | ret = -EIO; |
424 | kfree(info->si_imap); | 422 | goto out3; |
425 | goto out; | ||
426 | } | 423 | } |
427 | brelse(bh); | 424 | brelse(bh); |
428 | 425 | ||
@@ -459,11 +456,8 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
459 | printf("Inode 0x%08x corrupted\n", i); | 456 | printf("Inode 0x%08x corrupted\n", i); |
460 | 457 | ||
461 | brelse(bh); | 458 | brelse(bh); |
462 | s->s_root = NULL; | 459 | ret = -EIO; |
463 | kfree(info->si_imap); | 460 | goto out3; |
464 | kfree(info); | ||
465 | s->s_fs_info = NULL; | ||
466 | return -EIO; | ||
467 | } | 461 | } |
468 | 462 | ||
469 | if (!di->i_ino) { | 463 | if (!di->i_ino) { |
@@ -483,11 +477,17 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
483 | s->s_dirt = 1; | 477 | s->s_dirt = 1; |
484 | } | 478 | } |
485 | dump_imap("read_super", s); | 479 | dump_imap("read_super", s); |
486 | mutex_init(&info->bfs_lock); | ||
487 | return 0; | 480 | return 0; |
488 | 481 | ||
482 | out3: | ||
483 | dput(s->s_root); | ||
484 | s->s_root = NULL; | ||
485 | out2: | ||
486 | kfree(info->si_imap); | ||
487 | out1: | ||
488 | brelse(info->si_sbh); | ||
489 | out: | 489 | out: |
490 | brelse(bh); | 490 | mutex_destroy(&info->bfs_lock); |
491 | kfree(info); | 491 | kfree(info); |
492 | s->s_fs_info = NULL; | 492 | s->s_fs_info = NULL; |
493 | return ret; | 493 | return ret; |