diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-04-03 01:34:49 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-04-03 01:34:49 -0400 |
commit | e7c8f5079ed9ec9e6eb1abe3defc5fb4ebfdf1cb (patch) | |
tree | fd0191b45890e37b5e20a2d7e200d34a6432eb7e /fs/ext3 | |
parent | f7ab34ea723ed304b19698efca85d6f40cecd99b (diff) |
ext3: Add replace-on-rename hueristics for data=writeback mode
In data=writeback mode, start an asynchronous flush when renaming a
file on top of an already-existing file. This lowers the probability
of data loss in the case of applications that attempt to replace a
file via using rename().
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext3')
-rw-r--r-- | fs/ext3/namei.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 4db4ffa1edad..ab98a66ab8c7 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -2265,7 +2265,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, | |||
2265 | struct inode * old_inode, * new_inode; | 2265 | struct inode * old_inode, * new_inode; |
2266 | struct buffer_head * old_bh, * new_bh, * dir_bh; | 2266 | struct buffer_head * old_bh, * new_bh, * dir_bh; |
2267 | struct ext3_dir_entry_2 * old_de, * new_de; | 2267 | struct ext3_dir_entry_2 * old_de, * new_de; |
2268 | int retval; | 2268 | int retval, flush_file = 0; |
2269 | 2269 | ||
2270 | old_bh = new_bh = dir_bh = NULL; | 2270 | old_bh = new_bh = dir_bh = NULL; |
2271 | 2271 | ||
@@ -2401,6 +2401,8 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, | |||
2401 | ext3_mark_inode_dirty(handle, new_inode); | 2401 | ext3_mark_inode_dirty(handle, new_inode); |
2402 | if (!new_inode->i_nlink) | 2402 | if (!new_inode->i_nlink) |
2403 | ext3_orphan_add(handle, new_inode); | 2403 | ext3_orphan_add(handle, new_inode); |
2404 | if (ext3_should_writeback_data(new_inode)) | ||
2405 | flush_file = 1; | ||
2404 | } | 2406 | } |
2405 | retval = 0; | 2407 | retval = 0; |
2406 | 2408 | ||
@@ -2409,6 +2411,8 @@ end_rename: | |||
2409 | brelse (old_bh); | 2411 | brelse (old_bh); |
2410 | brelse (new_bh); | 2412 | brelse (new_bh); |
2411 | ext3_journal_stop(handle); | 2413 | ext3_journal_stop(handle); |
2414 | if (retval == 0 && flush_file) | ||
2415 | filemap_flush(old_inode->i_mapping); | ||
2412 | return retval; | 2416 | return retval; |
2413 | } | 2417 | } |
2414 | 2418 | ||