diff options
Diffstat (limited to 'fs/fat/fatent.c')
-rw-r--r-- | fs/fat/fatent.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c index 5fb366992b73..c7c8ab2209e1 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 | ||
@@ -615,7 +617,7 @@ int fat_count_free_clusters(struct super_block *sb) | |||
615 | int err = 0, free; | 617 | int err = 0, free; |
616 | 618 | ||
617 | lock_fat(sbi); | 619 | lock_fat(sbi); |
618 | if (sbi->free_clusters != -1) | 620 | if (sbi->free_clusters != -1 && sbi->free_clus_valid) |
619 | goto out; | 621 | goto out; |
620 | 622 | ||
621 | reada_blocks = FAT_READA_SIZE >> sb->s_blocksize_bits; | 623 | reada_blocks = FAT_READA_SIZE >> sb->s_blocksize_bits; |
@@ -643,6 +645,7 @@ int fat_count_free_clusters(struct super_block *sb) | |||
643 | } while (fat_ent_next(sbi, &fatent)); | 645 | } while (fat_ent_next(sbi, &fatent)); |
644 | } | 646 | } |
645 | sbi->free_clusters = free; | 647 | sbi->free_clusters = free; |
648 | sbi->free_clus_valid = 1; | ||
646 | sb->s_dirt = 1; | 649 | sb->s_dirt = 1; |
647 | fatent_brelse(&fatent); | 650 | fatent_brelse(&fatent); |
648 | out: | 651 | out: |