aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/fat/fatent.c8
-rw-r--r--fs/fat/inode.c10
-rw-r--r--fs/fat/misc.c2
3 files changed, 14 insertions, 6 deletions
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
index 4164cd54c4d1..20a22875f0a1 100644
--- a/fs/fat/fatent.c
+++ b/fs/fat/fatent.c
@@ -476,6 +476,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster)
476 sbi->prev_free = entry; 476 sbi->prev_free = entry;
477 if (sbi->free_clusters != -1) 477 if (sbi->free_clusters != -1)
478 sbi->free_clusters--; 478 sbi->free_clusters--;
479 sb->s_dirt = 1;
479 480
480 cluster[idx_clus] = entry; 481 cluster[idx_clus] = entry;
481 idx_clus++; 482 idx_clus++;
@@ -496,6 +497,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster)
496 497
497 /* Couldn't allocate the free entries */ 498 /* Couldn't allocate the free entries */
498 sbi->free_clusters = 0; 499 sbi->free_clusters = 0;
500 sb->s_dirt = 1;
499 err = -ENOSPC; 501 err = -ENOSPC;
500 502
501out: 503out:
@@ -509,7 +511,6 @@ out:
509 } 511 }
510 for (i = 0; i < nr_bhs; i++) 512 for (i = 0; i < nr_bhs; i++)
511 brelse(bhs[i]); 513 brelse(bhs[i]);
512 fat_clusters_flush(sb);
513 514
514 if (err && idx_clus) 515 if (err && idx_clus)
515 fat_free_clusters(inode, cluster[0]); 516 fat_free_clusters(inode, cluster[0]);
@@ -542,8 +543,10 @@ int fat_free_clusters(struct inode *inode, int cluster)
542 } 543 }
543 544
544 ops->ent_put(&fatent, FAT_ENT_FREE); 545 ops->ent_put(&fatent, FAT_ENT_FREE);
545 if (sbi->free_clusters != -1) 546 if (sbi->free_clusters != -1) {
546 sbi->free_clusters++; 547 sbi->free_clusters++;
548 sb->s_dirt = 1;
549 }
547 550
548 if (nr_bhs + fatent.nr_bhs > MAX_BUF_PER_PAGE) { 551 if (nr_bhs + fatent.nr_bhs > MAX_BUF_PER_PAGE) {
549 if (sb->s_flags & MS_SYNCHRONOUS) { 552 if (sb->s_flags & MS_SYNCHRONOUS) {
@@ -605,6 +608,7 @@ int fat_count_free_clusters(struct super_block *sb)
605 } while (fat_ent_next(sbi, &fatent)); 608 } while (fat_ent_next(sbi, &fatent));
606 } 609 }
607 sbi->free_clusters = free; 610 sbi->free_clusters = free;
611 sb->s_dirt = 1;
608 fatent_brelse(&fatent); 612 fatent_brelse(&fatent);
609out: 613out:
610 unlock_fat(sbi); 614 unlock_fat(sbi);
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index a0f9b9fe1307..897312616b0a 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -374,12 +374,17 @@ static void fat_clear_inode(struct inode *inode)
374 unlock_kernel(); 374 unlock_kernel();
375} 375}
376 376
377static void fat_put_super(struct super_block *sb) 377static void fat_write_super(struct super_block *sb)
378{ 378{
379 struct msdos_sb_info *sbi = MSDOS_SB(sb); 379 sb->s_dirt = 0;
380 380
381 if (!(sb->s_flags & MS_RDONLY)) 381 if (!(sb->s_flags & MS_RDONLY))
382 fat_clusters_flush(sb); 382 fat_clusters_flush(sb);
383}
384
385static void fat_put_super(struct super_block *sb)
386{
387 struct msdos_sb_info *sbi = MSDOS_SB(sb);
383 388
384 if (sbi->nls_disk) { 389 if (sbi->nls_disk) {
385 unload_nls(sbi->nls_disk); 390 unload_nls(sbi->nls_disk);
@@ -546,6 +551,7 @@ static struct super_operations fat_sops = {
546 .write_inode = fat_write_inode, 551 .write_inode = fat_write_inode,
547 .delete_inode = fat_delete_inode, 552 .delete_inode = fat_delete_inode,
548 .put_super = fat_put_super, 553 .put_super = fat_put_super,
554 .write_super = fat_write_super,
549 .statfs = fat_statfs, 555 .statfs = fat_statfs,
550 .clear_inode = fat_clear_inode, 556 .clear_inode = fat_clear_inode,
551 .remount_fs = fat_remount, 557 .remount_fs = fat_remount,
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index 2a0df2122f5d..9b592e37e259 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -67,8 +67,6 @@ void fat_clusters_flush(struct super_block *sb)
67 if (sbi->prev_free != -1) 67 if (sbi->prev_free != -1)
68 fsinfo->next_cluster = cpu_to_le32(sbi->prev_free); 68 fsinfo->next_cluster = cpu_to_le32(sbi->prev_free);
69 mark_buffer_dirty(bh); 69 mark_buffer_dirty(bh);
70 if (sb->s_flags & MS_SYNCHRONOUS)
71 sync_dirty_buffer(bh);
72 } 70 }
73 brelse(bh); 71 brelse(bh);
74} 72}