diff options
author | Jan Kara <jack@suse.cz> | 2010-04-15 16:24:26 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2010-05-21 13:30:41 -0400 |
commit | 5277970878a32e437b27296e34c592e5d351f11d (patch) | |
tree | 64f41152b95e670935192ee6061653d922b642f3 /fs/ext3 | |
parent | 03f4d804a1b4748885dc4613a4afe10089a731c8 (diff) |
ext3: Fix waiting on transaction during fsync
log_start_commit() returns 1 only when it started a transaction
commit. Thus in case transaction commit is already running, we
fail to wait for the commit to finish. Fix the issue by always
waiting for the commit regardless of the log_start_commit return
value.
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext3')
-rw-r--r-- | fs/ext3/fsync.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/fs/ext3/fsync.c b/fs/ext3/fsync.c index 8209f266e9ad..26289e8f4163 100644 --- a/fs/ext3/fsync.c +++ b/fs/ext3/fsync.c | |||
@@ -48,7 +48,7 @@ int ext3_sync_file(struct file * file, struct dentry *dentry, int datasync) | |||
48 | struct inode *inode = dentry->d_inode; | 48 | struct inode *inode = dentry->d_inode; |
49 | struct ext3_inode_info *ei = EXT3_I(inode); | 49 | struct ext3_inode_info *ei = EXT3_I(inode); |
50 | journal_t *journal = EXT3_SB(inode->i_sb)->s_journal; | 50 | journal_t *journal = EXT3_SB(inode->i_sb)->s_journal; |
51 | int ret = 0; | 51 | int ret, needs_barrier = 0; |
52 | tid_t commit_tid; | 52 | tid_t commit_tid; |
53 | 53 | ||
54 | if (inode->i_sb->s_flags & MS_RDONLY) | 54 | if (inode->i_sb->s_flags & MS_RDONLY) |
@@ -70,28 +70,26 @@ int ext3_sync_file(struct file * file, struct dentry *dentry, int datasync) | |||
70 | * (they were dirtied by commit). But that's OK - the blocks are | 70 | * (they were dirtied by commit). But that's OK - the blocks are |
71 | * safe in-journal, which is all fsync() needs to ensure. | 71 | * safe in-journal, which is all fsync() needs to ensure. |
72 | */ | 72 | */ |
73 | if (ext3_should_journal_data(inode)) { | 73 | if (ext3_should_journal_data(inode)) |
74 | ret = ext3_force_commit(inode->i_sb); | 74 | return ext3_force_commit(inode->i_sb); |
75 | goto out; | ||
76 | } | ||
77 | 75 | ||
78 | if (datasync) | 76 | if (datasync) |
79 | commit_tid = atomic_read(&ei->i_datasync_tid); | 77 | commit_tid = atomic_read(&ei->i_datasync_tid); |
80 | else | 78 | else |
81 | commit_tid = atomic_read(&ei->i_sync_tid); | 79 | commit_tid = atomic_read(&ei->i_sync_tid); |
82 | 80 | ||
83 | if (log_start_commit(journal, commit_tid)) { | 81 | if (test_opt(inode->i_sb, BARRIER) && |
84 | log_wait_commit(journal, commit_tid); | 82 | !journal_trans_will_send_data_barrier(journal, commit_tid)) |
85 | goto out; | 83 | needs_barrier = 1; |
86 | } | 84 | log_start_commit(journal, commit_tid); |
85 | ret = log_wait_commit(journal, commit_tid); | ||
87 | 86 | ||
88 | /* | 87 | /* |
89 | * In case we didn't commit a transaction, we have to flush | 88 | * In case we didn't commit a transaction, we have to flush |
90 | * disk caches manually so that data really is on persistent | 89 | * disk caches manually so that data really is on persistent |
91 | * storage | 90 | * storage |
92 | */ | 91 | */ |
93 | if (test_opt(inode->i_sb, BARRIER)) | 92 | if (needs_barrier) |
94 | blkdev_issue_flush(inode->i_sb->s_bdev, NULL); | 93 | blkdev_issue_flush(inode->i_sb->s_bdev, NULL); |
95 | out: | ||
96 | return ret; | 94 | return ret; |
97 | } | 95 | } |