diff options
Diffstat (limited to 'fs/fat/fatent.c')
-rw-r--r-- | fs/fat/fatent.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c index 5fb366992b73..13ab763cc510 100644 --- a/fs/fat/fatent.c +++ b/fs/fat/fatent.c | |||
@@ -450,7 +450,8 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) | |||
450 | BUG_ON(nr_cluster > (MAX_BUF_PER_PAGE / 2)); /* fixed limit */ | 450 | BUG_ON(nr_cluster > (MAX_BUF_PER_PAGE / 2)); /* fixed limit */ |
451 | 451 | ||
452 | lock_fat(sbi); | 452 | lock_fat(sbi); |
453 | if (sbi->free_clusters != -1 && sbi->free_clusters < nr_cluster) { | 453 | if (sbi->free_clusters != -1 && sbi->free_clus_valid && |
454 | sbi->free_clusters < nr_cluster) { | ||
454 | unlock_fat(sbi); | 455 | unlock_fat(sbi); |
455 | return -ENOSPC; | 456 | return -ENOSPC; |
456 | } | 457 | } |
@@ -504,6 +505,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) | |||
504 | 505 | ||
505 | /* Couldn't allocate the free entries */ | 506 | /* Couldn't allocate the free entries */ |
506 | sbi->free_clusters = 0; | 507 | sbi->free_clusters = 0; |
508 | sbi->free_clus_valid = 1; | ||
507 | sb->s_dirt = 1; | 509 | sb->s_dirt = 1; |
508 | err = -ENOSPC; | 510 | err = -ENOSPC; |
509 | 511 | ||
@@ -583,8 +585,6 @@ error: | |||
583 | brelse(bhs[i]); | 585 | brelse(bhs[i]); |
584 | unlock_fat(sbi); | 586 | unlock_fat(sbi); |
585 | 587 | ||
586 | fat_clusters_flush(sb); | ||
587 | |||
588 | return err; | 588 | return err; |
589 | } | 589 | } |
590 | 590 | ||
@@ -615,7 +615,7 @@ int fat_count_free_clusters(struct super_block *sb) | |||
615 | int err = 0, free; | 615 | int err = 0, free; |
616 | 616 | ||
617 | lock_fat(sbi); | 617 | lock_fat(sbi); |
618 | if (sbi->free_clusters != -1) | 618 | if (sbi->free_clusters != -1 && sbi->free_clus_valid) |
619 | goto out; | 619 | goto out; |
620 | 620 | ||
621 | reada_blocks = FAT_READA_SIZE >> sb->s_blocksize_bits; | 621 | reada_blocks = FAT_READA_SIZE >> sb->s_blocksize_bits; |
@@ -643,6 +643,7 @@ int fat_count_free_clusters(struct super_block *sb) | |||
643 | } while (fat_ent_next(sbi, &fatent)); | 643 | } while (fat_ent_next(sbi, &fatent)); |
644 | } | 644 | } |
645 | sbi->free_clusters = free; | 645 | sbi->free_clusters = free; |
646 | sbi->free_clus_valid = 1; | ||
646 | sb->s_dirt = 1; | 647 | sb->s_dirt = 1; |
647 | fatent_brelse(&fatent); | 648 | fatent_brelse(&fatent); |
648 | out: | 649 | out: |