diff options
author | Chris Mason <mason@suse.com> | 2006-09-29 05:00:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-29 12:18:12 -0400 |
commit | ae78bf9c4f5fde3c67e2829505f195d7347ce3e4 (patch) | |
tree | b9376237e596ed7e95db35b9ccf1ad3177b10460 /fs/fat/inode.c | |
parent | 6b77df08a36d989f7dd00ccb6a026a0e96170d16 (diff) |
[PATCH] add -o flush for fat
Fat is commonly used on removable media. Mounting with -o flush tells the
FS to write things to disk as quickly as possible. It is like -o sync, but
much faster (and not as safe).
Signed-off-by: Chris Mason <mason@suse.com>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/fat/inode.c')
-rw-r--r-- | fs/fat/inode.c | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index ab96ae823753..045738032a83 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/vfs.h> | 24 | #include <linux/vfs.h> |
25 | #include <linux/parser.h> | 25 | #include <linux/parser.h> |
26 | #include <linux/uio.h> | 26 | #include <linux/uio.h> |
27 | #include <linux/writeback.h> | ||
27 | #include <asm/unaligned.h> | 28 | #include <asm/unaligned.h> |
28 | 29 | ||
29 | #ifndef CONFIG_FAT_DEFAULT_IOCHARSET | 30 | #ifndef CONFIG_FAT_DEFAULT_IOCHARSET |
@@ -853,7 +854,7 @@ enum { | |||
853 | Opt_charset, Opt_shortname_lower, Opt_shortname_win95, | 854 | Opt_charset, Opt_shortname_lower, Opt_shortname_win95, |
854 | Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes, | 855 | Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes, |
855 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, | 856 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, |
856 | Opt_obsolate, Opt_err, | 857 | Opt_obsolate, Opt_flush, Opt_err, |
857 | }; | 858 | }; |
858 | 859 | ||
859 | static match_table_t fat_tokens = { | 860 | static match_table_t fat_tokens = { |
@@ -885,7 +886,8 @@ static match_table_t fat_tokens = { | |||
885 | {Opt_obsolate, "cvf_format=%20s"}, | 886 | {Opt_obsolate, "cvf_format=%20s"}, |
886 | {Opt_obsolate, "cvf_options=%100s"}, | 887 | {Opt_obsolate, "cvf_options=%100s"}, |
887 | {Opt_obsolate, "posix"}, | 888 | {Opt_obsolate, "posix"}, |
888 | {Opt_err, NULL} | 889 | {Opt_flush, "flush"}, |
890 | {Opt_err, NULL}, | ||
889 | }; | 891 | }; |
890 | static match_table_t msdos_tokens = { | 892 | static match_table_t msdos_tokens = { |
891 | {Opt_nodots, "nodots"}, | 893 | {Opt_nodots, "nodots"}, |
@@ -1026,6 +1028,9 @@ static int parse_options(char *options, int is_vfat, int silent, int *debug, | |||
1026 | return 0; | 1028 | return 0; |
1027 | opts->codepage = option; | 1029 | opts->codepage = option; |
1028 | break; | 1030 | break; |
1031 | case Opt_flush: | ||
1032 | opts->flush = 1; | ||
1033 | break; | ||
1029 | 1034 | ||
1030 | /* msdos specific */ | 1035 | /* msdos specific */ |
1031 | case Opt_dots: | 1036 | case Opt_dots: |
@@ -1425,6 +1430,56 @@ out_fail: | |||
1425 | 1430 | ||
1426 | EXPORT_SYMBOL_GPL(fat_fill_super); | 1431 | EXPORT_SYMBOL_GPL(fat_fill_super); |
1427 | 1432 | ||
1433 | /* | ||
1434 | * helper function for fat_flush_inodes. This writes both the inode | ||
1435 | * and the file data blocks, waiting for in flight data blocks before | ||
1436 | * the start of the call. It does not wait for any io started | ||
1437 | * during the call | ||
1438 | */ | ||
1439 | static int writeback_inode(struct inode *inode) | ||
1440 | { | ||
1441 | |||
1442 | int ret; | ||
1443 | struct address_space *mapping = inode->i_mapping; | ||
1444 | struct writeback_control wbc = { | ||
1445 | .sync_mode = WB_SYNC_NONE, | ||
1446 | .nr_to_write = 0, | ||
1447 | }; | ||
1448 | /* if we used WB_SYNC_ALL, sync_inode waits for the io for the | ||
1449 | * inode to finish. So WB_SYNC_NONE is sent down to sync_inode | ||
1450 | * and filemap_fdatawrite is used for the data blocks | ||
1451 | */ | ||
1452 | ret = sync_inode(inode, &wbc); | ||
1453 | if (!ret) | ||
1454 | ret = filemap_fdatawrite(mapping); | ||
1455 | return ret; | ||
1456 | } | ||
1457 | |||
1458 | /* | ||
1459 | * write data and metadata corresponding to i1 and i2. The io is | ||
1460 | * started but we do not wait for any of it to finish. | ||
1461 | * | ||
1462 | * filemap_flush is used for the block device, so if there is a dirty | ||
1463 | * page for a block already in flight, we will not wait and start the | ||
1464 | * io over again | ||
1465 | */ | ||
1466 | int fat_flush_inodes(struct super_block *sb, struct inode *i1, struct inode *i2) | ||
1467 | { | ||
1468 | int ret = 0; | ||
1469 | if (!MSDOS_SB(sb)->options.flush) | ||
1470 | return 0; | ||
1471 | if (i1) | ||
1472 | ret = writeback_inode(i1); | ||
1473 | if (!ret && i2) | ||
1474 | ret = writeback_inode(i2); | ||
1475 | if (!ret && sb) { | ||
1476 | struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping; | ||
1477 | ret = filemap_flush(mapping); | ||
1478 | } | ||
1479 | return ret; | ||
1480 | } | ||
1481 | EXPORT_SYMBOL_GPL(fat_flush_inodes); | ||
1482 | |||
1428 | static int __init init_fat_fs(void) | 1483 | static int __init init_fat_fs(void) |
1429 | { | 1484 | { |
1430 | int err; | 1485 | int err; |