diff options
author | Joern Engel <joern@logfs.org> | 2010-03-04 15:36:19 -0500 |
---|---|---|
committer | Joern Engel <joern@logfs.org> | 2010-03-04 15:36:19 -0500 |
commit | c6d3830140f1d56b07d8ab56a6e14ca3c492a39a (patch) | |
tree | 8dd9923b4217f6f7dc2735356d112fdcfa277852 /fs/logfs/journal.c | |
parent | 9421502b4fc894cc477be8fc49776830e37ca157 (diff) |
[LogFS] Only write journal if dirty
This prevents unnecessary journal writes. More importantly it prevents
an oops due to a journal write on failed mount.
Diffstat (limited to 'fs/logfs/journal.c')
-rw-r--r-- | fs/logfs/journal.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/logfs/journal.c b/fs/logfs/journal.c index c0e7d63221d4..57eb4fb444a9 100644 --- a/fs/logfs/journal.c +++ b/fs/logfs/journal.c | |||
@@ -724,14 +724,17 @@ static int logfs_write_obj_aliases(struct super_block *sb) | |||
724 | * bit wasteful, but robustness is more important. With this we can *always* | 724 | * bit wasteful, but robustness is more important. With this we can *always* |
725 | * erase all journal segments except the one containing the most recent commit. | 725 | * erase all journal segments except the one containing the most recent commit. |
726 | */ | 726 | */ |
727 | void logfs_write_anchor(struct inode *inode) | 727 | void logfs_write_anchor(struct super_block *sb) |
728 | { | 728 | { |
729 | struct super_block *sb = inode->i_sb; | ||
730 | struct logfs_super *super = logfs_super(sb); | 729 | struct logfs_super *super = logfs_super(sb); |
731 | struct logfs_area *area = super->s_journal_area; | 730 | struct logfs_area *area = super->s_journal_area; |
732 | int i, err; | 731 | int i, err; |
733 | 732 | ||
734 | BUG_ON(logfs_super(sb)->s_flags & LOGFS_SB_FLAG_SHUTDOWN); | 733 | if (!(super->s_flags & LOGFS_SB_FLAG_DIRTY)) |
734 | return; | ||
735 | super->s_flags &= ~LOGFS_SB_FLAG_DIRTY; | ||
736 | |||
737 | BUG_ON(super->s_flags & LOGFS_SB_FLAG_SHUTDOWN); | ||
735 | mutex_lock(&super->s_journal_mutex); | 738 | mutex_lock(&super->s_journal_mutex); |
736 | 739 | ||
737 | /* Do this first or suffer corruption */ | 740 | /* Do this first or suffer corruption */ |
@@ -821,7 +824,7 @@ void do_logfs_journal_wl_pass(struct super_block *sb) | |||
821 | area->a_is_open = 0; | 824 | area->a_is_open = 0; |
822 | area->a_used_bytes = 0; | 825 | area->a_used_bytes = 0; |
823 | /* Write journal */ | 826 | /* Write journal */ |
824 | logfs_write_anchor(super->s_master_inode); | 827 | logfs_write_anchor(sb); |
825 | /* Write superblocks */ | 828 | /* Write superblocks */ |
826 | err = logfs_write_sb(sb); | 829 | err = logfs_write_sb(sb); |
827 | BUG_ON(err); | 830 | BUG_ON(err); |