diff options
Diffstat (limited to 'fs/fat/inode.c')
-rw-r--r-- | fs/fat/inode.c | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index b3d290c1b513..c2973ea5df9a 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -459,37 +459,11 @@ static void fat_evict_inode(struct inode *inode) | |||
459 | fat_detach(inode); | 459 | fat_detach(inode); |
460 | } | 460 | } |
461 | 461 | ||
462 | static void fat_write_super(struct super_block *sb) | ||
463 | { | ||
464 | lock_super(sb); | ||
465 | sb->s_dirt = 0; | ||
466 | |||
467 | if (!(sb->s_flags & MS_RDONLY)) | ||
468 | fat_clusters_flush(sb); | ||
469 | unlock_super(sb); | ||
470 | } | ||
471 | |||
472 | static int fat_sync_fs(struct super_block *sb, int wait) | ||
473 | { | ||
474 | int err = 0; | ||
475 | |||
476 | if (sb->s_dirt) { | ||
477 | lock_super(sb); | ||
478 | sb->s_dirt = 0; | ||
479 | err = fat_clusters_flush(sb); | ||
480 | unlock_super(sb); | ||
481 | } | ||
482 | |||
483 | return err; | ||
484 | } | ||
485 | |||
486 | static void fat_put_super(struct super_block *sb) | 462 | static void fat_put_super(struct super_block *sb) |
487 | { | 463 | { |
488 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | 464 | struct msdos_sb_info *sbi = MSDOS_SB(sb); |
489 | 465 | ||
490 | if (sb->s_dirt) | 466 | iput(sbi->fsinfo_inode); |
491 | fat_write_super(sb); | ||
492 | |||
493 | iput(sbi->fat_inode); | 467 | iput(sbi->fat_inode); |
494 | 468 | ||
495 | unload_nls(sbi->nls_disk); | 469 | unload_nls(sbi->nls_disk); |
@@ -661,7 +635,18 @@ retry: | |||
661 | 635 | ||
662 | static int fat_write_inode(struct inode *inode, struct writeback_control *wbc) | 636 | static int fat_write_inode(struct inode *inode, struct writeback_control *wbc) |
663 | { | 637 | { |
664 | return __fat_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL); | 638 | int err; |
639 | |||
640 | if (inode->i_ino == MSDOS_FSINFO_INO) { | ||
641 | struct super_block *sb = inode->i_sb; | ||
642 | |||
643 | lock_super(sb); | ||
644 | err = fat_clusters_flush(sb); | ||
645 | unlock_super(sb); | ||
646 | } else | ||
647 | err = __fat_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL); | ||
648 | |||
649 | return err; | ||
665 | } | 650 | } |
666 | 651 | ||
667 | int fat_sync_inode(struct inode *inode) | 652 | int fat_sync_inode(struct inode *inode) |
@@ -678,8 +663,6 @@ static const struct super_operations fat_sops = { | |||
678 | .write_inode = fat_write_inode, | 663 | .write_inode = fat_write_inode, |
679 | .evict_inode = fat_evict_inode, | 664 | .evict_inode = fat_evict_inode, |
680 | .put_super = fat_put_super, | 665 | .put_super = fat_put_super, |
681 | .write_super = fat_write_super, | ||
682 | .sync_fs = fat_sync_fs, | ||
683 | .statfs = fat_statfs, | 666 | .statfs = fat_statfs, |
684 | .remount_fs = fat_remount, | 667 | .remount_fs = fat_remount, |
685 | 668 | ||
@@ -1244,6 +1227,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1244 | void (*setup)(struct super_block *)) | 1227 | void (*setup)(struct super_block *)) |
1245 | { | 1228 | { |
1246 | struct inode *root_inode = NULL, *fat_inode = NULL; | 1229 | struct inode *root_inode = NULL, *fat_inode = NULL; |
1230 | struct inode *fsinfo_inode = NULL; | ||
1247 | struct buffer_head *bh; | 1231 | struct buffer_head *bh; |
1248 | struct fat_boot_sector *b; | 1232 | struct fat_boot_sector *b; |
1249 | struct msdos_sb_info *sbi; | 1233 | struct msdos_sb_info *sbi; |
@@ -1490,6 +1474,14 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1490 | goto out_fail; | 1474 | goto out_fail; |
1491 | MSDOS_I(fat_inode)->i_pos = 0; | 1475 | MSDOS_I(fat_inode)->i_pos = 0; |
1492 | sbi->fat_inode = fat_inode; | 1476 | sbi->fat_inode = fat_inode; |
1477 | |||
1478 | fsinfo_inode = new_inode(sb); | ||
1479 | if (!fsinfo_inode) | ||
1480 | goto out_fail; | ||
1481 | fsinfo_inode->i_ino = MSDOS_FSINFO_INO; | ||
1482 | sbi->fsinfo_inode = fsinfo_inode; | ||
1483 | insert_inode_hash(fsinfo_inode); | ||
1484 | |||
1493 | root_inode = new_inode(sb); | 1485 | root_inode = new_inode(sb); |
1494 | if (!root_inode) | 1486 | if (!root_inode) |
1495 | goto out_fail; | 1487 | goto out_fail; |
@@ -1516,6 +1508,8 @@ out_invalid: | |||
1516 | fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem"); | 1508 | fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem"); |
1517 | 1509 | ||
1518 | out_fail: | 1510 | out_fail: |
1511 | if (fsinfo_inode) | ||
1512 | iput(fsinfo_inode); | ||
1519 | if (fat_inode) | 1513 | if (fat_inode) |
1520 | iput(fat_inode); | 1514 | iput(fat_inode); |
1521 | unload_nls(sbi->nls_io); | 1515 | unload_nls(sbi->nls_io); |