Commit a6bf6b21 authored by OGAWA Hirofumi's avatar OGAWA Hirofumi Committed by Linus Torvalds

[PATCH] fat: move fat_clusters_flush() to write_super()

It is overkill to update the FS_INFO whenever modifying
prev_free/free_clusters, because those are just a hint.

So, this patch uses ->write_super() for updating FS_INFO instead.
Signed-off-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9ded96f2
...@@ -476,6 +476,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) ...@@ -476,6 +476,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster)
sbi->prev_free = entry; sbi->prev_free = entry;
if (sbi->free_clusters != -1) if (sbi->free_clusters != -1)
sbi->free_clusters--; sbi->free_clusters--;
sb->s_dirt = 1;
cluster[idx_clus] = entry; cluster[idx_clus] = entry;
idx_clus++; idx_clus++;
...@@ -496,6 +497,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) ...@@ -496,6 +497,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster)
/* Couldn't allocate the free entries */ /* Couldn't allocate the free entries */
sbi->free_clusters = 0; sbi->free_clusters = 0;
sb->s_dirt = 1;
err = -ENOSPC; err = -ENOSPC;
out: out:
...@@ -509,7 +511,6 @@ out: ...@@ -509,7 +511,6 @@ out:
} }
for (i = 0; i < nr_bhs; i++) for (i = 0; i < nr_bhs; i++)
brelse(bhs[i]); brelse(bhs[i]);
fat_clusters_flush(sb);
if (err && idx_clus) if (err && idx_clus)
fat_free_clusters(inode, cluster[0]); fat_free_clusters(inode, cluster[0]);
...@@ -542,8 +543,10 @@ int fat_free_clusters(struct inode *inode, int cluster) ...@@ -542,8 +543,10 @@ int fat_free_clusters(struct inode *inode, int cluster)
} }
ops->ent_put(&fatent, FAT_ENT_FREE); ops->ent_put(&fatent, FAT_ENT_FREE);
if (sbi->free_clusters != -1) if (sbi->free_clusters != -1) {
sbi->free_clusters++; sbi->free_clusters++;
sb->s_dirt = 1;
}
if (nr_bhs + fatent.nr_bhs > MAX_BUF_PER_PAGE) { if (nr_bhs + fatent.nr_bhs > MAX_BUF_PER_PAGE) {
if (sb->s_flags & MS_SYNCHRONOUS) { if (sb->s_flags & MS_SYNCHRONOUS) {
...@@ -605,6 +608,7 @@ int fat_count_free_clusters(struct super_block *sb) ...@@ -605,6 +608,7 @@ int fat_count_free_clusters(struct super_block *sb)
} while (fat_ent_next(sbi, &fatent)); } while (fat_ent_next(sbi, &fatent));
} }
sbi->free_clusters = free; sbi->free_clusters = free;
sb->s_dirt = 1;
fatent_brelse(&fatent); fatent_brelse(&fatent);
out: out:
unlock_fat(sbi); unlock_fat(sbi);
......
...@@ -374,12 +374,17 @@ static void fat_clear_inode(struct inode *inode) ...@@ -374,12 +374,17 @@ static void fat_clear_inode(struct inode *inode)
unlock_kernel(); unlock_kernel();
} }
static void fat_put_super(struct super_block *sb) static void fat_write_super(struct super_block *sb)
{ {
struct msdos_sb_info *sbi = MSDOS_SB(sb); sb->s_dirt = 0;
if (!(sb->s_flags & MS_RDONLY)) if (!(sb->s_flags & MS_RDONLY))
fat_clusters_flush(sb); fat_clusters_flush(sb);
}
static void fat_put_super(struct super_block *sb)
{
struct msdos_sb_info *sbi = MSDOS_SB(sb);
if (sbi->nls_disk) { if (sbi->nls_disk) {
unload_nls(sbi->nls_disk); unload_nls(sbi->nls_disk);
...@@ -546,6 +551,7 @@ static struct super_operations fat_sops = { ...@@ -546,6 +551,7 @@ static struct super_operations fat_sops = {
.write_inode = fat_write_inode, .write_inode = fat_write_inode,
.delete_inode = fat_delete_inode, .delete_inode = fat_delete_inode,
.put_super = fat_put_super, .put_super = fat_put_super,
.write_super = fat_write_super,
.statfs = fat_statfs, .statfs = fat_statfs,
.clear_inode = fat_clear_inode, .clear_inode = fat_clear_inode,
.remount_fs = fat_remount, .remount_fs = fat_remount,
......
...@@ -67,8 +67,6 @@ void fat_clusters_flush(struct super_block *sb) ...@@ -67,8 +67,6 @@ void fat_clusters_flush(struct super_block *sb)
if (sbi->prev_free != -1) if (sbi->prev_free != -1)
fsinfo->next_cluster = cpu_to_le32(sbi->prev_free); fsinfo->next_cluster = cpu_to_le32(sbi->prev_free);
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
if (sb->s_flags & MS_SYNCHRONOUS)
sync_dirty_buffer(bh);
} }
brelse(bh); brelse(bh);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment