diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-12-23 06:52:08 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-12-23 06:52:08 -0500 |
commit | cc3e1bea5d87635c519da657303690f5538bb4eb (patch) | |
tree | 727b348d0389a2fe6618fb224fe1d81d207668c4 /fs/ext4 | |
parent | 034fb4c95fc0fed4ec4a50778127b92c6f2aec01 (diff) |
ext4, jbd2: Add barriers for file systems with exernal journals
This is a bit complicated because we are trying to optimize when we
send barriers to the fs data disk. We could just throw in an extra
barrier to the data disk whenever we send a barrier to the journal
disk, but that's not always strictly necessary.
We only need to send a barrier during a commit when there are data
blocks which are must be written out due to an inode written in
ordered mode, or if fsync() depends on the commit to force data blocks
to disk. Finally, before we drop transactions from the beginning of
the journal during a checkpoint operation, we need to guarantee that
any blocks that were flushed out to the data disk are firmly on the
rust platter before we drop the transaction from the journal.
Thanks to Oleg Drokin for pointing out this flaw in ext3/ext4.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/fsync.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c index 0b22497d92e..98bd140aad0 100644 --- a/fs/ext4/fsync.c +++ b/fs/ext4/fsync.c | |||
@@ -88,9 +88,21 @@ int ext4_sync_file(struct file *file, struct dentry *dentry, int datasync) | |||
88 | return ext4_force_commit(inode->i_sb); | 88 | return ext4_force_commit(inode->i_sb); |
89 | 89 | ||
90 | commit_tid = datasync ? ei->i_datasync_tid : ei->i_sync_tid; | 90 | commit_tid = datasync ? ei->i_datasync_tid : ei->i_sync_tid; |
91 | if (jbd2_log_start_commit(journal, commit_tid)) | 91 | if (jbd2_log_start_commit(journal, commit_tid)) { |
92 | /* | ||
93 | * When the journal is on a different device than the | ||
94 | * fs data disk, we need to issue the barrier in | ||
95 | * writeback mode. (In ordered mode, the jbd2 layer | ||
96 | * will take care of issuing the barrier. In | ||
97 | * data=journal, all of the data blocks are written to | ||
98 | * the journal device.) | ||
99 | */ | ||
100 | if (ext4_should_writeback_data(inode) && | ||
101 | (journal->j_fs_dev != journal->j_dev) && | ||
102 | (journal->j_flags & JBD2_BARRIER)) | ||
103 | blkdev_issue_flush(inode->i_sb->s_bdev, NULL); | ||
92 | jbd2_log_wait_commit(journal, commit_tid); | 104 | jbd2_log_wait_commit(journal, commit_tid); |
93 | else if (journal->j_flags & JBD2_BARRIER) | 105 | } else if (journal->j_flags & JBD2_BARRIER) |
94 | blkdev_issue_flush(inode->i_sb->s_bdev, NULL); | 106 | blkdev_issue_flush(inode->i_sb->s_bdev, NULL); |
95 | return ret; | 107 | return ret; |
96 | } | 108 | } |