aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/fat/inode.c')
-rw-r--r--fs/fat/inode.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 296785a0dec8..51a5ecf9000a 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -441,16 +441,35 @@ static void fat_clear_inode(struct inode *inode)
441 441
442static void fat_write_super(struct super_block *sb) 442static void fat_write_super(struct super_block *sb)
443{ 443{
444 lock_super(sb);
444 sb->s_dirt = 0; 445 sb->s_dirt = 0;
445 446
446 if (!(sb->s_flags & MS_RDONLY)) 447 if (!(sb->s_flags & MS_RDONLY))
447 fat_clusters_flush(sb); 448 fat_clusters_flush(sb);
449 unlock_super(sb);
450}
451
452static int fat_sync_fs(struct super_block *sb, int wait)
453{
454 lock_super(sb);
455 fat_clusters_flush(sb);
456 sb->s_dirt = 0;
457 unlock_super(sb);
458
459 return 0;
448} 460}
449 461
450static void fat_put_super(struct super_block *sb) 462static void fat_put_super(struct super_block *sb)
451{ 463{
452 struct msdos_sb_info *sbi = MSDOS_SB(sb); 464 struct msdos_sb_info *sbi = MSDOS_SB(sb);
453 465
466 lock_kernel();
467
468 if (sb->s_dirt)
469 fat_write_super(sb);
470
471 iput(sbi->fat_inode);
472
454 if (sbi->nls_disk) { 473 if (sbi->nls_disk) {
455 unload_nls(sbi->nls_disk); 474 unload_nls(sbi->nls_disk);
456 sbi->nls_disk = NULL; 475 sbi->nls_disk = NULL;
@@ -467,6 +486,8 @@ static void fat_put_super(struct super_block *sb)
467 486
468 sb->s_fs_info = NULL; 487 sb->s_fs_info = NULL;
469 kfree(sbi); 488 kfree(sbi);
489
490 unlock_kernel();
470} 491}
471 492
472static struct kmem_cache *fat_inode_cachep; 493static struct kmem_cache *fat_inode_cachep;
@@ -632,6 +653,7 @@ static const struct super_operations fat_sops = {
632 .delete_inode = fat_delete_inode, 653 .delete_inode = fat_delete_inode,
633 .put_super = fat_put_super, 654 .put_super = fat_put_super,
634 .write_super = fat_write_super, 655 .write_super = fat_write_super,
656 .sync_fs = fat_sync_fs,
635 .statfs = fat_statfs, 657 .statfs = fat_statfs,
636 .clear_inode = fat_clear_inode, 658 .clear_inode = fat_clear_inode,
637 .remount_fs = fat_remount, 659 .remount_fs = fat_remount,
@@ -1174,7 +1196,7 @@ static int fat_read_root(struct inode *inode)
1174int fat_fill_super(struct super_block *sb, void *data, int silent, 1196int fat_fill_super(struct super_block *sb, void *data, int silent,
1175 const struct inode_operations *fs_dir_inode_ops, int isvfat) 1197 const struct inode_operations *fs_dir_inode_ops, int isvfat)
1176{ 1198{
1177 struct inode *root_inode = NULL; 1199 struct inode *root_inode = NULL, *fat_inode = NULL;
1178 struct buffer_head *bh; 1200 struct buffer_head *bh;
1179 struct fat_boot_sector *b; 1201 struct fat_boot_sector *b;
1180 struct msdos_sb_info *sbi; 1202 struct msdos_sb_info *sbi;
@@ -1414,6 +1436,11 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
1414 } 1436 }
1415 1437
1416 error = -ENOMEM; 1438 error = -ENOMEM;
1439 fat_inode = new_inode(sb);
1440 if (!fat_inode)
1441 goto out_fail;
1442 MSDOS_I(fat_inode)->i_pos = 0;
1443 sbi->fat_inode = fat_inode;
1417 root_inode = new_inode(sb); 1444 root_inode = new_inode(sb);
1418 if (!root_inode) 1445 if (!root_inode)
1419 goto out_fail; 1446 goto out_fail;
@@ -1439,6 +1466,8 @@ out_invalid:
1439 " on dev %s.\n", sb->s_id); 1466 " on dev %s.\n", sb->s_id);
1440 1467
1441out_fail: 1468out_fail:
1469 if (fat_inode)
1470 iput(fat_inode);
1442 if (root_inode) 1471 if (root_inode)
1443 iput(root_inode); 1472 iput(root_inode);
1444 if (sbi->nls_io) 1473 if (sbi->nls_io)