diff options
Diffstat (limited to 'fs/fat/fatent.c')
-rw-r--r-- | fs/fat/fatent.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c index 2e81ac0df7e2..31f08ab62c56 100644 --- a/fs/fat/fatent.c +++ b/fs/fat/fatent.c | |||
@@ -308,6 +308,16 @@ void fat_ent_access_init(struct super_block *sb) | |||
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | static void mark_fsinfo_dirty(struct super_block *sb) | ||
312 | { | ||
313 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | ||
314 | |||
315 | if (sb->s_flags & MS_RDONLY || sbi->fat_bits != 32) | ||
316 | return; | ||
317 | |||
318 | __mark_inode_dirty(sbi->fsinfo_inode, I_DIRTY_SYNC); | ||
319 | } | ||
320 | |||
311 | static inline int fat_ent_update_ptr(struct super_block *sb, | 321 | static inline int fat_ent_update_ptr(struct super_block *sb, |
312 | struct fat_entry *fatent, | 322 | struct fat_entry *fatent, |
313 | int offset, sector_t blocknr) | 323 | int offset, sector_t blocknr) |
@@ -498,7 +508,6 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) | |||
498 | sbi->prev_free = entry; | 508 | sbi->prev_free = entry; |
499 | if (sbi->free_clusters != -1) | 509 | if (sbi->free_clusters != -1) |
500 | sbi->free_clusters--; | 510 | sbi->free_clusters--; |
501 | sb->s_dirt = 1; | ||
502 | 511 | ||
503 | cluster[idx_clus] = entry; | 512 | cluster[idx_clus] = entry; |
504 | idx_clus++; | 513 | idx_clus++; |
@@ -520,11 +529,11 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) | |||
520 | /* Couldn't allocate the free entries */ | 529 | /* Couldn't allocate the free entries */ |
521 | sbi->free_clusters = 0; | 530 | sbi->free_clusters = 0; |
522 | sbi->free_clus_valid = 1; | 531 | sbi->free_clus_valid = 1; |
523 | sb->s_dirt = 1; | ||
524 | err = -ENOSPC; | 532 | err = -ENOSPC; |
525 | 533 | ||
526 | out: | 534 | out: |
527 | unlock_fat(sbi); | 535 | unlock_fat(sbi); |
536 | mark_fsinfo_dirty(sb); | ||
528 | fatent_brelse(&fatent); | 537 | fatent_brelse(&fatent); |
529 | if (!err) { | 538 | if (!err) { |
530 | if (inode_needs_sync(inode)) | 539 | if (inode_needs_sync(inode)) |
@@ -549,7 +558,7 @@ int fat_free_clusters(struct inode *inode, int cluster) | |||
549 | struct fat_entry fatent; | 558 | struct fat_entry fatent; |
550 | struct buffer_head *bhs[MAX_BUF_PER_PAGE]; | 559 | struct buffer_head *bhs[MAX_BUF_PER_PAGE]; |
551 | int i, err, nr_bhs; | 560 | int i, err, nr_bhs; |
552 | int first_cl = cluster; | 561 | int first_cl = cluster, dirty_fsinfo = 0; |
553 | 562 | ||
554 | nr_bhs = 0; | 563 | nr_bhs = 0; |
555 | fatent_init(&fatent); | 564 | fatent_init(&fatent); |
@@ -587,7 +596,7 @@ int fat_free_clusters(struct inode *inode, int cluster) | |||
587 | ops->ent_put(&fatent, FAT_ENT_FREE); | 596 | ops->ent_put(&fatent, FAT_ENT_FREE); |
588 | if (sbi->free_clusters != -1) { | 597 | if (sbi->free_clusters != -1) { |
589 | sbi->free_clusters++; | 598 | sbi->free_clusters++; |
590 | sb->s_dirt = 1; | 599 | dirty_fsinfo = 1; |
591 | } | 600 | } |
592 | 601 | ||
593 | if (nr_bhs + fatent.nr_bhs > MAX_BUF_PER_PAGE) { | 602 | if (nr_bhs + fatent.nr_bhs > MAX_BUF_PER_PAGE) { |
@@ -617,6 +626,8 @@ error: | |||
617 | for (i = 0; i < nr_bhs; i++) | 626 | for (i = 0; i < nr_bhs; i++) |
618 | brelse(bhs[i]); | 627 | brelse(bhs[i]); |
619 | unlock_fat(sbi); | 628 | unlock_fat(sbi); |
629 | if (dirty_fsinfo) | ||
630 | mark_fsinfo_dirty(sb); | ||
620 | 631 | ||
621 | return err; | 632 | return err; |
622 | } | 633 | } |
@@ -677,7 +688,7 @@ int fat_count_free_clusters(struct super_block *sb) | |||
677 | } | 688 | } |
678 | sbi->free_clusters = free; | 689 | sbi->free_clusters = free; |
679 | sbi->free_clus_valid = 1; | 690 | sbi->free_clus_valid = 1; |
680 | sb->s_dirt = 1; | 691 | mark_fsinfo_dirty(sb); |
681 | fatent_brelse(&fatent); | 692 | fatent_brelse(&fatent); |
682 | out: | 693 | out: |
683 | unlock_fat(sbi); | 694 | unlock_fat(sbi); |