diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2009-09-19 12:31:58 -0400 |
---|---|---|
committer | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2009-09-19 12:35:25 -0400 |
commit | ed248b290da7297c9b9a3ff180f5eee4db016224 (patch) | |
tree | 86793695dccd8ff8e6973f546da0020964717534 /fs/fat | |
parent | 955234755ce4a2c33cfc558912aa8f2148cc1fc6 (diff) |
fat: Check s_dirt in fat_sync_fs()
If we didn't check sb->s_dirt, it will update the FSINFO
unconditionally. It will reduce the filetime of flash base device.
So, this checks sb->s_dirt. sb->s_dirt is racy, however FSINFO is just
hint. So even if there is race, and we hit it, it would not become big
problem.
And this also is as workaround of suspend problem.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Diffstat (limited to 'fs/fat')
-rw-r--r-- | fs/fat/fat.h | 2 | ||||
-rw-r--r-- | fs/fat/inode.c | 14 | ||||
-rw-r--r-- | fs/fat/misc.c | 8 |
3 files changed, 15 insertions, 9 deletions
diff --git a/fs/fat/fat.h b/fs/fat/fat.h index adb0e72a176..7db0979c6b7 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h | |||
@@ -323,7 +323,7 @@ extern int fat_flush_inodes(struct super_block *sb, struct inode *i1, | |||
323 | /* fat/misc.c */ | 323 | /* fat/misc.c */ |
324 | extern void fat_fs_error(struct super_block *s, const char *fmt, ...) | 324 | extern void fat_fs_error(struct super_block *s, const char *fmt, ...) |
325 | __attribute__ ((format (printf, 2, 3))) __cold; | 325 | __attribute__ ((format (printf, 2, 3))) __cold; |
326 | extern void fat_clusters_flush(struct super_block *sb); | 326 | extern int fat_clusters_flush(struct super_block *sb); |
327 | extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster); | 327 | extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster); |
328 | extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts, | 328 | extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts, |
329 | __le16 __time, __le16 __date, u8 time_cs); | 329 | __le16 __time, __le16 __date, u8 time_cs); |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 63a5c1a4ee6..a8a3afec875 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -451,12 +451,16 @@ static void fat_write_super(struct super_block *sb) | |||
451 | 451 | ||
452 | static int fat_sync_fs(struct super_block *sb, int wait) | 452 | static int fat_sync_fs(struct super_block *sb, int wait) |
453 | { | 453 | { |
454 | lock_super(sb); | 454 | int err = 0; |
455 | fat_clusters_flush(sb); | ||
456 | sb->s_dirt = 0; | ||
457 | unlock_super(sb); | ||
458 | 455 | ||
459 | return 0; | 456 | if (sb->s_dirt) { |
457 | lock_super(sb); | ||
458 | sb->s_dirt = 0; | ||
459 | err = fat_clusters_flush(sb); | ||
460 | unlock_super(sb); | ||
461 | } | ||
462 | |||
463 | return err; | ||
460 | } | 464 | } |
461 | 465 | ||
462 | static void fat_put_super(struct super_block *sb) | 466 | static void fat_put_super(struct super_block *sb) |
diff --git a/fs/fat/misc.c b/fs/fat/misc.c index a6c20473dfd..63785a15029 100644 --- a/fs/fat/misc.c +++ b/fs/fat/misc.c | |||
@@ -43,19 +43,19 @@ EXPORT_SYMBOL_GPL(fat_fs_error); | |||
43 | 43 | ||
44 | /* Flushes the number of free clusters on FAT32 */ | 44 | /* Flushes the number of free clusters on FAT32 */ |
45 | /* XXX: Need to write one per FSINFO block. Currently only writes 1 */ | 45 | /* XXX: Need to write one per FSINFO block. Currently only writes 1 */ |
46 | void fat_clusters_flush(struct super_block *sb) | 46 | int fat_clusters_flush(struct super_block *sb) |
47 | { | 47 | { |
48 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | 48 | struct msdos_sb_info *sbi = MSDOS_SB(sb); |
49 | struct buffer_head *bh; | 49 | struct buffer_head *bh; |
50 | struct fat_boot_fsinfo *fsinfo; | 50 | struct fat_boot_fsinfo *fsinfo; |
51 | 51 | ||
52 | if (sbi->fat_bits != 32) | 52 | if (sbi->fat_bits != 32) |
53 | return; | 53 | return 0; |
54 | 54 | ||
55 | bh = sb_bread(sb, sbi->fsinfo_sector); | 55 | bh = sb_bread(sb, sbi->fsinfo_sector); |
56 | if (bh == NULL) { | 56 | if (bh == NULL) { |
57 | printk(KERN_ERR "FAT: bread failed in fat_clusters_flush\n"); | 57 | printk(KERN_ERR "FAT: bread failed in fat_clusters_flush\n"); |
58 | return; | 58 | return -EIO; |
59 | } | 59 | } |
60 | 60 | ||
61 | fsinfo = (struct fat_boot_fsinfo *)bh->b_data; | 61 | fsinfo = (struct fat_boot_fsinfo *)bh->b_data; |
@@ -74,6 +74,8 @@ void fat_clusters_flush(struct super_block *sb) | |||
74 | mark_buffer_dirty(bh); | 74 | mark_buffer_dirty(bh); |
75 | } | 75 | } |
76 | brelse(bh); | 76 | brelse(bh); |
77 | |||
78 | return 0; | ||
77 | } | 79 | } |
78 | 80 | ||
79 | /* | 81 | /* |